Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions frontend/test/unit/connection-console-switch-known-status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,32 @@ import type { OpenCompanyClient } from "@/api/client";
import type { AppSpec, CompanyStatus } from "@/api/types";
import { HostsProvider } from "@/connections/HostsContext";

/**
* These exercise the create/reset flow itself, so they need the build where the
* product offers it.
*
* `canCreateCompanies` is `!COMPANY_SWITCHING_HIDDEN && carriesPlatformBearer`
* (b8a3e2e97), and `COMPANY_SWITCHING_HIDDEN` ships `true` — so in the shipped
* tree every trigger below is hidden and the dialog's own preflight never runs.
* Left unmocked, these files would assert against controls the product
* deliberately does not render, which is what broke them: they would be pinning
* the flag rather than the flow.
*
* The *hide* is not weakened by this. It has its own coverage, deliberately
* unmocked, in `product-scope-hidden-surfaces.test.ts` ("company creation is
* gone from every trigger, not just the switcher"), which is where a regression
* in the gate belongs. What is left here is the flow underneath it — including
* the #1894 pre-archive guard, whose whole job is to keep a reset from
* archiving a company before it knows the replacement has a usable admin. That
* logic is still in the tree and still worth failing a build over the day the
* flag flips back.
*/
vi.mock("@/product-scope", async (importOriginal) => ({
...(await importOriginal<typeof import("@/product-scope")>()),
COMPANY_SWITCHING_HIDDEN: false,
}));


/**
* Codex review on #1828 (PR comment 3864628314): `switchCompany`'s only
* caller that already holds fresh data for the company it is entering —
Expand Down
26 changes: 26 additions & 0 deletions frontend/test/unit/create-company-dialog-preflight-race.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,32 @@ import type { OpenCompanyClient } from "@/api/client";
import type { CompanyStatus, ProvisioningInfo } from "@/api/types";
import { CreateCompanyDialog } from "@/components/create-company-dialog";

/**
* These exercise the create/reset flow itself, so they need the build where the
* product offers it.
*
* `canCreateCompanies` is `!COMPANY_SWITCHING_HIDDEN && carriesPlatformBearer`
* (b8a3e2e97), and `COMPANY_SWITCHING_HIDDEN` ships `true` — so in the shipped
* tree every trigger below is hidden and the dialog's own preflight never runs.
* Left unmocked, these files would assert against controls the product
* deliberately does not render, which is what broke them: they would be pinning
* the flag rather than the flow.
*
* The *hide* is not weakened by this. It has its own coverage, deliberately
* unmocked, in `product-scope-hidden-surfaces.test.ts` ("company creation is
* gone from every trigger, not just the switcher"), which is where a regression
* in the gate belongs. What is left here is the flow underneath it — including
* the #1894 pre-archive guard, whose whole job is to keep a reset from
* archiving a company before it knows the replacement has a usable admin. That
* logic is still in the tree and still worth failing a build over the day the
* flag flips back.
*/
vi.mock("@/product-scope", async (importOriginal) => ({
...(await importOriginal<typeof import("@/product-scope")>()),
COMPANY_SWITCHING_HIDDEN: false,
}));


/**
* Codex review on #1943 (PR comment 3894416362): on a wallet-mode host with a
* slow or pending provisioning preflight, the dialog used to open with its
Expand Down
26 changes: 26 additions & 0 deletions frontend/test/unit/create-company-wallet-mode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,32 @@ import {
type CreateCompanyRequest,
} from "@/components/create-company-dialog";

/**
* These exercise the create/reset flow itself, so they need the build where the
* product offers it.
*
* `canCreateCompanies` is `!COMPANY_SWITCHING_HIDDEN && carriesPlatformBearer`
* (b8a3e2e97), and `COMPANY_SWITCHING_HIDDEN` ships `true` — so in the shipped
* tree every trigger below is hidden and the dialog's own preflight never runs.
* Left unmocked, these files would assert against controls the product
* deliberately does not render, which is what broke them: they would be pinning
* the flag rather than the flow.
*
* The *hide* is not weakened by this. It has its own coverage, deliberately
* unmocked, in `product-scope-hidden-surfaces.test.ts` ("company creation is
* gone from every trigger, not just the switcher"), which is where a regression
* in the gate belongs. What is left here is the flow underneath it — including
* the #1894 pre-archive guard, whose whole job is to keep a reset from
* archiving a company before it knows the replacement has a usable admin. That
* logic is still in the tree and still worth failing a build over the day the
* flag flips back.
*/
vi.mock("@/product-scope", async (importOriginal) => ({
...(await importOriginal<typeof import("@/product-scope")>()),
COMPANY_SWITCHING_HIDDEN: false,
}));


/**
* The wallet-mode create/reset flow (issues #1914, #1894).
*
Expand Down
26 changes: 26 additions & 0 deletions frontend/test/unit/settings-lifecycle-reset-button.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,32 @@ import type { OpenCompanyClient } from "@/api/client";
import type { CompanyStatus } from "@/api/types";
import { LifecycleControls } from "@/views/SettingsView";

/**
* These exercise the create/reset flow itself, so they need the build where the
* product offers it.
*
* `canCreateCompanies` is `!COMPANY_SWITCHING_HIDDEN && carriesPlatformBearer`
* (b8a3e2e97), and `COMPANY_SWITCHING_HIDDEN` ships `true` — so in the shipped
* tree every trigger below is hidden and the dialog's own preflight never runs.
* Left unmocked, these files would assert against controls the product
* deliberately does not render, which is what broke them: they would be pinning
* the flag rather than the flow.
*
* The *hide* is not weakened by this. It has its own coverage, deliberately
* unmocked, in `product-scope-hidden-surfaces.test.ts` ("company creation is
* gone from every trigger, not just the switcher"), which is where a regression
* in the gate belongs. What is left here is the flow underneath it — including
* the #1894 pre-archive guard, whose whole job is to keep a reset from
* archiving a company before it knows the replacement has a usable admin. That
* logic is still in the tree and still worth failing a build over the day the
* flag flips back.
*/
vi.mock("@/product-scope", async (importOriginal) => ({
...(await importOriginal<typeof import("@/product-scope")>()),
COMPANY_SWITCHING_HIDDEN: false,
}));
Comment on lines +32 to +35

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep an unmocked test for the reset-button gate

With this file-level mock, every LifecycleControls render runs with company switching enabled. The supposedly unmocked coverage in product-scope-hidden-surfaces.test.ts only asserts the return value of canCreateCompanies; it never mounts this surface. Consequently, if SettingsView later regresses to checking client.carriesPlatformBearer directly, both suites still pass while the destructive Reset control reappears in the shipped single-company build. Keep the flow tests mocked, but add an unmocked render assertion that the reset button is absent.

AGENTS.md reference: AGENTS.md:L93-L97

Useful? React with 👍 / 👎.



/**
* The Reset / Start clean button (#1807, SettingsView.tsx `LifecycleControls`)
* had no render test of its own — tinysweeper flagged the gap (PR comment
Expand Down
Loading