Tables is the eighth HTML tool: a read-only tabular view over a
directory of YAML files declared via `tables:` in `.zddc`. Anchor use
case is the Master Deliverables List, where each row is one
`<tracking>.yaml` under `Archive/<Party>/MDL/`. Rows click through to
the existing form renderer for editing.
Schema (zddc/internal/zddc/file.go)
- New `Tables map[string]string` on ZddcFile. Map key becomes the URL
stem (`tables[MDL]` → `<dir>/MDL.table.html`); the value is a path
relative to the .zddc pointing at a `*.table.yaml` spec describing
columns + the rows directory. No upward cascade in v1 — each
directory hosting a table declares it directly.
Server handler (zddc/internal/handler/tablehandler.go)
- `RecognizeTableRequest` matches GET `/<dir>/<name>.table.html`
against the cascade's `tables:` declarations. Dispatch routes
table requests before the form-system intercept.
- `ServeTable` ACL-gates with `policy.ActionRead` and serves the
embedded `tables.html` template; client walks the directory itself
via the listing JSON or FS Access API.
- tables.html embedded via //go:embed — same pattern as form.html.
Frontend (tables/)
- Vanilla JS: app/context/util/filters/sort/render/main modules.
- Reads spec + row YAML files via window.zddc.source (HTTP polyfill
or local FS handle); js-yaml 4.1.0 vendored in shared/vendor for
client-side parsing.
- Sample fixtures under tables/sample/ for local testing.
Build + CI
- Lockstep build registers tables alongside the other 7 tools (HTML
output, embed mirror, versions.txt, release-output, tags).
- Playwright project added; `npx playwright test --project=tables`
is part of `npm test`.
Drive-by: rename mdedit Playwright selectors `#select-directory` →
`#addDirectoryBtn` to fix three pre-existing failing tests.
Drive-by: ignore locally-built `zddc/zddc-server` binary so it doesn't
get accidentally staged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
77 lines
3.1 KiB
JavaScript
77 lines
3.1 KiB
JavaScript
import { test, expect } from '@playwright/test';
|
|
import { MOCK_FS_INIT_SCRIPT } from './fixtures/mock-fs-api.js';
|
|
import * as path from 'path';
|
|
|
|
const HTML_PATH = path.resolve('mdedit/dist/mdedit.html');
|
|
|
|
test.describe('Markdown Editor', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.addInitScript(MOCK_FS_INIT_SCRIPT);
|
|
});
|
|
|
|
test('loads without errors', async ({ page }) => {
|
|
// Use 'load' rather than 'networkidle' — the bundled Toast UI/Tailwind
|
|
// scripts run inline so there is no external network activity to wait for.
|
|
await page.goto(`file://${HTML_PATH}`, { waitUntil: 'load' });
|
|
await page.waitForSelector('#app', { timeout: 15000 });
|
|
|
|
// Scratchpad opens by default with welcome content seeded into the editor.
|
|
await expect(page.locator(`.file-item[data-path="__scratchpad__"]`)).toBeVisible();
|
|
await expect(page.locator('#content-container')).toBeVisible();
|
|
|
|
// Add Local Directory button is present and enabled
|
|
const addDirBtn = page.locator('#addDirectoryBtn');
|
|
await expect(addDirBtn).toBeVisible();
|
|
await expect(addDirBtn).not.toBeDisabled();
|
|
});
|
|
|
|
test('renders a file tree from a mock directory', async ({ page }) => {
|
|
await page.goto(`file://${HTML_PATH}`, { waitUntil: 'load' });
|
|
await page.waitForSelector('#addDirectoryBtn', { timeout: 15000 });
|
|
|
|
// Set up mock directory before triggering the picker
|
|
await page.evaluate(() => {
|
|
window.__setMockDirectory('notes', [
|
|
{ name: 'readme.md', content: '# Hello\n\nWelcome.', size: 30 },
|
|
{ name: 'notes.md', content: '# Notes\n\nSome notes.', size: 25 },
|
|
]);
|
|
});
|
|
|
|
await page.locator('#addDirectoryBtn').click();
|
|
|
|
// File tree should populate with the two files
|
|
await page.waitForFunction(
|
|
() => document.querySelector('#file-tree')?.children.length > 0,
|
|
{ timeout: 10000 }
|
|
);
|
|
|
|
const items = await page.locator('#file-tree *').count();
|
|
expect(items).toBeGreaterThanOrEqual(2);
|
|
});
|
|
|
|
test('DEBUG flag is defined and console.log calls are gated', async ({ page }) => {
|
|
const logs = [];
|
|
page.on('console', msg => msg.type() === 'log' && logs.push(msg.text()));
|
|
|
|
await page.goto(`file://${HTML_PATH}`, { waitUntil: 'load' });
|
|
await page.waitForSelector('#addDirectoryBtn', { timeout: 15000 });
|
|
|
|
const probe = await page.evaluate(() => ({
|
|
debugDefined: typeof DEBUG !== 'undefined',
|
|
debugValue: typeof DEBUG !== 'undefined' ? DEBUG : null,
|
|
}));
|
|
|
|
expect(probe.debugDefined).toBe(true);
|
|
expect(probe.debugValue).toBe(false);
|
|
|
|
// With DEBUG=false, no console.log should fire from app code on load.
|
|
// (Browser/Toast-UI may still log; we only check none of the gated lines fired.)
|
|
const ourLogs = logs.filter(l =>
|
|
l.startsWith('Opened scratchpad') ||
|
|
l.startsWith('Directory selected') ||
|
|
l.startsWith('File ') ||
|
|
l.startsWith('Created new file')
|
|
);
|
|
expect(ourLogs).toEqual([]);
|
|
});
|
|
});
|