Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Wait for the sandbox pick to land instead of a fixed 5ms tick (#15120)

Daniel Hanf31feed3d53c
diff --git a/studio/frontend/tests/account-permissions.test.ts b/studio/frontend/tests/account-permissions.test.ts
index 03cfddd341e..b55523f701a 100644
--- a/studio/frontend/tests/account-permissions.test.ts
+++ b/studio/frontend/tests/account-permissions.test.ts
@@ -201,6 +201,15 @@ test("the stored values keep their order and their names", () => {
const NO_OS_SANDBOX = { pythonOsIsolated: false, terminalOsIsolated: false, backend: "bubblewrap" };
const OS_SANDBOX = { pythonOsIsolated: true, terminalOsIsolated: true, backend: "bubblewrap" };
const tick = () => new Promise((resolve) => setTimeout(resolve, 5));
+// The pick resolves the capability, then defers the popup with setTimeout(0): on a busy runner
+// that lands after a fixed 5ms tick. Wait for the effect itself, bounded, instead of a guess.
+const until = async (done: () => boolean, ms = 2000) => {
+ const deadline = Date.now() + ms;
+ while (!done()) {
+ if (Date.now() > deadline) assert.fail("timed out waiting for the pick to take effect");
+ await tick();
+ }
+};
for (const [name, capability] of [
["no OS sandbox", NO_OS_SANDBOX],
@@ -280,7 +289,7 @@ test("under Full access, Disabled is ticked and picking it or a locked level cha
test("picking High without an OS sandbox opens the install popup and keeps Low", async () => {
const ui = permissionUi(true, "auto", "single", NO_OS_SANDBOX, "low");
(sandboxPicker(ui).level("high").props.onSelect as () => void)();
- await tick();
+ await until(() => ui.popups.length > 0);
assert.deepEqual(ui.popups, [true]);
assert.deepEqual(ui.levels, []);
@@ -289,20 +298,20 @@ test("picking High without an OS sandbox opens the install popup and keeps Low",
local.push("popup"),
);
(own.level("high").props.onSelect as () => void)();
- await tick();
+ await until(() => local.length > 0);
assert.deepEqual(local, ["popup"]);
});
test("picking High with a working OS sandbox applies it; picking Low applies at once", async () => {
const ui = permissionUi(true, "auto", "single", OS_SANDBOX, "low");
(sandboxPicker(ui).level("high").props.onSelect as () => void)();
- await tick();
+ await until(() => ui.levels.length > 0);
assert.deepEqual(ui.levels, ["high"]);
assert.deepEqual(ui.popups, []);
const high = permissionUi(true, "auto", "single", OS_SANDBOX, "high");
(sandboxPicker(high).level("low").props.onSelect as () => void)();
- await tick();
+ await until(() => high.levels.length > 0);
assert.deepEqual(high.levels, ["low"]);
});
@@ -318,6 +327,6 @@ test("Learn more beside the picker heading opens Settings > Sandbox at Permissio
const ui = permissionUi(true, "auto", "single", OS_SANDBOX);
const { learnMore } = sandboxPicker(ui);
(learnMore.props.onSelect as () => void)();
- await tick();
+ await until(() => ui.opened.length > 0);
assert.deepEqual(ui.opened, [["sandbox", "sandbox-permissions"]]);
});