From c1b9f1cb286d091f1560c329ecd157200cb0d9fe Mon Sep 17 00:00:00 2001 From: Kacper Date: Mon, 15 Dec 2025 15:11:15 +0100 Subject: [PATCH] refactor: address code review suggestions - Simplify countCustomProfiles by reusing getCustomProfiles helper - Fix misleading test name and assertion for thinking level controls --- apps/app/tests/profiles-view.spec.ts | 19 +++++++++---------- apps/app/tests/utils/views/profiles.ts | 15 ++------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/apps/app/tests/profiles-view.spec.ts b/apps/app/tests/profiles-view.spec.ts index 55c190bb..48dff458 100644 --- a/apps/app/tests/profiles-view.spec.ts +++ b/apps/app/tests/profiles-view.spec.ts @@ -643,24 +643,23 @@ test.describe("AI Profiles View", () => { await waitForSuccessToast(page, "Profile created"); }); - test("should hide thinking level when model doesn't support it", async ({ + test("should show thinking level controls when model supports it", async ({ page, }) => { await clickNewProfileButton(page); - // Select Haiku model (doesn't support thinking) - await selectModel(page, "haiku"); + // Select a model that supports thinking (all current models do) + await selectModel(page, "opus"); - // Thinking level selector should not be visible + // Verify that the thinking level section is visible + const thinkingLevelLabel = page.locator('text="Thinking Level"'); + await expect(thinkingLevelLabel).toBeVisible(); + + // Verify thinking level options are available const thinkingSelector = page.locator( '[data-testid^="thinking-select-"]' ); - const count = await thinkingSelector.count(); - - // Note: Haiku supports thinking levels too, so this test may need adjustment - // Based on the actual implementation. For now, we'll check if at least - // some thinking options are visible - expect(count).toBeGreaterThanOrEqual(0); + await expect(thinkingSelector.first()).toBeVisible(); }); }); diff --git a/apps/app/tests/utils/views/profiles.ts b/apps/app/tests/utils/views/profiles.ts index 0f451abd..693b38db 100644 --- a/apps/app/tests/utils/views/profiles.ts +++ b/apps/app/tests/utils/views/profiles.ts @@ -61,19 +61,8 @@ export async function getBuiltInProfiles(page: Page): Promise { * Count the number of custom profiles */ export async function countCustomProfiles(page: Page): Promise { - // Count profiles by checking each one for the "Built-in" text - const allCards = await page.locator('[data-testid^="profile-card-"]').all(); - let customCount = 0; - - for (const card of allCards) { - const builtInText = card.locator('text="Built-in"'); - const isBuiltIn = (await builtInText.count()) > 0; - if (!isBuiltIn) { - customCount++; - } - } - - return customCount; + const customProfiles = await getCustomProfiles(page); + return customProfiles.count(); } /**