Skip to content

Commit 5ce426b

Browse files
committed
[#3241] : One to one relationship field selection issue (#3274)
Added a button that opens the FieldSelector dialog, allowing the user to replace the currently selected content item.
1 parent b422031 commit 5ce426b

File tree

23 files changed

+544
-272
lines changed

23 files changed

+544
-272
lines changed

Diff for: cypress/e2e/content/actions.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,14 @@ describe("Actions in content editor", () => {
358358
cy.getBySelector("metaDescription").find("[data-cy='AIOpen']").click();
359359
cy.getBySelector("AIGenerate").click();
360360

361-
cy.wait("@ai");
361+
cy.wait("@ai", { timeout: 50000 });
362362

363363
cy.getBySelector("AISuggestion1").click();
364364
cy.getBySelector("AIApprove").click();
365365

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

368-
cy.contains("Created Item", { timeout: 5000 }).should("exist");
368+
cy.contains("Created Item", { timeout: 15000 }).should("exist");
369369
});
370370
});
371371

Diff for: cypress/e2e/content/comments.js

+60-23
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,48 @@
1+
const options = { timeout: 15000 };
2+
const forceClick = { force: true };
3+
4+
const commentBox = '#commentInputField[contenteditable="true"]';
5+
16
describe("Content Item: Comments", () => {
27
before(() => {
8+
cleanComments();
39
cy.waitOn("/v1/content/models*", () => {
410
cy.waitOn("/v1/comments*", () => {
5-
cy.visit("/content/6-556370-8sh47g/7-b939a4-457q19");
11+
cy.visit(
12+
"/content/6-556370-8sh47g/7-b939a4-457q19/comment/12-6d41d0-n10vtc"
13+
);
614
});
715
});
8-
cy.getBySelector("DuoModeToggle").click();
916
});
1017

1118
it("Creates an initial comment", () => {
12-
cy.getBySelector("OpenCommentsButton").first().click();
13-
cy.get("#commentInputField").click().type("This is a new comment.");
14-
cy.getBySelector("SubmitNewComment").click();
1519
cy.intercept("/v1/comments/*").as("getAllComments");
20+
cy.get(commentBox, { timeout: 50000 }).should("exist");
21+
cy.get(commentBox).focus();
22+
cy.get(commentBox).type("This is a new comment.");
23+
cy.get('[data-cy="SubmitNewComment"]').click();
24+
1625
cy.wait("@getAllComments");
17-
cy.getBySelector("CommentItem").should("have.length", 1);
26+
cy.get('[data-cy="CommentItem"]').should("have.length", 1);
1827
});
1928

2029
it("Replies to a comment", () => {
21-
cy.get("#commentInputField").click().type("Hello, this is a new reply!");
22-
cy.getBySelector("SubmitNewComment").click();
2330
cy.intercept("/v1/comments/*?showReplies=true&showResolved=true").as(
2431
"getReplies"
2532
);
33+
cy.get(commentBox, options).type("Hello, this is a new reply!");
34+
cy.get('[data-cy="SubmitNewComment"]').click();
35+
2636
cy.wait("@getReplies");
27-
cy.getBySelector("CommentItem").should("have.length", 2);
37+
cy.get('[data-cy="CommentItem"]').should("have.length", 2);
2838
});
2939

3040
it("Updates an existing comment", () => {
3141
const UPDATED_TEXT = "I am updating this comment now.";
3242

33-
cy.getBySelector("CommentMenuButton").first().click();
43+
cy.getBySelector("CommentMenuButton", options).first().click(forceClick);
3444
cy.getBySelector("EditCommentButton").click();
35-
cy.get("#commentInputField")
36-
.click()
37-
.type(`{selectall}{backspace}${UPDATED_TEXT}`);
45+
cy.get(commentBox).type(`{selectall}{backspace}${UPDATED_TEXT}`);
3846
cy.getBySelector("SubmitNewComment").click();
3947
cy.intercept("/v1/comments/*?showReplies=true&showResolved=true").as(
4048
"getReplies"
@@ -44,7 +52,7 @@ describe("Content Item: Comments", () => {
4452
});
4553

4654
it("Resolves a comment", () => {
47-
cy.getBySelector("ResolveCommentButton").click();
55+
cy.getBySelector("ResolveCommentButton").click(forceClick);
4856
cy.intercept("/v1/comments/*?showReplies=true&showResolved=true").as(
4957
"getReplies"
5058
);
@@ -57,7 +65,7 @@ describe("Content Item: Comments", () => {
5765
});
5866

5967
it("Reopens a comment when there is a new reply", () => {
60-
cy.get("#commentInputField").click().type("Reopening ticket.");
68+
cy.get(commentBox, options).type("Reopening ticket.");
6169
cy.getBySelector("SubmitNewComment").click();
6270
cy.intercept("/v1/comments/*?showReplies=true&showResolved=true").as(
6371
"getReplies"
@@ -71,14 +79,43 @@ describe("Content Item: Comments", () => {
7179
});
7280

7381
it("Delete a comment", () => {
74-
cy.getBySelector("CommentMenuButton").first().click();
75-
cy.getBySelector("DeleteCommentButton").click();
76-
cy.getBySelector("ConfirmDeleteCommentButton").click();
77-
cy.intercept("/v1/instances/*/comments?resource=*").as(
78-
"getCommentResourceData"
82+
cy.intercept("DELETE", "/v1/comments/*").as("deleteComment");
83+
cy.intercept("/v1/instances/*/comments?resource=*").as("getComments");
84+
85+
cy.get('[data-cy="CommentItem"]', { timeout: 40000 }).should("exist");
86+
87+
const beforeDeleteCount = Cypress.$('[data-cy="CommentItem"]').length;
88+
89+
cy.log("beforeDeleteCount: ", beforeDeleteCount);
90+
91+
cy.get('[data-cy="CommentItem"]:eq(0) [data-cy="CommentMenuButton"]').click(
92+
forceClick
93+
);
94+
95+
cy.get('[data-cy="DeleteCommentButton"]').click();
96+
97+
cy.get('[data-cy="ConfirmDeleteCommentButton"]', options).click();
98+
99+
cy.wait(["@deleteComment", "@getComments"]).spread(
100+
(deleteComment, getComments) => {
101+
const afterDeleteCount = getComments?.response?.body?.data?.length;
102+
expect(afterDeleteCount).to.be.lessThan(beforeDeleteCount);
103+
}
79104
);
80-
cy.wait("@getCommentResourceData");
81-
cy.getBySelector("OpenCommentsButton").first().click();
82-
cy.getBySelector("CommentItem").should("not.exist");
83105
});
84106
});
107+
108+
function cleanComments() {
109+
cy.apiRequest({
110+
url: `https://accounts.api.dev.zesty.io/v1/instances/8-f48cf3a682-7fthvk/comments?resource=7-b939a4-457q19&scope=12-6d41d0-n10vtc&showResolved=true`,
111+
method: "GET",
112+
}).then((response) => {
113+
const zuids = response?.data?.map((item) => item?.ZUID);
114+
zuids.forEach((zuid) => {
115+
cy.apiRequest({
116+
url: `https://accounts.api.dev.zesty.io/v1/comments/${zuid}`,
117+
method: "DELETE",
118+
});
119+
});
120+
});
121+
}

Diff for: cypress/e2e/content/content.spec.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import moment from "moment";
2-
2+
const options = { timeout: 15000 };
3+
const forceClick = { force: true };
34
describe("Content Specs", () => {
45
const TIMESTAMP = Date.now();
56

@@ -446,21 +447,25 @@ describe("Content Specs", () => {
446447
});
447448

448449
it("can only select/add one item", () => {
449-
cy.get("#12-edee00-6zb866 [data-cy='add-relational-item-button']").click({
450-
force: true,
451-
});
450+
cy.intercept({ method: "GET", url: "**/items*" }).as("getItems");
452451

453-
cy.wait("@fetchItems");
452+
cy.get(
453+
'[data-cy="add-relational-item-button"]:contains("Add Existing One to One")',
454+
options
455+
).click(forceClick);
454456

455-
cy.get(".MuiDataGrid-row").first().find("input").click();
456-
cy.get(".MuiDataGrid-row").eq(1).find("input").click();
457+
cy.wait("@getItems", { timeout: 40000 });
457458

458-
cy.getBySelector("selected-count").contains("1 / 1 selected");
459-
cy.getBySelector("done-selecting-item-button").click();
460-
cy.get("#12-edee00-6zb866 [data-cy='active-relational-item']").should(
459+
cy.get(".MuiDataGrid-row:eq(0) input", options).click(forceClick);
460+
cy.get(".MuiDataGrid-row:eq(1) input", options).click(forceClick);
461+
462+
cy.get(".MuiDataGrid-row input:checked", options).should(
461463
"have.length",
462464
1
463465
);
466+
cy.get('[data-cy="done-selecting-item-button"]', options).click(
467+
forceClick
468+
);
464469
});
465470

466471
it("can publish an item", () => {

Diff for: cypress/e2e/content/item-list-table.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ describe("Content item list table", () => {
66
});
77
});
88

9-
cy.getBySelector("SingleRelationshipCell", { timeout: 10000 })
9+
cy.getBySelector("SingleRelationshipCell", { timeout: 30000 })
1010
.first()
1111
.contains(
12-
"5 Tricks to Teach Your Pitbull: Fun & Easy Tips for You & Your Dog!"
12+
"5 Tricks to Teach Your Pitbull: Fun & Easy Tips for You & Your Dog!",
13+
{ timeout: 15_000 }
1314
);
1415
});
1516
});

Diff for: cypress/e2e/media/folders.spec.js

+53-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
const options = { timeout: 15000 };
2+
const forceClick = { force: true };
3+
const NEW_TEST_FOLDER = "CYPRESS TEST NEW FOLDER";
4+
15
describe("Media Folders", () => {
26
before(() => {
7+
cleanTestData();
38
cy.waitOn("*groups*", () => {
49
cy.visit("/media");
510
});
@@ -12,82 +17,90 @@ describe("Media Folders", () => {
1217
.type("zesty-{downArrow}{enter}");
1318

1419
cy.get(".MuiDialog-container").within(() => {
15-
cy.contains("Folder Name").next().type("CYPRESS TEST NEW FOLDER");
20+
cy.contains("Folder Name").next().type(NEW_TEST_FOLDER);
1621
cy.contains("Create").click();
1722
});
1823

1924
cy.intercept("POST", "/groups");
2025

21-
cy.get(".MuiTreeView-root")
22-
.contains("CYPRESS TEST NEW FOLDER")
26+
cy.get(".MuiTreeView-root", options)
27+
.contains(NEW_TEST_FOLDER)
2328
.should("exist");
2429
});
2530
it("Hides and shows folder", () => {
26-
cy.get(".MuiTreeView-root").contains("CYPRESS TEST NEW FOLDER").click();
31+
cy.get(".MuiTreeView-root").contains(NEW_TEST_FOLDER).click();
2732

28-
cy.get("[aria-label='Open folder menu']").click();
33+
cy.get("[aria-label='Open folder menu']", options).click(forceClick);
34+
35+
cy.contains("Hide", options).should("be.visible").click(forceClick);
2936

30-
cy.contains("Hide").click();
37+
cy.wait(500);
3138

3239
// Non hidden tree
33-
cy.get(".MuiTreeView-root")
40+
cy.get(".MuiTreeView-root", options)
3441
.first()
35-
.contains("CYPRESS TEST NEW FOLDER")
42+
.contains(NEW_TEST_FOLDER, options)
3643
.should("not.exist");
3744

3845
// Hidden Tree
3946
cy.get(".MuiTreeView-root")
4047
.next()
41-
.contains("CYPRESS TEST NEW FOLDER")
48+
.contains(NEW_TEST_FOLDER)
4249
.should("exist");
4350

4451
cy.get("[aria-label='Open folder menu']").click();
4552

46-
cy.contains("Show").click();
53+
cy.contains("Show", options).click();
54+
55+
cy.wait(500);
4756

4857
// Non hidden tree
49-
cy.get(".MuiTreeView-root")
58+
cy.get(".MuiTreeView-root", options)
5059
.first()
51-
.contains("CYPRESS TEST NEW FOLDER")
60+
.contains(NEW_TEST_FOLDER)
5261
.should("exist");
5362
});
5463
it("Navigates folders via breadcrumbs", () => {
55-
cy.get(".MuiTreeView-root").contains("CYPRESS TEST NEW FOLDER").click();
64+
cy.get(".MuiTreeView-root")
65+
.contains(NEW_TEST_FOLDER, options)
66+
.click(forceClick);
5667

5768
cy.getBySelector("breadcrumbs").find(".MuiBreadcrumbs-li").first().click();
5869
cy.location("pathname").should("eq", "/media/folder/1-6c9618c-r26pt");
5970
});
6071
it("Renames folder", () => {
61-
cy.get(".MuiTreeView-root").contains("CYPRESS TEST NEW FOLDER").click();
72+
cy.get(".MuiTreeView-root")
73+
.contains(NEW_TEST_FOLDER, options)
74+
.click(forceClick);
6275

63-
cy.get("[aria-label='Open folder menu']").click();
76+
cy.get("[aria-label='Open folder menu']", options).click();
6477

65-
cy.contains("Rename").click();
78+
cy.contains("Rename", options).should("be.visible").click();
6679

6780
cy.get(".MuiDialog-container").within(() => {
68-
cy.contains("New Folder Name")
81+
cy.contains("New Folder Name", options)
6982
.next()
7083
.clear()
84+
.wait(500)
7185
.type("CYPRESS TEST NEW FOLDER EDITED");
7286
cy.contains("Update").click();
7387
});
7488

7589
cy.intercept("PUT", "/groups");
7690

77-
cy.get(".MuiTreeView-root")
78-
.contains("CYPRESS TEST NEW FOLDER EDITED")
79-
.should("exist");
91+
cy.get(".MuiTreeView-root").should("be.visible");
92+
cy.contains("p", "CYPRESS TEST NEW FOLDER EDITED", options).should("exist");
8093
});
8194
it("Deletes folder", () => {
8295
cy.get(".MuiTreeView-root")
8396
.contains("CYPRESS TEST NEW FOLDER EDITED")
84-
.click();
97+
.click(forceClick);
8598

8699
cy.get("[aria-label='Open folder menu']").click();
87100

88-
cy.contains("Delete").click();
101+
cy.contains("Delete", options).should("be.visible").click(forceClick);
89102

90-
cy.get(".MuiButton-containedError").click();
103+
cy.get(".MuiButton-containedError", options).click();
91104

92105
cy.intercept("DELETE", "/groups");
93106

@@ -96,3 +109,20 @@ describe("Media Folders", () => {
96109
.should("not.exist");
97110
});
98111
});
112+
113+
function cleanTestData() {
114+
cy.apiRequest({
115+
url: `https://media-manager.api.dev.zesty.io/bin/1-6c9618c-r26pt/groups`,
116+
}).then((response) => {
117+
const zuids = response?.data
118+
?.filter((item) => item?.name?.includes(NEW_TEST_FOLDER))
119+
?.map((item) => item?.id);
120+
121+
zuids.forEach((zuid) => {
122+
cy.apiRequest({
123+
url: `https://media-manager.api.dev.zesty.io/group/${zuid}`,
124+
method: "DELETE",
125+
});
126+
});
127+
});
128+
}

Diff for: cypress/e2e/schema/models.spec.js

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
const options = { timeout: 15000 };
2+
const forceClick = { force: true };
3+
14
const SEARCH_TERM = `cypress ${Date.now()}`;
25
const TIMESTAMP = Date.now();
36
const TIMEOUT = {
@@ -62,24 +65,26 @@ describe("Schema: Models", () => {
6265
});
6366

6467
it("Renames model", () => {
65-
cy.getBySelector(`model-header-menu`).click(TIMEOUT);
66-
cy.contains("Rename Model").click();
67-
cy.get(".MuiDialog-container").within(() => {
68-
cy.get("label").contains("Display Name").next().type(" Updated");
69-
cy.get("label").contains("Reference ID").next().type("_updated");
68+
cy.getBySelector(`model-header-menu`, options).click(forceClick);
69+
cy.contains("Rename Model", options).click(forceClick);
70+
cy.get(".MuiDialog-container", options).within(() => {
71+
cy.get("label", options).contains("Display Name").next().type(" Updated");
72+
cy.get("label", options).contains("Reference ID").next().type("_updated");
7073
cy.contains("Save").click();
7174
});
7275
cy.intercept("PUT", "/models");
7376
cy.intercept("GET", "/models");
74-
cy.contains("Cypress Test Model Updated").should("exist");
77+
cy.contains("Cypress Test Model Updated", options).should("exist");
7578
});
7679
it("Deletes model", () => {
77-
cy.getBySelector(`model-header-menu`).click(TIMEOUT);
78-
cy.contains("Delete Model").click(TIMEOUT);
79-
cy.get(".MuiDialog-container").within(() => {
80-
cy.get(".MuiOutlinedInput-root").type("Cypress Test Model Updated");
80+
cy.getBySelector(`model-header-menu`, options).click(forceClick);
81+
cy.contains("Delete Model", options).click(forceClick);
82+
cy.get(".MuiDialog-container", options).within(() => {
83+
cy.get(".MuiOutlinedInput-root", options).type(
84+
"Cypress Test Model Updated"
85+
);
8186
});
82-
cy.contains("Delete Forever").click();
87+
cy.contains("Delete Forever", options).click();
8388
});
8489
it("Can navigate via breadcrumbs", () => {
8590
cy.waitOn(

0 commit comments

Comments
 (0)