Skip to content

Commit 609837b

Browse files
committed
fix: test compatibility issues
- Fix CommencerPage test: mock redirect to throw like real Next.js redirect, instead of expecting null render on missing session - Fix Python schema utils: convert dict_keys to list for JSON serialization (Python 3.12+ compat) - Add .venv/ to API .gitignore
1 parent dd1227b commit 609837b

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

packages/api/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ tmp/
66
htmlcov/
77
site/
88
venv/
9+
.venv/
910
.env
1011
.history/
1112
settings.json

packages/api/egapro/schema/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33

44

55
def regions():
6-
return {"type": "string", "enum": constants.REGIONS.keys()}
6+
return {"type": "string", "enum": list(constants.REGIONS.keys())}
77

88

99
def departements():
10-
return {"type": "string", "enum": constants.DEPARTEMENTS.keys()}
10+
return {"type": "string", "enum": list(constants.DEPARTEMENTS.keys())}
1111

1212

1313
def naf():
14-
return {"type": "string", "enum": NAF.keys()}
14+
return {"type": "string", "enum": list(NAF.keys())}
1515

1616

1717
def code_pays():
18-
return {"type": "string", "enum": constants.PAYS_ISO_TO_LIB.keys()}
18+
return {"type": "string", "enum": list(constants.PAYS_ISO_TO_LIB.keys())}
1919

2020

2121
def years():

packages/app/src/app/(default)/index-egapro/declaration/commencer/__tests__/page.test.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { render, screen } from "@testing-library/react";
2+
import { redirect } from "next/navigation";
23
import { getServerSession } from "next-auth";
34
import { type ReactElement } from "react";
45

@@ -28,10 +29,14 @@ describe("CommencerPage", () => {
2829
mockGetServerSession.mockReset();
2930
});
3031

31-
it("should return null when no session", async () => {
32+
it("should redirect to login when no session", async () => {
3233
mockGetServerSession.mockResolvedValue(null);
33-
const { container } = render((await CommencerPage()) as ReactElement);
34-
expect(container).toBeEmptyDOMElement();
34+
(redirect as jest.Mock).mockImplementation(() => {
35+
throw new Error("NEXT_REDIRECT");
36+
});
37+
38+
await expect(CommencerPage()).rejects.toThrow("NEXT_REDIRECT");
39+
expect(redirect).toHaveBeenCalledWith("/login");
3540
});
3641

3742
it("should show email login alert when no companies and email login", async () => {

0 commit comments

Comments
 (0)