дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 01:31:41 +02:00
Opening an untrusted project in a new window created the window first and asked inside it, where the splash gave way after its 4 s limit to the Welcome screen under the question. Entry points that may create a window (Open…, Open in New Window, recent projects, dropped folders, clone, plugin requests) now ask in the current window first and create the window only after Trust or Preview; Don't Open creates none. A launch without an originating window (openidea <path>, Dock drop) keeps the splash up under the dialog until the answer. WSL folders are still asked about by their remote window. Closes #3648 Co-authored-by: wildcatDownstairs <[email protected]>
40 рядки
1.4 KiB
TypeScript
40 рядки
1.4 KiB
TypeScript
import { afterEach, beforeEach, expect, it, vi } from "vitest";
|
|
|
|
beforeEach(() => {
|
|
vi.useFakeTimers({ toFake: ["setTimeout", "requestAnimationFrame"] });
|
|
vi.resetModules();
|
|
document.body.innerHTML = '<div id="splash" class="splash"></div>';
|
|
});
|
|
afterEach(() => vi.useRealTimers());
|
|
|
|
const splash = () => document.getElementById("splash");
|
|
|
|
it("gives up on a slow launch after its time limit", async () => {
|
|
const { holdSplash, hideSplash } = await import("./splash");
|
|
holdSplash(new Promise(() => {}));
|
|
hideSplash();
|
|
await vi.advanceTimersByTimeAsync(5000);
|
|
expect(splash()).toBeNull();
|
|
});
|
|
|
|
it("stays up, under dialogs, until a question asked while the window opens is answered", async () => {
|
|
const { askOverSplash, holdSplash, hideSplash } = await import("./splash");
|
|
let answer!: (open: boolean) => void;
|
|
const question = new Promise<boolean>((resolve) => (answer = resolve));
|
|
holdSplash(question);
|
|
hideSplash();
|
|
askOverSplash(question);
|
|
expect(splash()?.classList.contains("splash-under-dialogs")).toBe(true);
|
|
await vi.advanceTimersByTimeAsync(60_000);
|
|
expect(splash()).not.toBeNull();
|
|
answer(false);
|
|
await vi.advanceTimersByTimeAsync(1000);
|
|
expect(splash()).toBeNull();
|
|
});
|
|
|
|
it("leaves a page without a splash alone", async () => {
|
|
document.body.innerHTML = "";
|
|
const { askOverSplash } = await import("./splash");
|
|
expect(() => askOverSplash(Promise.resolve(true))).not.toThrow();
|
|
});
|