mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
fix(settings): reset scroll on tab switch (#4165)
This commit is contained in:
@@ -344,9 +344,7 @@ describe("SettingsPage Component", () => {
|
||||
fireEvent.click(screen.getByText("settings.advanced.data.title"));
|
||||
|
||||
// 有文件时,点击导入按钮执行 importConfig
|
||||
fireEvent.click(
|
||||
screen.getByRole("button", { name: /settings\.import/ }),
|
||||
);
|
||||
fireEvent.click(screen.getByRole("button", { name: /settings\.import/ }));
|
||||
expect(importExportMock.importConfig).toHaveBeenCalled();
|
||||
|
||||
fireEvent.click(
|
||||
@@ -359,6 +357,20 @@ describe("SettingsPage Component", () => {
|
||||
expect(importExportMock.clearSelection).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should reset tab content scroll position when switching settings tabs", () => {
|
||||
const { container } = renderSettingsPage();
|
||||
const scrollContainer = container.querySelector(
|
||||
".overflow-y-auto",
|
||||
) as HTMLDivElement | null;
|
||||
|
||||
expect(scrollContainer).not.toBeNull();
|
||||
|
||||
scrollContainer!.scrollTop = 640;
|
||||
fireEvent.click(screen.getByText("settings.tabAdvanced"));
|
||||
|
||||
expect(scrollContainer!.scrollTop).toBe(0);
|
||||
});
|
||||
|
||||
it("should pass onImportSuccess callback to useImportExport hook", async () => {
|
||||
const onImportSuccess = vi.fn();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user