Skip to content

Commit

Permalink
📦 deps: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
w3bdesign committed Feb 9, 2025
2 parents 2b12ba9 + 1f19eb2 commit 2c6c9ef
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 214 deletions.
295 changes: 154 additions & 141 deletions DOCS/repository_context.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This file is a merged representation of the entire codebase, combining all repository files into a single document.
Generated by Repomix on: 2025-02-07T06:34:12.979Z
This file is a merged representation of a subset of the codebase, containing files not matching ignore patterns, combined into a single document. The content has been processed where empty lines have been removed, line numbers have been added.
Generated by Repomix on: 2025-02-09T17:15:52.992Z

# File Summary

Expand Down Expand Up @@ -27,13 +27,13 @@ The content is organized as follows:
- Pay special attention to the Repository Description. These contain important context and guidelines specific to this project.

## Notes
- Some files may have been excluded based on .gitignore rules and Repomix's
configuration.
- Binary files are not included in this packed representation. Please refer to
the Repository Structure section for a complete list of file paths, including
binary files.

- Line numbers have been added to the beginning of each line.
- Some files may have been excluded based on .gitignore rules and Repomix's configuration
- Binary files are not included in this packed representation. Please refer to the Repository Structure section for a complete list of file paths, including binary files
- Files matching these patterns are excluded: DOCS/repository_context.txt, .env*, *.log, dist, build, coverage
- Files matching patterns in .gitignore are excluded
- Files matching default ignore patterns are excluded
- Empty lines have been removed from all files
- Line numbers have been added to the beginning of each line

## Additional Info
### User Provided Header
Expand Down Expand Up @@ -4219,131 +4219,144 @@ tsconfig.json
1: import { getProjects } from "@/app/prosjekter/actions";
2: import { client } from "@/lib/sanity/client";
3: import { projectsQuery } from "@/lib/sanity/queries";
4: // Mock the Sanity client
5: jest.mock("@/lib/sanity/client", () => ({
6: client: {
7: fetch: jest.fn(),
8: },
9: }));
10: describe("getProjects", () => {
11: beforeEach(() => {
12: jest.clearAllMocks();
13: });
14: it("fetches projects successfully", async () => {
15: // Arrange
16: const mockProjects = [
17: {
18: id: "1",
19: name: "Test Project",
20: description: "Test Description",
21: subdescription: "Test Subdescription",
22: projectimage: { asset: { _ref: "test" } },
23: urlwww: [],
24: urlgithub: [],
25: },
26: ];
27: const expectedFetchOptions = {
28: next: { revalidate: 3600 },
29: };
30: (client.fetch as jest.Mock).mockResolvedValueOnce(mockProjects);
31: // Act
32: const result = await getProjects();
33: // Assert
34: expect(result).toEqual(mockProjects);
35: expect(client.fetch).toHaveBeenCalledWith(
36: projectsQuery,
37: {},
38: expectedFetchOptions,
39: );
40: });
41: describe("error handling", () => {
42: it("handles authentication errors (401)", async () => {
43: // Arrange
44: const authError = {
45: statusCode: 401,
46: message: "Invalid token",
47: details: { type: "credentials", description: "Invalid token provided" }
48: };
49: (client.fetch as jest.Mock).mockRejectedValueOnce(authError);
50: // Act & Assert
51: await expect(getProjects()).rejects.toThrow("Authentication failed");
52: });
53: it("handles permission errors (403)", async () => {
54: // Arrange
55: const permError = {
56: statusCode: 403,
57: message: "Insufficient permissions",
58: details: { type: "authorization", description: "Missing read access" }
59: };
60: (client.fetch as jest.Mock).mockRejectedValueOnce(permError);
61: // Act & Assert
62: await expect(getProjects()).rejects.toThrow("Insufficient permissions");
63: });
64: it("handles rate limiting (429)", async () => {
65: // Arrange
66: const rateError = {
67: statusCode: 429,
68: message: "Too Many Requests",
69: details: { type: "rate_limit", description: "Rate limit exceeded" }
70: };
71: (client.fetch as jest.Mock).mockRejectedValueOnce(rateError);
72: // Act & Assert
73: await expect(getProjects()).rejects.toThrow("Rate limit exceeded");
74: });
75: it("handles malformed GROQ queries (400)", async () => {
76: // Arrange
77: const queryError = {
78: statusCode: 400,
79: message: "Invalid GROQ query",
80: details: { type: "query_error", description: "Syntax error in GROQ query" }
81: };
82: (client.fetch as jest.Mock).mockRejectedValueOnce(queryError);
83: // Act & Assert
84: await expect(getProjects()).rejects.toThrow("Sanity API error: Invalid GROQ query");
85: });
86: it("handles network timeouts", async () => {
87: // Arrange
88: const timeoutError = new Error("Network timeout");
89: timeoutError.name = "TimeoutError";
90: (client.fetch as jest.Mock).mockRejectedValueOnce(timeoutError);
91: // Act & Assert
92: await expect(getProjects()).rejects.toThrow("Request timed out");
93: });
94: it("handles generic fetch errors", async () => {
95: // Arrange
96: const expectedError = new Error("Fetch failed");
97: (client.fetch as jest.Mock).mockRejectedValueOnce(expectedError);
98: // Act & Assert
99: await expect(getProjects()).rejects.toThrow("Failed to fetch projects");
100: });
101: it("recovers after temporary errors", async () => {
102: // Arrange
103: const rateError = {
104: statusCode: 429,
105: message: "Too Many Requests",
106: details: { type: "rate_limit", description: "Rate limit exceeded" }
107: };
108: const mockProjects = [{
109: id: "1",
110: name: "Test Project",
111: description: "Test Description",
112: subdescription: "Test Subdescription",
113: projectimage: { asset: { _ref: "test" } },
114: urlwww: [],
115: urlgithub: []
116: }];
117: // First call fails with rate limit
118: (client.fetch as jest.Mock).mockRejectedValueOnce(rateError);
119: // Second call succeeds
120: (client.fetch as jest.Mock).mockResolvedValueOnce(mockProjects);
121: // First call should fail
122: await expect(getProjects()).rejects.toThrow("Rate limit exceeded");
123: // Second call should succeed
124: const result = await getProjects();
125: expect(result).toEqual(mockProjects);
126: });
127: });
128: });
4: interface ErrorTestCase {
5: name: string;
6: error: {
7: statusCode?: number;
8: message: string;
9: details?: {
10: type: string;
11: description: string;
12: };
13: name?: string;
14: };
15: expectedErrorMessage: string;
16: }
17: // Mock the Sanity client
18: jest.mock("@/lib/sanity/client", () => ({
19: client: {
20: fetch: jest.fn(),
21: },
22: }));
23: describe("getProjects", () => {
24: beforeEach(() => {
25: jest.clearAllMocks();
26: });
27: it("fetches projects successfully", async () => {
28: // Arrange
29: const mockProjects = [
30: {
31: id: "1",
32: name: "Test Project",
33: description: "Test Description",
34: subdescription: "Test Subdescription",
35: projectimage: { asset: { _ref: "test" } },
36: urlwww: [],
37: urlgithub: [],
38: },
39: ];
40: const expectedFetchOptions = {
41: next: { revalidate: 3600 },
42: };
43: (client.fetch as jest.Mock).mockResolvedValueOnce(mockProjects);
44: // Act
45: const result = await getProjects();
46: // Assert
47: expect(result).toEqual(mockProjects);
48: expect(client.fetch).toHaveBeenCalledWith(
49: projectsQuery,
50: {},
51: expectedFetchOptions,
52: );
53: });
54: describe("error handling", () => {
55: const testErrorHandling = async ({ name, error, expectedErrorMessage }: ErrorTestCase) => {
56: it(name, async () => {
57: // Arrange
58: (client.fetch as jest.Mock).mockRejectedValueOnce(error);
59: // Act & Assert
60: await expect(getProjects()).rejects.toThrow(expectedErrorMessage);
61: });
62: };
63: const errorCases: ErrorTestCase[] = [
64: {
65: name: "handles authentication errors (401)",
66: error: {
67: statusCode: 401,
68: message: "Invalid token",
69: details: { type: "credentials", description: "Invalid token provided" }
70: },
71: expectedErrorMessage: "Authentication failed"
72: },
73: {
74: name: "handles permission errors (403)",
75: error: {
76: statusCode: 403,
77: message: "Insufficient permissions",
78: details: { type: "authorization", description: "Missing read access" }
79: },
80: expectedErrorMessage: "Insufficient permissions"
81: },
82: {
83: name: "handles rate limiting (429)",
84: error: {
85: statusCode: 429,
86: message: "Too Many Requests",
87: details: { type: "rate_limit", description: "Rate limit exceeded" }
88: },
89: expectedErrorMessage: "Rate limit exceeded"
90: },
91: {
92: name: "handles malformed GROQ queries (400)",
93: error: {
94: statusCode: 400,
95: message: "Invalid GROQ query",
96: details: { type: "query_error", description: "Syntax error in GROQ query" }
97: },
98: expectedErrorMessage: "Sanity API error: Invalid GROQ query"
99: },
100: {
101: name: "handles network timeouts",
102: error: Object.assign(new Error("Network timeout"), { name: "TimeoutError" }),
103: expectedErrorMessage: "Request timed out"
104: },
105: {
106: name: "handles generic fetch errors",
107: error: {
108: message: "Fetch failed"
109: },
110: expectedErrorMessage: "Failed to fetch projects"
111: }
112: ];
113: errorCases.forEach(testErrorHandling);
114: it("recovers after temporary errors", async () => {
115: // Arrange
116: const rateError = {
117: statusCode: 429,
118: message: "Too Many Requests",
119: details: { type: "rate_limit", description: "Rate limit exceeded" }
120: };
121: const mockProjects = [{
122: id: "1",
123: name: "Test Project",
124: description: "Test Description",
125: subdescription: "Test Subdescription",
126: projectimage: { asset: { _ref: "test" } },
127: urlwww: [],
128: urlgithub: []
129: }];
130: // First call fails with rate limit
131: (client.fetch as jest.Mock).mockRejectedValueOnce(rateError);
132: // Second call succeeds
133: (client.fetch as jest.Mock).mockResolvedValueOnce(mockProjects);
134: // First call should fail
135: await expect(getProjects()).rejects.toThrow("Rate limit exceeded");
136: // Second call should succeed
137: const result = await getProjects();
138: expect(result).toEqual(mockProjects);
139: });
140: });
141: });
````

## File: src/__tests__/Prosjekter/error.test.tsx
Expand Down Expand Up @@ -10425,7 +10438,7 @@ tsconfig.json
14: "author": "",
15: "license": "ISC",
16: "peerDependencies": {
17: "eslint": ">=9.19.0"
17: "eslint": ">=9.20.0"
18: }
19: }
````
Expand Down Expand Up @@ -11049,8 +11062,8 @@ tsconfig.json
23: "devDependencies": {
24: "@sanity/eslint-config-studio": "^5.0.1",
25: "@types/react": "^19.0.8",
26: "eslint": "^9.19.0",
27: "prettier": "^3.4.2",
26: "eslint": "^9.20.0",
27: "prettier": "^3.5.0",
28: "typescript": "^5.7.3"
29: },
30: "prettier": {
Expand Down Expand Up @@ -13737,9 +13750,9 @@ tsconfig.json
34: "cookie": "^1.0.2",
35: "envalid": "^8.0.0",
36: "jest": "^29.7.0",
37: "motion": "^12.4.0",
37: "motion": "^12.4.1",
38: "next": "15.1.6",
39: "next-sanity": "^9.8.51",
39: "next-sanity": "^9.8.54",
40: "path-to-regexp": "^8.2.0",
41: "react": "^19.0.0",
42: "react-dom": "^19.0.0",
Expand Down Expand Up @@ -13771,7 +13784,7 @@ tsconfig.json
68: "axe-core": "^4.10.2",
69: "cypress": "13.17.0",
70: "cypress-axe": "^1.6.0",
71: "eslint": "9.19.0",
71: "eslint": "9.20.0",
72: "eslint-config-next": "15.1.6",
73: "eslint-plugin-jest": "^28.11.0",
74: "eslint-plugin-jsx-a11y": "^6.10.2",
Expand All @@ -13784,7 +13797,7 @@ tsconfig.json
81: "jest-extended": "^4.0.2",
82: "jsdom-testing-mocks": "^1.13.1",
83: "postcss": "^8.5.1",
84: "prettier": "3.4.2",
84: "prettier": "3.5.0",
85: "tailwindcss": "^3.4.17",
86: "ts-jest": "^29.2.5",
87: "typescript": "^5.7.3",
Expand Down
Loading

0 comments on commit 2c6c9ef

Please sign in to comment.