diff --git a/cypress.config.js b/cypress.config.js index 356e65aad..f9eca0174 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -1,20 +1,20 @@ -const { defineConfig } = require('cypress'); -require('dotenv').config({ - path: `.env.${process.env.STAGE_ENV || 'development'}` +const { defineConfig } = require("cypress"); +require("dotenv").config({ + path: `.env.${process.env.STAGE_ENV || "development"}`, }); module.exports = defineConfig({ e2e: { baseUrl: process.env.REACT_APP_POLICYENGINE_DOMAIN, - supportFile: 'cypress/support/e2e.js', - specPattern: 'cypress/tests/**/*.cy.js', + supportFile: "cypress/support/e2e.js", + specPattern: "cypress/tests/**/*.cy.js", }, setupNodeEvents(on, config) { - on('task', { + on("task", { log(message) { - console.log(message) - return null - } - }) - } -}); \ No newline at end of file + console.log(message); + return null; + }, + }); + }, +}); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 698b01a42..95857aea4 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -34,4 +34,4 @@ // visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable // } // } -// } \ No newline at end of file +// } diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js index f80f74f8e..6a173d6fc 100644 --- a/cypress/support/e2e.js +++ b/cypress/support/e2e.js @@ -14,7 +14,7 @@ // *********************************************************** // Import commands.js using ES2015 syntax: -import './commands' +import "./commands"; // Alternatively you can use CommonJS syntax: -// require('./commands') \ No newline at end of file +// require('./commands') diff --git a/cypress/tests/us/home.cy.js b/cypress/tests/us/home.cy.js index e6f612da7..1689ea66d 100644 --- a/cypress/tests/us/home.cy.js +++ b/cypress/tests/us/home.cy.js @@ -1,32 +1,32 @@ -import { checkCountryRedirect } from "../../utils/checkCountryRedirect" +import { checkCountryRedirect } from "../../utils/checkCountryRedirect"; -describe('PolicyEngine Homepage', () => { +describe("PolicyEngine Homepage", () => { const regexArg = /the\s(us|u\.s\.|usa|united states)/; beforeEach(() => { - cy.visit('/') - }) + cy.visit("/"); + }); afterEach(() => { - Object.defineProperty(window.navigator, 'language', { + Object.defineProperty(window.navigator, "language", { value: window.navigator.language, - configurable: true - }) - }) + configurable: true, + }); + }); - it('should redirect from root to US homepage by default', () => { - Object.defineProperty(window.navigator, 'language', { - value: '', - configurable: true - }) - checkCountryRedirect('us', regexArg) - }) + it("should redirect from root to US homepage by default", () => { + Object.defineProperty(window.navigator, "language", { + value: "", + configurable: true, + }); + checkCountryRedirect("us", regexArg); + }); - it('should redirect from root to US homepage if browser language is en-US', () => { - Object.defineProperty(window.navigator, 'language', { - value: 'en-US', - configurable: true - }) - checkCountryRedirect('us', regexArg) - }) -}) \ No newline at end of file + it("should redirect from root to US homepage if browser language is en-US", () => { + Object.defineProperty(window.navigator, "language", { + value: "en-US", + configurable: true, + }); + checkCountryRedirect("us", regexArg); + }); +}); diff --git a/cypress/utils/checkCountryRedirect.js b/cypress/utils/checkCountryRedirect.js index aae04c5cf..6de18fbc1 100644 --- a/cypress/utils/checkCountryRedirect.js +++ b/cypress/utils/checkCountryRedirect.js @@ -1,12 +1,12 @@ -export const checkCountryRedirect = (country, regexArg = '') => { - cy.location('pathname').should((loc) => { - const path = loc.split('/') - expect(path[1]).to.equal(country) - }) - - cy.get('#home-used-by').then(($ele) => { - const text = $ele.text()?.toLowerCase(); - const regex = new RegExp(regexArg, 'i') - expect(regex.test(text)).to.equal(true) - }) - } \ No newline at end of file +export const checkCountryRedirect = (country, regexArg = "") => { + cy.location("pathname").should((loc) => { + const path = loc.split("/"); + expect(path[1]).to.equal(country); + }); + + cy.get("#home-used-by").then(($ele) => { + const text = $ele.text()?.toLowerCase(); + const regex = new RegExp(regexArg, "i"); + expect(regex.test(text)).to.equal(true); + }); +}; diff --git a/package.json b/package.json index 5d353dfb3..a50961254 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "homepage": "https://policyengine.org", "engines": { - "node": ">=22.0.0" + "node": ">=19.0.0" }, "dependencies": { "@ant-design/icons": "^5.5.1", @@ -87,7 +87,7 @@ ] }, "lint-staged": { - "*.{js,jsx}": "eslint --fix", + "*.{js,jsx,ts,tsx}": "eslint --fix", "*": "prettier -w" }, "devDependencies": {