Skip to content

Commit 12e53f8

Browse files
committed
fix: consider the user agent, #1091
1 parent d0c62ed commit 12e53f8

File tree

4 files changed

+116
-5
lines changed

4 files changed

+116
-5
lines changed

.github/workflows/uuv-github-ci.yml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,59 @@ jobs:
404404
path: tests/integration/runner-playwright/uuv/reports/e2e/junit-report.xml
405405
reporter: jest-junit
406406

407+
integration-tests-playwright-yarn:
408+
runs-on: ubuntu-22.04
409+
container:
410+
image: e2etesting/uuv
411+
needs: [ lint, unit-tests, build, build-electron ]
412+
steps:
413+
- uses: actions/checkout@v4
414+
- name: Cache node modules
415+
uses: actions/cache@v4
416+
with:
417+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./package-lock.json') }}
418+
path: |
419+
node_modules
420+
packages/assistant/node_modules
421+
packages/docs/node_modules
422+
packages/a11y/node_modules
423+
packages/runner-commons/node_modules
424+
packages/runner-cypress/node_modules
425+
packages/runner-playwright/node_modules
426+
packages/vscode-extension/node_modules
427+
packages/a11y-dashboard/node_modules
428+
- name: Download build artifact
429+
uses: actions/download-artifact@v4
430+
with:
431+
name: build-artifacts
432+
path: packages
433+
- name: Use Node.js ${{ inputs.node-version }}
434+
uses: actions/setup-node@v4
435+
with:
436+
node-version:
437+
${{env.NODE_VERSION}}
438+
- run: npm ci
439+
- name: Package runner-playwright
440+
run: mkdir -p ./dist/packages && npx nx package a11y && npx nx package runner-commons && npx nx package runner-playwright
441+
- name: Running playwright integration tests with yarn
442+
env:
443+
UUV_BASE_URL: ${{env.UUV_BASE_URL}}
444+
run: cd ./tests/integration && chmod 755 ./integration-tests-yarn-runner-playwright.sh && ./integration-tests-yarn-runner-playwright.sh
445+
- name: Upload uuv test artifact
446+
uses: actions/upload-artifact@v4
447+
if: success() || failure()
448+
with:
449+
name: integration-tests-playwright-yarn-artifacts
450+
path: |
451+
tests/integration/runner-playwright/uuv/reports
452+
- name: Test Report
453+
uses: MichaelVoelkel/test-reporter@main
454+
if: success() || failure()
455+
with:
456+
name: Report - Integration Tests - Playwright (Yarn)
457+
path: tests/integration/runner-playwright/uuv/reports/e2e/junit-report.xml
458+
reporter: jest-junit
459+
407460
lint:
408461
runs-on: ubuntu-22.04
409462
needs: install
@@ -422,7 +475,7 @@ jobs:
422475

423476
release:
424477
if: github.ref == 'refs/heads/main'
425-
needs: [ integration-tests-cypress, integration-tests-playwright, unit-tests-a11y, unit-tests-playwright, unit-tests-cypress, integration-tests-assistant, unit-tests-runner-flutter, build-docker, build-gradle ]
478+
needs: [ integration-tests-cypress, integration-tests-playwright, integration-tests-playwright-yarn, unit-tests-a11y, unit-tests-playwright, unit-tests-cypress, integration-tests-assistant, unit-tests-runner-flutter, build-docker, build-gradle ]
426479
runs-on: ubuntu-22.04
427480
environment: release
428481
steps:

packages/runner-playwright/postinstall.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ function copyFileIfMissing(fileToCopy, originFolder, destFolder) {
3737
}
3838
}
3939

40+
function getUserAgent() {
41+
return process.env["npm_config_user_agent"]?.startsWith("yarn") ? "yarn" : "npx";
42+
}
43+
4044
function main () {
4145
if (fs.existsSync(`${PROJECT_DIR}/package.json`) && !fs.existsSync(`${PROJECT_DIR}/.no-postinstall`)) {
4246
copyFileIfMissing("playwright.config.ts", `${TARGET_CONFIG_DIR}`, `${PROJECT_DIR}/uuv`);
43-
execSync("npx playwright install", { stdio: "inherit" });
47+
execSync(`${getUserAgent()} playwright install`, { stdio: "inherit" });
4448
} else {
4549
console.log("postinstall - Nothing to copy");
4650
}

packages/runner-playwright/src/lib/runner-playwright.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class UUVCliPlaywrightRunner implements UUVCliRunner {
3636
async prepare(options: Partial<UUVCliOptions>) {
3737
try {
3838
console.log("running preprocessor...");
39-
this.executeSystemCommand(`npx bddgen -c ${this.projectDir}/playwright.config.ts`);
39+
this.executeSystemCommand(`${getUserAgent()} bddgen -c ${this.projectDir}/playwright.config.ts`);
4040
console.log("preprocessor executed\n");
4141
} catch (e) {
4242
console.warn(chalk.redBright("An error occured during preprocessor, please be sure to use existing step definitions"));
@@ -117,7 +117,7 @@ export class UUVCliPlaywrightRunner implements UUVCliRunner {
117117
private buildCommand(options: Partial<UUVCliOptions>, configFile: string, reporter: string): string {
118118
return _.trimEnd(
119119
[
120-
"npx",
120+
getUserAgent(),
121121
"playwright",
122122
"test",
123123
`--project="${options.browser}"`,
@@ -156,11 +156,15 @@ function executeSystemCommandHelper(command: string) {
156156
export function executePreprocessor(projectDir: string): boolean {
157157
console.log("running preprocessor...");
158158
try {
159-
executeSystemCommandHelper(`npx bddgen -c ${projectDir}/playwright.config.ts`);
159+
executeSystemCommandHelper(`${getUserAgent()} bddgen -c ${projectDir}/playwright.config.ts`);
160160
console.log("preprocessor executed\n");
161161
return true;
162162
} catch (e) {
163163
console.warn(chalk.redBright("An error occured during preprocessor, please be sure to use existing step definitions"));
164164
return false;
165165
}
166166
}
167+
168+
function getUserAgent(): string {
169+
return process.env["npm_config_user_agent"]?.startsWith("yarn") ? "yarn" : "npx";
170+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
set -o pipefail
4+
set -o errexit
5+
6+
source functions.sh
7+
RUNNER_NAME='playwright'
8+
WORKING_DIR="runner-${RUNNER_NAME}"
9+
RUNNER_DIR="../../../packages/runner-${RUNNER_NAME}"
10+
NPM_PACKAGE_COMMONS=$(ls ../../dist/packages/uuv-runner-commons-*)
11+
NPM_PACKAGE_A11Y=$(ls ../../dist/packages/uuv-a11y-*)
12+
NPM_PACKAGE_PLAYWRIGHT=$(ls ../../dist/packages/uuv-playwright-*)
13+
14+
log "I" "Cleaning existing directory"
15+
if [ -d "$WORKING_DIR" ]; then rm -Rf $WORKING_DIR; fi
16+
17+
log "I" "Creating directory"
18+
mkdir -p "$WORKING_DIR"
19+
cp "tsconfig.${RUNNER_NAME}.json" "$WORKING_DIR/tsconfig.json"
20+
cp "tsconfig.${RUNNER_NAME}.e2e.json" "$WORKING_DIR/tsconfig.e2e.json"
21+
mkdir -p "$WORKING_DIR/uuv/cucumber/step_definitions"
22+
cp "my-custom-step-definitions.${RUNNER_NAME}.ts" "$WORKING_DIR/uuv/cucumber/step_definitions/my-custom-step-definitions.ts"
23+
cd "$WORKING_DIR"
24+
25+
log "I" "Creating new npm project"
26+
yarn init -y
27+
cp -f "../package-playwright.json" "package.json"
28+
A11Y_VERSION="../$NPM_PACKAGE_A11Y"
29+
sed -i "s|to-replace|${A11Y_VERSION}|" package.json
30+
31+
log "I" "Installing npm dependencies"
32+
yarn add -D "../$NPM_PACKAGE_COMMONS" "../$NPM_PACKAGE_PLAYWRIGHT"
33+
34+
log "I" "Copying test files and dependencies"
35+
cp -R "${RUNNER_DIR}/e2e/" ./uuv
36+
cp "../custom-step-definition.feature" ./uuv/e2e
37+
rm ./uuv/e2e/ko.feature
38+
mkdir -p ./uuv/playwright/fixtures
39+
cp -R "${RUNNER_DIR}/playwright/fixtures/" ./uuv/playwright
40+
41+
log "I" "Replace baseUurl"
42+
sed -i 's/http:\/\/localhost:4200/https:\/\/e2e-test-quest.github.io\/simple-webapp\//g' uuv/playwright.config.ts
43+
44+
log "I" "Running e2e test"
45+
if ! yarn uuv e2e --generateHtmlReport --generateJunitReport --generateA11yReport; then
46+
log "E" "An error occured during e2e testing"
47+
exit 1
48+
fi
49+
50+
log "I" "Ended"

0 commit comments

Comments
 (0)