From f1fd4f7f78d4fd3ffb508a8ec50ef2fb833ee75f Mon Sep 17 00:00:00 2001 From: Jake Howell Date: Tue, 1 Dec 2026 12:05:59 +1100 Subject: [PATCH] test(site): replace toThrowError with toThrow (#32833) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > 🤖 This PR was written by Codex on behalf of Jake Howell. Replace the 22 remaining `toThrowError` calls in `site/` tests with `toThrow`. Vitest registers both names for the same matcher, so the existing error expectations and negations carry over. https://vitest.dev/api/expect.html#tothrow Depends on #32832 --- site/scripts/audit-docs-paths.test.mjs | 10 +++--- .../components/providerFormApiMap.test.ts | 2 +- .../TemplateSettingsPage.test.tsx | 2 +- .../TemplateSchedulePage.test.tsx | 34 ++++++++----------- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/site/scripts/audit-docs-paths.test.mjs b/site/scripts/audit-docs-paths.test.mjs index dd6c307649e..d48c0d84462 100644 --- a/site/scripts/audit-docs-paths.test.mjs +++ b/site/scripts/audit-docs-paths.test.mjs @@ -39,17 +39,17 @@ describe("docsRedirects", () => { }); it("throws a TypeError when given a non-array (e.g. object)", () => { - expect(() => docsRedirects({})).toThrowError(TypeError); - expect(() => docsRedirects({})).toThrowError(/got object/); + expect(() => docsRedirects({})).toThrow(TypeError); + expect(() => docsRedirects({})).toThrow(/got object/); }); it("throws a TypeError when given a non-array (e.g. string)", () => { - expect(() => docsRedirects("hello")).toThrowError(TypeError); - expect(() => docsRedirects("hello")).toThrowError(/got string/); + expect(() => docsRedirects("hello")).toThrow(TypeError); + expect(() => docsRedirects("hello")).toThrow(/got string/); }); it("throws a TypeError when given null", () => { - expect(() => docsRedirects(null)).toThrowError(TypeError); + expect(() => docsRedirects(null)).toThrow(TypeError); }); }); diff --git a/site/src/pages/AISettingsPage/ProvidersPage/components/providerFormApiMap.test.ts b/site/src/pages/AISettingsPage/ProvidersPage/components/providerFormApiMap.test.ts index d50eb6991f2..4eff08b7589 100644 --- a/site/src/pages/AISettingsPage/ProvidersPage/components/providerFormApiMap.test.ts +++ b/site/src/pages/AISettingsPage/ProvidersPage/components/providerFormApiMap.test.ts @@ -476,7 +476,7 @@ describe("providerFormValuesToCreate", () => { // to refuse to send a malformed payload if a caller bypasses it. expect(() => providerFormValuesToCreate({ ...baseOpenAIFormValues, type: "" }), - ).toThrowError(/provider type is required/); + ).toThrow(/provider type is required/); }); }); diff --git a/site/src/pages/TemplateSettingsPage/TemplateGeneralSettingsPage/TemplateSettingsPage.test.tsx b/site/src/pages/TemplateSettingsPage/TemplateGeneralSettingsPage/TemplateSettingsPage.test.tsx index 8b74edec34b..d201fb9b017 100644 --- a/site/src/pages/TemplateSettingsPage/TemplateGeneralSettingsPage/TemplateSettingsPage.test.tsx +++ b/site/src/pages/TemplateSettingsPage/TemplateGeneralSettingsPage/TemplateSettingsPage.test.tsx @@ -58,7 +58,7 @@ describe("TemplateSettingsPage", () => { "The quick brown fox jumps over the lazy dog repeatedly, enjoying the weather of the bright, summer day in the lush, scenic park.", }; const validate = () => validationSchema.validateSync(values); - expect(validate).not.toThrowError(); + expect(validate).not.toThrow(); }); it("disallows a description of 128 + 1 chars", () => { diff --git a/site/src/pages/TemplateSettingsPage/TemplateSchedulePage/TemplateSchedulePage.test.tsx b/site/src/pages/TemplateSettingsPage/TemplateSchedulePage/TemplateSchedulePage.test.tsx index b41f0f8b3d3..1979072421d 100644 --- a/site/src/pages/TemplateSettingsPage/TemplateSchedulePage/TemplateSchedulePage.test.tsx +++ b/site/src/pages/TemplateSettingsPage/TemplateSchedulePage/TemplateSchedulePage.test.tsx @@ -300,7 +300,7 @@ describe("TemplateSchedulePage", () => { default_ttl_ms: 24 * 7, }; const validate = () => getValidationSchema().validateSync(values); - expect(validate).not.toThrowError(); + expect(validate).not.toThrow(); }); it("allows default ttl of 0", () => { @@ -309,7 +309,7 @@ describe("TemplateSchedulePage", () => { default_ttl_ms: 0, }; const validate = () => getValidationSchema().validateSync(values); - expect(validate).not.toThrowError(); + expect(validate).not.toThrow(); }); it("allows a default ttl of 30 days", () => { @@ -318,7 +318,7 @@ describe("TemplateSchedulePage", () => { default_ttl_ms: 24 * 30, }; const validate = () => getValidationSchema().validateSync(values); - expect(validate).not.toThrowError(); + expect(validate).not.toThrow(); }); it("disallows a default ttl of 30 days + 1 hour", () => { @@ -327,7 +327,7 @@ describe("TemplateSchedulePage", () => { default_ttl_ms: 24 * 30 + 1, }; const validate = () => getValidationSchema().validateSync(values); - expect(validate).toThrowError( + expect(validate).toThrow( "Please enter a limit that is less than or equal to 720 hours (30 days).", ); }); @@ -338,7 +338,7 @@ describe("TemplateSchedulePage", () => { failure_ttl_ms: 86400000 * 7, }; const validate = () => getValidationSchema().validateSync(values); - expect(validate).not.toThrowError(); + expect(validate).not.toThrow(); }); it("allows failure ttl of 0", () => { @@ -347,7 +347,7 @@ describe("TemplateSchedulePage", () => { failure_ttl_ms: 0, }; const validate = () => getValidationSchema().validateSync(values); - expect(validate).not.toThrowError(); + expect(validate).not.toThrow(); }); it("disallows a negative failure ttl", () => { @@ -356,9 +356,7 @@ describe("TemplateSchedulePage", () => { failure_ttl_ms: -1, }; const validate = () => getValidationSchema().validateSync(values); - expect(validate).toThrowError( - "Failure cleanup days must not be less than 0.", - ); + expect(validate).toThrow("Failure cleanup days must not be less than 0."); }); it("allows an inactivity ttl of 7 days", () => { @@ -367,7 +365,7 @@ describe("TemplateSchedulePage", () => { time_til_dormant_ms: 86400000 * 7, }; const validate = () => getValidationSchema().validateSync(values); - expect(validate).not.toThrowError(); + expect(validate).not.toThrow(); }); it("allows an inactivity ttl of 0", () => { @@ -376,7 +374,7 @@ describe("TemplateSchedulePage", () => { time_til_dormant_ms: 0, }; const validate = () => getValidationSchema().validateSync(values); - expect(validate).not.toThrowError(); + expect(validate).not.toThrow(); }); it("disallows a negative inactivity ttl", () => { @@ -385,9 +383,7 @@ describe("TemplateSchedulePage", () => { time_til_dormant_ms: -1, }; const validate = () => getValidationSchema().validateSync(values); - expect(validate).toThrowError( - "Dormancy threshold must not be less than 0.", - ); + expect(validate).toThrow("Dormancy threshold must not be less than 0."); }); it("allows a dormancy ttl of 7 days", () => { @@ -396,7 +392,7 @@ describe("TemplateSchedulePage", () => { time_til_dormant_autodelete_ms: 86400000 * 7, }; const validate = () => getValidationSchema().validateSync(values); - expect(validate).not.toThrowError(); + expect(validate).not.toThrow(); }); it("allows a dormancy ttl of 0", () => { @@ -405,7 +401,7 @@ describe("TemplateSchedulePage", () => { time_til_dormant_autodelete_ms: 0, }; const validate = () => getValidationSchema().validateSync(values); - expect(validate).not.toThrowError(); + expect(validate).not.toThrow(); }); it("disallows a negative inactivity ttl", () => { @@ -414,7 +410,7 @@ describe("TemplateSchedulePage", () => { time_til_dormant_autodelete_ms: -1, }; const validate = () => getValidationSchema().validateSync(values); - expect(validate).toThrowError( + expect(validate).toThrow( "Dormancy auto-deletion days must not be less than 0.", ); }); @@ -426,7 +422,7 @@ describe("TemplateSchedulePage", () => { autostop_requirement_weeks: 1, }; const validate = () => getValidationSchema().validateSync(values); - expect(validate).not.toThrowError(); + expect(validate).not.toThrow(); }); it("allows a autostop requirement weeks of 16", () => { @@ -435,7 +431,7 @@ describe("TemplateSchedulePage", () => { autostop_requirement_weeks: 16, }; const validate = () => getValidationSchema().validateSync(values); - expect(validate).not.toThrowError(); + expect(validate).not.toThrow(); }); it("disallows a autostop requirement weeks of 0", () => {