Skip to content

Commit 5949204

Browse files
committed
take screenshots before and after running tests
1 parent 7be0d2c commit 5949204

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

scripts/pit/its/hello.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const log = s => process.stderr.write(`\x1b[1m=> TEST: \x1b[0;33m${s}\x1b[0m`);
3737

3838
// Go to http://localhost:8080/
3939
await page.goto(`http://${host}:${port}/`);
40+
// Wait for vaadin ready
41+
await page.waitForSelector('#outlet > * > *:not(style):not(script)');
4042

4143
await takeScreenshot(page, 'initial-view');
4244
// Click input[type="text"]

scripts/pit/its/test-utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ let mode, version;
4646
const args = () => {
4747
const ret = {
4848
headless: false,
49-
port: '8000',
49+
port: '8080',
5050
host: 'localhost',
5151
pass: 'Servantes',
5252
ignoreHTTPSErrors: false,
@@ -80,6 +80,8 @@ const args = () => {
8080
version = ret.version = a.split('=')[1];
8181
} else if (/^--prefix=/.test(a)) {
8282
ret.prefix = a.split('=')[1];
83+
} else if (/^--name=/.test(a)) {
84+
ret.name = a.split('=')[1];
8385
}
8486
});
8587
if (!ret.url) {

scripts/pit/lib/lib-args.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Use: $0 with the next options:
2323
--skip-clean Do not clean maven cache
2424
--skip-helm Do not re-install control-center with helm and continue running tests, implies (--offline, --keep-cc)
2525
--skip-pw Do not run playwright tests
26+
--screenshots Save screenshots before and after running tests (useful to visit them after theming changes)
2627
--cluster=name Run tests in an existing k8s cluster
2728
--vendor=name Use a specific cluster vendor to run control-center tests options: [dd, kind, do] (default: kind)
2829
--keep-cc Keep control-center running after tests
@@ -83,6 +84,7 @@ checkArgs() {
8384
--skip-dev) NODEV=true;;
8485
--skip-prod) NOPROD=true;;
8586
--skip-pw) SKIPPW=true;;
87+
--screenshots) SCREENSHOTS=true;;
8688
--cluster=*) CLUSTER="$arg";;
8789
--vendor=*)
8890
VENDOR="$arg"

scripts/pit/lib/lib-playwright.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
PIT_SCR_FOLDER=`computeAbsolutePath`
2+
SCRSHT="$PIT_SCR_FOLDER/its/screenshot.js"
23

34
## LIBRARY for installing and running playwright tests
45

@@ -60,3 +61,4 @@ runPlaywrightTests() {
6061
return $err
6162
}
6263

64+

scripts/pit/lib/lib-validate.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,18 @@ runValidations() {
111111

112112
# 11
113113
if [ -n "$test" -a -z "$SKIPTESTS" -a -z "$SKIPPW" ]; then
114-
runPlaywrightTests "$test" "$file" "$mode" "$name" "$version" "--port=$port" || return 1
114+
# Take screenshot before running tests
115+
[ -n "$SCREENSHOTS" ] && runPlaywrightTests "$SCRSHT" "$file" "$mode" "$name" "$version" "--port=$port" "--prefix=_before"
116+
117+
runPlaywrightTests "$test" "$file" "$mode" "$name" "$version" "--port=$port"
118+
test_result=$?
119+
120+
# Take screenshot after tests succeed
121+
[ -n "$SCREENSHOTS" -a $test_result = 0 ] && runPlaywrightTests "$SCRSHT" "$file" "$mode" "$name" "$version" "--port=$port" "--prefix=_after"
122+
123+
124+
# Return the test result
125+
[ $test_result != 0 ] && return 1
115126
elif [ -n "$TEST" ]; then
116127
cmd "## No PW tests to run"
117128
fi

0 commit comments

Comments
 (0)