Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions apps/web/src/pages/library-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,11 @@ export function LibraryPage({
}
subtitle={
selectedSummary === null
? `${artifacts.length} files`
? // Empty Files already has a poster invitation — a "0 files"
// count beside it is a second empty announcement (CL-6750).
artifacts.length === 0
? undefined
: `${artifacts.length} files`
: artifactKindLabel(selectedSummary.kind)
}
filter={{
Expand Down Expand Up @@ -543,7 +547,8 @@ export function LibraryPage({
type="file"
multiple
className="sr-only"
aria-label="Upload files"
tabIndex={-1}
aria-hidden="true"
onChange={(event) => {
const list = event.target.files;
if (list !== null && list.length > 0) {
Expand Down
4 changes: 3 additions & 1 deletion apps/web/test/library-upload-confirmation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ function jsonResponse(body: unknown, status = 200): Response {
}

function uploadFile(container: HTMLDivElement, file: File): void {
// The picker is unlabeled on purpose (CL-6750) — the visible Upload
// button is the only named control; this helper drives the ghost input.
const input = container.querySelector(
'input[aria-label="Upload files"]',
'input[type="file"]',
) as HTMLInputElement | null;
if (input === null) throw new Error("no upload input");
Object.defineProperty(input, "files", {
Expand Down
27 changes: 25 additions & 2 deletions apps/web/test/pages.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ describe("empty states", () => {
"Upload a file, or let your agents drop their work here",
);
});

// CL-6750 — empty Files must tell one story: invite to add files. A
// "0 files" count beside the poster reads as a second empty announcement,
// and a labeled ghost file input twins the visible Upload button.
test("empty library is one invitation, not count + poster + twin uploads", () => {
const markup = renderToStaticMarkup(
<LibraryPage artifacts={[]} onUpload={() => undefined} />,
);
expect(markup).toContain("No files yet");
expect(markup).not.toContain("0 files");
// One visible Upload in the top bar.
expect(markup).toMatch(/stage-top-bar-actions[\s\S]*?>Upload</);
// Hidden picker exists for the button, but is not a second labeled control.
expect(markup).toContain('type="file"');
expect(markup).toContain("sr-only");
expect(markup).not.toContain('aria-label="Upload files"');
expect(markup).toMatch(/type="file"[^>]*aria-hidden/);
expect(markup).toMatch(/type="file"[^>]*tabindex="-1"/);
});
});

describe("live data", () => {
Expand Down Expand Up @@ -55,14 +74,18 @@ describe("live data", () => {
<LibraryPage artifacts={[reportArtifact]} onUpload={() => undefined} />,
);
// Hidden file input behind the top-bar Upload action and
// workbench:library:upload.
// workbench:library:upload — unlabeled so it is not a twin control.
expect(markup).toContain('type="file"');
expect(markup).toContain('aria-label="Upload files"');
expect(markup).toContain("sr-only");
expect(markup).not.toContain('aria-label="Upload files"');
expect(markup).toMatch(/type="file"[^>]*aria-hidden/);
expect(markup).toMatch(/type="file"[^>]*tabindex="-1"/);
// Upload is a top-bar action (mock: primary chip in `.top`).
expect(markup).toMatch(/stage-top-bar-actions[\s\S]*?>Upload</);
// Sort is icon-only with an accessible name.
expect(markup).toContain('aria-label="Newest first"');
// With files present, the count subtitle is the honest inventory.
expect(markup).toContain("1 files");
});
});

Expand Down
Loading