Skip to content

Commit 85bbf70

Browse files
authored
Fixing flaky test (#1538)
1 parent 82cf08b commit 85bbf70

File tree

3 files changed

+61
-38
lines changed

3 files changed

+61
-38
lines changed

ui.tests/test-module/specs/actions/customProperties/customProperties.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe("Custom Properties Tests", () => {
6969
cy.get("coral-selectlist-item[role='option']").contains("Group 1").click({force: true});
7070
cy.get(".fd-CustomProperties-select").click(); // does the job of blur
7171

72-
cy.get(".fd-CustomProperties-additionalCustomPropertiesCheck").click();
72+
cy.get(".fd-CustomProperties-additionalCustomPropertiesCheck").click({force: true});
7373
cy.get(".fd-CustomProperties-additionalMultifield").contains("Add").click();
7474
cy.get(".fd-CustomProperties-additionalKeys").focus().type("addonKey1");
7575
cy.get(".fd-CustomProperties-additionalValues").focus().type("addonValue1");

ui.tests/test-module/specs/title/title.authoring.cy.js

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,32 @@ describe('Page - Authoring', function () {
3838
const testTitleEditDialog = function (titleEditPathSelector, titleDrop, isSites) {
3939
if (isSites) {
4040
dropTitleInSites();
41-
cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + titleEditPathSelector);
42-
cy.invokeEditableAction("[data-action='CONFIGURE']");
43-
cy.get('.cq-dialog-cancel').click();
44-
cy.deleteComponentByPath(titleDrop);
41+
cy.get(sitesSelectors.overlays.overlay.component + titleEditPathSelector)
42+
.should('be.visible')
43+
.first()
44+
.then($el => {
45+
cy.wrap($el).click();
46+
cy.invokeEditableAction("[data-action='CONFIGURE']");
47+
cy.get('.cq-dialog-cancel').should('be.visible').click();
48+
cy.deleteComponentByPath(titleDrop);
49+
});
4550
} else {
4651
dropTitleInContainer();
47-
cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + titleEditPathSelector);
48-
cy.invokeEditableAction("[data-action='CONFIGURE']");
49-
cy.get('.cq-dialog-cancel').click();
50-
cy.get('[data-path^="/content/forms/af/core-components-it/blank/jcr:content/guideContainer/title_"]')
51-
.invoke('attr', 'data-path')
52-
.then(dataPath => {
53-
cy.deleteComponentByPath(dataPath);
54-
})
52+
cy.get(sitesSelectors.overlays.overlay.component + titleEditPathSelector)
53+
.should('be.visible')
54+
.first()
55+
.then($el => {
56+
cy.wrap($el).click();
57+
cy.invokeEditableAction("[data-action='CONFIGURE']");
58+
cy.get('.cq-dialog-cancel').should('be.visible').click();
59+
cy.get('[data-path^="/content/forms/af/core-components-it/blank/jcr:content/guideContainer/title_"]')
60+
.should('exist')
61+
.invoke('attr', 'data-path')
62+
.then(dataPath => {
63+
cy.deleteComponentByPath(dataPath);
64+
});
65+
});
5566
}
56-
5767
}
5868

5969

@@ -82,9 +92,9 @@ describe('Page - Authoring', function () {
8292
});
8393

8494
it('check edit dialog availability of Title', function () {
85-
cy.cleanTitleTest(titleEditPath + "_").then(() => {
95+
cy.cleanTitleTest(titleEditPath).then(() => {
8696
testTitleEditDialog(titleEditPathSelector, titleDrop, false);
87-
})
97+
});
8898
});
8999
});
90100

@@ -106,7 +116,11 @@ describe('Page - Authoring', function () {
106116
});
107117

108118
it('check edit dialog availability of Title', function () {
109-
testTitleEditDialog(titleEditPathSelector, titleDrop, true);
119+
cy.wrap(null).then(() => {
120+
cy.cleanTitleTest(titleEditPath).then(() => {
121+
testTitleEditDialog(titleEditPathSelector, titleDrop, true);
122+
});
123+
});
110124
});
111125

112126
});

ui.tests/test-module/specs/title/titleV2.authoring.cy.js

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,31 @@ describe('Page - Authoring', function () {
3838
const testTitleEditDialog = function (titleEditPathSelector, titleDrop, isSites) {
3939
if (isSites) {
4040
dropTitleInSites();
41-
cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + titleEditPathSelector);
41+
cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + titleEditPathSelector)
42+
.should('exist');
4243
cy.invokeEditableAction("[data-action='CONFIGURE']");
4344
cy.get("[name='./fd:htmlelementType']")
44-
.should("exist");
45-
cy.get('.cq-dialog-cancel').click();
45+
.should("exist");
46+
cy.get('.cq-dialog-cancel').should('be.visible').click();
4647
cy.deleteComponentByPath(titleDrop);
4748
} else {
4849
dropTitleInContainer();
49-
cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + titleEditPathSelector);
50+
cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + titleEditPathSelector)
51+
.should('exist');
5052
cy.invokeEditableAction("[data-action='CONFIGURE']");
5153
cy.get("[name='./fd:htmlelementType']")
52-
cy.get('[name="./fd:htmlelementType"]').eq(0).click()
53-
.should("exist");
54-
cy.get('.cq-dialog-cancel').click();
54+
.should("exist");
55+
cy.get('[name="./fd:htmlelementType"]').eq(0).should('exist').click();
56+
cy.get('.cq-dialog-cancel').should('be.visible').click();
5557
cy.get('[data-path^="/content/forms/af/core-components-it/blank/jcr:content/guideContainer/title"]')
58+
.should('exist')
5659
.invoke('attr', 'data-path')
5760
.then(dataPath => {
5861
const id = dataPath.replace('/content/forms/af/core-components-it/blank/jcr:content/guideContainer/title', '');
5962
const _titleDrop = titleDrop + id;
6063
cy.deleteComponentByPath(dataPath);
61-
})
64+
});
6265
}
63-
6466
}
6567

6668
context('Open Forms Editor', function () {
@@ -76,8 +78,8 @@ describe('Page - Authoring', function () {
7678

7779
it('check edit dialog availability of Title', function () {
7880
cy.cleanTitleTest(titleEditPath).then(() => {
79-
testTitleEditDialog(titleEditPathSelector, titleDrop, false);
80-
})
81+
return testTitleEditDialog(titleEditPathSelector, titleDrop, false);
82+
});
8183
});
8284

8385
});
@@ -100,7 +102,9 @@ describe('Page - Authoring', function () {
100102
});
101103

102104
it('check edit dialog availability of Title', function () {
103-
testTitleEditDialog(titleEditPathSelector, titleDrop, true);
105+
cy.cleanTitleTest(titleEditPath).then(() => {
106+
testTitleEditDialog(titleEditPathSelector, titleDrop, true);
107+
});
104108
});
105109

106110
});
@@ -121,22 +125,27 @@ describe('Page - Authoring', function () {
121125

122126
it('Selecting default pattern from the policy and it should be selected by default', function () {
123127
cy.get(titlePolicy).click({force: true});
124-
cy.get(bemDesignDialog).contains('Title').click();
125-
cy.get('[name="./type"]').eq(0).click({ force: true }).then(() => {
126-
cy.get('coral-selectlist-item').contains(defaultValue).click({ force: true });
127-
cy.get('[name="./type"]').eq(0).should('contain', defaultValue);
128-
cy.get('[placeholder="New policy"]').eq(1).type("Default policy");
129-
cy.get('[title="Done"]').click();
130-
}).then(() => {
128+
cy.get(bemDesignDialog).contains('Title').click({force: true});
129+
cy.get('[name="./type"]').eq(0).click({ force: true });
130+
131+
// Handle coral-selectlist-item visibility issue
132+
cy.get('coral-selectlist-item').contains(defaultValue).click({ force: true });
133+
134+
// Verify the selection was made
135+
cy.get('[name="./type"]').eq(0).should('contain', defaultValue);
136+
cy.get('[placeholder="New policy"]').eq(1).type("Default policy", { force: true });
137+
cy.get('[title="Done"]').click({ force: true });
138+
139+
cy.cleanTitleTest(titleEditPath).then(() => {
131140
cy.openSiteAuthoring(pagePath);
132141
dropTitleInContainer();
133142
// Switching from edit layer to preview layer is flaky, so using previewForm method
134143
cy.previewForm(pagePath + ".html");
135-
cy.get("h2").should("be.visible");
144+
cy.get("h2").should('exist');
136145
cy.openPage("");
137146
cy.openSiteAuthoring(pagePath);
138147
cy.deleteComponentByTitle('Adaptive Form Title');
139-
})
148+
});
140149
});
141150
});
142151

0 commit comments

Comments
 (0)