Promote classifier's local toast (classifier/css/base.css + showToast
in classifier/js/excel.js) into shared/toast.{js,css}. Every tool's
build.sh now concatenates them, so window.zddc.toast(msg, level, opts)
is callable from any tool.
API:
window.zddc.toast('Saved.', 'success');
window.zddc.toast('Could not load: ' + err.message, 'error');
window.zddc.toast('Note', 'info', { durationMs: 3000 });
Levels: info (default) | success | warning | error. Single-toast
policy — a second call replaces the first. Click anywhere on the
toast to dismiss. ARIA: error → role=alert/aria-live=assertive,
others → role=status/aria-live=polite.
Class prefix is .zddc-toast (BEM-ish) to avoid colliding with any
tool-local .toast rules. Classifier's existing showToast now
delegates to window.zddc.toast — call sites in excel.js +
selection.js are unchanged. Classifier's local .toast CSS block
deleted in favor of the shared one.
This commit only EXPOSES the API. Replacing the ~25 alert() call
sites scattered across archive/transmittal/mdedit/classifier with
toast calls is left as follow-up — each alert needs per-call review
to decide if it's truly non-blocking.
Five Playwright tests in tests/toast.spec.js lock the contract:
API exposure, level mapping, ARIA roles, single-toast replace,
click-to-dismiss.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
109 lines
2.8 KiB
JavaScript
109 lines
2.8 KiB
JavaScript
import { defineConfig } from '@playwright/test';
|
|
|
|
export default defineConfig({
|
|
testDir: './tests',
|
|
// tokens.spec.js builds the Go binary on first run via podman + waits
|
|
// for the spawned master to listen — both can take longer than the
|
|
// default 30s on a cold cache. Other specs are file:// driven and
|
|
// unaffected by this bump.
|
|
timeout: 60000,
|
|
retries: 0,
|
|
reporter: [['line'], ['html', { open: 'never' }]],
|
|
|
|
use: {
|
|
// Chromium only -- File System Access API requires it,
|
|
// and the ZDDC tools target "any modern Chromium-based browser"
|
|
browserName: 'chromium',
|
|
screenshot: 'only-on-failure',
|
|
trace: 'retain-on-failure',
|
|
},
|
|
|
|
projects: [
|
|
{
|
|
name: 'archive',
|
|
testMatch: 'archive.spec.js',
|
|
},
|
|
{
|
|
name: 'archive-cascade',
|
|
testMatch: 'archive-cascade.spec.js',
|
|
},
|
|
{
|
|
name: 'landing',
|
|
testMatch: 'landing.spec.js',
|
|
},
|
|
{
|
|
name: 'transmittal',
|
|
testMatch: 'transmittal.spec.js',
|
|
},
|
|
{
|
|
name: 'transmittal-init',
|
|
testMatch: 'transmittal-init-check.spec.js',
|
|
},
|
|
{
|
|
name: 'transmittal-drag-drop',
|
|
testMatch: 'transmittal-drag-drop.spec.js',
|
|
},
|
|
{
|
|
name: 'classifier',
|
|
testMatch: 'classifier.spec.js',
|
|
},
|
|
{
|
|
name: 'mdedit',
|
|
testMatch: 'mdedit.spec.js',
|
|
},
|
|
{
|
|
name: 'browse',
|
|
testMatch: 'browse.spec.js',
|
|
},
|
|
{
|
|
name: 'zddc-source',
|
|
testMatch: 'zddc-source.spec.js',
|
|
},
|
|
{
|
|
name: 'toast',
|
|
testMatch: 'toast.spec.js',
|
|
},
|
|
{
|
|
name: 'zddc',
|
|
testMatch: 'zddc.spec.js',
|
|
},
|
|
{
|
|
name: 'form-safety',
|
|
testMatch: 'form-safety.spec.js',
|
|
},
|
|
{
|
|
name: 'tables',
|
|
testMatch: 'tables.spec.js',
|
|
},
|
|
{
|
|
name: 'zddc-filter',
|
|
testMatch: 'zddc-filter.spec.js',
|
|
},
|
|
{
|
|
name: 'build-label',
|
|
testMatch: 'build-label.spec.js',
|
|
},
|
|
{
|
|
name: 'schema',
|
|
testMatch: 'schema.spec.js',
|
|
},
|
|
{
|
|
// Server-backed: starts a real zddc-server master via
|
|
// tests/lib/server.mjs (which builds the binary on first run
|
|
// through the canonical podman/zddc-go:1.24 invocation), drives
|
|
// Chromium against http://127.0.0.1:<port>/.tokens, exercises
|
|
// create/list/revoke + bearer round-trip + cross-user 404 +
|
|
// XSS-guard. The binary build is cached at zddc/dist/zddc-server-
|
|
// test and invalidated by a hash of cmd/+internal/+go.{mod,sum}
|
|
// so a second run only takes the master-startup time (~1s).
|
|
// First run takes ~30s for the build.
|
|
//
|
|
// The lifecycle is per-spec via beforeAll/afterAll — Playwright's
|
|
// top-level webServer hook would fire for every project, including
|
|
// the file://-driven tool tests that don't need the server.
|
|
name: 'tokens',
|
|
testMatch: 'tokens.spec.js',
|
|
},
|
|
],
|
|
});
|
|
|