Skip to content

Commit ab17be0

Browse files
CQ-4356927 UI Tests in WKND project fails occasionally
1 parent 50a5240 commit ab17be0

File tree

1 file changed

+19
-0
lines changed
  • ui.tests/test-module/cypress/support

1 file changed

+19
-0
lines changed

ui.tests/test-module/cypress/support/aem.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ Cypress.Commands.add('AEMDeletePage', function (path, ignoreVerification = false
142142
cy.get('coral-dialog[aria-hidden="false"] coral-checkbox[name="archive"] input').uncheck()
143143
// confirm the delete dialog
144144
cy.get('coral-dialog[aria-hidden="false"] ._coral-Button--warning').click()
145+
146+
// wait until page is deleted
147+
cy.waitUntil(() => cy.AEMPathNotExists(Cypress.env('AEM_PUBLISH_URL'), path + '.html'), {
148+
errorMsg: `page ${path} should not exist`,
149+
timeout: 15000,
150+
interval: 1000
151+
});
145152
})
146153

147154
// AEMDeleteTestPages will find pages in the current path that match the pattern and delete them.
@@ -188,6 +195,18 @@ Cypress.Commands.add('AEMPathExists', function (baseUrl, path) {
188195
})
189196
})
190197

198+
Cypress.Commands.add('AEMPathNotExists', function (baseUrl, path) {
199+
const url = new URL(path, baseUrl)
200+
201+
return cy.request({
202+
url: url.href,
203+
failOnStatusCode: false
204+
})
205+
.then(response => {
206+
return (response.status === 404)
207+
})
208+
})
209+
191210
Cypress.Commands.add('AEMDeleteAsset', function (assetPath) {
192211
const tokenUrl = new URL('/libs/granite/csrf/token.json', Cypress.env('AEM_AUTHOR_URL'))
193212
let csrfToken

0 commit comments

Comments
 (0)