Skip to content

Commit 3f64846

Browse files
CQ-4356927 UI Tests in WKND project fails occasionally (#452)
1 parent 50a5240 commit 3f64846

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

ui.tests/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ RUN apt -qqy update \
1919
# Generic dependencies
2020
&& apt -qqy --no-install-recommends install \
2121
python \
22+
curl \
2223
build-essential
2324

2425
# Set Application Environment

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

ui.tests/test-module/run.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,24 @@ ps aux | grep Xvfb
2424
# disable color output when running Cypress
2525
export NO_COLOR=1
2626
#export ELECTRON_EXTRA_LAUNCH_ARGS=--remote-debugging-port=9222
27+
28+
# setup proxy environment variables
29+
if [ -n "${PROXY_HOST:-}" ]; then
30+
if [ -n "${PROXY_HTTPS_PORT:-}" ]; then
31+
export HTTP_PROXY="https://${PROXY_HOST}:${PROXY_HTTPS_PORT}"
32+
elif [ -n "${PROXY_HTTP_PORT:-}" ]; then
33+
export HTTP_PROXY="http://${PROXY_HOST}:${PROXY_HTTP_PORT}"
34+
fi
35+
if [ -n "${PROXY_CA_PATH:-}" ]; then
36+
export NODE_EXTRA_CA_CERTS=${PROXY_CA_PATH}
37+
fi
38+
if [ -n "${PROXY_OBSERVABILITY_PORT:-}" ] && [ -n "${HTTP_PROXY:-}" ]; then
39+
echo "Waiting for proxy"
40+
curl --silent --retry ${PROXY_RETRY_ATTEMPTS:-3} --retry-connrefused --retry-delay ${PROXY_RETRY_DELAY:-10} \
41+
--proxy ${HTTP_PROXY} --proxy-cacert ${PROXY_CA_PATH:-""} \
42+
${PROXY_HOST}:${PROXY_OBSERVABILITY_PORT}
43+
fi
44+
fi
45+
2746
# execute tests
2847
npm test

0 commit comments

Comments
 (0)