Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): removing a saved environment from the trash button never silently no-ops #18228

Closedfixfon(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/18228/headopened View on GitHub

Showing 3 changed files with 146 additions and 35 deletions.

x
0 of 3 viewed, 3 left
75 additions and 0 deletionsapps/mobile/src/state/remove-environment-confirm.test.tsAdded
View file
@@ -0,0 +1,75 @@
+import type { AtomCommandResult } from "@t3tools/client-runtime/state/runtime";
+import type { EnvironmentId } from "@t3tools/contracts";
+import * as Cause from "effect/Cause";
+import { AsyncResult } from "effect/reactivity";
+import { describe, expect, it, vi } from "vite-plus/test";
+​
+import { presentRemoveEnvironmentConfirm } from "./remove-environment-confirm";
+​
+const environmentId = "environment-1" as EnvironmentId;
+​
+function setup(options: {
+ readonly environment?: { environmentLabel: string; isRelayManaged: boolean };
+ readonly result?: AtomCommandResult<unknown, unknown>;
+}) {
+ const alert = vi.fn();
+ const remove = vi.fn(async () => options.result ?? AsyncResult.success(undefined));
+ presentRemoveEnvironmentConfirm({
+ environmentId,
+ environment: options.environment,
+ remove,
+ openAccount: vi.fn(),
+ alert,
+ });
+ const [title, message, buttons] = alert.mock.calls[0]!;
+ const confirm = buttons.find((button: { text: string }) => button.text === "Remove");
+ return { alert, remove, title, message, confirm };
+}
+​
+// The failure alert is chained on the promise `remove` returned, so awaiting
+// that same promise lets it run first.