-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add e2e tests #206
base: main
Are you sure you want to change the base?
Add e2e tests #206
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"baseUrl": "http://localhost:3000", | ||
"viewportWidth": 1536, | ||
"viewportHeight": 960 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
describe("Act Now page", () => { | ||
it("renders Act Now page", () => { | ||
cy.visit("/"); | ||
cy.get("[data-cy=navigation-buttons]").contains("Act Now").click(); | ||
cy.location("pathname", { timeout: 10000 }).should("include", "/act-now"); | ||
cy.get("[data-cy=actnow-desc]").contains( | ||
"Act now and create the change you want in your area." | ||
); | ||
}); | ||
it("select promise to petition", () => { | ||
cy.get("[data-cy=promise-select]").click(); | ||
cy.get("[data-cy=promise-item").first().click(); | ||
}); | ||
it("displays petiton form", () => { | ||
cy.get("[data-cy=start-petition]").click(); | ||
cy.get("[data-cy=petition-form]").contains("Petition Title"); | ||
cy.get("[data-cy=petition-form]").contains("Category & Promise"); | ||
cy.get("[data-cy=petition-form]").contains("Recipient"); | ||
cy.get("[data-cy=petition-form]").contains("What is the Issue"); | ||
cy.get("[data-cy=petition-form]").contains("Featured Image"); | ||
cy.get("[data-cy=close-form]").click(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
describe("Home page", () => { | ||
it("renders Key Promises", () => { | ||
cy.visit("/"); | ||
cy.get("[data-cy=key-promises]").contains("Key Promises"); | ||
}); | ||
|
||
it("renders Latest Promises", () => { | ||
cy.get("[data-cy=latest-promises]").contains("Latest Promises"); | ||
cy.get("[data-cy=latest-promises]") | ||
.find("img") | ||
.its("length") | ||
.then((length) => { | ||
expect(length).to.equal(5); | ||
}); | ||
}); | ||
|
||
it("renders Latest Articles", () => { | ||
cy.get("[data-cy=latest-articles]").contains("Latest Articles"); | ||
cy.get("[data-cy=latest-articles]") | ||
.find("img") | ||
.its("length") | ||
.then((length) => { | ||
expect(length).to.equal(2); | ||
}); | ||
}); | ||
|
||
it("renders Partners", () => { | ||
cy.get("[data-cy=partners]").contains("Partners"); | ||
cy.get("[data-cy=partners]") | ||
.find("a") | ||
.its("length") | ||
.then((length) => { | ||
expect(length).to.equal(6); | ||
}); | ||
}); | ||
|
||
it("has Neswletter section", () => { | ||
cy.get("[data-cy=subscribe]").contains("Subscribe"); | ||
}); | ||
|
||
it("has Act Now section", () => { | ||
cy.get("[data-cy=act-now]").contains("Act Now"); | ||
}); | ||
|
||
it("renders Latest Promises", () => { | ||
cy.get("[data-cy=latest-promises]").contains("Latest Promises"); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
describe("Promises page", () => { | ||
it("renders Promises page", () => { | ||
cy.visit("/"); | ||
cy.get("[data-cy=navigation-buttons]").contains("Promises").click(); | ||
cy.location("pathname", { timeout: 10000 }).should("include", "/promises"); | ||
cy.get("[data-cy=promises-section]").contains("Promises"); | ||
}); | ||
it("renders Promises categories", () => { | ||
cy.get("[data-cy=promises-section]").contains("Promises by status"); | ||
cy.get("[data-cy=promises-section]").contains("Promises by category"); | ||
}); | ||
it("filter in-progress promises", () => { | ||
cy.get("[data-cy=promises-section]") | ||
.find("img") | ||
.its("length") | ||
.then((length) => { | ||
expect(length).to.equal(5); | ||
}); | ||
cy.get("[data-cy=filter-buttons]").contains("In Progress").click(); | ||
cy.get("[data-cy=promises-section]") | ||
.find("img") | ||
.its("length") | ||
.then((length) => { | ||
expect(length).to.equal(3); | ||
}); | ||
cy.get("[data-cy=filter-buttons]").contains("In Progress").click(); | ||
}); | ||
|
||
it("filter unrated promises", () => { | ||
cy.get("[data-cy=promises-section]") | ||
.find("img") | ||
.its("length") | ||
.then((length) => { | ||
expect(length).to.equal(5); | ||
}); | ||
cy.get("[data-cy=filter-buttons]").contains("Unrated").click(); | ||
cy.get("[data-cy=promises-section]") | ||
.find("img") | ||
.its("length") | ||
.then((length) => { | ||
expect(length).to.equal(1); | ||
}); | ||
cy.get("[data-cy=filter-buttons]").contains("Unrated").click(); | ||
}); | ||
|
||
it("filter stalled promises", () => { | ||
cy.get("[data-cy=promises-section]") | ||
.find("img") | ||
.its("length") | ||
.then((length) => { | ||
expect(length).to.equal(5); | ||
}); | ||
Comment on lines
+46
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I'm getting this correct, it means everytime the PromiseTracker team add/remove promises in Check, these tests will fail. Correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Precisely. That's the problem I have at the moment, since I am using production database it is bound to change any time. And how to mock that data is a challenge on Cypress as it runs on the client side and the pages are SSR - so they already come with the data. |
||
cy.get("[data-cy=filter-buttons]").contains("Stalled").click(); | ||
cy.get("[data-cy=promises-section]") | ||
.find("img") | ||
.its("length") | ||
.then((length) => { | ||
expect(length).to.equal(1); | ||
}); | ||
cy.get("[data-cy=filter-buttons]").contains("Stalled").click(); | ||
}); | ||
|
||
it("filter governance category promises", () => { | ||
cy.get("[data-cy=promises-section]") | ||
.find("img") | ||
.its("length") | ||
.then((length) => { | ||
expect(length).to.equal(5); | ||
}); | ||
|
||
cy.get("[data-cy=filter-buttons]").contains("Governance").click(); | ||
cy.get("[data-cy=promises-section]") | ||
.find("img") | ||
.its("length") | ||
.then((length) => { | ||
expect(length).to.equal(1); | ||
}); | ||
cy.get("[data-cy=filter-buttons]").contains("Governance").click(); | ||
}); | ||
|
||
it("filter health category promises", () => { | ||
cy.get("[data-cy=promises-section]") | ||
.find("img") | ||
.its("length") | ||
.then((length) => { | ||
expect(length).to.equal(5); | ||
}); | ||
cy.get("[data-cy=filter-buttons]").contains("Health").click(); | ||
cy.get("[data-cy=promises-section]") | ||
.find("img") | ||
.its("length") | ||
.then((length) => { | ||
expect(length).to.equal(2); | ||
}); | ||
cy.get("[data-cy=filter-buttons]").contains("Health").click(); | ||
}); | ||
|
||
it("share promise to social platforms", () => { | ||
cy.get("[data-cy=share-button").first().click(); | ||
cy.get("[data-cy=twitter]").should("be.visible"); | ||
cy.get("[data-cy=facebook]").should("be.visible"); | ||
cy.get("[data-cy=linkedin]").should("be.visible"); | ||
cy.get("[data-cy=share-button").first().click(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
describe("Single Promise page", () => { | ||
it("renders promise radar", () => { | ||
cy.visit("/promises"); | ||
cy.get("[data-cy=promises-section]").contains("Promises"); | ||
/* eslint-disable cypress/no-unnecessary-waiting */ | ||
cy.get("[data-cy=promises-section").find("a").first().click().wait(20000); | ||
cy.get("[data-cy=promise-radar]").should("be.visible"); | ||
}); | ||
it("renders promise chart, dataset and datasource", () => { | ||
cy.get("[data-cy=datasource]").scrollIntoView(); | ||
cy.get("[data-cy=datasource").should("be.visible"); | ||
cy.get("[data-cy=dataset]").scrollIntoView(); | ||
cy.get("[data-cy=dataset]").should("be.visible"); | ||
cy.get("[data-cy=promise-chart]").scrollIntoView(); | ||
cy.get("[data-cy=promise-chart]").should("be.visible"); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
|
||
/** | ||
* @type {Cypress.PluginConfig} | ||
*/ | ||
module.exports = () => { | ||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// *********************************************** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need empty files like these? |
||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add("login", (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// *********************************************************** | ||
// This example support/index.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import "./commands"; | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we modified the navigation buttons to contain
data-cy=navigation-buttons
? This fails when I run locally.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The fail is probably from a timeout issue