* feat(review): add review queue schema with restore validation
Add the Needs review schema group (media_review_metadata,
media_review_items, media_review_decisions) beside the image annotation
group it cites. review_schema_error validates the catalog, columns,
foreign keys, row values and canonical 8 MiB evidence read-only;
migrate_review_state installs it in a SAVEPOINT after the annotation
group, and verify_database_file requires it under require_library_state.
A review group without a valid annotation group is refused. Decisions
null their pair and image navigation through indexes when those are
deleted. Old backups and annotation-era backups restore and gain the
group; browser fixtures clear the new tables on reset.
* feat(review): persist ambiguous sampler evidence from scans and new outputs
The output scan and the live monitor now queue every file the ingestion
resolver finds ambiguous for Needs review. The file is captured, its metadata
is read again from the capture and resolved with the default profile, and only
an ambiguous result is stored, bound to the capture's annotation byte record
and fenced by its storage epoch. Evidence holds one hashed projection per
selectable candidate; none, more than 16 or over 8 MiB is a limited item.
Recording is idempotent per bytes and evidence and never touches a decision.
Scan statuses, counters, outcome rows and legacy SSE events are unchanged; the
job scope gains review_items/review_errors and the log a Needs review line.
The monitor records after its fallback link, best effort.
* feat(review): explicit association decisions with compatible linking
Needs review gains its queue reads and decisions:
- GET /prompt_manager/review/items lists pending items oldest first with
the exact pending total and an HMAC keyset cursor bound to the storage
epoch and the review index revision.
- GET /prompt_manager/review/items/{id} adds the candidates (role texts,
label, selectability), the dependency fingerprint and the digest.
- POST /prompt_manager/review/items/{id}/decision applies a candidate only
for a capture of the item's bytes that the current file still hashes to
and whose evidence is unchanged, through the ingester's compatible-only
rules in the same transaction as the decision row; a conflict writes
nothing. Leave unresolved records the decision and links nothing.
ingest_resolved_pair keeps its contract; its body moves into
_ingest_resolved_pair_in, which runs in the caller's transaction.
Items keep the file's recorded spelling so targets keep their case on
Windows, and a rescan skips the copy and hash of a file whose size and
mtime match the bytes an item already cites.
* fix(review): build the spelling validation test from native paths
On Windows the locator is case-folded and uses backslashes, so the fixed
POSIX pair /out/a.png no longer folded to itself and the new spelling
check refused the good case. The test now spells a mixed-case native path
and folds it with os.path.normcase, and also refuses a locator of another
file.
* fix(review): Apply sees the file under every spelling and rechecks only its choice
Apply now finds the legacy rows of the same physical file however its root
is reached. The roots are real paths while the monitor links under the
directory it watches, so a symlinked or junctioned root, subst or a mapped
drive used to hide the monitor's row and Apply added a second, differently
linked row. Same-name rows are resolved to their physical identity
(normcase(realpath), else samefile); the dependency fingerprint covers all
of them, two rows refuse the choice, one row is enriched under the
ingester's compatible-only rules, and a same-name row the request did not
classify is a changed association.
Apply re-verifies only what the decision depends on: the bytes are still
ambiguous and still offer the chosen candidate. A resolver change that
rewords the reason or reorders candidates leaves pending items applicable.
The resolver version is one constant in prompt_pair_resolver, shared by
ingestion provenance and Needs review.
The transaction's byte check receives the re-hashed digest (or the body's
for Leave unresolved), every Apply refusal branch is tested with zero
writes, and the root listing and realpath calls run on a worker thread.
* fix(review): validate stored review evidence once per startup
Startup used to run the full review validation twice (the early guard and
the install) and the annotation group's row checks inside each, so every
evidence document was parsed and re-encoded twice. The early guard is now
catalog-only (a review group without annotation tables), and the install
validates the group once, trusting the annotation group it has just
validated. The evidence predicate no longer pattern-scans every document in
SQL, because the streamed canonical pass proves it, and the codec is built
once.
Measured on a database with 40,000 items of 4 KiB evidence: startup open
went from 7.7 s to 2.5 s. A test pins one evidence pass per reopen.
Restore and verify_database_file keep the full validation.
* fix(review): keep one capture worker for interactive requests
Needs review recording from the scan and the monitor shared the capture
store's two workers with the Tag dialog and Apply, so a busy scan could
answer a user's preview or decision with "Too many previews are open".
Background captures now never take the last worker or capture slot, and
wait up to two seconds for room before counting the file as not added.
Interactive captures are admitted or refused at once, as before.
* fix(review): refresh the recorded spelling when a file is seen under a new one
A case-only rename on Windows or macOS keeps size and mtime_ns, so the
rescan skipped the file and the item kept the old spelling. Its target was
then formatted from a name the directory no longer lists, the capture
refused it, and the item stayed pending with no way to apply it. The skip
path and a duplicate insert now record the current spelling for every item
at the locator and move the review index revision; item revisions do not
change, so an open decision stays valid. Tested under case-folding
semantics on every platform.
* fix(review): final capture store close and recoverable stale cursors
Closing the capture store at shutdown now runs under the store lock and is
final: a monitor recording or scan batch still in flight gets a capture
error instead of creating a new temp directory and restore subscription
after the cleanup.
A well-formed queue cursor this process cannot verify (opened before a
ComfyUI restart, whose cursor secret is per process) now answers 409
review-conflict with the current total, like any other stale page, instead
of an uncoded 400. Malformed cursors stay 400.
* fix(review): make only the shutdown cleanup final
The previous commit made every close of the capture store final, which
also refused the explicit closes that swap in a fresh store. Only the host's
on_cleanup hook is final now; an observe after it answers a coded capture
error instead of an unhandled 500.
* refactor(admin): move Needs review recording into its own mixin
_record_scanned_review, _record_review_sync, record_review_file and
_log_review_items move unchanged from py/api/admin.py to
py/api/review_recording.py (ReviewRecordingMixin), keeping admin.py from
growing further past the size ceiling. No behaviour change.
* fix(review): record the review fix round and the skip's residual risks in TESTING.md
The Needs review paragraphs now state the rescan skip's residual risks (an
in-place rewrite that keeps size and mtime_ns is never re-queued; a deleted
or moved file leaves its pending item counted), the physical identity rule
for Apply, the candidate-only recheck and shared resolver version, the
spelling refresh, background capture admission, the final shutdown close,
the stale-cursor answer and the measured startup validation cost.
* feat(review): bind queue cursors to the storage epoch only
A decision or a new item (the monitor records one per generation) no
longer makes an open cursor stale: the (created_at, id) keyset stays
ordered when items leave or are appended. A restore still answers
storage-changed and an unverifiable cursor review-conflict.
* feat(review): Needs review page, SAVED VIEWS row and Activity hook
The concept's Metadata review page at #/review: the notice with the
exact pending count, the queue's media cards (shared with Images through
image-card.mjs), and the Resolve the association panel with the sampler
context, the chosen path's prompt blocks, Leave for later and Apply
association. Apply takes a fresh capture; refusals keep the selection
and explain inline; an unanswered decision is resent once. SAVED VIEWS
lists Needs review after Favorites with its count (retires D50), and an
ended scan that recorded review items offers Review metadata in Activity
(D87). Queue items carry the card's media url.
* feat(review): re-read an open Needs review page when its queue changes
An open Needs review page now follows the queue without polling. A new
server-sent event stream, GET /prompt_manager/review/events, sends
"ready" when it opens and "change" after every committed queue change:
an item the scan or the monitor recorded, a spelling refresh, a decision
from any tab, and a restore. database/review_changes.py notifies after
the commit from whichever thread wrote it. The page re-reads its first
page on each event, keeps the open item, its choice and an unanswered
decision, and re-reads the SAVED VIEWS count with it. When the open item
left the queue, the next one opens with a note. A keepalive comment
every 25 s lets the server drop a closed tab; shutdown ends every stream.
Leaving the page mid-decision now releases that decision's capture.
D-NEW-F1 is renumbered D119 in markers and TESTING.md.
* test(review): Needs review page workflows
The review fixture now seeds a real monitor-fallback conflict (the
monitor pipeline links a new output to the most recent prompt, then
queues it), a limited item and a file under no current root, and can add
an output through the monitor or leave one for a metadata scan.
New workflows: Apply links the chosen pair to that file only; a real
association conflict leaves the links unchanged and explains; a limited
item and an unavailable file can only be left unresolved; a tag save
leaves the item pending; keyboard focus, labels and touch targets; an
open page shows items the monitor and a scan add and a decision made in
another tab; leaving the page releases captures, the change stream and
requests. The faked 409 conflict test is replaced by the real one.
* test(review): cover the card Tag button and raise the review floors
The card's Tag on Needs review now has a workflow, and the page's queue
change hook has no unused default. review.mjs and review-state.mjs
floors rise to their measured coverage; no other floor changes.
* feat(review): keep the loaded depth on live re-reads and read once per visit
A queue change re-read only the first 40 items, so the pages Load more had
shown vanished and the page jumped. Each re-read now reads page after page
until it holds as many items as were shown (a restore met after the first
page reads again from the start), so the cards and the scroll position stay.
The stream's ready made every visit read the queue twice. List reads now
answer the queue's version (library_epoch, review_revision) and ready names
the version read after subscribing; the page re-reads on ready only when the
queue it shows is older. The SAVED VIEWS count follows the page's total, so a
change costs no count read. A stream counts as open only once ready is sent.
* test(review): compare Needs review with the approved concept
review-concept.spec.mjs measures the whole Metadata review page as a tree
in the concept and in production, on the review fixture's new
concept-shaped queue (the concept's first three image names and sizes and
its first prompt). mapConceptReview applies only D29, D119, D3, production's
hooks and accessible names and sample data, and the page then matches at
1600x1100 and 390x844 in both themes. The gallery layout follows the
concept at every breakpoint, the SAVED VIEWS rows match with Needs review
after Favorites, the queue's Tag image dialog matches the needs-review
reference, and a dropped notice border or reordered actions fail.
The comparison found one gap: an unavailable file's card lost its media
area. Its empty media button now keeps the concept's 1.33 ratio (D119).
TESTING.md records the comparison, the extended D119 and a summary of the
image-tagging slice (routes, S1, capture limits, the record-changing job,
the no-download rule, the restart note). A ready whose version cannot be
read re-reads the queue (covered by a page test).
* test(review): give the multi-route shell comparison a fitting time budget
The dispatched CI run failed "shell geometry, tokens and controls match the
concept 390x844 light" on WebKit with a 30 s test timeout (no assertion
failed). Each of these tests makes twelve page loads with captures, hovers
and focus checks: 15-19 s on a CI WebKit runner on main, 22-31 s on this
run's loaded shard. With 2 CPUs and 3 workers it fails locally the same way
(6 of 12 timed out); with a 90 s budget, as the other multi-state concept
comparisons have, all 12 pass.
* fix(review): coalesce queue change events and answer queue thumbnails
- The change stream sends the first notice at once and collapses the
notices of the next 0.4 s into one trailing change, so a busy scan costs
an open page one re-read per 0.4 s at most (COALESCE_SECONDS).
- Queue items answer thumbnail_url, the same URL the Images listing builds
(one shared helper, media_thumbnail_url), or null without a thumbnail.
- The "duplicate and refused decision send nothing" test spies on
notify_review_change instead of reading the next event.
* fix(review): keep the live queue right through applies, Load more and lost streams
- A change heard while a decision is in flight is owed and read once the
decision is refused or unanswered (I1).
- Load more has its own read: during a re-read it waits and continues from
the re-read queue; a re-read started during Load more takes the click
over, and a failed re-read leaves Load more clickable (I2, M7).
- A stream the browser gave up on (503, proxy error) reopens after 3 s,
doubling to 30 s, with a quiet "Live updates are paused" line while it is
down (I3, D-NEW-F2).
- A hidden tab closes its stream and a visible one reopens it; the ready
version keeps that to at most one read (I4).
- Apply fences on the detail's epoch and a re-read under another epoch reads
the open item again (M3); leaving during the observe releases its capture
(M4); an unanswered decision that landed finishes as recorded (M5); cards
follow a re-read's url, target and availability and show thumbnails
(M6, M10).
- The unreadable-ready test asserts exactly one re-read (M1); the panel's
long-file-name wrap carries its D119 marker and TESTING.md entry (M8).
* docs(review): number the live-updates-paused deviation D120
* fix(review): refuse monitor recording beside record-changing jobs
System S1 (#289) gives every record change a registry admission class. The
scan already records Needs review items under its own records job. The
monitor's recording lasts one file and is not a job, so it now checks the
records admission: while a records or guarded job or hold runs it records
nothing, logs that the file waits for the next scan, and answers deferred.
The fallback link stands and the next "new" scan reads the ambiguous file
again, because a fallback link is not a resolved one.
JobRegistry.blocker and active iterate a snapshot of the jobs, since the
monitor's worker thread now asks them too.
* test(backup): wait for the restore, not a 5 s timer, in the thread test
test_database_is_usable_from_every_thread_after_restore let its worker
wait 5 s for the restore. On a stalled Windows runner (py3.11, where the
previous restore test also took 25 s instead of 0.3 s) the restore took
longer, the wait timed out, and the worker read the old database before
the restore ran. The worker now waits for the event under a 120 s bound
that only a hung test reaches, reports a timeout as an error, and the
main thread releases it even when the restore raises. With a restore
delayed by 6 s the old test fails and the new one passes.
* fix(activity): drop Cancel job from a job that had ended before Activity opened
Since #289 the Activity list removed an item's actions only when they were
isConnected. On the first render the item is not in the page yet, so a job
that had already ended when Activity opened kept its "Cancel job" (and a
running job's progress was moved after its actions, then back). The list
now asks parentNode instead. The review spec "a scan job with review items
offers Review metadata in Activity" failed on this before the change
(Expected 0 buttons on a finished job, Received 1) and passes after it.
* fix(review): store non-finite evidence as null and count pending items
canonical_evidence now follows main's non-finite policy (#303): NaN and
±Infinity are written as null instead of raising, so a NaN-stamped graph
never turns a review item limited. The System Overview reports the review
queue's pending total in needs_review.pending, read in the same snapshot
as the Library counts.
* fix(review): show the pending count on the System Overview review row
The Overview's review row now reads "N ambiguous image links" with the
concept's line, from needs_review.pending. Its Review metadata action
stays aria-disabled until the Needs review page ships. The system specs
and their concept comparison follow the real count.
* feat(review): open Needs review from the System Overview review row
Review metadata on the Overview's review row now opens #/review, the
concept's go-review, instead of staying aria-disabled.
* fix(system): answer the Overview and Statistics only after every read ended
asyncio.gather answered at the first failed read while its sibling
executor reads were still inside SQLite. In the suite the test teardown
then deleted the database under the running read, and py3.10 on Ubuntu
segfaulted in get_statistics (test_statistics_failure_is_an_error_envelope).
Both routes now wait for all their reads before answering.
* fix(review): queue only ambiguous files that nothing links, and heal the queue
The maintainer's live scan (19,908 files, scope "new") reported 4,677 files
under Needs review, but the queue held 10,232 items: every file the strict
resolver found ambiguous was queued, including the ones the legacy
browser-parser fallback then linked (all sampled "added" rows) and the ones
already linked to a known prompt (135 of 200 sampled "known" rows).
A file is now queued only when its final outcome is ambiguous and unlinked:
the resolver finds it ambiguous, the fallback links nothing and no saved row
links it already. An ambiguous file that a saved row links is reported as
unchanged ("Already linked to its prompt"), not as Needs review.
The queue heals itself. After each batch, the scan removes the pending items
of every listed file (read, or skipped as known) that a saved row now links.
The monitor does the same for each ambiguous output it links, and never
queues one. Only an undecided item is removed (pending, revision 0, no
decision row), so a decision is never deleted or changed and the schema
needs no new state.
The scan job's scope.review_items now counts this scan's files that are in
the pending queue after it, new or already there, so it agrees with the
review group's ambiguous rows and with the queue total. review_added and
review_settled are new, and the log gains "already in Needs review" and
"left Needs review · now linked" lines. A duplicate whose item is decided is
reported as "decided" and is not counted.
* fix(review): announce items that leave the queue, and seed only queueable files
#284 now queues a file only when its final outcome is ambiguous and unlinked,
and it removes the pending items of files that are now linked. That removal
is a queue change, so it calls notify_review_change after its commit, like
recording and decisions: an open Needs review page re-reads its queue, and
its count follows.
The review browser fixture wrote graphs that the scan's fallback links, and
it produced the conflict item through the monitor's fallback link. Neither is
queued any more. Its files now carry ComfyUI's Infinity stamp, which the
legacy parser cannot read, so they stay unlinked with the same two
candidates. The conflict item is queued first and its file is linked to
another prompt afterwards. "monitor" additions go through
record_review_file from a worker thread.
* fix(review): never queue an ambiguous file with nothing to choose
The maintainer's live queue held 39 items whose candidates all read
"unresolved" ("No positive / No negative"). An ambiguous result is now
reviewable only when at least two candidates are resolved with non-blank
positive text. With none the file could not be traced; with exactly one,
the untraced branches may still have made the file, so that text is not
certain either. Both are reported unresolved, never linked and never
queued (also the A1111 two-delimiter case, which has no candidates).
A rescan removes the pending items of such files whose own evidence
offers no choice, with the same safe delete as the linked settle
(pending, revision 0, no decision row). A limited item (over 16 candidates) that holds at least two
candidates is kept. The job scope gains review_untraced and the log
"= N images left Needs review · nothing to choose".
* test(review): seed the limited item from a graph with more candidates than stored
An A1111 block with two negative lines offers no candidate to choose, so
Needs review no longer queues it (#284). The fixture now records a graph of
17 samplers, which the recorder stores limited.
852 lines
53 KiB
JavaScript
852 lines
53 KiB
JavaScript
import { startCoverage, saveCoverage } from '../../tools/vendor/browser-coverage.mjs';
|
||
import { test, expect } from './fixtures.mjs';
|
||
|
||
const workspace = '/prompt_manager/workspace';
|
||
const statistic = (page, label) => page.locator('#workspace-main dt')
|
||
.filter({ hasText: new RegExp(`^${label}$`) }).locator('..').locator('dd');
|
||
// Concept sidebar: WORKSPACE links carry a real `.nav-count` once loaded, so their accessible name may end in it.
|
||
const escapeName = label => label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||
const navName = label => new RegExp(`^${escapeName(label)}(?:\\s*[\\d,]+)?$`);
|
||
const sidebarLink = (page, label) => page.locator('aside.sidebar nav').getByRole('link', { name: navName(label) });
|
||
const sidebarLinks = page => page.locator('aside.sidebar nav a');
|
||
const routes = [
|
||
['overview', 'Overview', null],
|
||
// D29: Images no longer links the legacy gallery; Overview's tool cards still do.
|
||
['images', 'Images', null],
|
||
// #249 E3: the shelf no longer links the legacy Library; Overview's tool card still does.
|
||
['library', 'Prompt library', null],
|
||
['tags', 'Tags & categories', null],
|
||
// #249 local Inspect: the native Inspect a file page; Overview's tool card still links the legacy metadata page.
|
||
['inspect', 'Inspect a file', null],
|
||
// #249 System S2: native System; its undelivered sections hand off per section (D94, asserted below).
|
||
['system', 'System', null],
|
||
// #249 D51: SAVED VIEWS' Favorites, Images filtered to favorites.
|
||
['favorites', 'Favorites', null],
|
||
// #249 PR F (ruling R5): SAVED VIEWS' Needs review, the concept's Metadata review page (its own heading).
|
||
['review', 'Needs review', null, 'Metadata review'],
|
||
// #249 Activity-1: the concept's Activity page in the tools-and-system group.
|
||
['activity', 'Activity', null],
|
||
];
|
||
|
||
async function countThemeWrites(page) {
|
||
await page.evaluate(() => {
|
||
window.__themeChanges = 0;
|
||
const original = Storage.prototype.setItem;
|
||
Storage.prototype.setItem = function (...args) {
|
||
if (args[0] === 'pm_workspace_theme') window.__themeChanges++;
|
||
return original.apply(this, args);
|
||
};
|
||
});
|
||
}
|
||
|
||
test.beforeEach(async ({ page, request, browserName }) => {
|
||
await startCoverage(page, browserName);
|
||
await expect(await request.post('/__test__/reset')).toBeOK();
|
||
page.workspaceErrors = [];
|
||
page.on('pageerror', error => page.workspaceErrors.push(error.message));
|
||
page.on('response', response => {
|
||
if (response.status() >= 400 && /\/prompt_manager\/(js|lib)\//.test(response.url())) {
|
||
page.workspaceErrors.push(`${response.status()} ${response.url()}`);
|
||
}
|
||
});
|
||
});
|
||
|
||
test.afterEach(async ({ page, browserName }) => {
|
||
// A route handler still running at teardown must not fail the test it outlived.
|
||
await page.unrouteAll({ behavior: 'ignoreErrors' });
|
||
await saveCoverage(page, browserName);
|
||
expect(page.workspaceErrors).toEqual([]);
|
||
});
|
||
|
||
test('workspace starts with real persisted statistics without mutating data', async ({ page, request }) => {
|
||
const before = await (await request.get('/prompt_manager/stats')).json();
|
||
const mutations = [];
|
||
page.on('request', request => {
|
||
if (!['GET', 'HEAD', 'OPTIONS'].includes(request.method())) mutations.push(request.url());
|
||
});
|
||
await page.goto(`${workspace}#/overview`);
|
||
await expect(page).toHaveTitle(/Prompt Manager/);
|
||
await expect(page.getByRole('navigation', { name: 'Workspace', exact: true })).toBeVisible();
|
||
const main = page.locator('#workspace-main');
|
||
await expect(main.getByRole('heading', { level: 1, name: 'Overview', exact: true })).toBeVisible();
|
||
for (const [label, key] of [['Prompts', 'total_prompts'], ['Images', 'total_images'], ['Tags', 'total_tags']]) {
|
||
await expect(statistic(page, label)).toHaveText(String(before.stats[key]));
|
||
}
|
||
expect(before.stats.total_prompts).toBe(2);
|
||
expect((await (await request.get('/prompt_manager/stats')).json()).stats).toEqual(before.stats);
|
||
expect(mutations).toEqual([]);
|
||
await expect(page.locator('iframe')).toHaveCount(0);
|
||
});
|
||
|
||
test('all shell destinations deep-link, reload and expose working existing applications', async ({ page, request }) => {
|
||
for (const [route, label, legacy, title = label] of routes) {
|
||
await page.goto(`${workspace}#/${route}`);
|
||
const main = page.locator('#workspace-main');
|
||
await expect(main.getByRole('heading', { level: 1, name: title, exact: true })).toBeVisible();
|
||
await expect(sidebarLink(page, label)).toHaveAttribute('aria-current', 'page');
|
||
if (route === 'tags' || route === 'inspect') await expect(main.locator('.handoff')).toHaveCount(0);
|
||
if (route === 'inspect') await expect(main.locator('#local-file')).toBeAttached();
|
||
if (legacy) {
|
||
await expect(main.locator(`a[href="${legacy}"]`)).toBeVisible();
|
||
await expect(await request.get(legacy.split('#')[0])).toBeOK();
|
||
}
|
||
await page.reload();
|
||
await expect(main.getByRole('heading', { level: 1, name: title, exact: true })).toBeVisible();
|
||
}
|
||
// D29 and #249 E3: the legacy gallery and Library are reached from Overview's tool cards, not from their pages.
|
||
await page.goto(`${workspace}#/overview`);
|
||
const library = page.locator('#workspace-main').getByRole('link', { name: 'Open existing prompt library', exact: true });
|
||
await expect(library).toHaveAttribute('href', '/prompt_manager/admin');
|
||
await expect(await request.get('/prompt_manager/admin')).toBeOK();
|
||
// The legacy metadata page stays reachable from Overview beside the native Inspect page.
|
||
const metadata = page.locator('#workspace-main').getByRole('link', { name: 'Open existing metadata inspector', exact: true });
|
||
await expect(metadata).toHaveAttribute('href', '/prompt_manager/gallery.html');
|
||
await expect(await request.get('/prompt_manager/gallery.html')).toBeOK();
|
||
const gallery = page.locator('#workspace-main').getByRole('link', { name: 'Open existing image gallery', exact: true });
|
||
await expect(gallery).toHaveAttribute('href', '/prompt_manager/gallery');
|
||
await expect(await request.get('/prompt_manager/gallery')).toBeOK();
|
||
await gallery.click();
|
||
await expect(page).toHaveURL(/\/prompt_manager\/gallery$/);
|
||
});
|
||
|
||
test('keyboard navigation, browser history and unknown routes remain usable', async ({ page }) => {
|
||
await page.goto(`${workspace}#/overview`);
|
||
const navigation = page.getByRole('navigation', { name: 'Workspace', exact: true });
|
||
const images = navigation.getByRole('link', { name: navName('Images') });
|
||
await images.focus();
|
||
await page.keyboard.press('Enter');
|
||
await expect(page.locator('#workspace-main h1')).toHaveText('Images');
|
||
await navigation.getByRole('link', { name: navName('Prompt library') }).click();
|
||
await expect(page.locator('#workspace-main h1')).toHaveText('Prompt library');
|
||
await page.goBack();
|
||
await expect(page.locator('#workspace-main h1')).toHaveText('Images');
|
||
await page.goForward();
|
||
await expect(page.locator('#workspace-main h1')).toHaveText('Prompt library');
|
||
await page.goto(`${workspace}#/not-a-page`);
|
||
await expect(page.locator('#workspace-main h1')).toHaveText('Images');
|
||
await expect(navigation.getByRole('link', { name: navName('Images') }))
|
||
.toHaveAttribute('aria-current', 'page');
|
||
});
|
||
|
||
test('skip to content focuses the current view without changing its route', async ({ page }) => {
|
||
await page.goto(`${workspace}#/library`);
|
||
await expect(page.locator('#workspace-main h1')).toHaveText('Prompt library');
|
||
await page.keyboard.press('Tab');
|
||
await expect(page.getByRole('link', { name: 'Skip to workspace', exact: true })).toBeFocused();
|
||
await page.keyboard.press('Enter');
|
||
await expect(page).toHaveURL(`${workspace}#/library`);
|
||
await expect(page.locator('#workspace-main')).toBeFocused();
|
||
await expect(page.locator('#workspace-main h1')).toHaveText('Prompt library');
|
||
});
|
||
|
||
// The concept focuses its page title on every hashchange navigation (docs/concepts/workspace/app.js 1168), so a screen
|
||
// reader announces "<page>, heading level 1"; the first render leaves focus alone.
|
||
test('a sidebar route change focuses the page title, as the concept does', async ({ page }) => {
|
||
await page.goto(`${workspace}#/library`);
|
||
const title = page.locator('#page-title');
|
||
await expect(title).toHaveText('Prompt library');
|
||
await expect(title).not.toBeFocused();
|
||
await sidebarLink(page, 'Images').click();
|
||
await expect(title).toHaveText('Images');
|
||
await expect(title).toBeFocused();
|
||
await expect(page.locator('#workspace-main')).not.toBeFocused();
|
||
await sidebarLink(page, 'Tags & categories').click();
|
||
await expect(title).toHaveText('Tags & categories');
|
||
await expect(title).toBeFocused();
|
||
await page.goBack();
|
||
await expect(title).toHaveText('Images');
|
||
await expect(title).toBeFocused();
|
||
});
|
||
|
||
test('returning to overview refreshes persisted counts without duplicating navigation', async ({ page, request }) => {
|
||
await page.goto(`${workspace}#/overview`);
|
||
const prompts = statistic(page, 'Prompts');
|
||
await expect(prompts).toHaveText('2');
|
||
const navigation = page.getByRole('navigation', { name: 'Workspace', exact: true });
|
||
await sidebarLink(page, 'Images').click();
|
||
await expect(await request.post('/prompt_manager/save', { data: { text: 'A new persisted workspace prompt' } })).toBeOK();
|
||
await sidebarLink(page, 'Overview').click();
|
||
await expect(prompts).toHaveText('3');
|
||
await expect(navigation).toHaveCount(1);
|
||
await expect(sidebarLinks(page)).toHaveCount(routes.length);
|
||
});
|
||
|
||
test('theme System follows ComfyUI and persists an explicit light or dark preference', async ({ page }) => {
|
||
await page.route('**/api/settings/Comfy.ColorPalette', route => route.fulfill({ json: 'light' }));
|
||
await page.goto(`${workspace}#/overview`);
|
||
const theme = page.locator('[data-ca-theme]').first();
|
||
await expect(theme).toHaveAttribute('data-ca-theme', 'light');
|
||
const themeSelect = page.getByRole('combobox', { name: 'Theme', exact: true });
|
||
await expect(themeSelect).toHaveValue('system');
|
||
await themeSelect.selectOption({ label: 'Dark' });
|
||
await expect(theme).toHaveAttribute('data-ca-theme', 'dark');
|
||
await page.reload();
|
||
await expect(theme).toHaveAttribute('data-ca-theme', 'dark');
|
||
await expect(themeSelect).toHaveValue('dark');
|
||
await themeSelect.selectOption({ label: 'Light' });
|
||
await expect(theme).toHaveAttribute('data-ca-theme', 'light');
|
||
await themeSelect.selectOption({ label: 'System' });
|
||
await expect(theme).toHaveAttribute('data-ca-theme', 'light');
|
||
});
|
||
|
||
// Task A4 (D4, D29): the concept topbar (index.html 45-63, style.css 225-277) without the prototype badge; Activity
|
||
// (D52, D53) shows its button, and its pill only while a job runs.
|
||
test('topbar matches the concept actions', async ({ page }) => {
|
||
await page.setViewportSize({ width: 1600, height: 1100 });
|
||
await page.goto(`${workspace}#/images`);
|
||
const topbar = page.locator('.workspace > header.topbar');
|
||
await expect(topbar).toHaveCount(1);
|
||
const shape = await topbar.evaluate(node => ({
|
||
children: [...node.children].map(child => `${child.localName}.${child.className}`),
|
||
crumbs: [...node.querySelector('.breadcrumbs').childNodes].filter(item => item.nodeType === 1 || item.textContent.trim())
|
||
.map(item => item.nodeType === 1 ? `${item.localName}${item.id ? `#${item.id}` : ''}:${item.textContent}` : item.textContent.trim()),
|
||
actions: [...node.querySelector('.top-actions').children].map(child => `${child.localName}.${child.className}`),
|
||
label: node.querySelector('.theme-label').firstChild.textContent.trim(),
|
||
labelFor: node.querySelector('.theme-label').htmlFor,
|
||
options: [...node.querySelectorAll('#theme option')].map(option => [option.value, option.textContent]),
|
||
arrow: [...node.querySelectorAll('.canvas-link span')].map(span => [span.textContent, span.getAttribute('aria-hidden')]),
|
||
tokens: {
|
||
height: getComputedStyle(node).height, padding: getComputedStyle(node).padding,
|
||
crumbs: getComputedStyle(node.querySelector('.breadcrumbs')).fontSize,
|
||
current: getComputedStyle(node.querySelector('#workspace-breadcrumb')).color === getComputedStyle(document.body).color,
|
||
label: getComputedStyle(node.querySelector('.theme-label')).fontSize,
|
||
select: getComputedStyle(node.querySelector('#theme')).fontSize,
|
||
link: getComputedStyle(node.querySelector('.canvas-link')).fontSize,
|
||
gap: getComputedStyle(node.querySelector('.top-actions')).columnGap,
|
||
},
|
||
}));
|
||
expect(shape).toEqual({
|
||
children: ['div.breadcrumbs', 'div.top-actions'],
|
||
crumbs: ['ComfyAssets', 'span:/', 'span#workspace-breadcrumb:Images'],
|
||
actions: ['a.activity-pill', 'button.', 'label.theme-label', 'a.canvas-link'],
|
||
label: 'Theme', labelFor: 'theme',
|
||
options: [['dark', 'Dark'], ['light', 'Light'], ['system', 'System']],
|
||
arrow: [['↗', 'true']],
|
||
tokens: { height: '68px', padding: '0px 30px', crumbs: '12px', current: true, label: '11px', select: '11px', link: '12px', gap: '12px' },
|
||
});
|
||
const theme = page.getByRole('combobox', { name: 'Theme', exact: true });
|
||
await expect(theme).toHaveValue('system');
|
||
const link = page.getByRole('link', { name: 'ComfyUI', exact: true });
|
||
await expect(link).toHaveText('ComfyUI ↗');
|
||
// D6: the ComfyUI canvas root under the page's mount (resolveUrl), never a hard-coded origin.
|
||
await expect(link).toHaveAttribute('href', '/');
|
||
expect(await link.evaluate(node => node.href === `${location.origin}/`)).toBe(true);
|
||
await expect(page.getByRole('combobox', { name: 'Appearance' })).toHaveCount(0);
|
||
await expect(page.getByRole('button', { name: 'Activity', exact: true })).toHaveCount(1);
|
||
await expect(page.locator('#activity-pill')).toBeHidden();
|
||
await expect(page.locator('.concept-badge')).toHaveCount(0);
|
||
await page.locator('nav [data-route="library"]').click();
|
||
await expect(page.locator('#workspace-breadcrumb')).toHaveText('Prompt library');
|
||
await expect(topbar.locator('.top-actions > *')).toHaveCount(4);
|
||
});
|
||
|
||
// Concept style.css 1375-1391: at <=700px the breadcrumbs hide, the actions spread across the bar and the Theme
|
||
// label text collapses while the select keeps its accessible name.
|
||
test('mobile topbar hides breadcrumbs and spreads actions', async ({ page }) => {
|
||
await page.setViewportSize({ width: 390, height: 844 });
|
||
await page.goto(`${workspace}#/images`);
|
||
const theme = page.getByRole('combobox', { name: 'Theme', exact: true });
|
||
await expect(theme).toBeVisible();
|
||
await expect(page.locator('.breadcrumbs')).toBeHidden();
|
||
const layout = await page.locator('.topbar').evaluate(node => {
|
||
const bar = node.getBoundingClientRect(), actions = node.querySelector('.top-actions');
|
||
const box = element => element.getBoundingClientRect();
|
||
return {
|
||
padding: getComputedStyle(node).paddingInline,
|
||
actions: { width: box(actions).width, justify: getComputedStyle(actions).justifyContent, gap: getComputedStyle(actions).columnGap },
|
||
expected: bar.width - 28,
|
||
label: getComputedStyle(node.querySelector('.theme-label')).fontSize,
|
||
select: getComputedStyle(node.querySelector('#theme')).fontSize,
|
||
activityLeft: box(node.querySelector('#activity-open')).left - bar.left,
|
||
actionsGap: [box(node.querySelector('#activity-open')).right, box(node.querySelector('.theme-label')).left,
|
||
box(node.querySelector('.theme-label')).right, box(node.querySelector('.canvas-link')).left],
|
||
linkRight: bar.right - box(node.querySelector('.canvas-link')).right,
|
||
};
|
||
});
|
||
expect(layout).toMatchObject({ padding: '14px', actions: { justify: 'space-between', gap: '8px' }, label: '0px', select: '11px' });
|
||
expect(Math.abs(layout.actions.width - layout.expected)).toBeLessThanOrEqual(1);
|
||
// The concept's three items spread with space-between: Activity first, Theme between equal gaps, ComfyUI last.
|
||
expect(Math.abs(layout.activityLeft - 14)).toBeLessThanOrEqual(1);
|
||
const [activityRight, themeLeft, themeRight, linkLeft] = layout.actionsGap;
|
||
expect(Math.abs((themeLeft - activityRight) - (linkLeft - themeRight))).toBeLessThanOrEqual(1);
|
||
expect(Math.abs(layout.linkRight - 14)).toBeLessThanOrEqual(1);
|
||
await expect(page.getByRole('link', { name: 'ComfyUI', exact: true })).toBeVisible();
|
||
await theme.selectOption('light');
|
||
await expect(page.locator('body')).toHaveAttribute('data-ca-theme', 'light');
|
||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true);
|
||
});
|
||
|
||
test('unavailable host palette falls back to the system theme and tracks system changes', async ({ page }) => {
|
||
await page.route('**/api/settings/Comfy.ColorPalette', route => route.fulfill({ status: 503, json: {} }));
|
||
await page.emulateMedia({ colorScheme: 'light' });
|
||
await page.goto(`${workspace}#/overview`);
|
||
const theme = page.locator('[data-ca-theme]').first();
|
||
await expect(theme).toHaveAttribute('data-ca-theme', 'light');
|
||
await page.emulateMedia({ colorScheme: 'dark' });
|
||
await expect(theme).toHaveAttribute('data-ca-theme', 'dark');
|
||
});
|
||
|
||
test('overview reports loading, offers retry after failure and renders real empty statistics', async ({ page }) => {
|
||
let release;
|
||
const pending = new Promise(resolve => { release = resolve; });
|
||
await page.route('**/prompt_manager/stats', async route => {
|
||
await pending;
|
||
await route.fulfill({ status: 503, json: { success: false, error: 'Unavailable' } });
|
||
});
|
||
await page.goto(`${workspace}#/overview`);
|
||
await expect(page.locator('#workspace-main').getByRole('status')).toBeVisible();
|
||
release();
|
||
await expect(page.locator('#workspace-main').getByRole('alert')).toBeVisible();
|
||
await page.unroute('**/prompt_manager/stats');
|
||
await page.route('**/prompt_manager/stats', route => route.fulfill({
|
||
json: { success: true, stats: { total_prompts: 0, total_images: 0, total_tags: 0 } },
|
||
}));
|
||
await page.getByRole('button', { name: 'Retry', exact: true }).click();
|
||
await expect(page.locator('#workspace-main').getByRole('alert')).toHaveCount(0);
|
||
for (const label of ['Prompts', 'Images', 'Tags']) {
|
||
await expect(statistic(page, label)).toHaveText('0');
|
||
}
|
||
});
|
||
|
||
test('small screens keep navigation and the theme accessible without horizontal page overflow', async ({ page }) => {
|
||
await page.setViewportSize({ width: 375, height: 812 });
|
||
await page.goto(`${workspace}#/overview`);
|
||
for (const [, label, , title = label] of routes) {
|
||
await sidebarLink(page, label).click();
|
||
await expect(page.locator('#workspace-main h1')).toHaveText(title);
|
||
}
|
||
await expect(page.getByRole('combobox', { name: 'Theme', exact: true })).toBeVisible();
|
||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true);
|
||
});
|
||
|
||
test('leaving a loading overview prevents its delayed result from replacing the new view', async ({ page }) => {
|
||
let release;
|
||
let completed;
|
||
const pending = new Promise(resolve => { release = resolve; });
|
||
const finished = new Promise(resolve => { completed = resolve; });
|
||
await page.route('**/prompt_manager/stats', async route => {
|
||
await pending;
|
||
await route.fulfill({ json: {
|
||
success: true, stats: { total_prompts: 999, total_images: 888, total_tags: 777 },
|
||
} }).catch(() => {});
|
||
completed();
|
||
});
|
||
await page.goto(`${workspace}#/overview`);
|
||
await expect(page.locator('#workspace-main').getByRole('status')).toBeVisible();
|
||
await sidebarLink(page, 'Images').click();
|
||
await expect(page.locator('#workspace-main h1')).toHaveText('Images');
|
||
release();
|
||
await finished;
|
||
await expect(page.locator('#workspace-main h1')).toHaveText('Images');
|
||
await expect(page.locator('#workspace-main')).not.toContainText('999');
|
||
await expect(page.locator('#primary-nav')).toHaveCount(1);
|
||
await expect(page.locator('#system-nav')).toHaveCount(1);
|
||
await expect(page.getByRole('combobox', { name: 'Theme', exact: true })).toHaveCount(1);
|
||
await expect(page.locator('#workspace-main .section-caption')).toBeVisible();
|
||
await countThemeWrites(page);
|
||
await page.getByRole('combobox', { name: 'Theme', exact: true }).selectOption('light');
|
||
expect(await page.evaluate(() => window.__themeChanges)).toBe(1);
|
||
});
|
||
|
||
test('cached-page restoration remounts one working shell and refreshes its data', async ({ page }) => {
|
||
let reads = 0;
|
||
page.on('request', request => {
|
||
if (new URL(request.url()).pathname === '/prompt_manager/stats') reads++;
|
||
});
|
||
await page.goto(`${workspace}#/overview`);
|
||
await expect(statistic(page, 'Prompts')).toHaveText('2');
|
||
for (let restore = 0; restore < 2; restore++) {
|
||
await page.evaluate(() => {
|
||
window.dispatchEvent(new PageTransitionEvent('pagehide', { persisted: true }));
|
||
window.dispatchEvent(new PageTransitionEvent('pageshow', { persisted: true }));
|
||
});
|
||
await expect(statistic(page, 'Prompts')).toHaveText('2');
|
||
}
|
||
expect(reads).toBe(3);
|
||
await expect(sidebarLinks(page)).toHaveCount(routes.length);
|
||
await expect(page.locator('#primary-nav')).toHaveCount(1);
|
||
await expect(page.locator('#system-nav')).toHaveCount(1);
|
||
await expect(page.getByRole('combobox', { name: 'Theme', exact: true })).toHaveCount(1);
|
||
await countThemeWrites(page);
|
||
await sidebarLink(page, 'Images').click();
|
||
await expect(page.locator('#workspace-main h1')).toHaveText('Images');
|
||
await page.getByRole('combobox', { name: 'Theme' }).selectOption('light');
|
||
await expect(page.locator('body')).toHaveAttribute('data-ca-theme', 'light');
|
||
expect(await page.evaluate(() => window.__themeChanges)).toBe(1);
|
||
});
|
||
|
||
// Task A2: the Overview and handoff panels use the concept's `.surface` (style.css 709-722) and `.small` from the
|
||
// concept base stylesheet, not the retired shell sheet (18px h2, 11px panel radius).
|
||
const surfaceStyle = node => {
|
||
const style = getComputedStyle(node);
|
||
const heading = getComputedStyle(node.querySelector(':scope > h2'));
|
||
const intro = node.querySelector(':scope > p');
|
||
return {
|
||
padding: [style.paddingTop, style.paddingRight, style.paddingBottom, style.paddingLeft],
|
||
radius: style.borderTopLeftRadius, border: `${style.borderTopWidth} ${style.borderTopStyle}`,
|
||
background: style.backgroundColor,
|
||
h2: { fontSize: heading.fontSize, fontWeight: heading.fontWeight, marginTop: heading.marginTop, marginBottom: heading.marginBottom },
|
||
intro: intro && { fontSize: getComputedStyle(intro).fontSize, marginTop: getComputedStyle(intro).marginTop },
|
||
};
|
||
};
|
||
const SURFACE = {
|
||
padding: ['22px', '22px', '22px', '22px'], radius: '7px', border: '1px solid',
|
||
h2: { fontSize: '17px', fontWeight: '600', marginTop: '0px', marginBottom: '0px' },
|
||
intro: { fontSize: '12px', marginTop: '7px' },
|
||
};
|
||
|
||
for (const width of [1600, 390]) test(`overview and handoff render with concept surfaces ${width}`, async ({ page }) => {
|
||
await page.setViewportSize({ width, height: 900 });
|
||
await page.goto(`${workspace}#/overview`);
|
||
const main = page.locator('#workspace-main');
|
||
await expect(statistic(page, 'Prompts')).toHaveText('2');
|
||
const tools = main.locator('section.surface').filter({ has: page.getByRole('heading', { level: 2, name: 'Continue creating', exact: true }) });
|
||
await expect(tools).toHaveCount(1);
|
||
const surface = await tools.evaluate(surfaceStyle);
|
||
expect(surface).toMatchObject(SURFACE);
|
||
expect(surface.background).not.toBe('rgba(0, 0, 0, 0)');
|
||
await expect(main.locator('.panel')).toHaveCount(0);
|
||
const card = tools.locator('.tool-card').first();
|
||
await expect(card.locator('p.small')).toHaveCount(1);
|
||
expect(await card.locator('p.small').evaluate(node => getComputedStyle(node).fontSize)).toBe('12px');
|
||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true);
|
||
|
||
await sidebarLink(page, 'System').click();
|
||
// System's Overview is native (S2 Task 6); a section not delivered yet still hands off (D94).
|
||
await main.locator('.section-nav').getByRole('button', { name: 'Integrations', exact: true }).click();
|
||
const handoff = main.locator('section.handoff');
|
||
await expect(handoff).toHaveClass(/\bsurface\b/);
|
||
expect(await handoff.evaluate(surfaceStyle)).toMatchObject(SURFACE);
|
||
await expect(handoff.locator('a[href="/prompt_manager/admin"]')).toBeVisible();
|
||
await expect(main.locator('.panel')).toHaveCount(0);
|
||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true);
|
||
});
|
||
|
||
// #249 System S2 Task 5: the concept's renderSystem shell (app.js 698–706) at `#/system/<section>`, every section a D94
|
||
// hand-off until its PR, and the Save row's truthful status (D92).
|
||
const SYSTEM_SECTION_LABELS = ['Overview', 'Appearance', 'Sources & scans', 'Integrations', 'Auto-tagging', 'Maintenance',
|
||
'Backup & export', 'Diagnostics & logs'];
|
||
const SYSTEM_HASHES = ['overview', 'appearance', 'sources', 'integrations', 'tagging', 'maintenance', 'backups', 'diagnostics'];
|
||
const SYSTEM_HANDOFFS = { maintenance: ['/prompt_manager/admin', '/prompt_manager/gallery'] };
|
||
|
||
test('System is native: the concept shell, section navigation, sections, hand-offs and the Save row', async ({ page }) => {
|
||
const mutations = [];
|
||
page.on('request', item => { if (!['GET', 'HEAD', 'OPTIONS'].includes(item.method())) mutations.push(item.url()); });
|
||
await page.goto(`${workspace}#/system`);
|
||
const main = page.locator('#workspace-main');
|
||
await expect(main.locator('h1')).toHaveText('System');
|
||
await expect(main.locator('.heading p.muted')).toHaveText('Configuration, maintenance and recovery—with browsing kept in the workspace.');
|
||
// D92: no "Sample configuration" chip.
|
||
await expect(main.locator('.heading .chip')).toHaveCount(0);
|
||
expect(await main.evaluate(node => [...node.children].map(child => `${child.localName}.${child.className}`)))
|
||
.toEqual(['div.heading', 'div.section-nav', 'div.settings-layout']);
|
||
const nav = main.getByRole('group', { name: 'System sections', exact: true });
|
||
await expect(nav.getByRole('button')).toHaveText(SYSTEM_SECTION_LABELS);
|
||
await expect(nav.getByRole('button', { name: 'Overview', exact: true })).toHaveAttribute('aria-pressed', 'true');
|
||
await expect(nav.locator('[aria-pressed="true"]')).toHaveCount(1);
|
||
await expect(page.locator('aside.sidebar a[href="#/system"]')).toHaveAttribute('aria-current', 'page');
|
||
const layout = main.locator('.settings-layout');
|
||
await expect(layout.locator(':scope > .save-row > span.small#settings-status')).toHaveText('No unsaved changes.');
|
||
const save = layout.locator(':scope > .save-row > button.ca-primary');
|
||
await expect(save).toHaveText('Save preferences');
|
||
await expect(save).toHaveAttribute('aria-disabled', 'true');
|
||
// Playwright waits on an aria-disabled control, so the ignored press is forced.
|
||
await save.click({ force: true });
|
||
await expect(layout.locator('#settings-status')).toHaveText('No unsaved changes.');
|
||
|
||
for (const [index, label] of SYSTEM_SECTION_LABELS.entries()) {
|
||
const hash = SYSTEM_HASHES[index];
|
||
const button = nav.getByRole('button', { name: label, exact: true });
|
||
await button.click();
|
||
await expect(page).toHaveURL(`${workspace}#/system/${hash}`);
|
||
await expect(button).toHaveAttribute('aria-pressed', 'true');
|
||
await expect(nav.locator('[aria-pressed="true"]')).toHaveCount(1);
|
||
// The section changes in place: focus stays on the pressed section, not the page title.
|
||
await expect(button).toBeFocused();
|
||
// S2 Task 6: Overview is native (workspace-system.spec.mjs), and so are Appearance (S3 Task 8) and Sources & scans
|
||
// (S4 Task 11, workspace-system-sources.spec.mjs, its update notice shown in a fresh browser); Maintenance shows
|
||
// its health-check notice above the hand-off (D123); every other section hands off.
|
||
if (hash === 'overview') await expect(layout.locator(':scope > .summary-metrics')).toBeVisible();
|
||
if (hash === 'sources') await expect(layout.locator('#source-list .operation')).toHaveCount(2);
|
||
expect(await layout.evaluate(node => [...node.children].map(child => `${child.localName}.${child.className}`)))
|
||
.toEqual({ overview: ['div.summary-metrics', 'div.two-col', 'div.save-row'], appearance: ['section.surface', 'div.save-row'],
|
||
sources: ['div.notice', 'section.surface', 'div.save-row'],
|
||
maintenance: ['div.notice', 'section.surface handoff', 'div.save-row'] }[hash]
|
||
?? ['section.surface handoff', 'div.save-row']);
|
||
if (['overview', 'appearance', 'sources'].includes(hash)) continue;
|
||
const handoff = layout.locator('section.handoff');
|
||
await expect(handoff.locator('h2')).toHaveText('Your current tools are ready');
|
||
expect(await handoff.locator('a.workspace-link').evaluateAll(links => links.map(link => link.getAttribute('href'))))
|
||
.toEqual(SYSTEM_HANDOFFS[hash] ?? ['/prompt_manager/admin']);
|
||
await expect(layout.locator('#settings-status')).toHaveText('No unsaved changes.');
|
||
await expect(page.locator('aside.sidebar a[href="#/system"]')).toHaveAttribute('aria-current', 'page');
|
||
}
|
||
// Deep links, reload and history keep the section; an unknown section is Overview under its own hash.
|
||
await page.reload();
|
||
await expect(nav.getByRole('button', { name: 'Diagnostics & logs', exact: true })).toHaveAttribute('aria-pressed', 'true');
|
||
await page.goBack();
|
||
await expect(page).toHaveURL(`${workspace}#/system/backups`);
|
||
await expect(nav.getByRole('button', { name: 'Backup & export', exact: true })).toHaveAttribute('aria-pressed', 'true');
|
||
await page.goto(`${workspace}#/system/general`);
|
||
await expect(page).toHaveURL(`${workspace}#/system/overview`);
|
||
await expect(nav.getByRole('button', { name: 'Overview', exact: true })).toHaveAttribute('aria-pressed', 'true');
|
||
// The sidebar's System returns to the Overview section.
|
||
await nav.getByRole('button', { name: 'Integrations', exact: true }).click();
|
||
await sidebarLink(page, 'System').click();
|
||
await expect(page).toHaveURL(`${workspace}#/system`);
|
||
await expect(nav.getByRole('button', { name: 'Overview', exact: true })).toHaveAttribute('aria-pressed', 'true');
|
||
// Leaving System and coming back renders it once, with a fresh section.
|
||
await sidebarLink(page, 'Images').click();
|
||
await expect(main.locator('h1')).toHaveText('Images');
|
||
await expect(main.locator('.section-nav')).toHaveCount(0);
|
||
await page.goBack();
|
||
await expect(main.locator('.section-nav')).toHaveCount(1);
|
||
await expect(main.locator('.settings-layout')).toHaveCount(1);
|
||
expect(mutations).toEqual([]);
|
||
});
|
||
|
||
test('Overview opens native System from its System card (Q12)', async ({ page }) => {
|
||
await page.goto(`${workspace}#/overview`);
|
||
const card = page.locator('#workspace-main .tool-card').filter({ has: page.getByRole('heading', { name: 'System', exact: true }) });
|
||
await expect(card.locator('p.small')).toHaveText('Configuration, maintenance and recovery—with browsing kept in the workspace.');
|
||
const link = card.getByRole('link', { name: 'Open System', exact: true });
|
||
await expect(link).toHaveAttribute('href', '#/system/overview');
|
||
await link.click();
|
||
await expect(page.locator('#workspace-main h1')).toHaveText('System');
|
||
await expect(page.locator('#workspace-main .section-nav [aria-pressed="true"]')).toHaveText('Overview');
|
||
});
|
||
|
||
// Task A3: the concept sidebar (index.html h16-41, app.js nav()) rendered from real data (D27, D28).
|
||
const NAV_TOTALS = [
|
||
['images', 'Images', '/prompt_manager/images/output?mode=workspace&limit=1'],
|
||
['library', 'Prompt library', '/prompt_manager/library?limit=1'],
|
||
['tags', 'Tags & categories', '/prompt_manager/vocabulary/tags?limit=1'],
|
||
];
|
||
async function serverTotals(request) {
|
||
const totals = {};
|
||
for (const [id, , url] of NAV_TOTALS) {
|
||
const response = await request.get(url);
|
||
await expect(response).toBeOK();
|
||
totals[id] = (await response.json()).total;
|
||
expect(Number.isSafeInteger(totals[id]) && totals[id] >= 0).toBe(true);
|
||
}
|
||
return totals;
|
||
}
|
||
const navCount = (page, route) => page.locator(`#primary-nav a[data-route="${route}"] .nav-count`);
|
||
const childShape = locator => locator.evaluate(node => [...node.children]
|
||
.map(child => `${child.localName}${child.id ? `#${child.id}` : ''}${[...child.classList].map(name => `.${name}`).join('')}`));
|
||
|
||
test('sidebar matches the concept groups and shows real counts', async ({ page, request }) => {
|
||
const totals = await serverTotals(request);
|
||
expect(totals.library).toBe(2);
|
||
await page.setViewportSize({ width: 1600, height: 1100 });
|
||
await page.goto(`${workspace}#/images`);
|
||
await expect(page.locator('body > .app-shell > aside.sidebar')).toHaveCount(1);
|
||
await expect(page.locator('body > .app-shell > .workspace > #workspace-main')).toHaveCount(1);
|
||
await expect(page.locator('.workspace-shell, .workspace-body, .sidebar-footer, .connection-dot, .workspace-icon')).toHaveCount(0);
|
||
const sidebar = page.locator('aside.sidebar');
|
||
expect(await childShape(sidebar)).toEqual(['a.brand', 'div.sidebar-label', 'nav#primary-nav', 'div.sidebar-label',
|
||
'nav#saved-nav', 'div.sidebar-bottom']);
|
||
await expect(sidebar.locator('.brand')).toHaveAttribute('href', '#/images');
|
||
// D49: SAVED VIEWS without the concept's PROPOSED badge; D28: still no COLLECTIONS.
|
||
await expect(sidebar.locator('.sidebar-label')).toHaveText(['WORKSPACE', 'SAVED VIEWS']);
|
||
await expect(page.locator('nav#saved-nav')).toHaveAttribute('aria-label', 'Saved views');
|
||
await expect(page.locator('#collections-nav, .new-label')).toHaveCount(0);
|
||
const primary = page.locator('nav#primary-nav');
|
||
await expect(primary).toHaveAttribute('aria-label', 'Workspace');
|
||
for (const [id] of NAV_TOTALS) await expect(navCount(page, id)).toHaveText(totals[id].toLocaleString('en-US'));
|
||
const links = await primary.evaluate(node => [...node.children].map(link => ({ tag: link.localName,
|
||
href: link.getAttribute('href'), icon: link.querySelector('svg')?.getAttribute('class'),
|
||
nodes: [...link.childNodes].map(child => child.nodeType === Node.TEXT_NODE ? `text:${child.textContent}`
|
||
: `${child.localName}${[...child.classList].map(name => `.${name}`).join('')}`) })));
|
||
expect(links).toEqual([
|
||
{ tag: 'a', href: '#/images', nodes: ['svg.icon', 'text:Images', 'span.nav-count'], icon: 'icon' },
|
||
{ tag: 'a', href: '#/library', nodes: ['svg.icon', 'text:Prompt library', 'span.nav-count'], icon: 'icon' },
|
||
{ tag: 'a', href: '#/tags', nodes: ['svg.icon', 'text:Tags & categories', 'span.nav-count'], icon: 'icon' },
|
||
{ tag: 'a', href: '#/inspect', nodes: ['svg.icon', 'text:Inspect a file'], icon: 'icon' },
|
||
]);
|
||
await expect(primary.locator('a[href="#/images"]')).toHaveAttribute('aria-current', 'page');
|
||
await expect(primary.locator('a[aria-current]')).toHaveCount(1);
|
||
await expect(page.locator('#primary-nav a[data-route="inspect"] .nav-count')).toHaveCount(0);
|
||
// Concept tokens: 38px rows, 12px muted labels, 10px muted counts pushed to the end.
|
||
const style = await primary.locator('a[href="#/library"]').evaluate(link => {
|
||
const own = getComputedStyle(link), count = link.querySelector('.nav-count');
|
||
return { minHeight: own.minHeight, fontSize: own.fontSize, gap: own.columnGap, count: getComputedStyle(count).fontSize,
|
||
end: Math.round(link.getBoundingClientRect().right - count.getBoundingClientRect().right) };
|
||
});
|
||
expect(style).toEqual({ minHeight: '38px', fontSize: '12px', gap: '11px', count: '10px', end: 12 });
|
||
// At phone width the concept wraps the links and hides counts and the connection (concept 950px block).
|
||
await page.setViewportSize({ width: 390, height: 844 });
|
||
await expect(navCount(page, 'library')).toBeHidden();
|
||
await expect(page.locator('.sidebar-label, .connection')).toHaveCount(3);
|
||
for (const hidden of await page.locator('.sidebar-label, .connection').all()) await expect(hidden).toBeHidden();
|
||
await expect(primary.locator('a[href="#/inspect"]')).toBeVisible();
|
||
});
|
||
|
||
test('nav counts stay hidden until loaded and when their request fails', async ({ page, request }) => {
|
||
const totals = await serverTotals(request);
|
||
let release;
|
||
const pending = new Promise(resolve => { release = resolve; });
|
||
await page.route('**/prompt_manager/library?limit=1', async route => {
|
||
await pending;
|
||
await route.fulfill({ status: 503, json: { success: false, error: 'Unavailable' } });
|
||
});
|
||
await page.route('**/prompt_manager/vocabulary/tags?limit=1', route => route.fulfill({ json: { success: true, total: -4 } }));
|
||
await page.goto(`${workspace}#/overview`);
|
||
await expect(page.locator('#workspace-main h1')).toHaveText('Overview');
|
||
// Nothing renders for a read that is outstanding: no "0" placeholder. The settled Images count does not wait for it.
|
||
await expect(navCount(page, 'images')).toHaveText(String(totals.images));
|
||
await expect(navCount(page, 'library')).toHaveCount(0);
|
||
await expect(navCount(page, 'tags')).toHaveCount(0);
|
||
release();
|
||
await expect(navCount(page, 'images')).toHaveText(String(totals.images));
|
||
await expect(navCount(page, 'library')).toHaveCount(0);
|
||
await expect(navCount(page, 'tags')).toHaveCount(0);
|
||
await expect(page.locator('#primary-nav .nav-count')).toHaveCount(1);
|
||
});
|
||
|
||
// A3 review: the Images listing scans output folders, so its slow count must not hold back Library and Tags.
|
||
test('a slow Images count does not delay the Library and Tags badges', async ({ page, request }) => {
|
||
const totals = await serverTotals(request);
|
||
let release;
|
||
const pending = new Promise(resolve => { release = resolve; });
|
||
await page.route(url => url.pathname.endsWith('/prompt_manager/images/output') && url.searchParams.get('limit') === '1', async route => {
|
||
await pending;
|
||
await route.continue().catch(() => {});
|
||
});
|
||
await page.goto(`${workspace}#/overview`);
|
||
await expect(navCount(page, 'library')).toHaveText(String(totals.library));
|
||
await expect(navCount(page, 'tags')).toHaveText(String(totals.tags));
|
||
await expect(navCount(page, 'images')).toHaveCount(0);
|
||
release();
|
||
await expect(navCount(page, 'images')).toHaveText(String(totals.images));
|
||
});
|
||
|
||
test('sidebar bottom holds Activity, System and Overview with a neutral connection', async ({ page }) => {
|
||
await page.goto(`${workspace}#/system`);
|
||
const bottom = page.locator('aside.sidebar > .sidebar-bottom');
|
||
expect(await childShape(bottom)).toEqual(['nav#system-nav', 'div.connection']);
|
||
const system = page.locator('nav#system-nav');
|
||
await expect(system).toHaveAttribute('aria-label', 'Tools and system');
|
||
expect(await system.locator(':scope > a').evaluateAll(nodes => nodes.map(node => [node.getAttribute('href'), node.textContent]))).toEqual([
|
||
['#/activity', 'Activity'], ['#/system', 'System'], ['#/overview', 'Overview'],
|
||
]);
|
||
await expect(system.locator('.nav-count')).toHaveCount(0);
|
||
await expect(system.locator('a[href="#/system"]')).toHaveAttribute('aria-current', 'page');
|
||
await expect(system.locator('svg.icon')).toHaveCount(3);
|
||
const connection = bottom.locator('.connection');
|
||
expect(await childShape(connection)).toEqual(['i', 'div']);
|
||
await expect(connection.locator(':scope > div')).toHaveText('ComfyUI workspaceYour library, on your server');
|
||
await expect(connection.locator('small')).toHaveText('Your library, on your server');
|
||
// D28: no fake connection state. The dot is the muted text colour, not the concept's demo green.
|
||
const dot = await connection.evaluate(node => ({ dot: getComputedStyle(node.querySelector('i')).backgroundColor,
|
||
muted: getComputedStyle(node.querySelector('small')).color }));
|
||
expect(dot.dot).toBe(dot.muted);
|
||
await page.locator('nav#system-nav').getByRole('link', { name: 'Overview', exact: true }).click();
|
||
await expect(page.locator('#workspace-main h1')).toHaveText('Overview');
|
||
await expect(system.locator('a[href="#/overview"]')).toHaveAttribute('aria-current', 'page');
|
||
await expect(page.locator('aside.sidebar a[aria-current]')).toHaveCount(1);
|
||
});
|
||
|
||
test('counts refresh after a confirmed editor save', async ({ page, request }) => {
|
||
const before = await serverTotals(request);
|
||
await page.goto(`${workspace}#/library`);
|
||
await expect(navCount(page, 'library')).toHaveText(String(before.library));
|
||
await expect(navCount(page, 'tags')).toHaveText(String(before.tags));
|
||
const reads = [];
|
||
page.on('request', item => {
|
||
const url = new URL(item.url());
|
||
if (url.searchParams.get('limit') === '1') reads.push(url.pathname);
|
||
});
|
||
await page.getByRole('button', { name: '+ New prompt', exact: true }).click();
|
||
const dialog = page.locator('dialog.library-editor');
|
||
await expect(dialog.getByRole('button', { name: 'Save', exact: true })).toBeEnabled();
|
||
await dialog.getByLabel('Title', { exact: true }).fill('Harbor at dawn');
|
||
await dialog.getByLabel('Positive prompt', { exact: true }).fill('A quiet harbor at dawn for the sidebar count');
|
||
await dialog.getByLabel('Tags, separated by commas', { exact: true }).fill('sidebar_count_tag');
|
||
await dialog.getByRole('button', { name: 'Save', exact: true }).click();
|
||
await expect(dialog).toHaveCount(0);
|
||
const after = await serverTotals(request);
|
||
expect(after.library).toBe(before.library + 1);
|
||
expect(after.tags).toBeGreaterThan(before.tags);
|
||
await expect(navCount(page, 'library')).toHaveText(String(after.library));
|
||
await expect(navCount(page, 'tags')).toHaveText(String(after.tags));
|
||
expect(reads.filter(path => path === '/prompt_manager/library').length).toBeGreaterThanOrEqual(1);
|
||
// A Library write cannot change the Images count, so the Images listing is not read again.
|
||
expect(reads.filter(path => path === '/prompt_manager/images/output')).toEqual([]);
|
||
});
|
||
|
||
test('a superseded count read never lands and a failed refresh removes the stale count', async ({ page, request }) => {
|
||
const totals = await serverTotals(request);
|
||
await page.goto(`${workspace}#/overview`);
|
||
await expect(navCount(page, 'library')).toHaveText(String(totals.library));
|
||
const held = [];
|
||
let reads = 0;
|
||
await page.route('**/prompt_manager/library?limit=1', route => {
|
||
if (reads++ === 0) { held.push(route); return undefined; }
|
||
return route.fulfill({ status: 503, json: { success: false, error: 'Unavailable' } });
|
||
});
|
||
const invalidate = () => page.evaluate(async () => {
|
||
const { invalidateLibraryAfterWrite } = await import('/prompt_manager/js/workspace/library.mjs');
|
||
invalidateLibraryAfterWrite({ kind: 'test', receipt: {} });
|
||
});
|
||
await invalidate();
|
||
await expect.poll(() => held.length).toBe(1);
|
||
await invalidate();
|
||
await expect(navCount(page, 'library')).toHaveCount(0);
|
||
await expect(navCount(page, 'images')).toHaveText(String(totals.images));
|
||
await expect(navCount(page, 'tags')).toHaveText(String(totals.tags));
|
||
await held[0].fulfill({ json: { success: true, total: 999 } }).catch(() => {});
|
||
await page.waitForTimeout(100);
|
||
await expect(navCount(page, 'library')).toHaveCount(0);
|
||
await page.unroute('**/prompt_manager/library?limit=1');
|
||
// Leaving the page with a read in flight aborts it; the restored shell reads the counts again.
|
||
let release;
|
||
const pending = new Promise(resolve => { release = resolve; });
|
||
await page.route('**/prompt_manager/library?limit=1', async route => { await pending; await route.continue().catch(() => {}); }, { times: 1 });
|
||
await invalidate();
|
||
await page.evaluate(() => {
|
||
window.dispatchEvent(new PageTransitionEvent('pagehide', { persisted: true }));
|
||
window.dispatchEvent(new PageTransitionEvent('pageshow', { persisted: true }));
|
||
});
|
||
release();
|
||
await expect(navCount(page, 'library')).toHaveText(String(totals.library));
|
||
await expect(page.locator('#primary-nav a')).toHaveCount(4);
|
||
await expect(page.locator('#primary-nav .nav-count')).toHaveCount(3);
|
||
});
|
||
|
||
// Task A5: the concept heading() (app.js 303-305) with its typography (style.css 73-103, 283-300; <=700 1408-1416) on
|
||
// every native route, and the production footer copy in the concept `.app-footer` (D29).
|
||
const headingShape = node => {
|
||
const style = element => getComputedStyle(element);
|
||
const shape = element => `${element.localName}${element.id ? `#${element.id}` : ''}${[...element.classList].map(name => `.${name}`).join('')}`;
|
||
const [copy, actions] = node.children;
|
||
const [h1, description] = copy.children;
|
||
const main = node.parentElement.getBoundingClientRect();
|
||
return {
|
||
children: [...node.children].map(shape), copy: [...copy.children].map(shape), tabIndex: h1.tabIndex,
|
||
direction: style(node).flexDirection, marginBottom: style(node).marginBottom,
|
||
h1: { fontSize: style(h1).fontSize, lineHeight: Math.round(parseFloat(style(h1).lineHeight) / parseFloat(style(h1).fontSize) * 100) / 100, fontWeight: style(h1).fontWeight, letterSpacing: style(h1).letterSpacing, marginTop: style(h1).marginTop },
|
||
description: { text: description.textContent.length > 0, fontSize: style(description).fontSize, marginTop: style(description).marginTop, muted: style(description).color === style(document.querySelector('.connection small')).color },
|
||
actions: { gap: style(actions).columnGap, left: Math.round(actions.getBoundingClientRect().left), fullWidth: Math.round(actions.getBoundingClientRect().width) === Math.round(node.getBoundingClientRect().width) },
|
||
mainLeft: Math.round(main.left + parseFloat(getComputedStyle(node.parentElement).paddingLeft)),
|
||
pageTitles: document.querySelectorAll('#page-title').length,
|
||
retired: document.querySelectorAll('.workspace-heading, .workspace-heading-copy, #workspace-main .intro').length,
|
||
};
|
||
};
|
||
|
||
test('every route renders the concept heading', async ({ page, request }) => {
|
||
const library = await (await request.get('/prompt_manager/library?limit=1')).json();
|
||
const positiveId = library.items[0].id;
|
||
const pages = [['overview', 'Overview'], ['images', 'Images'], ['library', 'Prompt library'], ['tags', 'Tags & categories'], [`library/${positiveId}`, null]];
|
||
for (const width of [1600, 390]) {
|
||
await page.setViewportSize({ width, height: 900 });
|
||
for (const [hash, title] of pages) {
|
||
await page.goto(`${workspace}#/${hash}`);
|
||
const heading = page.locator('#workspace-main > .heading');
|
||
await expect(heading).toHaveCount(1);
|
||
if (title) await expect(heading.locator('h1')).toHaveText(title);
|
||
else await expect(heading.getByRole('button', { name: '← Prompt library', exact: true })).toBeVisible();
|
||
await expect(heading.locator('p.muted')).not.toHaveText('');
|
||
const shape = await heading.evaluate(headingShape);
|
||
expect(shape, hash).toMatchObject({
|
||
children: ['div', 'div.heading-actions'], copy: ['h1#page-title', 'p.muted'], tabIndex: -1, marginBottom: '22px',
|
||
h1: width === 1600 ? { fontSize: '28px', lineHeight: 1.3, fontWeight: '620', letterSpacing: '-0.7px', marginTop: '0px' }
|
||
: { fontSize: '25px', lineHeight: 1.3, fontWeight: '620', letterSpacing: '-0.7px', marginTop: '0px' },
|
||
description: { text: true, fontSize: '12px', marginTop: '6px', muted: true },
|
||
actions: { gap: '8px' }, pageTitles: 1, retired: 0,
|
||
});
|
||
if (width === 1600) {
|
||
expect(shape.direction, hash).toBe('row');
|
||
} else {
|
||
// The concept stacks the heading and gives the actions the full row, starting at main's 14px gutter.
|
||
expect(shape.direction, hash).toBe('column');
|
||
expect(shape.actions, hash).toMatchObject({ left: 14, fullWidth: true });
|
||
expect(shape.mainLeft, hash).toBe(14);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
test('the footer is the concept app footer with production copy', async ({ page }) => {
|
||
for (const [width, padding, direction] of [[1600, '22px 30px', 'row'], [390, '20px 14px', 'column']]) {
|
||
await page.setViewportSize({ width, height: 900 });
|
||
await page.goto(`${workspace}#/overview`);
|
||
const footer = page.locator('.workspace > footer.app-footer');
|
||
await expect(footer).toHaveCount(1);
|
||
await expect(page.locator('.page-footer')).toHaveCount(0);
|
||
expect(await footer.evaluate(node => ({
|
||
children: [...node.children].map(child => child.localName), text: node.textContent,
|
||
padding: getComputedStyle(node).padding, fontSize: getComputedStyle(node).fontSize, direction: getComputedStyle(node).flexDirection,
|
||
muted: getComputedStyle(node).color === getComputedStyle(document.querySelector('.connection small')).color,
|
||
afterMain: node.previousElementSibling.id,
|
||
}))).toEqual({ children: ['span'], text: 'ComfyAssets · Local tools. Your library.', padding, fontSize: '10px', direction, muted: true, afterMain: 'workspace-main' });
|
||
}
|
||
});
|
||
|
||
// #164: the maintainer serves ComfyUI behind a proxy prefix. Everything, the ComfyUI link included, stays on that mount.
|
||
const PROXY_MOUNT = '/ComfyBackendDirect';
|
||
async function serveUnderProxyMount(page) {
|
||
const escaped = [];
|
||
page.on('request', item => {
|
||
const { pathname } = new URL(item.url());
|
||
if (pathname.startsWith('/prompt_manager/')) escaped.push(pathname);
|
||
});
|
||
await page.route(url => url.pathname.startsWith(`${PROXY_MOUNT}/`), async route => {
|
||
const url = new URL(route.request().url());
|
||
url.pathname = url.pathname.slice(PROXY_MOUNT.length);
|
||
// A request still in flight when the test ends (a thumbnail the last route started) meets a page that is
|
||
// closing: its fetched response is disposed under it. Only that teardown error is ignored.
|
||
try {
|
||
const response = await route.fetch({ url: url.href });
|
||
await route.fulfill({ response });
|
||
} catch (error) {
|
||
if (!/has been disposed|has been closed|Target page, context or browser has been closed/.test(String(error?.message))) throw error;
|
||
}
|
||
});
|
||
return escaped;
|
||
}
|
||
|
||
test('the ComfyUI link points to the root of a non-standard proxy mount', async ({ page }) => {
|
||
const escaped = await serveUnderProxyMount(page);
|
||
for (const route of ['overview', 'library', 'tags']) {
|
||
await page.goto(`${PROXY_MOUNT}${workspace}#/${route}`);
|
||
await expect(page.locator('#workspace-main > .heading h1')).toBeVisible();
|
||
const link = page.getByRole('link', { name: 'ComfyUI', exact: true });
|
||
await expect(link).toHaveAttribute('href', `${PROXY_MOUNT}/`);
|
||
expect(await link.evaluate(node => node.href)).toBe(new URL(`${PROXY_MOUNT}/`, page.url()).href);
|
||
}
|
||
await expect(navCount(page, 'library')).toHaveCount(1);
|
||
expect(escaped).toEqual([]);
|
||
});
|
||
|
||
test('a resolver failure for the ComfyUI link never stops the shell from mounting', async ({ page }) => {
|
||
await serveUnderProxyMount(page);
|
||
// Wrap the shared client as it loads so only the topbar's canvas-root lookup throws (the sender reads the same root).
|
||
// Every engine's stack names the calling module's URL; each injected failure is counted so a renamed module or a
|
||
// changed call site fails this test on the count instead of silently testing nothing.
|
||
await page.addInitScript(() => {
|
||
let client;
|
||
window.__resolverFailures = { injected: 0 };
|
||
Object.defineProperty(window, 'ApiClient', { configurable: true, get: () => client, set(value) {
|
||
client = { ...value, resolveUrl: (url, ...rest) => {
|
||
if (url === '/prompt_manager/' && /\/workspace\/topbar\.mjs\b/.test(String(new Error().stack))) {
|
||
window.__resolverFailures.injected += 1;
|
||
throw new Error('resolver unavailable');
|
||
}
|
||
return value.resolveUrl(url, ...rest);
|
||
} };
|
||
} });
|
||
});
|
||
const warnings = [];
|
||
page.on('console', message => { if (message.type() === 'warning') warnings.push(message.text()); });
|
||
await page.goto(`${PROXY_MOUNT}${workspace}#/overview`);
|
||
await expect(page.locator('#workspace-main h1')).toHaveText('Overview');
|
||
await expect(sidebarLinks(page)).toHaveCount(routes.length);
|
||
expect(await page.evaluate(() => window.__resolverFailures.injected), 'the topbar lookup was the one that failed').toBe(1);
|
||
expect(warnings.filter(text => text.includes('the ComfyUI link falls back to the page mount'))).toHaveLength(1);
|
||
await expect(page.getByRole('link', { name: 'ComfyUI', exact: true })).toHaveAttribute('href', `${PROXY_MOUNT}/`);
|
||
await sidebarLink(page, 'Prompt library').click();
|
||
await expect(page.locator('#workspace-main h1')).toHaveText('Prompt library');
|
||
});
|