Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/hub-checks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
test-results/
86 changes: 86 additions & 0 deletions .github/hub-checks/hub.spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { fileURLToPath } from 'node:url';
import { expect, test } from '@playwright/test';

const appNames = ['AllAboard', 'AllHail', 'OverBoard', 'OverHeard'];
const custom404 = fileURLToPath(new URL('../../404.html', import.meta.url));

test.beforeEach(async ({ context, baseURL }) => {
await context.route('**/*', route =>
new URL(route.request().url()).origin === baseURL ? route.continue() : route.abort()
);
});

test('the homepage displays the app cards and remembers the theme', async ({ page }) => {
const errors = [];
page.on('pageerror', error => errors.push(error.message));
await page.goto('/');
await expect(page.getByRole('heading', { level: 1 })).toBeVisible();
await expect(page.locator('link[rel="stylesheet"][href$="style.css"]')).toHaveCount(1);
for (const name of appNames) {
await expect(page.getByRole('heading', { name, exact: true })).toBeVisible();
}

await page.getByRole('button', { name: 'Switch to dark mode' }).click();
await expect(page.locator('html')).toHaveAttribute('data-theme', 'dark');
await page.reload();
await expect(page.getByRole('button', { name: 'Switch to light mode' })).toBeVisible();
expect(errors).toEqual([]);
});

test('the homepage fits a phone viewport', async ({ page }) => {
await page.setViewportSize({ width: 375, height: 812 });
await page.goto('/');
await expect(page.getByRole('heading', { level: 1 })).toBeVisible();
const overflows = await page.locator('body').evaluate(body =>
body.scrollWidth > document.documentElement.clientWidth
);
expect(overflows).toBe(false);
});

test('hub pages and their local links and assets resolve', async ({ page }) => {
const links = new Set();
for (const path of ['/', '/privacy.html', '/terms.html', '/404.html']) {
const response = await page.goto(path);
expect(response.status(), path).toBe(200);
await expect(page.getByRole('heading', { level: 1 })).toBeVisible();
const pageLinks = await page.locator('a[href], link[href], script[src], img[src]').evaluateAll(elements =>
elements.map(element => {
const url = new URL(element.getAttribute('href') ?? element.getAttribute('src'), document.baseURI);
url.hash = '';
return url.origin === window.location.origin ? url.href : null;
}).filter(Boolean)
);
for (const url of pageLinks) links.add(url);
}

for (const url of links) {
const response = await page.request.head(url);
await expect(response, url).toBeOK();
}
});

const roomOrigin = 'https://over-heard-606573080592.us-east1.run.app';
const shortcuts = [
['/chefbot/', '/ChefBot/'],
['/cHeFbOt', '/ChefBot/'],
['/AlLaBoArD/', 'https://allaboard-606573080592.us-east1.run.app/'],
['/OvErBoArD/', 'https://bpmdata.github.io/OverBoard/app/'],
['/OvErHeArD/', roomOrigin + '/'],
['/Physics-42/', roomOrigin + '/physics-42'],
];

for (const [shortcut, target] of shortcuts) {
test(`the 404 page routes ${shortcut}`, async ({ page, baseURL }) => {
const destination = new URL(target, baseURL);
// GitHub Pages serves this file at the missing URL. Stub the destination so
// a linked app's availability cannot affect the test.
await page.route(url => url.pathname === shortcut, route =>
route.fulfill({ status: 404, path: custom404 })
);
await page.route(url => url.origin === destination.origin && url.pathname === destination.pathname, route =>
route.fulfill({ contentType: 'text/html', body: '<title>Destination</title>' })
);
await page.goto(shortcut + '?source=test#section');
await expect(page).toHaveURL(destination.href + '?source=test#section');
});
}
58 changes: 58 additions & 0 deletions .github/hub-checks/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .github/hub-checks/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "bpmdata-hub-checks",
"private": true,
"scripts": {
"test": "playwright test"
},
"devDependencies": {
"@playwright/test": "1.63.0"
}
}
12 changes: 12 additions & 0 deletions .github/hub-checks/playwright.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from '@playwright/test';

const baseURL = 'http://127.0.0.1:4173';

export default defineConfig({
testDir: '.',
use: { baseURL, colorScheme: 'light' },
webServer: {
command: 'python3 -m http.server 4173 --bind 127.0.0.1 --directory ../..',
url: baseURL,
},
});
30 changes: 30 additions & 0 deletions .github/workflows/hub-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Hub checks

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
check:
name: Check hub
runs-on: ubuntu-latest
timeout-minutes: 10
defaults:
run:
working-directory: .github/hub-checks
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: actions/setup-node@v6
with:
node-version: "22"
cache: npm
cache-dependency-path: .github/hub-checks/package-lock.json
- run: npm ci
- run: npx playwright install --with-deps --only-shell chromium
- run: npm test
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,18 @@ Also here:
the icon generator script there, rebuild, and copy the new files here.

Plain HTML and CSS; no build step. `.nojekyll` turns off GitHub's Jekyll processing.

## Hub checks

GitHub Actions checks pull requests and pushes to `main`. It opens a local copy in Chromium, checks
the homepage, theme toggle, policy pages, and local links and assets, and exercises app shortcuts
and an OverHeard room redirect. The checks use stub pages for the linked services.

To run the checks locally with Node.js 22 and Python 3:

```sh
cd .github/hub-checks
npm ci
npx playwright install --only-shell chromium
npm test
```