Skip to content

Commit

Permalink
updated blocks.specs to accomodate new starter blocks UI
Browse files Browse the repository at this point in the history
  • Loading branch information
geodem127 committed Feb 25, 2025
1 parent cff741e commit bca80e5
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 33 deletions.
6 changes: 3 additions & 3 deletions cypress/e2e/blocks/pages/AllBlocksPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AllBlocksPage {
}

get createBlockButton() {
return cy.getBySelector("create-block-button");
return cy.getBySelector("create-block-button", TIMEOUT);
}

get onboardingDialog() {
Expand All @@ -33,8 +33,8 @@ class AllBlocksPage {

createBlock(name) {
this.createBlockButton.click(TIMEOUT);
cy.getBySelector("create-model-display-name-input").type(name);
cy.getBySelector("create-model-submit-button").click(TIMEOUT);
cy.getBySelector("create-model-display-name-input", TIMEOUT).type(name);
cy.getBySelector("create-model-submit-button", TIMEOUT).click();
}
}

Expand Down
55 changes: 49 additions & 6 deletions cypress/e2e/blocks/tests/blocks.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import AllBlocksPage from "../pages/AllBlocksPage";
import BlockPage from "../pages/BlockPage";
import SchemaPage from "../../schema/pages/SchemaPage";
import { API_ENDPOINTS } from "../../../support/api";

const CypressTestBlock = "Cypress Test Block";
const CypressTestVariant = "Cypress Test Variant";
Expand All @@ -11,12 +12,14 @@ const TIMEOUT = {

describe("All Blocks Tests", () => {
before(() => {
deleteTestDataModels();
AllBlocksPage.visit();
});

after(() => {
SchemaPage.visit();
SchemaPage.deleteModel(CypressTestBlock);
// SchemaPage.visit();
// SchemaPage.deleteModel(CypressTestBlock);
deleteTestDataModels();
});

it("should show and traverse onboarding flow", () => {
Expand All @@ -28,7 +31,8 @@ describe("All Blocks Tests", () => {
AllBlocksPage.onboardingDialog.should("not.exist");
});

it("creates new block with default values", () => {
// Skiped since starter blocks are introduced.
it.skip("creates new block with default values", () => {
AllBlocksPage.createBlock(CypressTestBlock);
cy.contains(CypressTestBlock, TIMEOUT).should("exist");
SchemaPage.visit();
Expand All @@ -40,6 +44,26 @@ describe("All Blocks Tests", () => {
AllBlocksPage.visit();
});

it("creates new block with default values", () => {
AllBlocksPage.visit();
cy.get('[data-cy="create_new_content_item"]').click();
cy.get('[data-cy="starter-block-card"]').first().click();
cy.get('[data-cy="select-block-type-next-button"]').click();
cy.get('[data-cy="starter-block-form-label"] input')
.clear()
.type(CypressTestBlock);
cy.intercept("POST", "/v1/content/models").as("createModel");
cy.get('[data-cy="starter-block-form-submit"]').click();
cy.wait("@createModel").then((interception) => {
const ZUID = interception?.response?.body?.data?.ZUID;
Cypress.env("model_zuid", ZUID);

console.debug("ZUID: ", ZUID);
// expect(res.data.label).to.eq(CypressTestBlock);
});
AllBlocksPage.visit();
});

it("searches for a block", () => {
AllBlocksPage.searchBlocksInput.type(CypressTestBlock);
cy.contains(CypressTestBlock).should("exist");
Expand All @@ -54,16 +78,35 @@ describe("All Blocks Tests", () => {
});

it("navigates to block detail page", () => {
cy.contains(CypressTestBlock).click(TIMEOUT);
cy.contains("Start Creating Variants Now").should("exist");
AllBlocksPage.visit();
cy.contains(CypressTestBlock, TIMEOUT).click();
cy.contains("Start Creating Variants Now", TIMEOUT).should("exist");
});

it("creates a variant with default values", () => {
AllBlocksPage.visit();
cy.contains(CypressTestBlock).click(TIMEOUT);
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"]').should("have.value", "Default Foo");
});
});

function deleteTestDataModels() {
cy.apiRequest({
url: `${API_ENDPOINTS.devInstance}/content/models`,
}).then((response) => {
response?.data
?.filter((resData) =>
[CypressTestBlock, CypressTestVariant].includes(resData?.label)
)
.forEach((forDelete) => {
cy.apiRequest({
url: `${API_ENDPOINTS.devInstance}/content/models/${forDelete.ZUID}`,
method: "DELETE",
});
});
});
}
21 changes: 4 additions & 17 deletions cypress/e2e/content/actions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const yesterdayTimestamp = moment()
.subtract(1, "day")
.format("x");

const SUFFIX = "-TEST-DATA";
const SUFFIX = "---T";

const TEST_DATA = {
newItem: `new_item${SUFFIX}`,
Expand Down Expand Up @@ -231,13 +231,12 @@ describe("Actions in content editor", () => {
});

it("Creates a new item", () => {
cleanTestData();
cy.waitOn("/v1/content/models*", () => {
cy.visit("/content/6-a1a600-k0b6f0/new");
});

cy.get("input[name=title]", TIMEOUT)
// .click()
.type(TEST_DATA?.newItem);
cy.get("input[name=title]", TIMEOUT).type(TEST_DATA?.newItem, TIMEOUT);
cy.getBySelector("ManualMetaFlow").click();
cy.getBySelector("metaDescription")
.find("textarea")
Expand All @@ -262,7 +261,7 @@ describe("Actions in content editor", () => {

it("Deletes an item", () => {
cy.contains(TEST_DATA?.newItem, TIMEOUT).click();
cy.getBySelector("ContentItemMoreButton").click();
cy.getBySelector("ContentItemMoreButton", TIMEOUT).click();
cy.getBySelector("DeleteContentItem").click();
cy.getBySelector("DeleteContentItemConfirmButton").click();

Expand Down Expand Up @@ -359,25 +358,13 @@ describe("Actions in content editor", () => {
});
});

function repeat(cb) {
cb();
cb();
}

function cleanTestData() {
cy.apiRequest({
url: `${API_ENDPOINTS.devInstance}/content/models/6-a1a600-k0b6f0/items?limit=5000&page=1&lang=en-US`,
}).then((response) => {
const zuids = response?.data
?.filter((resData) => resData?.data?.title?.includes(SUFFIX))
?.map((item) => item?.meta?.ZUID);
// .forEach((forDelete) => {
// cy.apiRequest({
// url: `${API_ENDPOINTS.devInstance}/content/models/6-a1a600-k0b6f0/items/batch`,
// method: "DELETE",
// body:"cc"
// });
// });

cy.apiRequest({
url: `${API_ENDPOINTS.devInstance}/content/models/6-a1a600-k0b6f0/items/batch`,
Expand Down
16 changes: 11 additions & 5 deletions cypress/e2e/schema/models.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ const TIMEOUT = {
timeout: 15000,
};

const BLOCK_MODEL_NAME = "Test Block Model";

describe("Schema: Models", () => {
before(() => {
cy.deleteModels([BLOCK_MODEL_NAME]);
cy.waitOn("/v1/content/models*", () => {
cy.visit("/schema");
});
Expand Down Expand Up @@ -45,7 +48,9 @@ describe("Schema: Models", () => {
.type("Cypress test (Group with visible fields in list)");

cy.get(".MuiAutocomplete-popper")
.contains("Cypress test (Group with visible fields in list)")
.contains("Cypress test (Group with visible fields in list)", {
timeout: 50_000,
})
.click();

cy.contains("Description").next().type("Cypress test model description");
Expand Down Expand Up @@ -126,19 +131,20 @@ describe("Schema: Models", () => {
.contains("Model parenting itself");
});

it("Can create a block model", () => {
//Skipped this. This has been tested on the starter block feature.
it.skip("Can create a block model", () => {
cy.waitOn("/v1/content/models*", () => {
cy.visit("/schema");
});

cy.getBySelector(`create-model-button-all-models`).click(TIMEOUT);
cy.contains("Block Model").click();
cy.contains("Next").click();
cy.contains("Display Name").next().type(`Block Test Model ${TIMESTAMP}`);
cy.contains("Display Name").next().type(BLOCK_MODEL_NAME);
cy.contains("Reference ID")
.next()
.find("input")
.should("have.value", `block_test_model_${TIMESTAMP}`);
.should("have.value", BLOCK_MODEL_NAME);

cy.contains("Description").next().type("Block test model description");
cy.get(".MuiDialog-container").within(() => {
Expand All @@ -147,6 +153,6 @@ describe("Schema: Models", () => {
cy.intercept("POST", "/models");
cy.intercept("GET", "/models");

cy.contains(`Block Test Model ${TIMESTAMP}`).should("exist");
cy.contains(BLOCK_MODEL_NAME, TIMEOUT).should("exist");
});
});
5 changes: 3 additions & 2 deletions src/apps/schema/src/app/components/CreateModelDialogue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,9 @@ export const CreateModelDialogue = ({ onClose, modelType = "" }: Props) => {
/>
<Stack>
<Typography variant="h5" fontWeight={700}>
Create
{modelTypes.find((x) => x.key === model.type).name}
{`Create ${
modelTypes.find((x) => x.key === model.type).name
}`}
</Typography>
<Typography variant="body3" color="text.secondary">
{
Expand Down

0 comments on commit bca80e5

Please sign in to comment.