Skip to content

Commit

Permalink
Merge pull request #78 from Som-Energia/NEW_form_figma_no_partner
Browse files Browse the repository at this point in the history
New form figma no partner
  • Loading branch information
dukenuken09 authored Sep 8, 2023
2 parents 7ce77b5 + 64aa0a4 commit 020ba0d
Show file tree
Hide file tree
Showing 19 changed files with 787 additions and 449 deletions.
6 changes: 5 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## Unreleased

- Added: Generation kwh form. Path for non partners

## 1.9.1 2023-09-04

- Fix general conditions for holderchange form
Expand All @@ -8,7 +12,7 @@

## 1.9.0 2023-08-29

- Added: Generation kwh. the way for partners
- Added: Generation kwh form. Path for partners

## 1.8.2 2023-08-23

Expand Down
20 changes: 20 additions & 0 deletions cypress/fixtures/generationkwhContribution.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,25 @@
"payment_data": {
"iban": "ES18 1465 7317 8144 5866 4841",
"err_iban": "ES18 9999 0000 9999 0000 9999"
},
"out_zone_data":{
"postal_code": 90902
},
"new_member":{
"vat": "78912872X",
"previous_holder": true,
"name": "Pere",
"surname1": "Pi",
"surname2": "Palmera",
"postal_code": "25320",
"address": "C/Percebe",
"number": 13,
"email": "[email protected]",
"phone": "636696969",
"language": "ca_ES",
"voluntary_cent": true,
"iban": "ES77 1234 1234 1612 3456 7890",
"bad_iban": "ES77 1234 1234 1612 3456 AAAA",
"bad_email": "perepisomenergia.coop"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,84 @@ describe('Generation Form', () => {
return false
})

function fillInData(data) {
cy.get('#member_name')
.type(data.new_member.name)
.should('have.value', data.new_member.name)

cy.get('#member_surname1')
.type(data.new_member.surname1)
.should('have.value', data.new_member.surname1)

cy.get('#member_surname2')
.type(data.new_member.surname2)
.should('have.value', data.new_member.surname2)

cy.get('#member_address')
.type(data.new_member.address)
.should('have.value', data.new_member.address)

cy.get('#member_number')
.type(data.new_member.number)
.should('have.value', data.new_member.number)

cy.get('#member_email')
.type(data.new_member.email)
.should('have.value', data.new_member.email)

cy.get('#member_email2')
.type(data.new_member.email)
.should('have.value', data.new_member.email)

cy.get('#member_phone')
.type(data.new_member.phone)
.should('have.value', data.new_member.phone)

cy.get('#member_phone2')
.type(data.new_member.phone)
.should('have.value', data.new_member.phone)

cy.get('[name="privacy_policy_accepted"]').click()
cy.get('[data-cy=next]').click()



}

beforeEach(() => {
cy.visit('/generationkwh/contribution')
cy.fixture('generationkwhContribution.json').as('data')
})

it('Contribute with an action', function () {
//Member page
cy.identifyMember(this.data.member.number, this.data.member.vat)
context('Member - Success Tests', () => {
it('Contribute with an action', function () {
//Member page
cy.identifyMember(this.data.member.number, this.data.member.vat)

//Contribution page
cy.get('#annual_use')
.clear()
.type(this.data.annual_use.low)
.should('have.value', this.data.annual_use.low)
//Contribution page
cy.get('#annual_use')
.clear()
.type(this.data.annual_use.low)
.should('have.value', this.data.annual_use.low)

for (let n = 0; n < this.data.number_of_action.normal; n++) {
cy.get('#add_action').click()
}
for (let n = 0; n < this.data.number_of_action.normal; n++) {
cy.get('#add_action').click()
}

cy.get('[name="payment.iban"]')
.clear()
.type(this.data.payment_data.iban)
.should('have.value', this.data.payment_data.iban)
cy.get('[data-cy=next]').click()
cy.get('[name="payment.iban"]')
.clear()
.type(this.data.payment_data.iban)
.should('have.value', this.data.payment_data.iban)
cy.get('[data-cy=next]').click()

//Review page
cy.get('#privacy_plicy_check').check()
cy.get('[data-cy=next]').click()
})
//Review page
cy.get('#privacy_plicy_check').check()
cy.get('[data-cy=submit]').click()
})

it('Try to contribute with out of zone member', function () {
//Member page
let memberNumber = this.data.member_out_first_fase_zone.number
it('Try to contribute with out of zone member', function () {
//Member page
let memberNumber = this.data.member_out_first_fase_zone.number
let memberVat = this.data.member_out_first_fase_zone.vat

cy.intercept('GET', '/data/soci/**').as('checkMember')
Expand All @@ -50,13 +95,62 @@ describe('Generation Form', () => {

cy.get('#vat').clear().type(memberVat).should('have.value', memberVat)
cy.wait('@checkMember')
.its('response.statusCode')
.should('be.oneOf', [200, 304])
.its('response.statusCode')
.should('be.oneOf', [200, 304])
cy.get('[data-cy=exit]').click()
})
})

context(' NO Member - Success Tests', () => {
it('Contribute with an action', function () {
//Member page
let postal_code = this.data.new_member.postal_code
let vat = this.data.new_member.vat

cy.get('#member_choose_no').click()
cy.get('#input_postalcode')
.clear()
.type(postal_code)
.should('have.value', postal_code)
cy.get('#vat').clear().type(vat).should('have.value', vat)

cy.get('[data-cy=next]').click()

context('Fail Tests', () => {
fillInData(this.data)
//Contribution page
cy.get('#annual_use')
.clear()
.type(this.data.annual_use.low)
.should('have.value', this.data.annual_use.low)

for (let n = 0; n < this.data.number_of_action.normal; n++) {
cy.get('#add_action').click()
}

cy.get('[name="payment.iban"]')
.clear()
.type(this.data.payment_data.iban)
.should('have.value', this.data.payment_data.iban)
cy.get('[data-cy=next]').click()

//Review page
cy.get('#privacy_plicy_check').check()
/* cy.get('[data-cy=next]').click() */
})

it('Try to contribute with out of zone postal code', function () {
//Member page
let postal_code = this.data.out_zone_data.postal_code
cy.get('#member_choose_no').click()
cy.get('#input_postalcode')
.clear()
.type(postal_code)
.should('have.value', postal_code)
cy.get('[data-cy=exit]').click()
})
})

context('Member - Fail Tests', () => {
it('Try to contribute with erroneous credentials', function () {
//Member page
let memberNumber = this.data.member.number
Expand Down Expand Up @@ -119,24 +213,24 @@ describe('Generation Form', () => {
})

it('Erroneous IBAN', function () {
//Member page
cy.identifyMember(this.data.member.number, this.data.member.vat)
//Contribution page
cy.get('#annual_use')
.clear()
.type(this.data.annual_use.normal)
.should('have.value', this.data.annual_use.normal)
for (let n = 0; n < this.data.number_of_action.normal; n++) {
cy.get('#add_action').click()
}
cy.get('[name="payment.iban"]')
.clear()
.type(this.data.payment_data.err_iban)
.should('have.value', this.data.payment_data.err_iban)
cy.get('[data-cy=next]').should('be.disabled')
})
})
//Member page
cy.identifyMember(this.data.member.number, this.data.member.vat)

//Contribution page
cy.get('#annual_use')
.clear()
.type(this.data.annual_use.normal)
.should('have.value', this.data.annual_use.normal)

for (let n = 0; n < this.data.number_of_action.normal; n++) {
cy.get('#add_action').click()
}

cy.get('[name="payment.iban"]')
.clear()
.type(this.data.payment_data.err_iban)
.should('have.value', this.data.payment_data.err_iban)
cy.get('[data-cy=next]').should('be.disabled')
})
})
})
2 changes: 1 addition & 1 deletion src/components/IBANField.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function IBANField(props) {

useEffect(() => {
onChange({ IBAN: IBAN, IBANValid: false })
if (IBAN.length > 27) {
if (IBAN.length > 28) {
setIsLoading(true)
checkIban(IBAN)
.then((response) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useState } from 'react'
import React, { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import { makeStyles } from '@material-ui/core/styles'

Expand All @@ -8,7 +8,6 @@ import IBANField from '../../../components/IBANField'
import AddIcon from '@material-ui/icons/AddBox'
import RemoveIcon from '@material-ui/icons/IndeterminateCheckBox'
import Box from '@material-ui/core/Box'
import IconButton from '@material-ui/core/IconButton'
import Button from '@material-ui/core/Button'
import Grid from '@material-ui/core/Grid'
import InputAdornment from '@material-ui/core/InputAdornment'
Expand Down Expand Up @@ -156,7 +155,6 @@ const GenerationContributionForm = (props) => {
})
}}
/>
{/*TODO: POSAR ELS ESTILS CORRECTAMENT*/}
<Grid container style={{ gap: '1rem' }}>
<Grid item xs={12} md>
<TextField
Expand Down
Loading

1 comment on commit 020ba0d

@vercel
Copy link

@vercel vercel bot commented on 020ba0d Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

webforms-ui – ./

webforms-ui-somenergia.vercel.app
webforms-ui.vercel.app
webforms-ui-git-master-somenergia.vercel.app

Please sign in to comment.