

























@@ -50,6 +50,40 @@ beforeAll(async () => {
5050({ listSandboxBrowsers, removeSandboxBrowserContainer } = await import("./manage.js"));
5151});
525253+function firstDescribeRuntimeInput(): { agentId?: string; entry?: { configLabelKind?: string } } {
54+const input = backendMocks.describeRuntime.mock.calls[0]?.[0] as
55+| { agentId?: string; entry?: { configLabelKind?: string } }
56+| undefined;
57+if (!input) {
58+throw new Error("expected describe runtime input");
59+}
60+return input;
61+}
62+63+function firstRemoveRuntimeInput(): {
64+entry?: {
65+containerName?: string;
66+configLabelKind?: string;
67+runtimeLabel?: string;
68+backendId?: string;
69+};
70+} {
71+const input = backendMocks.removeRuntime.mock.calls[0]?.[0] as
72+| {
73+entry?: {
74+containerName?: string;
75+configLabelKind?: string;
76+runtimeLabel?: string;
77+backendId?: string;
78+};
79+}
80+| undefined;
81+if (!input) {
82+throw new Error("expected remove runtime input");
83+}
84+return input;
85+}
86+5387describe("listSandboxBrowsers", () => {
5488beforeEach(async () => {
5589configMocks.getRuntimeConfig.mockReset();
@@ -101,9 +135,7 @@ describe("listSandboxBrowsers", () => {
101135it("compares browser runtimes against sandbox.browser.image", async () => {
102136const results = await listSandboxBrowsers();
103137104-const describeInput = backendMocks.describeRuntime.mock.calls.at(0)?.[0] as
105-| { agentId?: string; entry?: { configLabelKind?: string } }
106-| undefined;
138+const describeInput = firstDescribeRuntimeInput();
107139expect(describeInput?.agentId).toBe("coder");
108140expect(describeInput?.entry?.configLabelKind).toBe("BrowserImage");
109141expect(results).toHaveLength(1);
@@ -115,16 +147,7 @@ describe("listSandboxBrowsers", () => {
115147it("removes browser runtimes with BrowserImage config label kind", async () => {
116148await removeSandboxBrowserContainer("browser-1");
117149118-const removeInput = backendMocks.removeRuntime.mock.calls.at(0)?.[0] as
119-| {
120-entry?: {
121-containerName?: string;
122-configLabelKind?: string;
123-runtimeLabel?: string;
124-backendId?: string;
125-};
126-}
127-| undefined;
150+const removeInput = firstRemoveRuntimeInput();
128151expect(removeInput?.entry?.containerName).toBe("browser-1");
129152expect(removeInput?.entry?.configLabelKind).toBe("BrowserImage");
130153expect(removeInput?.entry?.runtimeLabel).toBe("browser-1");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。