Skip to content

Commit 3c496ca

Browse files
authored
Merge pull request #59 from SafeExamBrowser/tests-e2e
Tests e2e
2 parents a773c57 + 2100d7d commit 3c496ca

21 files changed

Lines changed: 355 additions & 233 deletions

.github/workflows/auto-test-deploy.yml

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,28 @@ on:
66
- "auto-testing-deploy"
77

88
jobs:
9+
10+
shai-hulud-detector:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout seb-server-gui repo
14+
uses: actions/checkout@v6
15+
with:
16+
path: seb
17+
clean: false
18+
- name: Checkout Cobenian/shai-hulud-detect
19+
uses: actions/checkout@v6
20+
with:
21+
repository: Cobenian/shai-hulud-detect
22+
path: hulud
23+
clean: false
24+
- # Pipeline will automatically fail on exit codes 1 or 2
25+
name: Security Scan with Shai-Hulud Detector
26+
run: |
27+
chmod +x ./hulud/shai-hulud-detector.sh
28+
./hulud/shai-hulud-detector.sh ./seb
29+
30+
931
build-and-push-admin-auto-test:
1032
runs-on: ubuntu-latest
1133
strategy:
@@ -69,6 +91,36 @@ jobs:
6991
uses: docker/build-push-action@v6.17.0
7092
with:
7193
context: .
72-
file: ./Dockerfile.storybook
94+
file: ./client/Dockerfile.storybook
95+
push: true
96+
tags: docker.io/${{ secrets.DOCKERHUB_ADMIN_USERNAME }}/seb-server-gui-storybook:${{ env.TAG_NAME }}
97+
98+
build-and-push-e2e-runner:
99+
runs-on: ubuntu-latest
100+
needs: build-and-push-admin-auto-test
101+
102+
steps:
103+
- name: Set env for dynamic tag
104+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
105+
run: echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
106+
107+
- name: Set env manual
108+
if: github.event_name == 'workflow_dispatch'
109+
run: echo "TAG_NAME=default_version" >> $GITHUB_ENV
110+
111+
- name: Checkout code
112+
uses: actions/checkout@v4.2.2
113+
114+
- name: Login to DockerHub
115+
uses: docker/login-action@v3.4.0
116+
with:
117+
username: ${{ secrets.DOCKERHUB_ADMIN_USERNAME }}
118+
password: ${{ secrets.DOCKERHUB_ADMIN_TOKEN }}
119+
120+
- name: Build and push E2E runner image
121+
uses: docker/build-push-action@v6.17.0
122+
with:
123+
context: .
124+
file: ./client/Dockerfile.e2e
73125
push: true
74-
tags: docker.io/${{ secrets.DOCKERHUB_ADMIN_USERNAME }}/storybook:${{ env.TAG_NAME }}
126+
tags: docker.io/${{ secrets.DOCKERHUB_ADMIN_USERNAME }}/seb-server-gui-e2e-runner:${{ env.TAG_NAME }}

Dockerfile.storybook

Lines changed: 0 additions & 20 deletions
This file was deleted.

client/.storybook/main.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
import type { StorybookConfig } from "@storybook/vue3-vite";
2+
import { mergeConfig } from "vite";
23

34
const config: StorybookConfig = {
45
framework: {
56
name: "@storybook/vue3-vite",
67
options: {},
78
},
8-
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
9+
stories: [
10+
"../tests/stories/**/*.mdx",
11+
"../tests/stories/**/*.stories.@(js|jsx|mjs|ts|tsx)",
12+
],
913
addons: [
1014
"@chromatic-com/storybook",
1115
"@storybook/addon-docs",
1216
"@storybook/addon-onboarding",
1317
"@storybook/addon-a11y",
1418
],
15-
1619
core: {
1720
builder: "@storybook/builder-vite",
1821
},
19-
20-
async viteFinal(config) {
21-
return config;
22+
async viteFinal(cfg) {
23+
return mergeConfig(cfg, {
24+
base: "",
25+
});
2226
},
2327
};
2428

client/.storybook/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"skipLibCheck": true,
99
"jsx": "preserve"
1010
},
11-
"include": ["./**/*", "../src/**/*"]
11+
"include": ["./**/*", "../src/**/*", "../tests/stories/**/*"]
1212
}

client/Dockerfile.e2e

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Choose a pinned version that matches your @playwright/test version as closely as possible
2+
FROM mcr.microsoft.com/playwright:v1.56.1-jammy
3+
4+
WORKDIR /work
5+
6+
# Copy only what the runner needs (keeps image smaller + build faster)
7+
COPY client/package.json client/package-lock.json* client/pnpm-lock.yaml* client/yarn.lock* ./client/
8+
COPY client/playwright.config.ts ./client/
9+
COPY client/tsconfig.playwright.json ./client/
10+
COPY client/tests/e2e ./client/tests/e2e
11+
12+
# Install deps
13+
WORKDIR /work/client
14+
# If you use npm:
15+
RUN npm ci
16+
17+
# If your project uses pnpm or yarn, swap accordingly.
18+
19+
# Default output locations (we’ll also set these in playwright.config.ts)
20+
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
21+
ENV NODE_ENV=production
22+
23+
# Entrypoint runs the tests
24+
CMD ["npx", "playwright", "test"]

client/Dockerfile.storybook

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:20-alpine AS build
2+
WORKDIR /app/client
3+
4+
COPY client/package.json client/package-lock.json ./
5+
RUN npm ci
6+
7+
COPY client/ ./
8+
9+
RUN npm run build-storybook
10+
11+
FROM nginx:alpine
12+
COPY --from=build /app/client/storybook-static/ /usr/share/nginx/html/
13+
EXPOSE 80

client/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
"test:e2e": "npx playwright test",
2626
"test:e2eui": "npx playwright test --ui",
2727
"test:e2e:headed": "npx playwright test --headed",
28+
"test:e2e:interactive": "npx playwright codegen http://localhost:8082",
2829
"test:e2e:chromium": "npx playwright test --project=chromium --headed",
29-
"build-storybook": "storybook build"
30+
"build-storybook": "storybook build --disable-telemetry"
3031
},
3132
"lint-staged": {
3233
"*.{vue,js,jsx,ts,tsx}": [
@@ -71,7 +72,7 @@
7172
"@testing-library/dom": "^10.4.1",
7273
"@testing-library/vue": "^8.1.0",
7374
"@types/luxon": "^3.4.2",
74-
"@types/node": "^20.19.24",
75+
"@types/node": "^20.19.27",
7576
"@types/webfontloader": "^1.6.38",
7677
"@vitejs/plugin-vue": "^5.2.4",
7778
"@vitest/browser-playwright": "^4.0.8",

client/playwright.config.ts

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,38 @@
11
import { defineConfig, devices } from "@playwright/test";
22

3+
const isCI = !!process.env.CI;
4+
5+
const baseURL = process.env.BASE_URL || "https://ralphina.ethz.ch";
6+
7+
const ignoreHTTPSErrors = process.env.E2E_IGNORE_HTTPS_ERRORS === "true";
8+
9+
const outputDir = process.env.E2E_OUTPUT_DIR || "test-results";
10+
const reportDir = process.env.E2E_REPORT_DIR || "playwright-report";
11+
12+
const reporters = isCI
13+
? [["line"], ["html", { outputFolder: reportDir, open: "never" }]]
14+
: [["html", { outputFolder: reportDir, open: "never" }]];
15+
316
export default defineConfig({
417
testDir: "tests/e2e",
5-
fullyParallel: false,
6-
forbidOnly: !!process.env.CI,
7-
retries: process.env.CI ? 2 : 0,
8-
workers: process.env.CI ? 1 : undefined,
9-
reporter: process.env.CI ? "line" : "html",
18+
fullyParallel: true,
19+
forbidOnly: isCI,
20+
retries: isCI ? 2 : 0,
21+
workers: isCI ? 1 : undefined,
22+
23+
reporter: reporters,
24+
25+
outputDir,
26+
1027
use: {
11-
baseURL: process.env.BASE_URL || "http://localhost:8082",
12-
trace: "on-first-retry",
13-
launchOptions: {
14-
slowMo: 500,
15-
},
28+
baseURL,
29+
trace: "on",
30+
ignoreHTTPSErrors,
1631
contextOptions: {
1732
javaScriptEnabled: true,
1833
},
1934
},
35+
2036
projects: [
2137
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
2238
{ name: "firefox", use: { ...devices["Desktop Firefox"] } },

client/src/App.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<template>
22
<v-app>
33
<ErrorMsg></ErrorMsg>
4-
54
<loading
65
:active="loadingStore.isLoading"
76
color="#215CAF"

client/src/stories/Sanity.stories.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)