From 86183116e5389b58e8b48085446cdbf6bafc32f4 Mon Sep 17 00:00:00 2001 From: Ans Date: Wed, 29 Mar 2023 15:00:53 -0400 Subject: [PATCH] Add rate-explorer tests --- .../owning-a-home/explore-rates-helpers.cy.js | 56 ++++++++- .../owning-a-home/owning-a-home.cy.js | 108 +++++++++++++++++- 2 files changed, 157 insertions(+), 7 deletions(-) diff --git a/test/cypress/integration/consumer-tools/owning-a-home/explore-rates-helpers.cy.js b/test/cypress/integration/consumer-tools/owning-a-home/explore-rates-helpers.cy.js index 8ffa66b6ebc..5f1cbf1dc95 100644 --- a/test/cypress/integration/consumer-tools/owning-a-home/explore-rates-helpers.cy.js +++ b/test/cypress/integration/consumer-tools/owning-a-home/explore-rates-helpers.cy.js @@ -1,13 +1,59 @@ export class ExploreRates { - open() { - cy.visit('/owning-a-home/explore-rates/'); - } - selectState(state) { cy.get('#location').select(state); } - graph() { + selectRateType(val) { + this.getRateTypeSelector().select(val); + } + + selectLoanType(val) { + this.getLoanTypeSelector().select(val); + } + + selectCounty(val) { + this.getCountySelector().select(val); + } + + getHousePriceInput() { + return cy.get('#house-price'); + } + + getCountySelector() { + return cy.get('#county'); + } + + getCountyAlert() { + return cy.get('#county-warning'); + } + + getHighBalanceAlert() { + return cy.get('#hb-warning'); + } + + // Loan type and term drop-down menus. + getRateTypeSelector() { + return cy.get('#rate-structure'); + } + + getLoanTermSelector() { + return cy.get('#loan-term'); + } + + getLoanTypeSelector() { + return cy.get('#loan-type'); + } + + getArmTypeSelector() { + return cy.get('#arm-type'); + } + + // Main graph area. + getGraph() { return cy.get('#chart-section').within(() => cy.get('figure:first')); } + + getChartResultAlert() { + return cy.get('#chart-result-alert'); + } } diff --git a/test/cypress/integration/consumer-tools/owning-a-home/owning-a-home.cy.js b/test/cypress/integration/consumer-tools/owning-a-home/owning-a-home.cy.js index f2b00b843a9..e2f49f79a74 100644 --- a/test/cypress/integration/consumer-tools/owning-a-home/owning-a-home.cy.js +++ b/test/cypress/integration/consumer-tools/owning-a-home/owning-a-home.cy.js @@ -4,10 +4,114 @@ const exploreRates = new ExploreRates(); describe('Owning a Home', () => { describe('Explore Rates', () => { + beforeEach(() => { + cy.visit('/owning-a-home/explore-rates/'); + }); it('Should load the interest rates graph when a state has changed', () => { - exploreRates.open(); exploreRates.selectState('Virginia'); - exploreRates.graph().should('exist'); + exploreRates.getGraph().should('exist'); + }); + + it('Should display high balance FHA loan when house price is high', () => { + exploreRates.getHousePriceInput().type('400000'); + exploreRates.getCountySelector().should('not.be.visible'); + exploreRates.getCountyAlert().should('not.be.visible'); + exploreRates + .getLoanTypeSelector() + .get('[value="fha-hb"]') + .should('not.exist'); + exploreRates.getHighBalanceAlert().should('not.be.visible'); + + exploreRates.selectLoanType('fha'); + exploreRates.getCountySelector().should('be.visible'); + exploreRates.getCountyAlert().should('be.visible'); + exploreRates.selectCounty('Baldwin'); + exploreRates.getLoanTypeSelector().get('[value="conf"]').should('exist'); + exploreRates.getLoanTypeSelector().get('[value="fha"]').should('exist'); + exploreRates.getLoanTypeSelector().get('[value="va"]').should('exist'); + exploreRates + .getLoanTypeSelector() + .get('[value="fha-hb"]') + .should('exist'); + exploreRates.getHighBalanceAlert().should('be.visible'); + }); + + it('Should display high balance VA loan when house price is high', () => { + exploreRates.getHousePriceInput().type('600000'); + exploreRates.getCountySelector().should('be.visible'); + exploreRates.getCountyAlert().should('be.visible'); + exploreRates + .getLoanTypeSelector() + .get('[value="va-hb"]') + .should('not.exist'); + exploreRates.getHighBalanceAlert().should('not.be.visible'); + + exploreRates.selectLoanType('va'); + exploreRates.selectCounty('Baldwin'); + exploreRates.getLoanTypeSelector().get('[value="conf"]').should('exist'); + exploreRates.getLoanTypeSelector().get('[value="fha"]').should('exist'); + exploreRates.getLoanTypeSelector().get('[value="va"]').should('exist'); + exploreRates.getLoanTypeSelector().get('[value="va-hb"]').should('exist'); + exploreRates.getHighBalanceAlert().should('be.visible'); + }); + + it('Should display conforming jumbo loan type when house price is very high', () => { + exploreRates.getHousePriceInput().type('700000'); + exploreRates.getCountySelector().should('be.visible'); + exploreRates.getCountyAlert().should('be.visible'); + exploreRates + .getLoanTypeSelector() + .get('[value="agency"]') + .should('not.exist'); + exploreRates.getHighBalanceAlert().should('not.be.visible'); + exploreRates.selectCounty('Baldwin'); + exploreRates + .getLoanTypeSelector() + .get('[value="agency"]') + .should('exist'); + exploreRates.getHighBalanceAlert().should('be.visible'); + }); + + it('Should display non-conforming jumbo loan type when house price is very very high', () => { + exploreRates.getHousePriceInput().type('1000000'); + exploreRates.getCountySelector().should('be.visible'); + exploreRates.getCountyAlert().should('be.visible'); + exploreRates + .getLoanTypeSelector() + .get('[value="jumbo"]') + .should('not.exist'); + exploreRates.getHighBalanceAlert().should('not.be.visible'); + exploreRates.selectCounty('Baldwin'); + exploreRates.getLoanTypeSelector().get('[value="jumbo"]').should('exist'); + exploreRates.getHighBalanceAlert().should('be.visible'); + }); + + it('Should display ARM type selector when rate type is adjustable', () => { + exploreRates.getChartResultAlert().should('not.be.visible'); + exploreRates.getArmTypeSelector().should('not.be.visible'); + exploreRates.selectRateType('Adjustable'); + exploreRates.getChartResultAlert().should('be.visible'); + exploreRates.getArmTypeSelector().should('be.visible'); + exploreRates + .getLoanTermSelector() + .get('[value="30"]') + .should('not.be.disabled'); + exploreRates + .getLoanTermSelector() + .get('[value="15"]') + .should('be.disabled'); + exploreRates + .getLoanTypeSelector() + .get('[value="conf"]') + .should('not.be.disabled'); + exploreRates + .getLoanTypeSelector() + .get('[value="fha"]') + .should('be.disabled'); + exploreRates + .getLoanTypeSelector() + .get('[value="va"]') + .should('be.disabled'); }); }); });