Reload even when there is an unsent draft
Holding the reload back while a compose window had unsaved text protected the text, but it meant a tab could sit on a build the server no longer runs for as long as someone left a draft open -- which is not automatic, and automatic is the point. So the reload is unconditional once the versions differ, and this will sometimes take an unsent draft with it. The trade is deliberate: a tab talking to a server it does not match is the worse failure, and it fails quietly.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
import { reloadIfServerRebuilt, holdReloadWhile, makeConnectionWatcher, startBuildWatch } from "@/lib/staleBuild";
|
||||
import { reloadIfServerRebuilt, makeConnectionWatcher, startBuildWatch } from "@/lib/staleBuild";
|
||||
import { APP_VERSION } from "@/lib/version";
|
||||
|
||||
function healthReplies(body: unknown, ok = true) {
|
||||
@@ -66,27 +66,6 @@ describe("reloadIfServerRebuilt", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("unsaved work holds the page", () => {
|
||||
it("does not reload while something says it has unsaved work", async () => {
|
||||
const release = holdReloadWhile(() => true);
|
||||
vi.stubGlobal("fetch", healthReplies({ ok: true, version: "9.9.9" }));
|
||||
expect(await reloadIfServerRebuilt()).toBe(false);
|
||||
expect(reload).not.toHaveBeenCalled();
|
||||
release();
|
||||
expect(await reloadIfServerRebuilt()).toBe(true);
|
||||
expect(reload).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("treats a predicate that throws as a reason to wait", async () => {
|
||||
const release = holdReloadWhile(() => {
|
||||
throw new Error("broken");
|
||||
});
|
||||
vi.stubGlobal("fetch", healthReplies({ ok: true, version: "9.9.9" }));
|
||||
expect(await reloadIfServerRebuilt()).toBe(false);
|
||||
release();
|
||||
});
|
||||
});
|
||||
|
||||
describe("noticing without being asked", () => {
|
||||
it("checks when the push stream drops, but not before it has connected", async () => {
|
||||
const fetchMock = healthReplies({ ok: true, version: APP_VERSION });
|
||||
|
||||
Reference in New Issue
Block a user