Revert "fix: harden automatic mobile boards"
This reverts commit d0b9348b86.
This commit is contained in:
1 parent
92a2be2b65
commit
dba9a250ff
37 files changed
+137
-637
No files matched your search
@@ -30,17 +30,6 @@ describe("board layout selection", () => {
|
||||
expect(getCurrentLayout(createBoard(), false, viewportWidth)).toBe(expectedLayoutId);
|
||||
});
|
||||
|
||||
test("legacy mode falls back to the desktop layout before the client viewport is known", () => {
|
||||
expect(getCurrentLayout(createBoard(), false, undefined)).toBe("large");
|
||||
});
|
||||
|
||||
test("rejects boards without a layout", () => {
|
||||
const board = { ...createBoard(), layouts: [] };
|
||||
|
||||
expect(() => getDesktopLayout(board)).toThrow("Board must have a layout");
|
||||
expect(() => getCurrentLayout(board, false, 390)).toThrow("Board must have a layout");
|
||||
});
|
||||
|
||||
test("keeps every saved layout available for reversible mutations", () => {
|
||||
expect(getBoardLayouts(createBoard())).toEqual(["small", "medium", "large"]);
|
||||
});
|
||||
|
||||
@@ -27,15 +27,4 @@ describe("requestBoardEditAction", () => {
|
||||
void deferredAction?.();
|
||||
expect(action).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
test("reports rejected actions instead of creating an unhandled rejection", async () => {
|
||||
const error = new Error("sign-out failed");
|
||||
const reportError = vi.fn();
|
||||
vi.stubGlobal("reportError", reportError);
|
||||
|
||||
requestBoardEditAction(() => Promise.reject(error));
|
||||
|
||||
await vi.waitFor(() => expect(reportError).toHaveBeenCalledWith(error));
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
});
|
||||
@@ -12,27 +12,9 @@ export type BoardEditActionResult = boolean | void;
|
||||
export type BoardEditAction = () => BoardEditActionResult | Promise<BoardEditActionResult>;
|
||||
export type BoardEditActionEvent = CustomEvent<{ action: BoardEditAction }>;
|
||||
|
||||
const reportBoardEditActionError = (error: unknown) => {
|
||||
const reportError = (globalThis as { reportError?: (reportedError: unknown) => void }).reportError;
|
||||
if (reportError) {
|
||||
reportError(error);
|
||||
return;
|
||||
}
|
||||
|
||||
console.error("Board edit action failed", error);
|
||||
};
|
||||
|
||||
const runBoardEditAction = (action: BoardEditAction) => {
|
||||
try {
|
||||
void Promise.resolve(action()).catch(reportBoardEditActionError);
|
||||
} catch (error) {
|
||||
reportBoardEditActionError(error);
|
||||
}
|
||||
};
|
||||
|
||||
export const requestBoardEditAction = (action: BoardEditAction) => {
|
||||
if (typeof document === "undefined") {
|
||||
runBoardEditAction(action);
|
||||
void action();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,7 +24,7 @@ export const requestBoardEditAction = (action: BoardEditAction) => {
|
||||
});
|
||||
|
||||
if (document.dispatchEvent(event)) {
|
||||
runBoardEditAction(action);
|
||||
void action();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user