Skip to content

Commit c9c20d1

Browse files
committed
fix: address remaining copilot review feedback
Signed-off-by: kartik <kartikrautan0@gmail.com>
1 parent c10cf29 commit c9c20d1

File tree

10 files changed

+156
-66
lines changed

10 files changed

+156
-66
lines changed

dco_log.txt

7.11 KB
Binary file not shown.

dco_log_utf8.txt

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
c10cf29 | kartik <kartikrautan0@gmail.com> | Merge branch 'differentLanguageSupport' of https://github.com/kartikrautan/template-playground into differentLanguageSupport | Signed-off-by: kartik <kartikrautan0@gmail.com>
2+
3+
d6199d2 | kartik <kartikrautan0@gmail.com> | Updation on copilot reviews |
4+
9a71e91 | Kartik Rautan <kartikrautan0@gmail.com> | Merge branch 'main' into differentLanguageSupport |
5+
76717a7 | Harshit Kumar <10harshitkumar@gmail.com> | feat: Implement Error Boundary for better error handling (#734) | * feat: add ErrorBoundary to prevent app crashes
6+
7+
Signed-off-by: Harshit Kumar <10harshitkumar@gmail.com>
8+
9+
* refactor: address code review feedback
10+
11+
- Add type='button' to prevent unintended form submission
12+
- Hide error details in production for security (only show in dev mode)
13+
14+
Signed-off-by: Harshit Kumar <10harshitkumar@gmail.com>
15+
16+
* test(ErrorBoundary): add comprehensive test coverage for error boundary component
17+
18+
Signed-off-by: Harshit Kumar <10harshitkumar@gmail.com>
19+
20+
* feat(ErrorBoundary): add theme-aware colors and component stack to error details
21+
22+
Signed-off-by: Harshit Kumar <10harshitkumar@gmail.com>
23+
24+
* fix(ErrorBoundary): address Copilot review suggestions for test quality
25+
26+
- Add showDevDetails prop for testable dev mode control
27+
28+
- Fix window.location.reload mock to avoid test pollution
29+
30+
- Correct dark mode color to #121212 (matches store)
31+
32+
- Remove import.meta.env.DEV mutations (read-only property)
33+
34+
Signed-off-by: Harshit Kumar <10harshitkumar@gmail.com>
35+
36+
* fix(ErrorBoundary): resolve TypeScript error in test
37+
38+
Signed-off-by: Harshit Kumar <10harshitkumar@gmail.com>
39+
40+
* fix(ErrorBoundary): implement 3 additional Copilot suggestions
41+
42+
- Properly type consoleErrorSpy as MockInstance (no eslint-disable)
43+
44+
- Add async/await for component stack test to handle state update timing
45+
46+
- Capture and restore Zustand state in theme test to prevent order-dependency
47+
48+
Signed-off-by: Harshit Kumar <10harshitkumar@gmail.com>
49+
50+
---------
51+
52+
Signed-off-by: Harshit Kumar <10harshitkumar@gmail.com>
53+
Co-authored-by: Matt Roberts <7544022+mttrbrts@users.noreply.github.com>
54+
7b51f8a | kartik <kartikrautan0@gmail.com> | Merge remote-tracking branch 'upstream/main' into differentLanguageSupport | Signed-off-by: kartik <kartikrautan0@gmail.com>
55+
56+
# Conflicts:
57+
# package-lock.json
58+
59+
b8ead94 | kartik <kartikrautan0@gmail.com> | Different Language Support | Signed-off-by: kartik <kartikrautan0@gmail.com>
60+
61+
cb2e662 | Vaggelis Argyropoulos <69078031+Vaggelis-Arg@users.noreply.github.com> | fix(AIConfigPopup): UX: validate model selection and allow API key visibility (#744) | Signed-off-by: Evangelos Argyropoulos <vag.argyropoulos@gmail.com>
62+
1272f54 | Majoju Vaishnavi <majojuvaishnavi@gmail.com> | feat(playground): improve default agreement sample (#702) | * feat(playground): improve default agreement sample to better reflect legal use case
63+
64+
Signed-off-by: Vaishnavi <majojuvaishnavi@gmail.com>
65+
66+
* Update Service Agreement template
67+
68+
Signed-off-by: Vaishnavi <majojuvaishnavi@gmail.com>
69+
70+
---------
71+
72+
Signed-off-by: Vaishnavi <majojuvaishnavi@gmail.com>
73+
Co-authored-by: Matt Roberts <7544022+mttrbrts@users.noreply.github.com>
74+
ddf33c2 | Kartik Rautan <kartikrautan0@gmail.com> | fix: Replace plaintext API key storage with hardware-backed WebAuthn PRF + AES-GCM encryption (#762) | * Replaced plaintext storage with WebAuthn PRF encryption
75+
76+
Signed-off-by: kartik <kartikrautan0@gmail.com>
77+
78+
* Updation on copilot reviews
79+
80+
Signed-off-by: kartik <kartikrautan0@gmail.com>
81+
82+
---------
83+
84+
Signed-off-by: kartik <kartikrautan0@gmail.com>

pr_diff.txt

1.17 MB
Binary file not shown.

src/components/Navbar.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ function Navbar() {
213213
void i18n.changeLanguage(lng);
214214
};
215215

216-
const currentLang = LANGUAGES.find(l => l.code === i18n.language) || LANGUAGES[0];
216+
const currentLanguageCode = i18n.resolvedLanguage || (i18n.language ? i18n.language.split('-')[0] : 'en');
217+
const currentLang = LANGUAGES.find(l => l.code === currentLanguageCode) || LANGUAGES[0];
217218

218219
const props = useSpring({
219220
loop: true,
@@ -231,7 +232,7 @@ function Navbar() {
231232
<MenuItem
232233
key={lang.code}
233234
onClick={() => changeLanguage(lang.code)}
234-
className={i18n.language === lang.code ? 'bg-gray-100 dark:bg-gray-700 font-semibold' : ''}
235+
className={currentLanguageCode === lang.code ? 'bg-gray-100 dark:bg-gray-700 font-semibold' : ''}
235236
>
236237
<span>{lang.flag}</span>
237238
<span>{lang.label}</span>

src/tests/components/Footer.test.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { render } from "@testing-library/react";
22
import { describe, it, expect, vi, beforeAll } from "vitest";
33
import Footer from "../../components/Footer";
44

5-
vi.mock('react-i18next', async () => {
6-
const { reactI18nextMock } = await import("../../utils/testing/i18nMock");
7-
return reactI18nextMock;
8-
});
5+
96

107
vi.mock("../../public/logo.png", () => ({
118
default: "logo.png",

src/tests/components/Navbar.test.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import "@testing-library/jest-dom";
33
import Navbar from "../../components/Navbar";
44
import { MemoryRouter } from "react-router-dom";
55
import { vi, describe, it, expect, afterEach } from "vitest";
6-
import { mockChangeLanguage } from "../../utils/testing/i18nMock";
76

8-
vi.mock("react-i18next", async () => {
9-
const { reactI18nextMock } = await import("../../utils/testing/i18nMock");
7+
const mockChangeLanguage = vi.fn();
8+
9+
vi.mock("react-i18next", async (importOriginal) => {
10+
const actual = await importOriginal<typeof import('react-i18next')>();
1011
return {
12+
...actual,
1113
useTranslation: () => ({
1214
t: (key: string) => {
1315
const map: Record<string, string> = {
@@ -25,7 +27,12 @@ vi.mock("react-i18next", async () => {
2527
};
2628
return map[key] || key;
2729
},
28-
i18n: reactI18nextMock.useTranslation().i18n,
30+
i18n: {
31+
get language() {
32+
return localStorage.getItem("i18nextLng") || "en";
33+
},
34+
changeLanguage: mockChangeLanguage,
35+
},
2936
}),
3037
};
3138
});

src/tests/components/PlaygroundSidebar.test.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ import PlaygroundSidebar from "../../components/PlaygroundSidebar";
44
import { vi } from "vitest";
55

66

7-
vi.mock('react-i18next', async () => {
8-
const { reactI18nextMock } = await import("../../utils/testing/i18nMock");
7+
vi.mock('react-i18next', async (importOriginal) => {
8+
const actual = await importOriginal<typeof import('react-i18next')>();
9+
// The global mock in setup.ts doesn't export its inner reactI18nextMock.
10+
// Instead, we just provide the specific `t` we need and a basic `i18n` object
11+
// since vitest hoists this. We can use the global mockChangeLanguage.
912
return {
13+
...actual,
1014
useTranslation: () => ({
1115
t: (key: string) => {
1216
const map: Record<string, string> = {
@@ -21,7 +25,12 @@ vi.mock('react-i18next', async () => {
2125
};
2226
return map[key] || key;
2327
},
24-
i18n: reactI18nextMock.useTranslation().i18n,
28+
i18n: {
29+
get language() {
30+
return localStorage.getItem("i18nextLng") || "en";
31+
},
32+
changeLanguage: vi.fn(), // We can just mock this per file if needed, or import the global one if it wasn't hoisted
33+
},
2534
})
2635
};
2736
});

src/tests/components/SettingsModal.test.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
22
import { render, screen } from '@testing-library/react';
33
import SettingsModal from '../../components/SettingsModal';
44

5-
vi.mock('react-i18next', async () => {
6-
const { reactI18nextMock } = await import('../../utils/testing/i18nMock');
5+
vi.mock('react-i18next', async (importOriginal) => {
6+
const actual = await importOriginal<typeof import('react-i18next')>();
77
return {
8+
...actual,
89
useTranslation: () => ({
910
t: (key: string) => {
1011
const map: Record<string, string> = {
@@ -16,7 +17,12 @@ vi.mock('react-i18next', async () => {
1617
};
1718
return map[key] || key;
1819
},
19-
i18n: reactI18nextMock.useTranslation().i18n,
20+
i18n: {
21+
get language() {
22+
return localStorage.getItem("i18nextLng") || "en";
23+
},
24+
changeLanguage: vi.fn(),
25+
},
2026
})
2127
};
2228
});

src/utils/testing/i18nMock.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/utils/testing/setup.ts

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expect, afterEach } from "vitest";
1+
import { expect, afterEach, vi } from "vitest";
22
import { cleanup } from "@testing-library/react";
33
import * as matchers from "@testing-library/jest-dom/matchers";
44

@@ -60,32 +60,47 @@ HTMLCanvasElement.prototype.getContext = ((originalGetContext) => {
6060
if (contextId === '2d') {
6161
return {
6262
fillStyle: '',
63-
fillRect: () => {},
64-
clearRect: () => {},
63+
fillRect: () => { },
64+
clearRect: () => { },
6565
getImageData: () => ({ data: [] }),
66-
putImageData: () => {},
66+
putImageData: () => { },
6767
createImageData: () => ({ data: [] }),
68-
setTransform: () => {},
69-
drawImage: () => {},
70-
save: () => {},
71-
restore: () => {},
72-
beginPath: () => {},
73-
moveTo: () => {},
74-
lineTo: () => {},
75-
closePath: () => {},
76-
stroke: () => {},
77-
fill: () => {},
78-
translate: () => {},
79-
scale: () => {},
80-
rotate: () => {},
81-
arc: () => {},
68+
setTransform: () => { },
69+
drawImage: () => { },
70+
save: () => { },
71+
restore: () => { },
72+
beginPath: () => { },
73+
moveTo: () => { },
74+
lineTo: () => { },
75+
closePath: () => { },
76+
stroke: () => { },
77+
fill: () => { },
78+
translate: () => { },
79+
scale: () => { },
80+
rotate: () => { },
81+
arc: () => { },
8282
measureText: () => ({ width: 0 }),
83-
transform: () => {},
84-
rect: () => {},
85-
clip: () => {},
83+
transform: () => { },
84+
rect: () => { },
85+
clip: () => { },
8686
canvas: this,
8787
} as unknown as CanvasRenderingContext2D;
8888
}
8989
return originalGetContext.call(this, contextId as any, options);
9090
};
9191
})(HTMLCanvasElement.prototype.getContext);
92+
93+
// Global mock for react-i18next
94+
export const mockChangeLanguage = vi.fn();
95+
96+
vi.mock("react-i18next", () => ({
97+
useTranslation: () => ({
98+
t: (key: string) => key,
99+
i18n: {
100+
get language() {
101+
return localStorage.getItem("i18nextLng") || "en";
102+
},
103+
changeLanguage: mockChangeLanguage,
104+
},
105+
}),
106+
}));

0 commit comments

Comments
 (0)