Skip to content
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

Cypress test config #3127

Draft
wants to merge 78 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
113e190
task: create new version selector button
finnar-bin Nov 26, 2024
f5ea2b4
task: create version item component
finnar-bin Nov 26, 2024
828cf06
task: move menuItem to parent
finnar-bin Nov 26, 2024
ed0e32b
task: wire load version
finnar-bin Nov 27, 2024
323b451
task: render labels
finnar-bin Nov 27, 2024
25413ad
task: use new version selector
finnar-bin Nov 28, 2024
4c57890
task: create add label component
finnar-bin Dec 3, 2024
135d640
task: create rtk queries
finnar-bin Dec 3, 2024
9866289
task: virtualize list
finnar-bin Dec 4, 2024
485d34a
task: dynamically change row height
finnar-bin Dec 4, 2024
5160299
task: prevent jank when opening add label form
finnar-bin Dec 5, 2024
34800d0
task: add label select
finnar-bin Dec 5, 2024
18641fa
task: calculate max list height dynamically
finnar-bin Dec 5, 2024
1ac802f
task: remove ununsed hook
finnar-bin Dec 5, 2024
2c9ce2b
chore: cleanup
finnar-bin Dec 5, 2024
7113141
task: map an item's active status labels
finnar-bin Dec 6, 2024
02eccc1
chore: cleanup
finnar-bin Dec 10, 2024
243fe2c
Merge branch 'dev' into feature/2132-workflow-status
finnar-bin Dec 10, 2024
058d747
task: label mapping
finnar-bin Dec 10, 2024
f458535
task: add/remove status
finnar-bin Dec 11, 2024
ed32b1b
Merge branch 'dev' into feature/2132-workflow-status
finnar-bin Dec 11, 2024
c7c9b67
task: wire edit statuses button
finnar-bin Dec 11, 2024
40363e7
task: wire add/remove label
finnar-bin Dec 11, 2024
05029ae
task: invalidate itemworkflowstatus on content item update
finnar-bin Dec 12, 2024
1bf08ab
task: show most recent label on the header
finnar-bin Dec 12, 2024
fbe6ce3
task: change dropdown position
finnar-bin Dec 16, 2024
0aef49b
task: set max width for chip
finnar-bin Dec 16, 2024
7c4a6c0
task: show counter if active label is more than 1
finnar-bin Dec 16, 2024
75b35a9
task: add publish check
finnar-bin Dec 16, 2024
38a56c8
task: simplify row calculation
finnar-bin Dec 17, 2024
9bda0dc
task: optimize row height calculation
finnar-bin Dec 17, 2024
d2b7743
Merge branch 'dev' into feature/2132-workflow-status
finnar-bin Dec 18, 2024
3fee7d7
[feature/2132-workflow-status-labels]: Create workflows page | status…
geodem127 Dec 18, 2024
683c158
Merge branch 'dev' into feature/2132-workflow-status
finnar-bin Dec 20, 2024
dbff4de
fix: sort labels
finnar-bin Dec 20, 2024
0a2a67d
task: add e2e tests
finnar-bin Dec 20, 2024
5e4002c
Fix reorder trigger
geodem127 Dec 20, 2024
ec3e4f2
Added test cases
geodem127 Dec 20, 2024
c073edb
Added test cases
geodem127 Dec 20, 2024
0e7840b
Added test cases
geodem127 Dec 20, 2024
f9d76b8
Added test cases for reordering labels.
geodem127 Dec 22, 2024
ba438ed
Merge branch 'dev' into feature/2132-workflow-status
finnar-bin Jan 2, 2025
aea7d7b
task: update tests
finnar-bin Jan 2, 2025
00377ee
fix: filter out undefined workflow labels
finnar-bin Jan 2, 2025
6eda4c5
fix: update tests
finnar-bin Jan 2, 2025
296ac60
Added workflow labels test cases, added config to support ts in cypre…
geodem127 Jan 2, 2025
c96b661
Merge remote-tracking branch 'refs/remotes/origin/feature/2132-workfl…
geodem127 Jan 2, 2025
6cc3ae0
Merge remote-tracking branch 'refs/remotes/origin/feature/2132-workfl…
geodem127 Jan 2, 2025
a3ff119
Merge remote-tracking branch 'refs/remotes/origin/feature/2132-workfl…
geodem127 Jan 2, 2025
ce5ea6d
Merge remote-tracking branch 'refs/remotes/origin/feature/2132-workfl…
geodem127 Jan 2, 2025
b32086c
Merge remote-tracking branch 'refs/remotes/origin/feature/2132-workfl…
geodem127 Jan 2, 2025
acf1622
Merge remote-tracking branch 'refs/remotes/origin/feature/2132-workfl…
geodem127 Jan 2, 2025
8a487bf
Merge remote-tracking branch 'refs/remotes/origin/feature/2132-workfl…
geodem127 Jan 2, 2025
772715a
Merge remote-tracking branch 'refs/remotes/origin/feature/2132-workfl…
geodem127 Jan 2, 2025
deab34e
Merge remote-tracking branch 'refs/remotes/origin/feature/2132-workfl…
geodem127 Jan 2, 2025
e08647d
task: remove unused mocks
finnar-bin Jan 3, 2025
a5e8e81
task: fix cache invalidation
finnar-bin Jan 3, 2025
85de838
task: remove timeout
finnar-bin Jan 3, 2025
7eaeb71
Merge branch 'dev' into feature/2132-workflow-status
finnar-bin Jan 3, 2025
5695e41
Relocated prop types | refactored user role identifier - changed to s…
geodem127 Jan 3, 2025
78bb88b
Added test cases to cover important scenarios
geodem127 Jan 3, 2025
f434075
Added test cases to cover important scenarios
geodem127 Jan 3, 2025
3ec6c2b
Fix test errors in deactivating status label
geodem127 Jan 3, 2025
0cc2171
Refactored test cases to resolve flaky test issues
geodem127 Jan 6, 2025
73d5f57
Refactored test cases to resolve flaky test issues
geodem127 Jan 6, 2025
0371227
Merge branch 'dev' into feature/2132-workflow-status
finnar-bin Jan 7, 2025
860f490
Merge remote-tracking branch 'refs/remotes/origin/feature/2132-workfl…
geodem127 Jan 7, 2025
fca84d9
Merge branch 'dev' into feature/2132-workflow-status
finnar-bin Jan 8, 2025
b732280
fix: fixed broken tests
finnar-bin Jan 9, 2025
4559256
Fixed workflow status labels test cases
geodem127 Jan 9, 2025
3a3172e
Fixed workflow status labels test cases
geodem127 Jan 9, 2025
31c2e10
Merge remote-tracking branch 'refs/remotes/origin/feature/2132-workfl…
geodem127 Jan 9, 2025
ee05946
Fixed test cases
geodem127 Jan 9, 2025
f08c7ca
Fixed test cases
geodem127 Jan 9, 2025
914bf2a
Merge remote-tracking branch 'refs/remotes/origin/feature/2132-workfl…
geodem127 Jan 9, 2025
69ad65a
Fix flaky test
geodem127 Jan 9, 2025
08ab081
cypress-test-config-experimental
geodem127 Jan 9, 2025
76dbc37
cypress-test-config-experimental
geodem127 Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = defineConfig({
viewportWidth: 1920,
viewportHeight: 1080,
video: false,
defaultCommandTimeout: 15000,
env: {
API_AUTH: "https://auth.api.dev.zesty.io",
COOKIE_NAME: "DEV_APP_SID",
Expand All @@ -27,4 +28,7 @@ module.exports = defineConfig({
specPattern: "cypress/e2e/**/*.{js,jsx,ts,tsx}",
testIsolation: false,
},
requestTimeout: 60_000,
responseTimeout: 60_000,
retries: 1,
});
10 changes: 5 additions & 5 deletions cypress/e2e/content/actions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe("Actions in content editor", () => {
cy.getBySelector("ConfirmPublishButton").click();

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

cy.getBySelector("ContentPublishedIndicator").should("exist");
});
Expand Down Expand Up @@ -257,9 +257,9 @@ describe("Actions in content editor", () => {
// these waits are due to a delay
// dealing with these specific endpoints
// the local environment is slow
cy.contains("Successfully sent workflow request", { timeout: 5000 }).should(
"exist"
);
cy.contains("Successfully sent workflow request", {
timeout: 15_000,
}).should("exist");
});

// it("Refreshes the CDN cache", () => {
Expand Down Expand Up @@ -330,6 +330,6 @@ describe("Actions in content editor", () => {

cy.getBySelector("CreateItemSaveButton").click();

cy.contains("Created Item", { timeout: 5000 }).should("exist");
cy.contains("Created Item", { timeout: 30_000 }).should("exist");
});
});
24 changes: 24 additions & 0 deletions cypress/e2e/content/pages/ContentItemPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class ContentItemPage {
elements = {
createItemButton: () => cy.getBySelector("CreateItemSaveButton"),
duoModeToggle: () => cy.getBySelector("DuoModeToggle"),
moreMenu: () => cy.getBySelector("ContentItemMoreButton"),
deleteItemButton: () => cy.getBySelector("DeleteContentItem"),
confirmDeleteItemButton: () =>
cy.getBySelector("DeleteContentItemConfirmButton"),
versionSelector: () => cy.getBySelector("VersionSelector"),
versionItem: () => cy.getBySelector("VersionItem"),
addWorkflowStatusLabel: () => cy.getBySelector("AddWorkflowStatusLabel"),
workflowStatusLabelOption: () =>
cy.getBySelector("WorkflowStatusLabelOption"),
activeWorkflowStatusLabel: () =>
cy.getBySelector("ActiveWorkflowStatusLabel"),
publishItemButton: () => cy.getBySelector("PublishButton"),
confirmPublishItemButton: () => cy.getBySelector("ConfirmPublishButton"),
toast: () => cy.getBySelector("toast"),
contentPublishedIndicator: () =>
cy.getBySelector("ContentPublishedIndicator"),
};
}

export default new ContentItemPage();
198 changes: 198 additions & 0 deletions cypress/e2e/content/workflows.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
import ContentItemPage from "./pages/ContentItemPage";
import CONFIG from "../../../src/shell/app.config";
import instanceZUID from "../../../src/utility/instanceZUID";

const INSTANCE_API = `${
CONFIG?.[process.env.NODE_ENV]?.API_INSTANCE_PROTOCOL
}${instanceZUID}${CONFIG?.[process.env.NODE_ENV]?.API_INSTANCE}`;
const TITLES = {
contentItem: "Content item workflow test",
publishLabel: "Publish Approval",
testLabel: "Random Test Label",
};
const LABEL_DATA = {
publishLabel: {
name: TITLES.publishLabel,
description: "",
color: "#4E5BA6",
allowPublish: true,
addPermissionRoles: ["30-86f8ccec82-swp72s", "30-8ee88afe82-gmx631"],
removePermissionRoles: ["30-86f8ccec82-swp72s", "30-8ee88afe82-gmx631"],
},
testLabel: {
name: TITLES.testLabel,
description: "",
color: "#4E5BA6",
allowPublish: false,
addPermissionRoles: ["30-86f8ccec82-swp72s", "30-8ee88afe82-gmx631"],
removePermissionRoles: ["30-86f8ccec82-swp72s", "30-8ee88afe82-gmx631"],
},
};

describe("Content Item Workflows", () => {
before(() => {
cy.intercept("POST", "**/labels").as("createLabel");
cy.intercept("GET", "**/labels*").as("getLabels");

// Create allow publish workflow label
Object.values(LABEL_DATA).forEach((data) => {
cy.apiRequest({
method: "POST",
url: `${INSTANCE_API}/env/labels`,
body: data,
});
});

// Visit test page
cy.apiRequest({
method: "POST",
url: `${INSTANCE_API}/content/models/6-b6cde1aa9f-wftv50/items`,
body: {
data: {
title: TITLES.contentItem,
description: TITLES.contentItem,
tc_title: TITLES.contentItem,
tc_description: TITLES.contentItem,
tc_image: null,
},
web: {
canonicalTagMode: 1,
parentZUID: "0",
metaLinkText: TITLES.contentItem,
metaTitle: TITLES.contentItem,
pathPart: TITLES.contentItem?.replaceAll(" ", "-")?.toLowerCase(),
metaDescription: TITLES.contentItem,
},
meta: { langID: 1, contentModelZUID: "6-b6cde1aa9f-wftv50" },
},
}).then((response) => {
cy.visit(`/content/6-b6cde1aa9f-wftv50/${response.data?.ZUID}`);
});
});

after(() => {
// Delete test content item
cy.location("pathname").then((loc) => {
const [_, __, modelZUID, itemZUID] = loc?.split("/");
cy.apiRequest({
method: "DELETE",
url: `${INSTANCE_API}/content/models/${modelZUID}/items/${itemZUID}`,
});
});

// Delete test labels
cy.apiRequest({ url: `${INSTANCE_API}/env/labels?showDeleted=true` }).then(
(response) => {
response?.data
?.filter(
(label) =>
!label?.deletedAt &&
[TITLES.publishLabel, TITLES.testLabel].includes(label?.name)
)
.forEach((label) => {
cy.apiRequest({
url: `${INSTANCE_API}/env/labels/${label.ZUID}`,
method: "DELETE",
});
});
}
);
});

it("Can add a workflow label", () => {
ContentItemPage.elements.versionSelector().should("exist").click();
ContentItemPage.elements.addWorkflowStatusLabel().should("exist").click();
ContentItemPage.elements
.workflowStatusLabelOption()
.contains(TITLES.testLabel)
.should("exist")
.click({ force: true });

cy.get("body").type("{esc}");

cy.intercept("PUT", "**/labels/*").as("updateLabel");
cy.wait("@updateLabel");

cy.reload();

ContentItemPage.elements.versionSelector().should("exist").click();
ContentItemPage.elements
.versionItem()
.first()
.within(() => {
ContentItemPage.elements
.activeWorkflowStatusLabel()
.should("have.length", 1);
});

cy.get("body").type("{esc}");
});

it("Cannot add a workflow label when role has no permission", () => {
ContentItemPage.elements.versionSelector().should("exist").click();
ContentItemPage.elements.addWorkflowStatusLabel().should("exist").click();
ContentItemPage.elements
.workflowStatusLabelOption()
.first()
.should("exist")
.click({ force: true });

cy.get("body").type("{esc}");

cy.reload();

ContentItemPage.elements.versionSelector().should("exist").click();
ContentItemPage.elements
.versionItem()
.first()
.within(() => {
ContentItemPage.elements
.activeWorkflowStatusLabel()
.should("have.length", 1);
});

cy.get("body").type("{esc}");
});

it("Cannot publish a content item if label with allowPublish is missing", () => {
ContentItemPage.elements
.publishItemButton()
.should("exist")
.click({ force: true });
ContentItemPage.elements
.confirmPublishItemButton()
.should("exist")
.click({ force: true });
ContentItemPage.elements
.toast()
.contains(
`Cannot Publish: "${TITLES.contentItem}". Does not have a status that allows publishing`
);
});

it("Can publish a content item if label with allowPublish is applied", () => {
cy.reload();
ContentItemPage.elements.versionSelector().should("exist").click();
ContentItemPage.elements.addWorkflowStatusLabel().should("exist").click();
ContentItemPage.elements
.workflowStatusLabelOption()
.contains(TITLES.publishLabel)
.should("exist")
.click({ force: true });

cy.get("body").type("{esc}");

cy.intercept("PUT", "**/labels/*").as("updateLabel");
cy.wait("@updateLabel");

cy.reload();

ContentItemPage.elements.publishItemButton().should("exist").click();
ContentItemPage.elements.confirmPublishItemButton().should("exist").click();

cy.intercept("GET", "**/publishings").as("publish");
cy.wait("@publish");

ContentItemPage.elements.contentPublishedIndicator().should("exist");
});
});
Loading
Loading