Skip to content

Commit

Permalink
test(e2e): always give valid dates by using the next month
Browse files Browse the repository at this point in the history
  • Loading branch information
sgfost committed Oct 29, 2024
1 parent d105df4 commit 77a705c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion e2e/cypress/fixtures/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"description": "Job Description",
"summary": "Job Summary",
"external-url": "https://www.comses.net/",
"application-deadline": "29"
"application-deadline": "21"
}
]
}
4 changes: 4 additions & 0 deletions e2e/cypress/support/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
export function getDataCy(value: string): Cypress.Chainable {
return cy.get(`[data-cy="${value}"]`);
}

export function selectNextMonthDate(element: Cypress.Chainable, day: number): Cypress.Chainable {
return element.contains("aria-label", "Next month").click().contains(day).click();
}
34 changes: 21 additions & 13 deletions e2e/cypress/tests/event.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { loginBeforeEach } from "../support/setup";
import { getDataCy } from "../support/util";
import { getDataCy, selectNextMonthDate } from "../support/util";
import "cypress-file-upload";

describe("Visit events page", () => {
Expand Down Expand Up @@ -31,18 +31,26 @@ describe("Visit events page", () => {
cy.contains("Submit an event").click();
getDataCy("event-title").type(event.title);
getDataCy("event-location").type(event.location);
getDataCy("event-start-date").first().click();
getDataCy("event-start-date").contains(event["start-date"]).click();
getDataCy("event-end-date").first().click();
getDataCy("event-end-date").contains(event["end-date"]).click();
getDataCy("early-registration-deadline").first().click();
getDataCy("early-registration-deadline")
.contains(event["early-registration-deadline"])
.click();
getDataCy("registration-deadline").first().click();
getDataCy("registration-deadline").contains(event["registration-deadline"]).click();
getDataCy("submission-deadline").first().click();
getDataCy("submission-deadline").contains(event["submission-deadline"]).click();
selectNextMonthDate(getDataCy("event-start-date"), event["start-date"]);
// getDataCy("event-start-date").first().click();
// getDataCy("event-start-date").contains(event["start-date"]).click();
selectNextMonthDate(getDataCy("event-end-date"), event["end-date"]);
// getDataCy("event-end-date").first().click();
// getDataCy("event-end-date").contains(event["end-date"]).click();
selectNextMonthDate(
getDataCy("early-registration-deadline"),
event["early-registration-deadline"]
);
// getDataCy("early-registration-deadline").first().click();
// getDataCy("early-registration-deadline")
// .contains(event["early-registration-deadline"])
// .click();
selectNextMonthDate(getDataCy("registration-deadline"), event["registration-deadline"]);
// getDataCy("registration-deadline").first().click();
// getDataCy("registration-deadline").contains(event["registration-deadline"]).click();
selectNextMonthDate(getDataCy("submission-deadline"), event["submission-deadline"]);
// getDataCy("submission-deadline").first().click();
// getDataCy("submission-deadline").contains(event["submission-deadline"]).click();
getDataCy("description").type(event.description);
getDataCy("summary").type(event.summary);
getDataCy("external-url").type(event["external-url"]);
Expand Down
8 changes: 5 additions & 3 deletions e2e/cypress/tests/job.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { loginBeforeEach } from "../support/setup";
import { getDataCy } from "../support/util";
import { getDataCy, selectNextMonthDate } from "../support/util";
import "cypress-file-upload";

describe("Visit jobs page", () => {
Expand All @@ -21,8 +21,10 @@ describe("Visit jobs page", () => {
getDataCy("job-description").type(job.description);
getDataCy("job-summary").type(job.summary);
getDataCy("external-url").type(job["external-url"]);
getDataCy("application-deadline").first().click();
getDataCy("application-deadline").contains(job["application-deadline"]).click();
selectNextMonthDate(getDataCy("application-deadline"), job["application-deadline"]);
// getDataCy("application-deadline").first().click();
// getDataCy("application-deadline").contains("aria-label", "Next month").click();
// getDataCy("application-deadline").contains(job["application-deadline"]).click();
getDataCy("create-button").click();
cy.wait(2000);
});
Expand Down

0 comments on commit 77a705c

Please sign in to comment.