Skip to content

The timetable dialog says when a chosen file cannot be read - #662

Merged
MerciHanrim merged 1 commit into
mainfrom
timetable-file-read-failed
Nov 24, 2026
Merged

MerciHanrim merged 1 commit into
mainfrom
timetable-file-read-failed

Conversation

@MerciHanrim

Copy link
Copy Markdown
Owner

Part of #615 (item 5, part B: the timetable dialog's file read; part A was #661. With this PR merged, #615's item 5 is complete).

What was wrong

In Data ▸ New timetable…, a CSV chosen with the file input is read with await file.text(), with no catch (TimetableImportDialog.tsx, pickFile). Measured on main 64c1fea1 (scratch reproduction), with this page's file read made to fail:

  • the text box stays empty;
  • the dialog shows no message;
  • the page has an unhandled promise rejection ("The file could not be read.").

The dialog stays usable: pasting the contents by hand works. The data import wizard already handles the same case with a message (#423).

The change (src/components/dataImport/TimetableImportDialog.tsx)

  • A failed read is caught. The dialog shows the data import wizard's own message, import.fileReadFailed: "The file could not be read. Try choosing it again, or paste its contents instead." It is shown as an alert under the file field.
  • The message clears with the next text, typed or read, as in the wizard.
  • There is no new catalog key; the message exists in every language.

Tests (e2e/timetable-file-read.spec.ts, new, written first)

Test On main's code With the change
A failed read (this page's File.prototype.text rejects): the dialog's alert reads the message; no page error; the text box is empty; pasting the contents by hand gives "Rows read: 2" and clears the message, still with no page error fails (no alert; the page error fails the test) passes
Control: a file that reads fills the text box, "Rows read: 2", no message passes passes

Checks

  • npx tsc -b: clean.
  • npm run lint: 88 warnings, the baseline.
  • All check:* scripts: pass.
  • Unit suite: 5758 passed, 4 skipped.
  • Related e2e, one worker, no retries: e2e/timetable-file-read.spec.ts, e2e/timetable-available.spec.ts and e2e/timetable-screens.spec.ts, 13 passed. None holds a screenshot comparison.

What it touches

  • Only the timetable dialog's file read.
  • What a read file or a pasted text makes is unchanged.

A rejected file.text() is caught and shown with the data import wizard's own message (import.fileReadFailed), cleared by the next text typed or read; no unhandled rejection is left on the page. Part of #615.
@MerciHanrim MerciHanrim added the bug Something isn't working label Nov 24, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying cozy-loop-studio with  Cloudflare Pages  Cloudflare Pages

Latest commit: cf0840b
Status: ✅  Deploy successful!
Preview URL: https://3a3ff726.cozy-loop-studio.pages.dev
Branch Preview URL: https://timetable-file-read-failed.cozy-loop-studio.pages.dev

View logs

@MerciHanrim
MerciHanrim merged commit 3864ce9 into main Nov 24, 2026
13 checks passed
@MerciHanrim
MerciHanrim deleted the timetable-file-read-failed branch November 24, 2026 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant