Skip to content

Commit fa69822

Browse files
authored
fix: windows cli tests fails (#1927)
* test: normalize paths in bucket and locale file tests * feat: add settings configuration for permissions in Claude * chore: add changeset to address Windows test failures
1 parent bed7ea3 commit fa69822

File tree

6 files changed

+44
-14
lines changed

6 files changed

+44
-14
lines changed

.changeset/wise-shrimps-tickle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"lingo.dev": minor
3+
---
4+
5+
Fix Windows test failures

.claude/settings.local.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(pnpm test:*)"
5+
]
6+
}
7+
}

packages/cli/src/cli/loaders/mdx2/code-placeholder.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -911,9 +911,9 @@ describe("placeholder format edge cases (regression)", () => {
911911
const pulled = await loader.pull("en", mdContent);
912912

913913
// Simulate Markdown parsing
914-
const { unified } = require('unified');
915-
const remarkParse = require('remark-parse').default;
916-
const remarkStringify = require('remark-stringify').default;
914+
const { unified } = await import('unified');
915+
const remarkParse = (await import('remark-parse')).default;
916+
const remarkStringify = (await import('remark-stringify')).default;
917917

918918
const processor = unified().use(remarkParse).use(remarkStringify);
919919
const parsed = processor.stringify(processor.parse(pulled));

packages/cli/src/cli/utils/buckets.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { describe, it, expect, vi } from "vitest";
22
import { getBuckets } from "./buckets";
33
import * as pkg from "glob";
44
import type { Path } from "glob";
5+
import { normalizePaths } from "./test-helpers";
56
const { glob } = pkg;
67

78
vi.mock("glob", () => ({
@@ -33,7 +34,7 @@ describe("getBuckets", () => {
3334
"src/translations/[locale]/messages.json",
3435
]);
3536
const buckets = getBuckets(i18nConfig);
36-
expect(buckets).toEqual([
37+
expect(normalizePaths(buckets)).toEqual([
3738
{
3839
type: "json",
3940
paths: [
@@ -78,7 +79,7 @@ describe("getBuckets", () => {
7879
"src/i18n/data-*-[locale]-*/[locale].*.json",
7980
]);
8081
const buckets = getBuckets(i18nConfig);
81-
expect(buckets).toEqual([
82+
expect(normalizePaths(buckets)).toEqual([
8283
{
8384
type: "json",
8485
paths: [
@@ -138,7 +139,7 @@ describe("getBuckets", () => {
138139
{ path: "src/i18n/[locale].json", delimiter: "-" },
139140
]);
140141
const buckets = getBuckets(i18nConfig);
141-
expect(buckets).toEqual([
142+
expect(normalizePaths(buckets)).toEqual([
142143
{
143144
type: "json",
144145
paths: [{ pathPattern: "src/i18n/[locale].json", delimiter: "-" }],
@@ -156,7 +157,7 @@ describe("getBuckets", () => {
156157
"src/[locale]/translations/[locale]/messages.json",
157158
]);
158159
const buckets = getBuckets(i18nConfig);
159-
expect(buckets).toEqual([
160+
expect(normalizePaths(buckets)).toEqual([
160161
{
161162
type: "json",
162163
paths: [

packages/cli/src/cli/utils/find-locale-paths.spec.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
22
import * as pkg from "glob";
33
const { glob } = pkg;
44
import findLocaleFiles from "./find-locale-paths";
5+
import { normalizePaths } from "./test-helpers";
56

67
vi.mock("glob", () => ({
78
glob: {
@@ -29,7 +30,7 @@ describe("findLocaleFiles", () => {
2930

3031
const result = findLocaleFiles("json");
3132

32-
expect(result).toEqual({
33+
expect(normalizePaths(result)).toEqual({
3334
patterns: ["src/i18n/[locale].json", "src/translations/[locale].json"],
3435
defaultPatterns: ["i18n/[locale].json"],
3536
});
@@ -44,7 +45,7 @@ describe("findLocaleFiles", () => {
4445

4546
const result = findLocaleFiles("yaml");
4647

47-
expect(result).toEqual({
48+
expect(normalizePaths(result)).toEqual({
4849
patterns: ["locales/[locale].yml", "translations/[locale].yml"],
4950
defaultPatterns: ["i18n/[locale].yml"],
5051
});
@@ -59,7 +60,7 @@ describe("findLocaleFiles", () => {
5960

6061
const result = findLocaleFiles("flutter");
6162

62-
expect(result).toEqual({
63+
expect(normalizePaths(result)).toEqual({
6364
patterns: ["lib/l10n/[locale].arb", "lib/translations/[locale].arb"],
6465
defaultPatterns: ["i18n/[locale].arb"],
6566
});
@@ -88,7 +89,7 @@ describe("findLocaleFiles", () => {
8889

8990
const result = findLocaleFiles("json");
9091

91-
expect(result).toEqual({
92+
expect(normalizePaths(result)).toEqual({
9293
patterns: [
9394
"src/locales/[locale]/messages.json",
9495
"src/i18n/[locale]/strings.json",
@@ -111,7 +112,7 @@ describe("findLocaleFiles", () => {
111112

112113
const result = findLocaleFiles("json");
113114

114-
expect(result).toEqual({
115+
expect(normalizePaths(result)).toEqual({
115116
patterns: [],
116117
defaultPatterns: ["i18n/[locale].json"],
117118
});
@@ -127,7 +128,7 @@ describe("findLocaleFiles", () => {
127128

128129
const result = findLocaleFiles("xcode-xcstrings");
129130

130-
expect(result).toEqual({
131+
expect(normalizePaths(result)).toEqual({
131132
patterns: [
132133
"ios/MyApp/Localizable.xcstrings",
133134
"ios/MyApp/Onboarding/Localizable.xcstrings",
@@ -142,7 +143,7 @@ describe("findLocaleFiles", () => {
142143

143144
const result = findLocaleFiles("xcode-xcstrings");
144145

145-
expect(result).toEqual({
146+
expect(normalizePaths(result)).toEqual({
146147
patterns: [],
147148
defaultPatterns: ["Localizable.xcstrings"],
148149
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export function normalizePaths<T>(value: T): T {
2+
if (typeof value === "string") {
3+
return value.replace(/\\/g, "/") as T;
4+
}
5+
if (Array.isArray(value)) {
6+
return value.map(normalizePaths) as T;
7+
}
8+
if (value && typeof value === "object") {
9+
const normalized = {} as T;
10+
for (const [key, val] of Object.entries(value)) {
11+
(normalized as any)[key] = normalizePaths(val);
12+
}
13+
return normalized;
14+
}
15+
return value;
16+
}

0 commit comments

Comments
 (0)