-
-
-
-
-
-
-
-
-
-
-
+ {!showSpatial && (
+
-
+ )}
@@ -64,17 +54,18 @@ const Opening: React.FC = () => {
-
+
-
-
- >
- );
- };
+ >
+ );
+};
export default Opening;
diff --git a/frontend/src/services/OpeningService.js b/frontend/src/services/OpeningService.js
index c04bb433..20824f71 100644
--- a/frontend/src/services/OpeningService.js
+++ b/frontend/src/services/OpeningService.js
@@ -2,9 +2,9 @@ import axios from 'axios';
import { getAuthIdToken } from './AuthService';
export async function fetchRecentOpenings() {
- let authToken = await getAuthIdToken();
+ let authToken = getAuthIdToken();
try {
- const response = await axios.get('https://nr-silva-test-backend.apps.silver.devops.gov.bc.ca/api/openings/recent-openings?page=0&perPage=15', {
+ const response = await axios.get('https://nr-silva-test-backend.apps.silver.devops.gov.bc.ca/api/openings/recent-openings?page=0&perPage=100', {
headers: {
Authorization: `Bearer ${authToken}`
}
diff --git a/frontend/src/setupTests.ts b/frontend/src/setupTests.ts
index 8f2609b7..ef3e1633 100644
--- a/frontend/src/setupTests.ts
+++ b/frontend/src/setupTests.ts
@@ -3,3 +3,64 @@
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';
+import { expect, afterEach, vi } from 'vitest';
+import { cleanup } from '@testing-library/react';
+import * as matchers from '@testing-library/jest-dom/matchers';
+
+expect.extend(matchers);
+
+// runs a cleanup after each test case (e.g. clearing jsdom)
+afterEach(() => {
+ cleanup();
+});
+
+window.matchMedia = window.matchMedia || function() {
+ return {
+ matches: false,
+ addListener: function() {},
+ removeListener: function() {}
+ };
+};
+
+global.ResizeObserver = vi.fn().mockImplementation(() => ({
+ observe: vi.fn(),
+ unobserve: vi.fn(),
+ disconnect: vi.fn(),
+}));
+
+Object.defineProperty(global.SVGElement.prototype, 'getScreenCTM', {
+ writable: true,
+ value: vi.fn(),
+});
+
+Object.defineProperty(global.SVGElement.prototype, 'getBBox', {
+ writable: true,
+ value: vi.fn().mockReturnValue({
+ x: 0,
+ y: 0,
+ }),
+});
+
+Object.defineProperty(global.SVGElement.prototype, 'getComputedTextLength', {
+ writable: true,
+ value: vi.fn().mockReturnValue(220),
+});
+
+Object.defineProperty(global.SVGElement.prototype, 'transform', {
+ writable: true,
+ value: {
+ baseVal: {
+ consolidate: vi.fn(() => {})
+ },
+ }
+});
+
+Object.defineProperty(global.SVGElement.prototype, 'createSVGMatrix', {
+ writable: true,
+ value: vi.fn().mockReturnValue({
+ x: 10,
+ y: 10,
+ inverse: () => {},
+ multiply: () => {},
+ }),
+});
diff --git a/frontend/src/types/MapLayer.ts b/frontend/src/types/MapLayer.ts
new file mode 100644
index 00000000..e1b5be88
--- /dev/null
+++ b/frontend/src/types/MapLayer.ts
@@ -0,0 +1,8 @@
+export type MapLayer = {
+ key: string;
+ name: string;
+ pathOptions: object;
+ popup?: JSX.Element;
+ bounds: number[][][];
+ properties: object;
+};
diff --git a/frontend/src/types/OpeningPolygon.ts b/frontend/src/types/OpeningPolygon.ts
new file mode 100644
index 00000000..4d848652
--- /dev/null
+++ b/frontend/src/types/OpeningPolygon.ts
@@ -0,0 +1,9 @@
+export type OpeningPolygon = {
+ key: string;
+ bounds: number[][][];
+ properties: object;
+ id: string;
+ positionLat: number;
+ positionLong: number;
+ popup?: JSX.Element;
+};
diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts
index 7ad084ab..9c40bd47 100644
--- a/frontend/vite.config.ts
+++ b/frontend/vite.config.ts
@@ -1,10 +1,10 @@
import { fileURLToPath, URL } from 'node:url';
-import { defineConfig } from 'vite'
+import { defineConfig, UserConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
- const config = {
+ const config: UserConfig = {
define: {} as any,
plugins: [
{
@@ -35,30 +35,19 @@ export default defineConfig(({ mode }) => {
port: 3000,
hmr: {
overlay: false
- }
+ },
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
- test: {
- globals: true,
- environment: 'jsdom',
- setupFiles: './src/setupTests.ts',
- css: true,
- reporters: ['verbose'],
- coverage: {
- provider: 'v8',
- reporter: ['text', 'json', 'html'],
- include: ['src/**/*'],
- exclude: [],
- }
- },
};
if (mode === 'development') {
- config.define.global = {};
+ if (config.define) {
+ config.define.global = {};
+ }
}
return config;
diff --git a/frontend/vitest.config.ts b/frontend/vitest.config.ts
new file mode 100644
index 00000000..40a3dcfe
--- /dev/null
+++ b/frontend/vitest.config.ts
@@ -0,0 +1,23 @@
+///
+import { defineConfig } from 'vite'
+
+export default defineConfig({
+ test: {
+ globals: true,
+ environment: 'jsdom',
+ setupFiles: './src/setupTests.ts',
+ css: true,
+ reporters: ['verbose'],
+ coverage: {
+ provider: 'v8',
+ reporter: ['text', 'json', 'html', 'lcov'],
+ include: ['src/**/*'],
+ exclude: [],
+ },
+ server: {
+ deps: {
+ inline: [/^(?!.*vitest).*$/]
+ }
+ },
+ },
+});