-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2. Amending Tooltip function in Dashboard's Chip to disappear when the pulse animation is active. 3. Amending datagrid tooltips to disable interactivity with the text itself, ensuring that user can move from one button to the next without accidentally holding the tooltip open.
- Loading branch information
1 parent
c1127a1
commit f4390e7
Showing
205 changed files
with
4,577 additions
and
4,574 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,22 @@ | ||
module.exports = { | ||
parser: "@typescript-eslint/parser", | ||
extends: ["next", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"], | ||
parser: '@typescript-eslint/parser', | ||
extends: ['next', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'], | ||
settings: { | ||
next: { | ||
rootDir: "." | ||
rootDir: '.' | ||
} | ||
}, | ||
plugins: ["@typescript-eslint", "unused-imports", "prettier", "import"], | ||
plugins: ['@typescript-eslint', 'unused-imports', 'prettier', 'import'], | ||
rules: { | ||
"react-hooks/exhaustive-deps": "off", | ||
semi: ["error", "always"], | ||
"unused-imports/no-unused-imports": "error", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-unused-vars": "off", | ||
"unused-imports/no-unused-vars": "off", | ||
"react-hooks/rules-of-hooks": "off", | ||
"no-case-declarations": "off", | ||
"prettier/prettier": "error", | ||
"import/order": [ | ||
"error", | ||
{ | ||
groups: [["builtin", "external", "internal"]], | ||
"newlines-between": "always" | ||
} | ||
] | ||
'react-hooks/exhaustive-deps': 'off', | ||
semi: ['error', 'always'], | ||
'unused-imports/no-unused-imports': 'error', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-unused-vars': 'off', | ||
'@typescript-eslint/no-var-requires': 'off', | ||
'unused-imports/no-unused-vars': 'off', | ||
'react-hooks/rules-of-hooks': 'off', | ||
'no-case-declarations': 'off', | ||
'prettier/prettier': 'error' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,94 @@ | ||
import { describe, it, expect, vi, beforeEach } from "vitest"; | ||
import { GET } from "@/app/api/fetchall/[[...slugs]]/route"; | ||
import { getConn, runQuery } from "@/components/processors/processormacros"; | ||
import MapperFactory, { IDataMapper } from "@/config/datamapper"; | ||
import { createMocks } from "node-mocks-http"; | ||
import { NextRequest } from "next/server"; | ||
import { describe, it, expect, vi, beforeEach } from 'vitest'; | ||
import { GET } from '@/app/api/fetchall/[[...slugs]]/route'; | ||
import { getConn, runQuery } from '@/components/processors/processormacros'; | ||
import MapperFactory, { IDataMapper } from '@/config/datamapper'; | ||
import { createMocks } from 'node-mocks-http'; | ||
import { NextRequest } from 'next/server'; | ||
|
||
// Mocking getConn and runQuery functions | ||
vi.mock("@/components/processors/processormacros", () => ({ | ||
vi.mock('@/components/processors/processormacros', () => ({ | ||
getConn: vi.fn(), | ||
runQuery: vi.fn() | ||
})); | ||
|
||
// Mocking MapperFactory | ||
vi.mock("@/config/datamapper", () => ({ | ||
vi.mock('@/config/datamapper', () => ({ | ||
default: { | ||
getMapper: vi.fn() | ||
} | ||
})); | ||
|
||
describe("GET /api/fetchall/[[...slugs]]", () => { | ||
describe('GET /api/fetchall/[[...slugs]]', () => { | ||
beforeEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
it("should return 500 if schema is not provided", async () => { | ||
it('should return 500 if schema is not provided', async () => { | ||
const { req } = createMocks({ | ||
method: "GET", | ||
url: "http://localhost/api/fetchall/plots" | ||
method: 'GET', | ||
url: 'http://localhost/api/fetchall/plots' | ||
}); | ||
|
||
const mockReq = new NextRequest(req.url); | ||
|
||
await expect(GET(mockReq, { params: { slugs: ["plots"] } })).rejects.toThrow("Schema selection was not provided to API endpoint"); | ||
await expect(GET(mockReq, { params: { slugs: ['plots'] } })).rejects.toThrow('Schema selection was not provided to API endpoint'); | ||
}); | ||
|
||
it("should return 500 if fetchType is not provided", async () => { | ||
it('should return 500 if fetchType is not provided', async () => { | ||
const { req } = createMocks({ | ||
method: "GET", | ||
url: "http://localhost/api/fetchall?schema=test_schema" | ||
method: 'GET', | ||
url: 'http://localhost/api/fetchall?schema=test_schema' | ||
}); | ||
|
||
const mockReq = new NextRequest(req.url); | ||
|
||
await expect(GET(mockReq, { params: { slugs: [] } })).rejects.toThrow("fetchType was not correctly provided"); | ||
await expect(GET(mockReq, { params: { slugs: [] } })).rejects.toThrow('fetchType was not correctly provided'); | ||
}); | ||
|
||
it("should return 200 and data if query is successful", async () => { | ||
it('should return 200 and data if query is successful', async () => { | ||
const mockConn = { release: vi.fn() }; | ||
(getConn as ReturnType<typeof vi.fn>).mockResolvedValue(mockConn); | ||
const mockResults = [{ PlotID: 1, PlotName: "Plot 1" }]; | ||
const mockResults = [{ PlotID: 1, PlotName: 'Plot 1' }]; | ||
(runQuery as ReturnType<typeof vi.fn>).mockResolvedValue(mockResults); | ||
|
||
const mockMapper: IDataMapper<any, any> = { | ||
mapData: vi.fn().mockReturnValue([{ plotID: 1, plotName: "Plot 1" }]), | ||
mapData: vi.fn().mockReturnValue([{ plotID: 1, plotName: 'Plot 1' }]), | ||
demapData: vi.fn() | ||
}; | ||
(MapperFactory.getMapper as ReturnType<typeof vi.fn>).mockReturnValue(mockMapper); | ||
|
||
const { req } = createMocks({ | ||
method: "GET", | ||
url: "http://localhost/api/fetchall/plots?schema=test_schema" | ||
method: 'GET', | ||
url: 'http://localhost/api/fetchall/plots?schema=test_schema' | ||
}); | ||
|
||
const mockReq = new NextRequest(req.url); | ||
const response = await GET(mockReq, { params: { slugs: ["plots"] } }); | ||
const response = await GET(mockReq, { params: { slugs: ['plots'] } }); | ||
|
||
expect(response.status).toBe(200); | ||
const data = await response.json(); | ||
expect(data).toEqual([{ plotID: 1, plotName: "Plot 1" }]); | ||
expect(data).toEqual([{ plotID: 1, plotName: 'Plot 1' }]); | ||
expect(getConn).toHaveBeenCalled(); | ||
expect(runQuery).toHaveBeenCalledWith(mockConn, expect.stringContaining("SELECT")); | ||
expect(runQuery).toHaveBeenCalledWith(mockConn, expect.stringContaining('SELECT')); | ||
expect(mockMapper.mapData).toHaveBeenCalledWith(mockResults); | ||
expect(mockConn.release).toHaveBeenCalled(); | ||
}); | ||
|
||
it("should return 500 if there is a database error", async () => { | ||
it('should return 500 if there is a database error', async () => { | ||
const mockConn = { release: vi.fn() }; | ||
(getConn as ReturnType<typeof vi.fn>).mockResolvedValue(mockConn); | ||
(runQuery as ReturnType<typeof vi.fn>).mockRejectedValue(new Error("Database error")); | ||
(runQuery as ReturnType<typeof vi.fn>).mockRejectedValue(new Error('Database error')); | ||
|
||
const { req } = createMocks({ | ||
method: "GET", | ||
url: "http://localhost/api/fetchall/plots?schema=test_schema" | ||
method: 'GET', | ||
url: 'http://localhost/api/fetchall/plots?schema=test_schema' | ||
}); | ||
|
||
const mockReq = new NextRequest(req.url); | ||
|
||
await expect(GET(mockReq, { params: { slugs: ["plots"] } })).rejects.toThrow("Call failed"); | ||
await expect(GET(mockReq, { params: { slugs: ['plots'] } })).rejects.toThrow('Call failed'); | ||
expect(getConn).toHaveBeenCalled(); | ||
expect(runQuery).toHaveBeenCalledWith(mockConn, expect.stringContaining("SELECT")); | ||
expect(runQuery).toHaveBeenCalledWith(mockConn, expect.stringContaining('SELECT')); | ||
expect(mockConn.release).toHaveBeenCalled(); | ||
}); | ||
}); |
Oops, something went wrong.