-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8297be
commit ea5d848
Showing
6 changed files
with
52 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
}) | ||
} | ||
}); | ||
console.log(message); | ||
return null; | ||
}, | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
}) | ||
}) | ||
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
}) | ||
} | ||
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); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters