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 15, 2025
1 parent 99385cc commit 6b783cd
Show file tree
Hide file tree
Showing 18 changed files with 472 additions and 535 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,
});
5 changes: 4 additions & 1 deletion cypress/e2e/blocks/pages/AllBlocksPage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const TIMEOUT = { timeout: 30_000 };
class AllBlocksPage {
visit() {
cy.visit("/blocks");
Expand Down Expand Up @@ -28,9 +29,11 @@ class AllBlocksPage {
}

createBlock(name) {
this.createBlockButton.click();
cy.intercept("POST", "**/content/models").as("createModel");
this.createBlockButton.click(TIMEOUT);
cy.getBySelector("create-model-display-name-input").type(name);
cy.getBySelector("create-model-submit-button").click();
cy.wait("@createModel");
}
}

Expand Down
30 changes: 21 additions & 9 deletions cypress/e2e/blocks/tests/blocks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ import SchemaPage from "../../schema/pages/SchemaPage";
const CypressTestBlock = "Cypress Test Block";
const CypressTestVariant = "Cypress Test Variant";

const TIMEOUT = { timeout: 30_000 };

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

after(() => {
SchemaPage.visit();
SchemaPage.deleteModel(CypressTestBlock);
cy.deleteContentModels(["Cypress Test Block", "Cypress Test Variant"]);
});

it("should show and traverse onboarding flow", () => {
AllBlocksPage.onboardingDialog.should("be.visible");
cy.visit("/blocks");
cy.get('[data-cy="onboarding-dialog"]', TIMEOUT).should("be.visible");
const totalSteps = 4;
for (let i = 0; i < totalSteps; i++) {
AllBlocksPage.clickOnboardingNextButton();
Expand All @@ -26,13 +29,15 @@ describe("All Blocks Tests", () => {

it("creates new block with default values", () => {
AllBlocksPage.createBlock(CypressTestBlock);
cy.contains(CypressTestBlock).should("exist");
cy.contains(CypressTestBlock, TIMEOUT).should("exist");
SchemaPage.visit();

SchemaPage.addSingleLineTextFieldWithDefaultValue(
CypressTestBlock,
"Foo",
"Default Foo"
);

AllBlocksPage.visit();
});

Expand All @@ -50,16 +55,23 @@ 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", () => {
cy.contains(CypressTestBlock).click();
AllBlocksPage.visit();
cy.contains(CypressTestBlock).click(TIMEOUT);
BlockPage.createVariant(CypressTestVariant);
cy.contains(
new RegExp(`${CypressTestBlock}:\\s*${CypressTestVariant}`)
new RegExp(`${CypressTestBlock}:\\s*${CypressTestVariant}`),
TIMEOUT
).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 6b783cd

Please sign in to comment.