Skip to content

Commit b51a60a

Browse files
committed
Add golden master test
1 parent d216580 commit b51a60a

12 files changed

Lines changed: 2425 additions & 13 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/playwright:next
1+
FROM mcr.microsoft.com/playwright:v1.50.0-noble
22
RUN apt-get update && apt-get install -y wget apt-transport-https gnupg\
33
&& wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | apt-key add -\
44
&& echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list\

.devcontainer/devcontainer.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,20 @@
1010
"mavenVersion": "3.8.6",
1111
"installGradle": "false"
1212
},
13-
"docker-in-docker": {
14-
"version": "latest",
13+
"ghcr.io/devcontainers/features/docker-in-docker:2": {
1514
"dockerDashComposeVersion": "v2"
1615
}
1716
},
18-
"containerEnv": {
19-
"DISPLAY": "host.docker.internal:0.0"
20-
},
17+
"postCreateCommand": "cd golden-master-tests && npm ci && npx playwright install --with-deps chromium",
18+
"postStartCommand": "docker compose up -d && cd golden-master-tests && npm run test:ui:codespaces",
2119
"customizations": {
2220
"vscode": {
2321
"settings": {},
2422
"extensions": [
25-
"streetsidesoftware.code-spell-checker"
23+
"streetsidesoftware.code-spell-checker",
24+
"ms-playwright.playwright"
2625
]
2726
}
28-
}
27+
},
28+
"forwardPorts": [80, 4001, 8080, 8832]
2929
}
30-

.github/workflows/build.yaml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,38 @@ jobs:
2222
- name: Build with Docker
2323
run: docker compose build
2424

25-
- name: Start with Docker
25+
- name: Start Docker services
2626
run: docker compose up -d
2727

28-
- name: Stop Docker Containers
28+
- name: Wait for online shop
29+
run: until curl -sf http://localhost/index.html; do sleep 2; done
30+
timeout-minutes: 2
31+
32+
- name: Set up Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: '20'
36+
cache: npm
37+
cache-dependency-path: golden-master-tests/package-lock.json
38+
39+
- name: Install dependencies
40+
run: npm ci
41+
working-directory: golden-master-tests
42+
43+
- name: Check formatting
44+
run: npm run format:check
45+
working-directory: golden-master-tests
46+
47+
- name: Install Playwright browsers
48+
run: npx playwright install --with-deps chromium
49+
working-directory: golden-master-tests
50+
51+
- name: Run Playwright tests
52+
run: npm test
53+
working-directory: golden-master-tests
54+
env:
55+
ONLINE_SHOP_URL: http://localhost
56+
57+
- name: Stop Docker services
58+
if: always()
2959
run: docker compose down

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,41 @@ um in die Datenbank zu schauen.
2929

3030
## Aufgabe
3131

32-
Navigieren Sie zum Warenkorb und schauen Sie sich dann den Inhalt der Tabelle `tab_order` an.
33-
Navigieren Sie durch den Checkout-Prozess und sehen Sie, wie sich der Inhalt der Tabelle ändert.
32+
Die Datei `checkout.spec.ts` im Ordner `golden-master-tests/tests`
33+
enthält einen UI-Test mit dem Framework Playwright.
34+
Führen Sie den Test aus und schauen Sie, dass er grün ist.
35+
Überlegen Sie, welche weiteren Pfade durch den Bestellabschluss es geben könnte.
36+
Schreiben Sie Tests für diese Fälle.
37+
Schreiben Sie auch Tests für das Pflegen der Adressen in der Kundenverwaltung.
38+
39+
## Tests ausführen
40+
41+
### Lokal
42+
43+
```
44+
cd golden-master-tests
45+
npm install
46+
npx playwright install --with-deps chromium
47+
npm test
48+
```
49+
50+
Die Playwright UI lässt sich lokal folgendermaßen starten:
51+
52+
```
53+
npm run test:ui
54+
```
55+
56+
### GitHub Codespaces
57+
58+
Im Codespace sind alle Abhängigkeiten bereits installiert. Die Playwright VS Code Extension
59+
ist vorinstalliert und ermöglicht das Ausführen und Debuggen der Tests direkt im Editor.
60+
61+
Alternativ lässt sich die Playwright UI über das Terminal starten:
62+
63+
```
64+
cd golden-master-tests
65+
npm run test:ui:codespaces
66+
```
67+
68+
Anschließend öffnet GitHub Codespaces automatisch einen Dialog zum Weiterleiten von Port `8832`.
69+
Die Playwright UI ist dann über den angezeigten Link im Browser erreichbar.

golden-master-tests/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/target/
2+
/node_modules/
3+
/dist/
4+
/test-results/
5+
/playwright-report/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default async function globalSetup() {
2+
process.env.ONLINE_SHOP_URL =
3+
process.env.ONLINE_SHOP_URL ?? "http://localhost";
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default async function globalTeardown() {}

0 commit comments

Comments
 (0)