4.6 KiB
QA: Read-only view of a built-in type (SPA slice 2)
Runner: Vitest + Vue Test Utils (task test:web). No Go test: there is no backend change.
Same pattern as features/schema_list_and_content_nav.qa.md: mock /v1 through the existing api composable, mount with a test router (routes /schema, /schema/:key) and a resolved session whose role varies. The forbidden cases use a session with an unknown role.
Automated
Fixtures: the five built-in types with the board's sample data; "articles" has the 5 fields of the board (Title, Slug, Body, Online, Published on), the others only need a fields array of the right length (5, 5, 8, 6, 6). Three custom types as in slice 1.
SchemaTable / list (extend SchemaView.spec and the SchemaTable spec):
- Built-in rows are single links (
awith href /schema/), accessible name = type name, chevron present, "Managed by RenewCMS" in the desktop Last updated cell, no "Updated" text on the mobile card (usecomponents/__tests__/viewport.ts). - Custom rows are not links and have no chevron. Replaces the slice-1 test "rows are not links".
- Activating the "Articles" row navigates to /schema/articles; no second GET /v1/builtin-type.
Read-only view (new SchemaBuiltinView.spec), one test per state: 4. Read-only: owner and admin. Assert the breadcrumb, h1 with lock and "Built-in", alert title and text, columns, the five rows (label, key, type label, rules) in order, the note, and the absence of any new/edit/delete/add/save/discard button. Both /v1 calls made once. 5. Mobile: arrow-left + title, cards with key and rules, no Type column. 6. Type labels and icons (it.each over the 6 types). 7. Rules derivation (it.each over the Examples table of the feature, incl. 10,000 separator, the en dash for empty, and capitalisation of the first part). Cases tagged "proposed copy" are separate it.each rows so a design change touches them only. 8. Back: the breadcrumb and the mobile arrow push /schema. 9. Deep link: a store in its initial state loads the builtin list once on mount. 10. Loading: unresolved promise, fake timers. Nothing at 149 ms, skeleton at 150 ms, no not-found or 403 page. A fast response never shows the skeleton. 11. Unknown key: it.each over /schema/unknown, /schema/events. Assert the "Content type not found" page copy, URL unchanged, no table. 12. Error: 500 and network failure. Assert the alert copy ("GET /v1/builtin-type failed. ..."), "Try again", no table. Retry then returns 200 and the view replaces the alert (second call made). 13. Forbidden: unknown role gives the 403 page copy, "Go to Home" navigates to /home, URL stays /schema/articles, builtin-type never called. Plus a case where builtin-type answers 403 for an owner. 14. Shared load: navigating /schema -> /schema/articles -> back calls each list endpoint once.
Router and guard:
15. /schema/:key is registered with auth "verified" and title "Schema". Unverified and signed-out users get the existing redirects (extend routerGuard.spec). /schema (exact) is unchanged.
Visual (task visual:check -- schema)
Run task visual:check -- schema; every capture within 10 % at desktop and mobile, light and dark. Nothing is clock-sensitive.
- Replace
skip: 'pending'of state 6 inweb/visual/states.tswith a real setup: open /schema/articles. Mock GET /v1/session, GET /v1/content-type (the 3 custom types), GET /v1/builtin-type with the five types. "articles" must carry the board's 5 fields: Title (text, required, max 200), Slug (text, required, unique), Body (richtext, max 10000), Online (boolean, default false), Published on (date, none). Field counts 5, 5, 8, 6, 6. Keys in the mock follow the board's sample text ("articles" etc.), since the view resolves the key from data. Use the sidebar mock of states 1-5 and mock every other /v1 call the screen makes. - States 1 to 5 must still pass after the list-row change (chevron on built-in rows, "Managed by RenewCMS" in Last updated). If the board and the slice-1 rendering differ on custom rows' chevron, report it, do not fix it silently.
- Loading, Error, Unknown key and Forbidden-on-detail have no board frame: Vitest only, not in the visual check.
Manual
- Keyboard: Tab order list rows (each row one stop), Enter on a focused built-in row opens it; visible focus ring; the breadcrumb and back arrow are reachable.
- Hover on a built-in row, and focus/hover motion.
- Real backend: log in as owner and as admin, open each of the five built-in rows, compare the rendered Rules with the actual fields returned by GET /v1/builtin-type (the board's rules are illustrative), and confirm a plain user gets the 403 page on /schema/article.