E2E browser tests in Chromium, Firefox, WebKit and mobile (Playwright)
Runs against the real .deb in the Playwright container with a real PAM login and the same test config as CT 151 (now a fixture in test/fixtures; scripts/e2e-setup.sh creates folders, groups and users). Covers: wrong password message, login → dashboard → shares → share detail (plain words, ⓘ tooltip, custom-settings warning) → logout, dark mode; fails on any console/page error (incl. CSP violations). Screenshots of every page per browser are kept as artifact. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
010188e858
commit
6fbe5c324e
9 files changed
+263
-2
No files matched your search
@@ -116,3 +116,49 @@ jobs:
|
||||
for i in $(seq 1 20); do curl -skf https://127.0.0.1:8443/healthz && break; sleep 0.5; done
|
||||
curl -skf https://127.0.0.1:8443/healthz | grep -q '"status":"ok"'
|
||||
test "$(curl -sk -o /dev/null -w '%{http_code}' https://127.0.0.1:8443/api/v1/auth/session)" = 401
|
||||
|
||||
e2e:
|
||||
# Browser tests in Chromium, Firefox, WebKit and a mobile viewport against
|
||||
# the real package, with a real PAM login. Screenshots are kept as artifact.
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
needs: package
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: mcr.microsoft.com/playwright:v1.65.1-noble
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: deb-packages
|
||||
path: pkg
|
||||
- name: install sharestead + test config
|
||||
run: |
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update -qq && apt-get install -y -qq ./pkg/*_amd64.deb >/dev/null
|
||||
echo "SST_PASS=e2e-$(head -c 12 /dev/urandom | base64 | tr -dc A-Za-z0-9)" >> "$GITHUB_ENV"
|
||||
- name: prepare users and shares
|
||||
run: scripts/e2e-setup.sh "$SST_PASS"
|
||||
- name: start sharestead
|
||||
run: |
|
||||
nohup sharestead -data-dir /tmp/sst -listen 127.0.0.1:8443 > /tmp/sharestead.log 2>&1 &
|
||||
for i in $(seq 1 30); do curl -skf https://127.0.0.1:8443/healthz && break; sleep 0.5; done
|
||||
- name: browser tests
|
||||
working-directory: web
|
||||
env:
|
||||
SST_URL: https://127.0.0.1:8443
|
||||
SST_USER: e2e-admin
|
||||
run: |
|
||||
npm ci --no-audit --no-fund
|
||||
npx playwright test
|
||||
- name: server log
|
||||
if: always()
|
||||
run: cat /tmp/sharestead.log
|
||||
- name: keep screenshots and report
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: e2e-screenshots
|
||||
path: |
|
||||
web/e2e-results/screens
|
||||
web/e2e-report
|
||||
retention-days: 14
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# Prepares a throwaway system (CI container) for the end-to-end tests:
|
||||
# test config, share folders, groups and users. Run as root.
|
||||
# Usage: scripts/e2e-setup.sh <admin-password>
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
pass=${1:?admin password}
|
||||
|
||||
mkdir -p /srv/sst-test/{family,public,media,files,scans} /etc/samba
|
||||
install -m 0644 test/fixtures/smb.conf /etc/samba/smb.conf
|
||||
install -m 0644 test/fixtures/exports /etc/exports
|
||||
getent group family >/dev/null || groupadd family
|
||||
getent group sharestead-admins >/dev/null || groupadd sharestead-admins
|
||||
for u in alex sam kim; do id "$u" >/dev/null 2>&1 || useradd -M -s /usr/sbin/nologin -G family "$u"; done
|
||||
id e2e-admin >/dev/null 2>&1 || useradd -M -s /usr/sbin/nologin -G sharestead-admins e2e-admin
|
||||
echo "e2e-admin:$pass" | chpasswd
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
# NFS exports for the Sharestead test instance
|
||||
/srv/sst-test/family 10.0.0.0/24(rw,sync,no_subtree_check,root_squash,crossmnt)
|
||||
/srv/sst-test/media 10.0.0.0/24(ro,sync,no_subtree_check) 10.0.0.161(rw,sync,no_subtree_check)
|
||||
/srv/sst-test/files 10.0.0.0/24(rw,sync,no_subtree_check)
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
# Sharestead test configuration (CT 151 + CI) — modelled on a typical homelab NAS
|
||||
[global]
|
||||
workgroup = WORKGROUP
|
||||
server string = sharestead-test
|
||||
security = user
|
||||
map to guest = Bad User
|
||||
vfs objects = fruit streams_xattr
|
||||
|
||||
[homes]
|
||||
comment = Home Directories
|
||||
read only = No
|
||||
valid users = %S
|
||||
create mask = 0700
|
||||
|
||||
# Family files – keep the group writable
|
||||
[Family]
|
||||
comment = Shared family files
|
||||
path = /srv/sst-test/family
|
||||
read only = No
|
||||
valid users = @family
|
||||
force group = family
|
||||
|
||||
[Public]
|
||||
comment = Für alle im Netz
|
||||
path = /srv/sst-test/public
|
||||
guest ok = Yes
|
||||
read only = No
|
||||
force user = nobody
|
||||
|
||||
[Media]
|
||||
comment = Movies, series, music
|
||||
path = /srv/sst-test/media
|
||||
valid users = @family e2e-admin
|
||||
invalid users = kim
|
||||
read list = @family
|
||||
write list = e2e-admin
|
||||
|
||||
[Scans]
|
||||
comment = from the printer
|
||||
path = /srv/sst-test/scans
|
||||
valid users = %U
|
||||
hosts allow = 192.168.0.
|
||||
browseable = no
|
||||
@@ -0,0 +1,2 @@
|
||||
/e2e-results/
|
||||
/e2e-report/
|
||||
@@ -0,0 +1,81 @@
|
||||
import { expect, test, type Page } from '@playwright/test';
|
||||
|
||||
const user = process.env.SST_USER ?? 'e2e-admin';
|
||||
const pass = process.env.SST_PASS ?? '';
|
||||
|
||||
// Fails the test on any console error or CSP violation.
|
||||
function watchConsole(page: Page) {
|
||||
const errors: string[] = [];
|
||||
page.on('console', (m) => { if (m.type() === 'error') errors.push(m.text()); });
|
||||
page.on('pageerror', (e) => errors.push(e.message));
|
||||
return errors;
|
||||
}
|
||||
|
||||
async function login(page: Page) {
|
||||
await page.goto('/');
|
||||
await page.getByLabel('User name').fill(user);
|
||||
await page.getByLabel('Password').fill(pass);
|
||||
await page.getByRole('button', { name: 'Log in' }).click();
|
||||
}
|
||||
|
||||
async function openNav(page: Page, name: string, isMobile: boolean) {
|
||||
if (isMobile) await page.getByRole('button', { name: 'Open menu' }).click();
|
||||
await page.getByRole('navigation', { name: 'Main' }).getByRole('link', { name }).click();
|
||||
}
|
||||
|
||||
test('wrong password shows an actionable message', async ({ page }, info) => {
|
||||
const errors = watchConsole(page);
|
||||
await page.goto('/');
|
||||
await page.getByLabel('User name').fill(user);
|
||||
await page.getByLabel('Password').fill('definitely-wrong');
|
||||
await page.getByRole('button', { name: 'Log in' }).click();
|
||||
await expect(page.getByRole('alert')).toContainText('Wrong user name or password');
|
||||
await expect(page.getByRole('alert')).toContainText('Check both and try again');
|
||||
await page.screenshot({ path: `e2e-results/screens/${info.project.name}-login-error.png`, fullPage: true });
|
||||
// A 401 response logs a console error in some browsers; only page errors count here.
|
||||
expect(errors.filter((e) => !e.includes('401'))).toEqual([]);
|
||||
});
|
||||
|
||||
test('login, dashboard, shares, share detail, logout', async ({ page, isMobile }, info) => {
|
||||
const errors = watchConsole(page);
|
||||
await login(page);
|
||||
await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
|
||||
await expect(page.getByText('Storage by share')).toBeVisible();
|
||||
await page.screenshot({ path: `e2e-results/screens/${info.project.name}-dashboard.png`, fullPage: true });
|
||||
|
||||
await openNav(page, 'Shares', isMobile);
|
||||
await expect(page.getByRole('heading', { name: 'Shares' })).toBeVisible();
|
||||
for (const name of ['Family', 'Media', 'Public', 'Scans', 'files', 'homes']) {
|
||||
await expect(page.getByRole('link', { name, exact: true })).toBeVisible();
|
||||
}
|
||||
await page.screenshot({ path: `e2e-results/screens/${info.project.name}-shares.png`, fullPage: true });
|
||||
|
||||
await page.getByRole('link', { name: 'Media', exact: true }).click();
|
||||
await expect(page.getByRole('heading', { name: 'Media' })).toBeVisible();
|
||||
await expect(page.getByText("kim can't open this share.")).toBeVisible();
|
||||
await expect(page.getByText('Members of family can open and copy files, but not change them.')).toBeVisible();
|
||||
await page.getByRole('button', { name: 'What is Guests?' }).hover();
|
||||
await expect(page.getByRole('tooltip').filter({ hasText: 'Anyone on your network' })).toBeVisible();
|
||||
await page.screenshot({ path: `e2e-results/screens/${info.project.name}-share-media.png`, fullPage: true });
|
||||
|
||||
await page.goto('/#/shares/Scans');
|
||||
await expect(page.getByText('access is also limited by host')).toBeVisible();
|
||||
|
||||
// Logout
|
||||
if (isMobile) await page.getByRole('button', { name: 'Open menu' }).click();
|
||||
await page.getByRole('button', { name: 'Log out' }).click();
|
||||
await expect(page.getByLabel('User name')).toBeVisible();
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
|
||||
test('dark mode toggle switches the theme', async ({ page, isMobile }, info) => {
|
||||
await login(page);
|
||||
await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
|
||||
if (isMobile) await page.getByRole('button', { name: 'Open menu' }).click();
|
||||
const before = await page.locator('html').getAttribute('data-theme');
|
||||
await page.getByRole('button', { name: /mode$/ }).click();
|
||||
const after = await page.locator('html').getAttribute('data-theme');
|
||||
expect(after).not.toBe(before);
|
||||
if (isMobile) await page.getByRole('button', { name: 'Close menu' }).click();
|
||||
await page.screenshot({ path: `e2e-results/screens/${info.project.name}-dashboard-${after}.png`, fullPage: true });
|
||||
});
|
||||
Generated
+46
@@ -6,6 +6,7 @@
|
||||
"": {
|
||||
"name": "sharestead-web",
|
||||
"devDependencies": {
|
||||
"@playwright/test": "1.65.1",
|
||||
"@sveltejs/vite-plugin-svelte": "7.3.2",
|
||||
"@tsconfig/svelte": "5.0.9",
|
||||
"svelte": "5.59.2",
|
||||
@@ -75,6 +76,22 @@
|
||||
"url": "https://github.com/sponsors/oxc-project"
|
||||
}
|
||||
},
|
||||
"node_modules/@playwright/test": {
|
||||
"version": "1.65.1",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.65.1.tgz",
|
||||
"integrity": "sha512-y+NCIRm2LvY4slUVWvGh1nujJ8RF/hEisIsq2mtUPgdQC4L701bq5hZGMhrpeXjACvwvO9tj5dJqhvM6TP9lbw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright": "1.65.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-android-arm-eabi": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.3.4.tgz",
|
||||
@@ -1066,6 +1083,35 @@
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright": {
|
||||
"version": "1.65.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.1.tgz",
|
||||
"integrity": "sha512-vJ1FuoOrNwOKHUIVEvSt3jT1L+wjjDpwhwIstKtfvTh8XIG4FG4bIFuvNdMxi81LGfAhUgUZleVFaOLY4RIUUw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright-core": "1.65.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright-core": {
|
||||
"version": "1.65.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.1.tgz",
|
||||
"integrity": "sha512-hqPpz7blSMPxWVdoeE1yiBSzXsKiVOd2k+kjCvmUywD2GPO2Dd9HfcWnq9NN0GHbNZDFgZ9JfBFr+X5/BLo0qw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"playwright-core": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.5.34",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.34.tgz",
|
||||
|
||||
+4
-2
@@ -6,7 +6,8 @@
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings",
|
||||
"test": "vitest run"
|
||||
"test": "vitest run",
|
||||
"e2e": "playwright test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "7.3.2",
|
||||
@@ -15,6 +16,7 @@
|
||||
"svelte-check": "4.7.8",
|
||||
"typescript": "5.9.3",
|
||||
"vite": "8.4.0",
|
||||
"vitest": "5.1.2"
|
||||
"vitest": "5.1.2",
|
||||
"@playwright/test": "1.65.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
|
||||
// End-to-end tests against a running sharestead (CI starts one in a container).
|
||||
// SST_URL, SST_USER, SST_PASS are set by the CI job.
|
||||
export default defineConfig({
|
||||
testDir: './e2e',
|
||||
outputDir: './e2e-results',
|
||||
reporter: [['list'], ['html', { open: 'never', outputFolder: './e2e-report' }]],
|
||||
timeout: 30_000,
|
||||
use: {
|
||||
baseURL: process.env.SST_URL ?? 'https://127.0.0.1:8443',
|
||||
ignoreHTTPSErrors: true, // self-signed certificate
|
||||
trace: 'off',
|
||||
},
|
||||
projects: [
|
||||
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
|
||||
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
|
||||
{ name: 'webkit', use: { ...devices['Desktop Safari'] } },
|
||||
{ name: 'mobile', use: { ...devices['Pixel 7'] } },
|
||||
],
|
||||
});
|
||||
Reference in new issue
Block a user