Skip to content

Commit d446630

Browse files
committed
Merge branch 'feat/move-terminal-settings-general' into develop
2 parents bc90028 + 9cba4bd commit d446630

2 files changed

Lines changed: 131 additions & 116 deletions

File tree

packages/web/src/features/settings/components/settings-page.test.tsx

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,6 @@ describe("SettingsPage", () => {
867867
if (op === "settings.get") {
868868
return {
869869
"appearance.locale": "zh",
870-
"appearance.terminalRenderer": "standard",
871870
};
872871
}
873872
return {};
@@ -879,33 +878,52 @@ describe("SettingsPage", () => {
879878

880879
const darkThemePill = await screen.findByRole("button", { name: "深色" });
881880
const lightThemePill = screen.getByRole("button", { name: "浅色" });
882-
const standardRendererPill = screen.getByRole("button", { name: "标准" });
883881
const chineseLanguagePill = screen.getByRole("button", { name: "中文" });
884882

885883
expect(
886884
screen.getByRole("group", {
887885
name: "主题",
888886
})
889887
).toHaveAccessibleDescription("选择应用主题");
890-
expect(
891-
screen.getByRole("group", {
892-
name: "终端渲染器",
893-
})
894-
).toHaveAccessibleDescription("选择终端渲染模式");
895888
expect(
896889
screen.getByRole("group", {
897890
name: "语言",
898891
})
899892
).toHaveAccessibleDescription("选择界面语言");
893+
expect(screen.queryByRole("group", { name: "终端渲染器" })).not.toBeInTheDocument();
894+
expect(screen.queryByRole("switch", { name: "选中自动复制" })).not.toBeInTheDocument();
900895
expect(darkThemePill).toHaveClass("settings-pill", "settings-pill-active");
901896
expect(darkThemePill).toHaveAttribute("aria-pressed", "true");
902897
expect(lightThemePill).toHaveClass("settings-pill");
903898
expect(lightThemePill).toHaveAttribute("aria-pressed", "false");
904-
expect(standardRendererPill).toHaveAttribute("aria-pressed", "true");
905899
expect(chineseLanguagePill).toHaveAttribute("aria-pressed", "true");
906900
});
907901

908-
it("keeps copy-on-select visible on desktop appearance settings", async () => {
902+
it("renders terminal option groups through shared pills in general settings", async () => {
903+
const sendCommand = vi.fn().mockImplementation(async (op: string) => {
904+
if (op === "settings.get") {
905+
return {
906+
"appearance.terminalRenderer": "standard",
907+
};
908+
}
909+
return {};
910+
});
911+
const store = createConnectedStore(sendCommand);
912+
913+
renderSettingsPage(store);
914+
fireEvent.click(screen.getByRole("button", { name: "通用" }));
915+
916+
const standardRendererPill = await screen.findByRole("button", { name: "标准" });
917+
918+
expect(
919+
screen.getByRole("group", {
920+
name: "终端渲染器",
921+
})
922+
).toHaveAccessibleDescription("选择终端渲染模式");
923+
expect(standardRendererPill).toHaveAttribute("aria-pressed", "true");
924+
});
925+
926+
it("keeps copy-on-select visible on desktop general settings", async () => {
909927
const sendCommand = vi.fn().mockImplementation(async (op: string) => {
910928
if (op === "settings.get") {
911929
return {
@@ -917,12 +935,12 @@ describe("SettingsPage", () => {
917935
const store = createConnectedStore(sendCommand);
918936

919937
renderSettingsPage(store);
920-
fireEvent.click(screen.getByRole("button", { name: "外观" }));
938+
fireEvent.click(screen.getByRole("button", { name: "通用" }));
921939

922940
expect(await screen.findByRole("switch", { name: "选中自动复制" })).toBeInTheDocument();
923941
});
924942

925-
it("does not show copy-on-select on mobile appearance settings", async () => {
943+
it("does not show copy-on-select on mobile general settings", async () => {
926944
viewportMocks.viewport = "mobile";
927945
const sendCommand = vi.fn().mockImplementation(async (op: string) => {
928946
if (op === "settings.get") {
@@ -935,9 +953,9 @@ describe("SettingsPage", () => {
935953
const store = createConnectedStore(sendCommand);
936954

937955
renderSettingsPage(store);
938-
fireEvent.click(screen.getByRole("button", { name: "外观" }));
956+
fireEvent.click(screen.getByRole("button", { name: "通用" }));
939957

940-
await screen.findByText("主题");
958+
await screen.findByText("通知");
941959

942960
expect(screen.queryByRole("switch", { name: "选中自动复制" })).not.toBeInTheDocument();
943961
expect(screen.queryByText("选中自动复制")).not.toBeInTheDocument();
@@ -975,7 +993,7 @@ describe("SettingsPage", () => {
975993
expect(screen.getByRole("button", { name: "深色" })).toHaveAttribute("aria-pressed", "false");
976994
});
977995

978-
it("updates terminal renderer selection through the shared appearance pills", async () => {
996+
it("updates terminal renderer selection through the shared general pills", async () => {
979997
const sendCommand = vi.fn().mockImplementation(async (op: string) => {
980998
if (op === "settings.get") {
981999
return {
@@ -987,7 +1005,7 @@ describe("SettingsPage", () => {
9871005
const store = createConnectedStore(sendCommand);
9881006

9891007
renderSettingsPage(store);
990-
fireEvent.click(screen.getByRole("button", { name: "外观" }));
1008+
fireEvent.click(screen.getByRole("button", { name: "通用" }));
9911009
fireEvent.click(await screen.findByRole("button", { name: "兼容模式" }));
9921010

9931011
await waitFor(() => {
@@ -1015,7 +1033,7 @@ describe("SettingsPage", () => {
10151033
expect(screen.getByRole("button", { name: "标准" })).toHaveAttribute("aria-pressed", "false");
10161034
});
10171035

1018-
it("preserves terminal renderer selection when a stale settings load resolves afterward", async () => {
1036+
it("preserves terminal renderer selection when a stale settings load resolves afterward in general settings", async () => {
10191037
let resolveSettingsGet: ((value: Record<string, unknown>) => void) | undefined;
10201038
const settingsGetPromise = new Promise<Record<string, unknown>>((resolve) => {
10211039
resolveSettingsGet = resolve;
@@ -1029,7 +1047,7 @@ describe("SettingsPage", () => {
10291047
const store = createConnectedStore(sendCommand);
10301048

10311049
renderSettingsPage(store);
1032-
fireEvent.click(screen.getByRole("button", { name: "外观" }));
1050+
fireEvent.click(screen.getByRole("button", { name: "通用" }));
10331051
fireEvent.click(await screen.findByRole("button", { name: "兼容模式" }));
10341052

10351053
await waitFor(() => {
@@ -1061,7 +1079,7 @@ describe("SettingsPage", () => {
10611079
expect(screen.getByRole("button", { name: "标准" })).toHaveAttribute("aria-pressed", "false");
10621080
});
10631081

1064-
it("renders the copy-on-select switch from loaded appearance settings", async () => {
1082+
it("renders the copy-on-select switch from loaded general settings", async () => {
10651083
const sendCommand = vi.fn().mockImplementation(async (op: string) => {
10661084
if (op === "settings.get") {
10671085
return {
@@ -1073,16 +1091,18 @@ describe("SettingsPage", () => {
10731091
const store = createConnectedStore(sendCommand);
10741092

10751093
renderSettingsPage(store);
1076-
fireEvent.click(screen.getByRole("button", { name: "外观" }));
1094+
fireEvent.click(screen.getByRole("button", { name: "通用" }));
10771095

1078-
expect(await screen.findByRole("switch", { name: "选中自动复制" })).toHaveAttribute(
1079-
"aria-checked",
1080-
"true"
1081-
);
1096+
await waitFor(() => {
1097+
expect(screen.getByRole("switch", { name: "选中自动复制" })).toHaveAttribute(
1098+
"aria-checked",
1099+
"true"
1100+
);
1101+
});
10821102
expect(store.get(terminalPreferencesAtom)).toEqual({ copyOnSelect: true });
10831103
});
10841104

1085-
it("updates copy-on-select through the appearance switch and syncs the global atom", async () => {
1105+
it("updates copy-on-select through the general switch and syncs the global atom", async () => {
10861106
const sendCommand = vi.fn().mockImplementation(async (op: string) => {
10871107
if (op === "settings.get") {
10881108
return {
@@ -1094,7 +1114,7 @@ describe("SettingsPage", () => {
10941114
const store = createConnectedStore(sendCommand);
10951115

10961116
renderSettingsPage(store);
1097-
fireEvent.click(screen.getByRole("button", { name: "外观" }));
1117+
fireEvent.click(screen.getByRole("button", { name: "通用" }));
10981118
fireEvent.click(await screen.findByRole("switch", { name: "选中自动复制" }));
10991119

11001120
await waitFor(() => {
@@ -1114,7 +1134,7 @@ describe("SettingsPage", () => {
11141134
expect(store.get(terminalPreferencesAtom)).toEqual({ copyOnSelect: true });
11151135
});
11161136

1117-
it("renders copy-on-select from the terminal preferences atom before settings load resolves", async () => {
1137+
it("renders copy-on-select from the terminal preferences atom before general settings load resolves", async () => {
11181138
let resolveSettingsGet: ((value: Record<string, unknown>) => void) | undefined;
11191139
const settingsGetPromise = new Promise<Record<string, unknown>>((resolve) => {
11201140
resolveSettingsGet = resolve;
@@ -1129,7 +1149,7 @@ describe("SettingsPage", () => {
11291149
store.set(terminalPreferencesAtom, { copyOnSelect: true });
11301150

11311151
renderSettingsPage(store);
1132-
fireEvent.click(screen.getByRole("button", { name: "外观" }));
1152+
fireEvent.click(screen.getByRole("button", { name: "通用" }));
11331153

11341154
expect(await screen.findByRole("switch", { name: "选中自动复制" })).toHaveAttribute(
11351155
"aria-checked",
@@ -1142,7 +1162,7 @@ describe("SettingsPage", () => {
11421162
});
11431163
});
11441164

1145-
it("preserves copy-on-select when a stale settings load resolves afterward", async () => {
1165+
it("preserves copy-on-select when a stale general settings load resolves afterward", async () => {
11461166
let resolveSettingsGet: ((value: Record<string, unknown>) => void) | undefined;
11471167
const settingsGetPromise = new Promise<Record<string, unknown>>((resolve) => {
11481168
resolveSettingsGet = resolve;
@@ -1156,7 +1176,7 @@ describe("SettingsPage", () => {
11561176
const store = createConnectedStore(sendCommand);
11571177

11581178
renderSettingsPage(store);
1159-
fireEvent.click(screen.getByRole("button", { name: "外观" }));
1179+
fireEvent.click(screen.getByRole("button", { name: "通用" }));
11601180
fireEvent.click(await screen.findByRole("switch", { name: "选中自动复制" }));
11611181

11621182
await waitFor(() => {

0 commit comments

Comments
 (0)