65 lines
3.1 KiB
JavaScript
65 lines
3.1 KiB
JavaScript
import { readAppFile } from '../test-support/i18n.js';
|
||
import assert from 'node:assert/strict';
|
||
import fs from 'node:fs/promises';
|
||
import path from 'node:path';
|
||
import test from 'node:test';
|
||
|
||
const root = path.resolve(import.meta.dirname, '..');
|
||
|
||
async function read(relativePath) {
|
||
return readAppFile(relativePath);
|
||
}
|
||
|
||
test('start screen uses the presentation-style hero and one action slot', async () => {
|
||
const html = await read('public/index.html');
|
||
|
||
assert.match(html, /class="bootstrap-brand"/);
|
||
assert.match(html, /class="bootstrap-hero"/);
|
||
assert.match(html, /class="bootstrap-features"/);
|
||
assert.match(html, /id="bootstrap-action-status"/);
|
||
assert.match(html, /id="bootstrap-status-text"/);
|
||
assert.match(html, /id="bootstrap-enter"[^>]*hidden/);
|
||
assert.match(html, />Los geht’s</);
|
||
assert.match(html, /<ol class="bootstrap-state-model" hidden>[\s\S]*data-step="storage"/);
|
||
assert.match(html, /id="bootstrap-progress"[^>]*hidden/);
|
||
assert.match(html, /id="android-browser-hint"[^>]*hidden/);
|
||
});
|
||
|
||
test('bootstrap status text fades between loading steps and is replaced by the start button', async () => {
|
||
const css = await read('public/css/bootstrap.css');
|
||
const loader = await read('public/js/bootstrap-loader.js');
|
||
|
||
const statusTextRule = css.match(/\.bootstrap-status-text\s*\{([\s\S]*?)\}/)?.[1] ?? '';
|
||
const fadingRule = css.match(/\.bootstrap-status-text\.is-fading\s*\{([\s\S]*?)\}/)?.[1] ?? '';
|
||
|
||
assert.match(statusTextRule, /transition:\s*opacity/);
|
||
assert.match(fadingRule, /opacity:\s*0/);
|
||
assert.match(loader, /statusText\.classList\.add\('is-fading'\)/);
|
||
assert.match(loader, /statusText\.classList\.remove\('is-fading'\)/);
|
||
assert.match(loader, /get storage\(\) \{ return globalThis\.Wegwichtel\.I18n\.t\(/);
|
||
assert.match(loader, /get server\(\) \{ return globalThis\.Wegwichtel\.I18n\.t\(/);
|
||
assert.match(loader, /get routes\(\) \{ return globalThis\.Wegwichtel\.I18n\.t\(/);
|
||
assert.match(loader, /get location\(\) \{ return globalThis\.Wegwichtel\.I18n\.t\(/);
|
||
assert.match(loader, /actionStatus\?\.classList\.add\('is-leaving'\)/);
|
||
assert.match(loader, /enter\.classList\.add\('is-visible'\)/);
|
||
assert.match(loader, /const completedSteps = new Set\(\)/);
|
||
assert.match(loader, /function schedule\(callback, delay = 0\)/);
|
||
assert.match(loader, /typeof globalThis\.setTimeout === 'function'/);
|
||
assert.doesNotMatch(loader, /dataset\.state/);
|
||
assert.match(loader, /event\.stopPropagation\?\.\(\)/);
|
||
});
|
||
|
||
|
||
test('Android start hint distinguishes Chrome from other Android browsers', async () => {
|
||
const css = await read('public/css/bootstrap.css');
|
||
const loader = await read('public/js/bootstrap-loader.js');
|
||
|
||
assert.match(css, /\.android-browser-hint\s*\{/);
|
||
assert.match(css, /\.android-browser-hint\[data-browser="other"\]/);
|
||
assert.match(loader, /getElementById\('android-browser-hint'\)/);
|
||
assert.match(loader, /\/Android\/i/);
|
||
assert.match(loader, /\/Chrome\\\//i);
|
||
assert.match(loader, /I18n\.t\("bootstrap-loader\.auf\.diesem\.gerat\.kannst\.du\.bilder\.und"\)/);
|
||
assert.match(loader, /I18n\.t\("bootstrap-loader\.tipp\.fur\.android\.mit\.chrome\.lassen\.sich"\)/);
|
||
});
|