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
12 changes: 8 additions & 4 deletions app/queries/mailboxes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ export function useUpdateMailbox() {
return useMutation({
mutationFn: ({ mailboxId, settings }: { mailboxId: string; settings: unknown }) =>
api.updateMailbox(mailboxId, settings),
onSuccess: (_data, { mailboxId }) => {
qc.invalidateQueries({ queryKey: queryKeys.mailboxes.detail(mailboxId) });
qc.invalidateQueries({ queryKey: queryKeys.mailboxes.all });
},
// The save is over when the app holds what was saved: the two lists are read again before
// the caller is told. Told earlier, a person who saved a signature and wrote at once got a
// message without it.
onSuccess: (_data, { mailboxId }) =>
Promise.all([
qc.invalidateQueries({ queryKey: queryKeys.mailboxes.detail(mailboxId) }),
qc.invalidateQueries({ queryKey: queryKeys.mailboxes.all }),
]),
});
}

Expand Down
14 changes: 14 additions & 0 deletions test/e2e/mailbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,9 +656,23 @@ test("settings are in tabs; a person's choices take effect at once and stay, a m
await page.getByLabel("Add a signature to new messages").check();
await page.locator(".ProseMirror").click();
await page.keyboard.type("Kind regards from the pod bay");
// The app reads the mailbox again after a save. That answer is held back here, so that
// "saved" said before it arrived would open a window without the signature.
const held: Promise<void>[] = [];
const mailboxRead = (url: URL) => /^\/api\/v1\/mailboxes(\/[^/]+)?$/.test(url.pathname);
await page.route(mailboxRead, (route) => {
if (route.request().method() !== "GET") return route.continue();
const answered = new Promise((resolve) => setTimeout(resolve, 1000)).then(() =>
route.continue(),
);
held.push(answered);
return answered;
});
await page.getByRole("button", { name: "Save signature" }).click();
await expect(page.getByText("Signature saved")).toBeVisible();
await page.getByRole("button", { name: "Compose" }).click();
await Promise.all(held);
await page.unroute(mailboxRead);
const compose = page.getByRole("region", { name: "Compose" });
await expect(compose.locator(".ProseMirror")).toContainText("Kind regards from the pod bay");
await compose.getByRole("button", { name: "Discard" }).click();
Expand Down
Loading