Skip to content

Commit 1f2b8df

Browse files
im-shivShivam Agarwal
andauthored
fixing flaky test (#1450)
Co-authored-by: Shivam Agarwal <shivama@adobe.com>
1 parent e6fa8bb commit 1f2b8df

File tree

1 file changed

+31
-36
lines changed

1 file changed

+31
-36
lines changed

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

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
const sitesSelectors = require('../../libs/commons/sitesSelectors'),
1919
afConstants = require('../../libs/commons/formsConstants');
20+
const formsSelectors = require("../../libs/commons/guideSelectors");
2021

2122
/**
2223
* Testing CheckBoxGroup with Sites Editor
@@ -49,15 +50,6 @@ describe('Page - Authoring', function () {
4950
.then(cy.wrap)
5051
}
5152

52-
const getRuleEditorIframe = () => {
53-
// get the iframe > document > body
54-
// and retry until the body element is not empty
55-
return cy
56-
.get('iframe#af-rule-editor')
57-
.its('0.contentDocument.body').should('not.be.empty')
58-
.then(cy.wrap)
59-
}
60-
6153
const testCheckBoxGroupBehaviour = function(checkBoxGroupEditPathSelector, checkBoxGroupDrop, isSites) {
6254
if (isSites) {
6355
dropTextInputInSites();
@@ -211,34 +203,37 @@ describe('Page - Authoring', function () {
211203
});
212204

213205
// adding retry since rule editor sometimes does not open at first try
214-
it('rule editor is working with rich text enum names', { retries: 3 }, function(){
206+
it('rule editor is working with rich text enum names', {retries: 2}, function () {
215207
cy.openEditableToolbar(sitesSelectors.overlays.overlay.component + checkBoxGroupEditPathSelector);
216-
cy.invokeEditableAction("[data-action='editexpression']");
217-
cy.get("#af-rule-editor").should("be.visible");
218-
getRuleEditorIframe().find("#objectNavigationTree").should("be.visible");
219-
getRuleEditorIframe().find("#create-rule-button").click();
220-
getRuleEditorIframe().find('#create-rule-button').then(($el) => {
221-
$el[0].click();
222-
getRuleEditorIframe().find('.child-choice-name').click();
223-
getRuleEditorIframe().find('coral-selectlist-item[value="EVENT_SCRIPTS"]').then(($el) => {
224-
$el[0].scrollIntoView();
225-
$el[0].click();
226-
getRuleEditorIframe().find('.EVENT_AND_COMPARISON_OPERATOR').then(($el) => {
227-
$el[0].click();
228-
getRuleEditorIframe().find('coral-selectlist-item[value="CONTAINS"]').then(($el) => {
229-
$el[0].click();
230-
getRuleEditorIframe().find('.PRIMITIVE_EXPRESSION .NUMERIC_LITERAL button').then(($el) => {
231-
$el[0].click();
232-
getRuleEditorIframe().find('[handle="selectList"] coral-list-item-content').first().should("have.text", "Select 1");
233-
});
234-
});
235-
});
236-
});
237-
getRuleEditorIframe().find('.exp-Close-Button').then(($el) => {
238-
$el[0].click();
239-
});
240-
});
241-
});
208+
cy.get(formsSelectors.ruleEditor.action.editRule).should("exist");
209+
cy.initializeEventHandlerOnChannel("af-rule-editor-initialized").as("isRuleEditorInitialized");
210+
cy.get(formsSelectors.ruleEditor.action.editRule).click();
211+
212+
// click on create option from rule editor header
213+
cy.get("@isRuleEditorInitialized").its('done').should('equal', true);
214+
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.action.createRuleButton).should("be.visible").click();
215+
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.action.sideToggleButton + ":first").click();
216+
217+
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.choiceModels.STATEMENT + " .child-choice-name").should("exist");
218+
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.choiceModels.STATEMENT + " .child-choice-name").click();
219+
220+
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.choiceModels.STATEMENT + " .expeditor-customoverlay.is-open coral-selectlist-item[value='EVENT_SCRIPTS']")
221+
.click({force: true});
222+
223+
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.choiceModels.EVENT_AND_COMPARISON_OPERATOR + " .choice-view-default").should("exist");
224+
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.choiceModels.EVENT_AND_COMPARISON_OPERATOR + " .choice-view-default").click();
225+
226+
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.operator.CONTAINS).should("exist");
227+
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.operator.CONTAINS).click();
228+
229+
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.choiceModels.PRIMITIVE_EXPRESSION + " .NUMERIC_LITERAL button").should("exist");
230+
cy.getRuleEditorIframe().find(formsSelectors.ruleEditor.choiceModels.PRIMITIVE_EXPRESSION + " .NUMERIC_LITERAL button").first().click();
231+
232+
cy.getRuleEditorIframe().find('[handle="selectList"] coral-list-item-content').first().contains("Select 1");
233+
cy.getRuleEditorIframe().find('.exp-Cancel-Button').click();
234+
cy.getRuleEditorIframe().find('.exp-Close-Button').click();
235+
cy.deleteComponentByPath(checkBoxGroupDrop);
236+
});
242237
});
243238
/*
244239
context('Open Sites Editor', function () {

0 commit comments

Comments
 (0)