Skip to content

Commit

Permalink
updated cypress config, added custom commands for data cleanup, updat…
Browse files Browse the repository at this point in the history
…ed test cases
  • Loading branch information
geodem127 committed Jan 14, 2025
1 parent 99385cc commit 4edd15b
Show file tree
Hide file tree
Showing 16 changed files with 454 additions and 524 deletions.
5 changes: 2 additions & 3 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ module.exports = defineConfig({
testIsolation: false,
},
defaultCommandTimeout: 15_000,
pageLoadTimeout: 60_000,
requestTimeout: 30_000,
pageLoadTimeout: 80_000,
requestTimeout: 40_000,
responseTimeout: 80_000,
retries: 1,
});
18 changes: 15 additions & 3 deletions cypress/e2e/blocks/tests/blocks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const CypressTestVariant = "Cypress Test Variant";

describe("All Blocks Tests", () => {
before(() => {
cy.deleteContentModels(["Cypress Test Block", "Cypress Test Variant"]);
AllBlocksPage.visit();
});

Expand All @@ -28,11 +29,16 @@ describe("All Blocks Tests", () => {
AllBlocksPage.createBlock(CypressTestBlock);
cy.contains(CypressTestBlock).should("exist");
SchemaPage.visit();
cy.intercept("POST", "**/v1/content/models/**").as("createModel");
cy.intercept("GET", "**/v1/content/models/*/fields?showDeleted=true").as(
"getModels"
);
SchemaPage.addSingleLineTextFieldWithDefaultValue(
CypressTestBlock,
"Foo",
"Default Foo"
);
cy.wait(["@createModel", "@getModels"], { timeout: 60_000 });
AllBlocksPage.visit();
});

Expand All @@ -50,16 +56,22 @@ describe("All Blocks Tests", () => {
});

it("navigates to block detail page", () => {
cy.contains(CypressTestBlock).click();
cy.contains("Start Creating Variants Now").should("exist");
cy.contains(CypressTestBlock).click({ timeout: 30_000 });
cy.contains("Start Creating Variants Now", { timeout: 30_000 }).should(
"exist"
);
});

it("creates a variant with default values", () => {
AllBlocksPage.visit();
cy.contains(CypressTestBlock).click();
BlockPage.createVariant(CypressTestVariant);
cy.contains(
new RegExp(`${CypressTestBlock}:\\s*${CypressTestVariant}`)
).should("exist");
cy.get('input[name="foo"]').should("have.value", "Default Foo");
cy.get('input[name="foo"]', { timeout: 30_000 }).should(
"have.value",
"Default Foo"
);
});
});
23 changes: 13 additions & 10 deletions cypress/e2e/content/actions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const yesterdayTimestamp = moment()
describe("Actions in content editor", () => {
const timestamp = Date.now();

before(() => {
cy.cleanStatusLabels();
});

it("Must not save when missing required Field", () => {
cy.waitOn("/v1/content/models*", () => {
cy.visit("/content/6-556370-8sh47g/7-82a5c7ffb0-07vj1c");
Expand Down Expand Up @@ -83,7 +87,7 @@ describe("Actions in content editor", () => {
cy.get("#12-f8efe4e0f5-xj7pj6 input").should("not.exist");

// Make an edit to enable save button
cy.get("#12-849844-t8v5l6 input").clear().type(timestamp);
cy.get("#12-849844-t8v5l6 input").clear().type(timestamp.toString());

// save to api
cy.waitOn(
Expand All @@ -95,7 +99,6 @@ describe("Actions in content editor", () => {

cy.get("[data-cy=toast]").contains("Item Saved");
});

it("Saves homepage item metadata", () => {
cy.waitOn("/v1/content/models*", () => {
cy.visit("/content/6-a1a600-k0b6f0/7-a1be38-1b42ht/meta");
Expand All @@ -119,9 +122,8 @@ describe("Actions in content editor", () => {
it("Publishes an item", () => {
cy.getBySelector("PublishButton").click();
cy.getBySelector("ConfirmPublishModal").should("exist");
cy.getBySelector("ConfirmPublishButton").click();

cy.intercept("GET", "**/publishings").as("publish");
cy.getBySelector("ConfirmPublishButton").click();
cy.wait("@publish", { timeout: 30_000 });

cy.getBySelector("ContentPublishedIndicator").should("exist");
Expand Down Expand Up @@ -212,17 +214,18 @@ describe("Actions in content editor", () => {
cy.visit("/content/6-a1a600-k0b6f0/new");
});

cy.get("input[name=title]", { timeout: 5000 }).click().type(timestamp);
cy.get("input[name=title]")
.click({ timeout: 30_000 })
.type(timestamp.toString());
cy.getBySelector("ManualMetaFlow").click();
cy.getBySelector("metaDescription")
.find("textarea")
.first()
.type(timestamp);
.type(timestamp.toString());
cy.getBySelector("CreateItemSaveButton").click();

cy.contains("Created Item", { timeout: 5000 }).should("exist");
cy.contains("Created Item", { timeout: 30_000 }).should("exist");
});

it("Saved item becomes publishable", () => {
cy.get("#PublishButton").should("exist");
});
Expand All @@ -232,7 +235,7 @@ describe("Actions in content editor", () => {
cy.visit("/content/6-a1a600-k0b6f0");
});

cy.contains(timestamp, { timeout: 5000 }).should("exist");
cy.contains(timestamp, { timeout: 30_000 }).should("exist");
});

it("Deletes an item", () => {
Expand All @@ -258,7 +261,7 @@ describe("Actions in content editor", () => {
// dealing with these specific endpoints
// the local environment is slow
cy.contains("Successfully sent workflow request", {
timeout: 15_000,
timeout: 30_000,
}).should("exist");
});

Expand Down
5 changes: 3 additions & 2 deletions cypress/e2e/content/item-list-table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ describe("Content item list table", () => {
});
});

cy.getBySelector("SingleRelationshipCell", { timeout: 10000 })
cy.getBySelector("SingleRelationshipCell")
.first()
.contains(
"5 Tricks to Teach Your Pitbull: Fun & Easy Tips for You & Your Dog!"
"5 Tricks to Teach Your Pitbull: Fun & Easy Tips for You & Your Dog!",
{ timeout: 30_000 }
);
});
});
6 changes: 5 additions & 1 deletion cypress/e2e/content/navigation.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const LABELS = {
cypressTest: "Cypress test (Group with visible fields in list)",
};

describe("Navigation through content editor", () => {
before(() => {
cy.waitOn("/v1/env/nav", () => {
Expand All @@ -24,7 +28,7 @@ describe("Navigation through content editor", () => {
cy.getBySelector("create_new_content_item_dialog").should("exist");
cy.getBySelector("create_new_content_item_input")
.find("input")
.type("cypress");
.type(LABELS.cypressTest);
cy.get(".MuiAutocomplete-listbox .MuiAutocomplete-option")
.first()
.should("exist")
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/content/workflows.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ describe("Content Item Workflows", () => {
cy.visit(`/content/6-b6cde1aa9f-wftv50/${response.data?.ZUID}`);
});
});

after(() => {
// Delete test content item
cy.location("pathname").then((loc) => {
Expand Down
Loading

0 comments on commit 4edd15b

Please sign in to comment.