forked from mfittko/geo-playground
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Parent: #7
Scope
Add unit tests for URL helpers and Playwright E2E tests that verify layouts/toggles and live URL updates. Update user docs. Incorporate an automation guide to enable direct implementation of e2e/share-panel.spec.ts.
Deliverables (updated)
- Unit:
src/__tests__/utils/urlEncoding.shareView.test.ts(COMPLETE; updated in PR #15) - E2E:
e2e/share-panel.spec.tscovering:- Default layout without params
layout=noninteractiveshows content, hides UI, disables interactionsfuncControls/toolsbehavior and precedencefullscreen=1shows fullscreen toggle; no auto-entertools=0,zoom=0,unitCtl=0,header=0hide respective UIs;unitCtl=0locks unitlangapplied; unsupported falls back- URL updates live when options change in the Settings modal
- Embed snippet reflects options
- Docs: update
docs/user-guide.mdwith examples (links + embed) and reference to PRD
Automation guide (for e2e/share-panel.spec.ts)
-
Test harness
- Dev server auto-starts via Playwright config; do not start a separate server.
- Browser: Chromium (config sets
channel: 'chrome'). - Base URL:
/. - Use stable selectors: ids in Unified Settings modal Share tab:
#funcControls,#tools,#header,#zoom,#unitCtl,#fullscreen,#admin(read-only for live effects), and#languagefor Share tab language select. - Settings modal open button: use role or title text — click the settings icon button with tooltip
Settings(translated; English default). Alternatively,getByRole('button', { name: /settings/i }). - Zoom controls buttons:
[data-testid="grid-zoom-in"],[data-testid="grid-zoom-reset"]. - Function plotting button:
[data-testid="plot-formula-button"]. - Toolbar container:
#geometry-toolbar. - Formula editor presence can be detected by
[data-testid="formula-editor"].
-
Scenario A: Default layout without params
page.goto('/').- Assert header visible (look for page title text from header or a container above the canvas),
#geometry-toolbarvisible, zoom control visible, unit selector visible, fullscreen control may be hidden by default. - Open Settings and verify modal heading
Settingsand tabsGeneral,View,Shareare present.
-
Scenario B: Live toggles (funcControls/tools/header/zoom/unitCtl/fullscreen)
- Open Settings → View tab.
- Toggle
#funcControlsoff → expect function controls (formula editor + plot button) to be hidden; keep geometry tools visibility as configured. - Toggle
#toolsoff → expect#geometry-toolbarhidden (no geometric tools). If bothfuncControls=0andtools=0, toolbar and function controls should both be hidden. - Toggle
#headeroff → expect header container absent. - Toggle
#zoomoff →[data-testid="grid-zoom-in"]absent. - Toggle
#unitCtloff → unit selector absent and unit remains fixed under interactions. - Toggle
#fullscreenon → expect a fullscreen button present (button labelEnter Fullscreen); do not auto-enter fullscreen. - For each toggle change, assert
page.url()contains the corresponding param updated immediately (e.g.,funcControls=0,tools=0,header=0,zoom=0,unitCtl=0,fullscreen=1).
-
Scenario C: Deferred toggles (layout/admin/lang)
- Open Settings → View tab; switch
layouttononinteractive. While modal is open, the app remains configurable for preview. - Close modal → expect non-interactive mode applied: all UI controls hidden (toolbar, zoom, header, unit selector, fullscreen), interactions disabled (pointer events off), but canvas content (grid, shapes, formulas) visible.
- Tip: Load with a sample URL that includes a formula to verify content (e.g., use an encoded
formulas=...param as in the PRD examples), or plot a quick function before switching.
- Tip: Load with a sample URL that includes a formula to verify content (e.g., use an encoded
- Re-open Settings → Share tab; toggle
#adminoff; close modal → expect admin controls (share/settings buttons) hidden in the main UI. Verifyadmin=0in URL. - Share tab language: change
lang(e.g.,de) and close → URL haslang=de; UI language remains as-is (General tab controls the current session language).
- Open Settings → View tab; switch
-
Scenario D: Share URL and embed snippet
- Open Settings → Share tab.
- Validate the Share URL input reflects current toggles (read-only input shows URL containing current query string).
- Adjust width/height; validate the embed textarea contains an
<iframe>with the current URL and updated dimensions.
-
Scenario E: Direct URL loads
page.goto('/?layout=noninteractive&header=0&tools=0&zoom=0&unitCtl=0&fullscreen=1&funcControls=0&lang=de').- Assert noninteractive precedence: all UI hidden; content visible.
- Validate
langfallback/acceptance: UI language for General tab (if used) is separate from Share URL language; Share tab language affects URLs only.
-
Scenario F: Legacy compatibility
page.goto('/?funcOnly=1').- Validate behavior maps to new schema (e.g., implies tools off). If we do not convert legacy automatically in URL, assert the defaults remain consistent and our serializer does not emit
funcOnlywhen generating new URLs.
-
Example code snippets
- Open Settings:
await page.getByRole('button', { name: /settings/i }).click(); - Toggle:
await page.locator('#tools').click(); - Assert toolbar hidden:
await expect(page.locator('#geometry-toolbar')).toBeHidden(); - Assert zoom hidden:
await expect(page.locator('[data-testid="grid-zoom-in"]')).toHaveCount(0); - Assert URL update:
await expect.poll(() => page.url()).toContain('tools=0');
- Open Settings:
Docs update outline
- Add a Unified Settings section to
docs/user-guide.md:- Overview of tabs (General/View/Share) and live vs deferred options.
- Parameter table and examples (from PRD and manual report).
- Embed snippet instructions.
- Noninteractive mode notes (shows content, disables UI/interactions).
Acceptance Criteria
- Unit tests pass (already green).
- New
e2e/share-panel.spec.tscovers all scenarios above and passes locally and in CI (Chromium/Chrome). docs/user-guide.mdupdated with examples and PRD reference.
References
Copilot