mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
test(ui): assert migrated playground path route in sidebar e2e
The playground migration moved LLM Playground from the legacy ?page=llm-playground switch to the /ui/playground/ path route, but sidebar.spec.ts still asserted the query-param URL, so both clicking the sidebar item and the direct-nav helper failed. Drive the expected URL off a small migrated-segment map (mirroring MIGRATED_PAGES) so migrated pages assert their path route while legacy pages keep ?page=
This commit is contained in:
parent
c6f223cfcd
commit
4b4c8ba423
1 changed files with 15 additions and 5 deletions
|
|
@ -9,6 +9,17 @@ const sidebarButtons = {
|
|||
[Role.ProxyAdmin]: ["Virtual Keys", "Playground", "Models", "Usage", "Teams", "Internal Users", "AI Hub"],
|
||||
};
|
||||
|
||||
// Route segment for pages migrated to path routes; mirror of MIGRATED_PAGES in src/utils/migratedPages.ts.
|
||||
const migratedPageSegments: Partial<Record<Page, string>> = {
|
||||
[Page.ApiRef]: "api-reference",
|
||||
[Page.LlmPlayground]: "playground",
|
||||
};
|
||||
|
||||
function expectedUrlPattern(pageKey: Page): RegExp {
|
||||
const segment = migratedPageSegments[pageKey];
|
||||
return segment ? new RegExp(`/ui/${segment}/?($|\\?)`) : new RegExp(`[?&]page=${pageKey}(&|$)`);
|
||||
}
|
||||
|
||||
const roles = [{ role: Role.ProxyAdmin, storage: ADMIN_STORAGE_PATH }];
|
||||
|
||||
for (const { role, storage } of roles) {
|
||||
|
|
@ -35,8 +46,7 @@ for (const { role, storage } of roles) {
|
|||
|
||||
await tab.click();
|
||||
|
||||
// Verify URL contains the correct page query parameter
|
||||
await expect(page).toHaveURL(new RegExp(`[?&]page=${expectedPage}(&|$)`));
|
||||
await expect(page).toHaveURL(expectedUrlPattern(expectedPage));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -50,13 +60,13 @@ for (const { role, storage } of roles) {
|
|||
|
||||
// Test direct navigation to verify the helper function works
|
||||
await navigateToPage(page, Page.ApiKeys);
|
||||
await expect(page).toHaveURL(new RegExp(`[?&]page=${Page.ApiKeys}(&|$)`));
|
||||
await expect(page).toHaveURL(expectedUrlPattern(Page.ApiKeys));
|
||||
|
||||
await navigateToPage(page, Page.Models);
|
||||
await expect(page).toHaveURL(new RegExp(`[?&]page=${Page.Models}(&|$)`));
|
||||
await expect(page).toHaveURL(expectedUrlPattern(Page.Models));
|
||||
|
||||
await navigateToPage(page, Page.LlmPlayground);
|
||||
await expect(page).toHaveURL(new RegExp(`[?&]page=${Page.LlmPlayground}(&|$)`));
|
||||
await expect(page).toHaveURL(expectedUrlPattern(Page.LlmPlayground));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue