fix: make settings nav not enter history (#9376)
* remove unused location store * make sidebar component replace route in order for back button to go back to previous page before settings * added test to back button functionality * [autofix.ci] apply automated fixes --------- Co-authored-by: Mike Fortman <michael.fortman@datastax.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
181606fd80
commit
9141005e6b
3 changed files with 46 additions and 22 deletions
|
|
@ -34,7 +34,7 @@ const SideBarButtonsComponent = ({ items }: SideBarButtonsComponentProps) => {
|
|||
<SidebarMenu>
|
||||
{items.map((item, index) => (
|
||||
<SidebarMenuItem key={index}>
|
||||
<CustomLink to={item.href!}>
|
||||
<CustomLink to={item.href!} replace>
|
||||
<SidebarMenuButton
|
||||
size="md"
|
||||
isActive={
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
import { create } from "zustand";
|
||||
import type { LocationStoreType } from "../types/zustand/location";
|
||||
|
||||
export const useLocationStore = create<LocationStoreType>((set, get) => ({
|
||||
routeHistory: [],
|
||||
setRouteHistory: (location) => {
|
||||
const routeHistoryArray = get().routeHistory;
|
||||
routeHistoryArray.push(location);
|
||||
|
||||
if (routeHistoryArray?.length > 100) {
|
||||
routeHistoryArray.shift();
|
||||
set({
|
||||
routeHistory: routeHistoryArray,
|
||||
});
|
||||
}
|
||||
|
||||
set({
|
||||
routeHistory: routeHistoryArray,
|
||||
});
|
||||
},
|
||||
}));
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { expect, test } from "@playwright/test";
|
||||
import { awaitBootstrapTest } from "../../utils/await-bootstrap-test";
|
||||
|
||||
test.beforeAll(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 7000));
|
||||
|
|
@ -200,3 +201,47 @@ test(
|
|||
await page.getByText(randomName).isVisible();
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
"should navigate back to flow from global variables",
|
||||
{ tag: ["@release", "@workspace"] },
|
||||
async ({ page }) => {
|
||||
await awaitBootstrapTest(page);
|
||||
|
||||
await page.getByTestId("side_nav_options_all-templates").click();
|
||||
await page.getByRole("heading", { name: "Basic Prompting" }).click();
|
||||
await page.waitForSelector('[data-testid="fit_view"]', {
|
||||
timeout: 100000,
|
||||
});
|
||||
// Now navigate to user settings
|
||||
await page.getByTestId("user-profile-settings").click();
|
||||
await page.getByTestId("menu_settings_button").click();
|
||||
|
||||
// Verify we're on the settings page
|
||||
await expect(page.getByText("General").nth(2)).toBeVisible({
|
||||
timeout: 4000,
|
||||
});
|
||||
|
||||
// Navigate to Global Variables
|
||||
await page.getByText("Global Variables").click();
|
||||
await page.getByText("Global Variables").nth(2);
|
||||
await page
|
||||
.getByText("Global Variables", { exact: true })
|
||||
.nth(1)
|
||||
.isVisible();
|
||||
|
||||
// Click the back button - this should take us back to the flow, not to the main settings page
|
||||
await page.getByTestId("back_page_button").click();
|
||||
|
||||
// Verify we're back on the flow page, not the settings main page
|
||||
await page.waitForSelector('[data-testid="sidebar-search-input"]', {
|
||||
timeout: 5000,
|
||||
});
|
||||
|
||||
// Additional verification that we're on the flow page
|
||||
expect(page.url()).toMatch(/\/flow\//);
|
||||
|
||||
// Verify we can see flow-specific elements
|
||||
await expect(page.getByTestId("sidebar-search-input")).toBeVisible();
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue