Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure project selection #171

Merged
merged 8 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions cypress/e2e/state-calculator-events.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ describe('rewiring-america-state-calculator events', () => {
element.get(0).addEventListener('calculator-submitted', submit);
});

cy.selectProjects(['hvac', 'ev']);

cy.get('rewiring-america-state-calculator')
.shadow()
.find('input#zip')
Expand All @@ -29,10 +27,6 @@ describe('rewiring-america-state-calculator events', () => {
expect(event.detail).to.exist;
expect(event.detail.formData).to.exist;
expect(event.detail.formData.zip).to.equal('02859');
expect(Array.from(event.detail.formData.projects).sort()).to.eql([
'ev',
'hvac',
]);
});
});

Expand Down
58 changes: 3 additions & 55 deletions cypress/e2e/state-calculator.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ describe('rewiring-america-state-calculator', () => {
});

it('fetches results if you submit after entering a RI zip code', () => {
cy.selectProjects(['hvac']);

cy.get('rewiring-america-state-calculator')
.shadow()
.find('input#zip')
Expand All @@ -51,7 +49,9 @@ describe('rewiring-america-state-calculator', () => {

cy.get('rewiring-america-state-calculator')
.shadow()
.contains('Incentives you’re interested in');
.contains(/We found \d+ results across \d+ projects./);

cy.selectProjects(['hvac']);

cy.get('rewiring-america-state-calculator')
.shadow()
Expand All @@ -73,10 +73,6 @@ describe('rewiring-america-state-calculator', () => {
.shadow()
.contains('$2,000 off an air source heat pump');

cy.get('rewiring-america-state-calculator')
.shadow()
.contains('Other incentives available to you');

cy.get('rewiring-america-state-calculator')
.shadow()
.contains('Brought to you in partnership with');
Expand All @@ -88,54 +84,6 @@ describe('rewiring-america-state-calculator', () => {
});
});

it('shows an empty state if you are not eligible for any incentives for your chosen project', () => {
oyamauchi marked this conversation as resolved.
Show resolved Hide resolved
cy.selectProjects(['cooking']);

cy.get('rewiring-america-state-calculator')
.shadow()
.find('#zip')
.type('02859');

// "force" to work around a Cypress bug
// https://github.com/cypress-io/cypress/issues/5830
cy.get('rewiring-america-state-calculator')
.shadow()
.find('#household_income')
.type('200000{enter}', { force: true });

// make sure we saw an empty result state, and scroll down to it:
cy.get('rewiring-america-state-calculator')
.shadow()
.contains('No incentives available for this project')
.scrollIntoView();

cy.get('rewiring-america-state-calculator')
.shadow()
.checkA11y(null, {
runOnly: ['wcag2a', 'wcag2aa'],
});

// // make sure we have scrolled down
cy.get('rewiring-america-state-calculator')
.shadow()
.contains('Your household info')
.isNotInViewport();

cy.get('rewiring-america-state-calculator')
.shadow()
.contains('Back to calculator')
.click();

// wait for animated scroll
cy.wait(1000);

// make sure we scrolled back up
cy.get('rewiring-america-state-calculator')
.shadow()
.contains('Your household info')
.isInViewport();
});

it('shows an error if you query in the wrong state', () => {
// Add the state-restricting attribute to the element
cy.get('rewiring-america-state-calculator').invoke('attr', 'state', 'RI');
Expand Down
8 changes: 1 addition & 7 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Cypress.Commands.add(
(projects: string[]) => {
cy.get('rewiring-america-state-calculator')
.shadow()
.find('button#projects')
.find('button#project-selector')
.click();

projects.forEach(project =>
Expand All @@ -98,11 +98,5 @@ Cypress.Commands.add(
.find(`li[data-value="${project}"]`)
.click(),
);

// Unfocus the project selector
cy.get('rewiring-america-state-calculator')
.shadow()
.find('button#projects')
.click();
},
);
Loading
Loading