Skip to content

Commit d465268

Browse files
test(line,mattermost): pin wizard locale in setup surface tests
Wizard copy is localized at module evaluation time, so prompt assertions failed on machines with a zh locale. Pin OPENCLAW_LOCALE=en via vi.hoisted (before imports) and restore afterwards.
1 parent 01a80f4 commit d465268

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

‎extensions/line/src/setup-surface.test.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,19 @@ import { setLineRuntime } from "./runtime.js";
1818
import { lineSetupAdapter } from "./setup-core.js";
1919
import { lineSetupWizard } from "./setup-surface.js";
2020

21-
const { getBotInfoMock, MessagingApiClientMock } = vi.hoisted(() => {
21+
const { getBotInfoMock, MessagingApiClientMock, previousLocale } = vi.hoisted(() => {
2222
const getBotInfoMockLocal = vi.fn();
2323
const MessagingApiClientMockLocal = vi.fn(function () {
2424
return { getBotInfo: getBotInfoMockLocal };
2525
});
26+
// Wizard copy is localized at module evaluation time; pin English before
27+
// imports so prompt assertions do not depend on the developer machine's locale.
28+
const previousLocaleLocal = process.env.OPENCLAW_LOCALE;
29+
process.env.OPENCLAW_LOCALE = "en";
2630
return {
2731
getBotInfoMock: getBotInfoMockLocal,
2832
MessagingApiClientMock: MessagingApiClientMockLocal,
33+
previousLocale: previousLocaleLocal,
2934
};
3035
});
3136

@@ -36,6 +41,11 @@ vi.mock("@line/bot-sdk", () => ({
3641
afterAll(() => {
3742
vi.doUnmock("@line/bot-sdk");
3843
vi.resetModules();
44+
if (previousLocale === undefined) {
45+
delete process.env.OPENCLAW_LOCALE;
46+
} else {
47+
process.env.OPENCLAW_LOCALE = previousLocale;
48+
}
3949
});
4050

4151
const lineConfigure = createPluginSetupWizardConfigure(linePlugin);

‎extensions/mattermost/src/setup.test.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@ import {
66
runSetupWizardConfigure,
77
} from "openclaw/plugin-sdk/plugin-test-runtime";
88
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/setup";
9-
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
9+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
1010
import type { OpenClawConfig, OpenClawPluginApi } from "../runtime-api.js";
1111

1212
const resolveMattermostAccount = vi.hoisted(() => vi.fn());
1313
const normalizeMattermostBaseUrl = vi.hoisted(() => vi.fn((value: string | undefined) => value));
1414
const hasConfiguredSecretInput = vi.hoisted(() => vi.fn((value: unknown) => Boolean(value)));
15+
const previousLocale = vi.hoisted(() => {
16+
// Wizard copy is localized at module evaluation time; pin English before
17+
// imports so prompt assertions do not depend on the developer machine's locale.
18+
const previousLocaleLocal = process.env.OPENCLAW_LOCALE;
19+
process.env.OPENCLAW_LOCALE = "en";
20+
return previousLocaleLocal;
21+
});
1522

1623
vi.mock("./setup.accounts.runtime.js", () => {
1724
const resolveAccount = (params: Parameters<typeof resolveMattermostAccount>[0]) => {
@@ -105,6 +112,14 @@ describe("mattermost setup", () => {
105112
vi.unstubAllEnvs();
106113
});
107114

115+
afterAll(() => {
116+
if (previousLocale === undefined) {
117+
delete process.env.OPENCLAW_LOCALE;
118+
} else {
119+
process.env.OPENCLAW_LOCALE = previousLocale;
120+
}
121+
});
122+
108123
it("reports configuration only when token and base url are both present", () => {
109124
expect(
110125
isMattermostConfigured({

0 commit comments

Comments
 (0)