@northern.tech/testing 0.8.1 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mockData.cjs +1302 -0
- package/dist/mockData.cjs.map +1 -0
- package/dist/mockData.d.cts +662 -0
- package/dist/mockData.d.ts +662 -0
- package/dist/mockData.js +1280 -0
- package/dist/mockData.js.map +1 -0
- package/dist/public/baseTestConfig.json +17 -0
- package/dist/requestHandlers/deploymentHandlers.cjs +193 -0
- package/dist/requestHandlers/deploymentHandlers.cjs.map +1 -0
- package/dist/requestHandlers/deploymentHandlers.d.cts +7 -0
- package/dist/requestHandlers/deploymentHandlers.d.ts +7 -0
- package/dist/requestHandlers/deploymentHandlers.js +191 -0
- package/dist/requestHandlers/deploymentHandlers.js.map +1 -0
- package/dist/requestHandlers/deviceHandlers.cjs +432 -0
- package/dist/requestHandlers/deviceHandlers.cjs.map +1 -0
- package/dist/requestHandlers/deviceHandlers.d.cts +22 -0
- package/dist/requestHandlers/deviceHandlers.d.ts +22 -0
- package/dist/requestHandlers/deviceHandlers.js +428 -0
- package/dist/requestHandlers/deviceHandlers.js.map +1 -0
- package/dist/requestHandlers/monitorHandlers.cjs +23 -0
- package/dist/requestHandlers/monitorHandlers.cjs.map +1 -0
- package/dist/requestHandlers/monitorHandlers.d.cts +7 -0
- package/dist/requestHandlers/monitorHandlers.d.ts +7 -0
- package/dist/requestHandlers/monitorHandlers.js +21 -0
- package/dist/requestHandlers/monitorHandlers.js.map +1 -0
- package/dist/requestHandlers/organizationHandlers.cjs +312 -0
- package/dist/requestHandlers/organizationHandlers.cjs.map +1 -0
- package/dist/requestHandlers/organizationHandlers.d.cts +7 -0
- package/dist/requestHandlers/organizationHandlers.d.ts +7 -0
- package/dist/requestHandlers/organizationHandlers.js +310 -0
- package/dist/requestHandlers/organizationHandlers.js.map +1 -0
- package/dist/requestHandlers/releaseHandlers.cjs +161 -0
- package/dist/requestHandlers/releaseHandlers.cjs.map +1 -0
- package/dist/requestHandlers/releaseHandlers.d.cts +7 -0
- package/dist/requestHandlers/releaseHandlers.d.ts +7 -0
- package/dist/requestHandlers/releaseHandlers.js +159 -0
- package/dist/requestHandlers/releaseHandlers.js.map +1 -0
- package/dist/requestHandlers/requestHandlers.cjs +28 -0
- package/dist/requestHandlers/requestHandlers.cjs.map +1 -0
- package/dist/requestHandlers/requestHandlers.d.cts +6 -0
- package/dist/requestHandlers/requestHandlers.d.ts +7 -0
- package/dist/requestHandlers/requestHandlers.js +27 -0
- package/dist/requestHandlers/requestHandlers.js.map +1 -0
- package/dist/requestHandlers/userHandlers.cjs +141 -0
- package/dist/requestHandlers/userHandlers.cjs.map +1 -0
- package/dist/requestHandlers/userHandlers.d.cts +7 -0
- package/dist/requestHandlers/userHandlers.d.ts +7 -0
- package/dist/requestHandlers/userHandlers.js +139 -0
- package/dist/requestHandlers/userHandlers.js.map +1 -0
- package/dist/setupTests.cjs +173 -0
- package/dist/setupTests.cjs.map +1 -0
- package/dist/setupTests.d.cts +79 -0
- package/dist/setupTests.d.ts +79 -0
- package/dist/setupTests.js +135 -0
- package/dist/setupTests.js.map +1 -0
- package/dist/theme/light.cjs +9 -0
- package/dist/theme/light.cjs.map +1 -0
- package/dist/theme/light.d.cts +7 -0
- package/dist/theme/light.d.ts +7 -0
- package/dist/theme/light.js +8 -0
- package/dist/theme/light.js.map +1 -0
- package/dist/theme/mui.d.cjs +0 -0
- package/dist/theme/mui.d.cts +11 -0
- package/dist/theme/mui.d.ts +11 -0
- package/dist/utils.cjs +21 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +8 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.js +18 -0
- package/dist/utils.js.map +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userHandlers.js","names":["defaultUserId","userId"],"sources":["../../src/requestHandlers/userHandlers.ts"],"sourcesContent":["// Copyright 2020 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//@ts-nocheck\nimport { APPLICATION_JWT_CONTENT_TYPE, useradmApiUrl, useradmApiUrlv2 } from '@northern.tech/utils/constants';\nimport { HttpResponse, http } from 'msw';\n\nimport { accessTokens, defaultPassword, userId as defaultUserId, mockApiResponses, permissionSets, rbacRoles, testSsoId, token } from '../mockData';\n\nexport const userHandlers = [\n http.post(`${useradmApiUrl}/auth/login`, ({ request }) => {\n const authHeader = request.headers.get('authorization');\n const authInfo = atob(authHeader?.split(' ')[1]);\n const [user, password] = authInfo.split(':');\n\n if (!password) {\n return HttpResponse.json({ id: testSsoId, kind: 'sso/saml' });\n } else if (password !== defaultPassword) {\n return new HttpResponse(null, { status: 401 });\n } else if (user.includes('limited')) {\n return new HttpResponse('limitedToken', { headers: { 'Content-Type': APPLICATION_JWT_CONTENT_TYPE } });\n } else if (user.includes('2fa')) {\n return new HttpResponse(JSON.stringify({ error: '2fa needed' }), { status: 401 });\n }\n\n return new HttpResponse(token, { headers: { 'Content-Type': APPLICATION_JWT_CONTENT_TYPE } });\n }),\n http.get(`https://hosted.mender.io${useradmApiUrl}/auth/magic/:id`, ({ params: { id } }) => {\n if (id) {\n return new HttpResponse('test', { headers: { 'Set-Cookie': 'JWT=test' } });\n }\n return new HttpResponse(null, { status: 400 });\n }),\n http.post(`${useradmApiUrl}/auth/logout`, () => new HttpResponse(null, { status: 200 })),\n http.post(`${useradmApiUrl}/auth/password-reset/:status`, async ({ params: { status }, request }) => {\n const { email, secret_hash, password } = await request.json();\n if (!['start', 'complete'].includes(status) && ![email, secret_hash, password].some(item => item)) {\n return new HttpResponse(null, { status: 560 });\n }\n if (status === 'start' && email) {\n return new HttpResponse(null, { status: 200 });\n }\n if (status === 'complete' && secret_hash && password) {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 561 });\n }),\n http.put(`${useradmApiUrl}/2faverify`, async ({ request }) => {\n const { token2fa } = await request.json();\n if (!token2fa) {\n return new HttpResponse(null, { status: 562 });\n }\n return new HttpResponse(null, { status: 200 });\n }),\n http.get(`${useradmApiUrl}/users`, () => HttpResponse.json(Object.values(mockApiResponses.users.byId))),\n http.get(`${useradmApiUrl}/users/me`, ({ request }) => {\n const authHeader = request.headers.get('authorization');\n if (authHeader?.includes('limited')) {\n return new HttpResponse(JSON.stringify({ error: 'forbidden by role-based access control' }), { status: 403 });\n }\n return HttpResponse.json(mockApiResponses.users.byId[defaultUserId]);\n }),\n http.get(`${useradmApiUrl}/users/exists`, ({ request }) => {\n const url = new URL(request.url);\n const email = url.searchParams.get('email');\n if (!decodeURIComponent(email).includes('child+123')) {\n return new HttpResponse(null, { status: 578 });\n }\n return HttpResponse.json({ exists: true });\n }),\n http.get(`${useradmApiUrl}/users/:userId`, ({ params: { userId } }) => {\n if (userId === 'me' || mockApiResponses.users.byId[userId]) {\n const user = userId === 'me' ? defaultUserId : userId;\n return HttpResponse.json(mockApiResponses.users.byId[user]);\n }\n return new HttpResponse(null, { status: 563 });\n }),\n http.post(`${useradmApiUrl}/users`, async ({ request }) => {\n const { email, password } = await request.json();\n if (email === 'test@test.com' || [email, password].every(value => value)) {\n return HttpResponse.json(mockApiResponses.users.byId.a1);\n }\n return new HttpResponse(null, { status: 564 });\n }),\n http.put(`${useradmApiUrl}/users/:userId`, async ({ params: { userId }, request }) => {\n const { email, password, current_password } = await request.json();\n if (current_password === 'bad_password') {\n return new HttpResponse(null, { status: 401 });\n }\n if (\n (mockApiResponses.users.byId[userId] && [email, password].some(value => Object.values(mockApiResponses.users.byId[userId]).includes(value))) ||\n email === 'test@test.com'\n ) {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 565 });\n }),\n http.delete(\n `${useradmApiUrl}/users/:userId`,\n ({ params: { userId } }) => new HttpResponse(null, { status: mockApiResponses.users.byId[userId] ? 200 : 566 })\n ),\n http.get(`${useradmApiUrl}/roles`, () => HttpResponse.json(rbacRoles)),\n http.post(`${useradmApiUrl}/roles`, async ({ request }) => {\n const { name, permissions } = await request.json();\n if (\n [name, permissions].every(value => value) &&\n permissions.every(permission => permission.action && permission.object && permission.object.type && permission.object.value)\n ) {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 567 });\n }),\n http.put(`${useradmApiUrl}/roles/:roleId`, async ({ params: { roleId }, request }) => {\n const { description, name, permissions } = await request.json();\n if (mockApiResponses.users.rolesById[roleId] && [description, name, permissions].some(value => value)) {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 568 });\n }),\n http.post(`${useradmApiUrlv2}/support/feedback/product`, async () => new HttpResponse(null, { status: 200 })),\n http.delete(\n `${useradmApiUrl}/roles/:roleId`,\n ({ params: { roleId } }) => new HttpResponse(null, { status: mockApiResponses.users.rolesById[roleId] ? 200 : 569 })\n ),\n http.get(`${useradmApiUrlv2}/roles`, () => HttpResponse.json(rbacRoles)),\n http.get(`${useradmApiUrlv2}/roles/:roleId`, async ({ params: { roleId } }) => {\n if (mockApiResponses.users.rolesById[roleId]) {\n return HttpResponse.json(mockApiResponses.users.rolesById[roleId]);\n }\n return new HttpResponse(null, { status: 571 });\n }),\n http.post(`${useradmApiUrlv2}/roles`, async ({ request }) => {\n const { name, permission_sets_with_scope } = await request.json();\n if (\n !!name &&\n permission_sets_with_scope.every(permission => permission.name && permissionSets.find(permissionSet => permissionSet.name === permission.name))\n ) {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 572 });\n }),\n http.put(`${useradmApiUrlv2}/roles/:roleId`, async ({ params: { roleId }, request }) => {\n const { description, name, permission_sets_with_scope } = await request.json();\n if (mockApiResponses.users.rolesById[roleId] && [description, name, permission_sets_with_scope].some(value => value)) {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 573 });\n }),\n http.delete(`${useradmApiUrlv2}/roles/:roleId`, ({ params: { roleId } }) => {\n if (mockApiResponses.users.rolesById[roleId]) {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 574 });\n }),\n http.get(`${useradmApiUrl}/settings`, () => HttpResponse.json(mockApiResponses.users.globalSettings)),\n http.post(`${useradmApiUrl}/settings`, () => new HttpResponse(null, { status: 200 })),\n http.get(`${useradmApiUrl}/settings/me`, () => HttpResponse.json(mockApiResponses.users.userSettings)),\n http.post(`${useradmApiUrl}/settings/me`, () => new HttpResponse(null, { status: 200 })),\n http.get(`${useradmApiUrl}/settings/tokens`, () => HttpResponse.json(accessTokens)),\n http.post(`${useradmApiUrl}/settings/tokens`, () => HttpResponse.json('aNewToken')),\n http.delete(\n `${useradmApiUrl}/settings/tokens/:tokenId`,\n ({ params: { tokenId } }) => new HttpResponse(null, { status: tokenId === 'some-id-1' ? 200 : 577 })\n ),\n http.get(`${useradmApiUrl}/2faqr`, () => HttpResponse.json({ qr: btoa('test') })),\n http.post(`${useradmApiUrl}/users/:userId/2fa/enable`, ({ params: { userId } }) => {\n if (mockApiResponses.users.byId[userId] || userId === 'me') {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 570 });\n }),\n http.post(`${useradmApiUrl}/users/:userId/2fa/disable`, ({ params: { userId } }) => {\n if (mockApiResponses.users.byId[userId] || userId === 'me') {\n return new HttpResponse(null, { status: 200 });\n }\n return new HttpResponse(null, { status: 571 });\n }),\n http.post(`${useradmApiUrl}/auth/verify-email/start`, () => new HttpResponse(null, { status: 200 })),\n http.post(`${useradmApiUrl}/auth/verify-email/complete`, async ({ request }) => {\n const { secret_hash } = await request.json();\n return new HttpResponse(null, { status: secret_hash === 'superSecret' ? 200 : 576 });\n }),\n http.get(`${useradmApiUrlv2}/permission_sets`, () => HttpResponse.json(permissionSets)),\n http.post(`${useradmApiUrl}/users/:userId/assign`, async ({ request }) => {\n const { tenant_ids } = await request.json();\n return new HttpResponse(null, { status: tenant_ids.length ? 200 : 577 });\n }),\n http.get(`${useradmApiUrl}/users/tenants/:tenantId/token`, () => HttpResponse.text('differentToken'))\n];\n"],"mappings":";;;;AAmBA,MAAa,eAAe;CAC1B,KAAK,KAAK,GAAG,cAAc,eAAe,EAAE,cAAc;EACxD,MAAM,aAAa,QAAQ,QAAQ,IAAI,gBAAgB;EAEvD,MAAM,CAAC,MAAM,YADI,KAAK,YAAY,MAAM,IAAI,CAAC,GAAG,CACd,MAAM,IAAI;AAE5C,MAAI,CAAC,SACH,QAAO,aAAa,KAAK;GAAE,IAAI;GAAW,MAAM;GAAY,CAAC;WACpD,aAAA,uBACT,QAAO,IAAI,aAAa,MAAM,EAAE,QAAQ,KAAK,CAAC;WACrC,KAAK,SAAS,UAAU,CACjC,QAAO,IAAI,aAAa,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,8BAA8B,EAAE,CAAC;WAC7F,KAAK,SAAS,MAAM,CAC7B,QAAO,IAAI,aAAa,KAAK,UAAU,EAAE,OAAO,cAAc,CAAC,EAAE,EAAE,QAAQ,KAAK,CAAC;AAGnF,SAAO,IAAI,aAAa,OAAO,EAAE,SAAS,EAAE,gBAAgB,8BAA8B,EAAE,CAAC;GAC7F;CACF,KAAK,IAAI,2BAA2B,cAAc,mBAAmB,EAAE,QAAQ,EAAE,WAAW;AAC1F,MAAI,GACF,QAAO,IAAI,aAAa,QAAQ,EAAE,SAAS,EAAE,cAAc,YAAY,EAAE,CAAC;AAE5E,SAAO,IAAI,aAAa,MAAM,EAAE,QAAQ,KAAK,CAAC;GAC9C;CACF,KAAK,KAAK,GAAG,cAAc,qBAAqB,IAAI,aAAa,MAAM,EAAE,QAAQ,KAAK,CAAC,CAAC;CACxF,KAAK,KAAK,GAAG,cAAc,+BAA+B,OAAO,EAAE,QAAQ,EAAE,UA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,KAAK,eAAe,CAAC;CACvF,KAAK,KAAK,GAAG,cAAc,wBAAwB,OAAO,EAAE,cAAc;EACxE,MAAM,EAAE,eAAe,MAAM,QAAQ,MAAM;AAC3C,SAAO,IAAI,aAAa,MAAM,EAAE,QAAQ,WAAW,SAAS,MAAM,KAAK,CAAC;GACxE;CACF,KAAK,IAAI,GAAG,cAAc,uCAAuC,aAAa,KAAK,iBAAiB,CAAC;CACtG"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
const require_mockData = require("./mockData.cjs");
|
|
25
|
+
const require_utils = require("./utils.cjs");
|
|
26
|
+
let react = require("react");
|
|
27
|
+
react = __toESM(react);
|
|
28
|
+
let react_redux = require("react-redux");
|
|
29
|
+
let react_router_dom = require("react-router-dom");
|
|
30
|
+
let _emotion_jest = require("@emotion/jest");
|
|
31
|
+
let _mui_material_styles = require("@mui/material/styles");
|
|
32
|
+
let _northern_tech_utils_helpers = require("@northern.tech/utils/helpers");
|
|
33
|
+
let _reduxjs_toolkit = require("@reduxjs/toolkit");
|
|
34
|
+
require("@testing-library/jest-dom/vitest");
|
|
35
|
+
let _testing_library_react = require("@testing-library/react");
|
|
36
|
+
let vitest = require("vitest");
|
|
37
|
+
let worker_threads = require("worker_threads");
|
|
38
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
39
|
+
//#region src/setupTests.tsx
|
|
40
|
+
vitest.expect.addSnapshotSerializer((0, _emotion_jest.createSerializer)({ includeStyles: true }));
|
|
41
|
+
const TEST_LOCATION = "localhost";
|
|
42
|
+
const mockAbortController = {
|
|
43
|
+
abort: vitest.vi.fn(),
|
|
44
|
+
signal: {
|
|
45
|
+
addEventListener: () => {},
|
|
46
|
+
removeEventListener: () => {}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const oldWindowLocalStorage = window.localStorage;
|
|
50
|
+
const oldWindowLocation = window.location;
|
|
51
|
+
const oldWindowSessionStorage = window.sessionStorage;
|
|
52
|
+
vitest.vi.mock("uuid", () => ({ v4: () => "mock-uuid" }));
|
|
53
|
+
const storage = {};
|
|
54
|
+
global.HTMLCanvasElement.prototype.getContext = vitest.vi.fn();
|
|
55
|
+
const beforeAll = async () => {
|
|
56
|
+
delete window.location;
|
|
57
|
+
window.location = {
|
|
58
|
+
...oldWindowLocation,
|
|
59
|
+
hostname: TEST_LOCATION,
|
|
60
|
+
origin: "http://localhost",
|
|
61
|
+
assign: vitest.vi.fn(),
|
|
62
|
+
replace: vitest.vi.fn(),
|
|
63
|
+
reload: vitest.vi.fn()
|
|
64
|
+
};
|
|
65
|
+
delete window.sessionStorage;
|
|
66
|
+
window.sessionStorage = {
|
|
67
|
+
...oldWindowSessionStorage,
|
|
68
|
+
getItem: vitest.vi.fn(_northern_tech_utils_helpers.yes),
|
|
69
|
+
setItem: vitest.vi.fn(),
|
|
70
|
+
removeItem: vitest.vi.fn()
|
|
71
|
+
};
|
|
72
|
+
delete window.localStorage;
|
|
73
|
+
window.localStorage = {
|
|
74
|
+
...oldWindowLocalStorage,
|
|
75
|
+
getItem: vitest.vi.fn((name) => {
|
|
76
|
+
if (name === "JWT") return JSON.stringify({ token: require_mockData.token });
|
|
77
|
+
return storage[name];
|
|
78
|
+
}),
|
|
79
|
+
setItem: vitest.vi.fn((name) => storage[name]),
|
|
80
|
+
removeItem: vitest.vi.fn()
|
|
81
|
+
};
|
|
82
|
+
window.mender_environment = require_mockData.menderEnvironment;
|
|
83
|
+
window.ENV = "test";
|
|
84
|
+
global.AbortController = vitest.vi.fn().mockImplementation(function() {
|
|
85
|
+
return mockAbortController;
|
|
86
|
+
});
|
|
87
|
+
global.MessageChannel = worker_threads.MessageChannel;
|
|
88
|
+
global.ResizeObserver = vitest.vi.fn().mockImplementation(function() {
|
|
89
|
+
return {
|
|
90
|
+
observe: vitest.vi.fn(),
|
|
91
|
+
unobserve: vitest.vi.fn(),
|
|
92
|
+
disconnect: vitest.vi.fn()
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
window.RTCPeerConnection = () => ({
|
|
96
|
+
createOffer: () => {},
|
|
97
|
+
setLocalDescription: () => {},
|
|
98
|
+
createDataChannel: () => {}
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(navigator, "appVersion", {
|
|
101
|
+
value: "Test",
|
|
102
|
+
writable: true
|
|
103
|
+
});
|
|
104
|
+
const intersectionObserverMock = function() {
|
|
105
|
+
return {
|
|
106
|
+
observe: vitest.vi.fn(),
|
|
107
|
+
disconnect: vitest.vi.fn()
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
window.prompt = vitest.vi.fn();
|
|
111
|
+
window.IntersectionObserver = vitest.vi.fn().mockImplementation(intersectionObserverMock);
|
|
112
|
+
vitest.vi.spyOn(react.default, "useEffect").mockImplementation(react.default.useLayoutEffect);
|
|
113
|
+
const _jest = globalThis.jest;
|
|
114
|
+
globalThis.jest = { ...globalThis.jest };
|
|
115
|
+
vitest.vi.stubGlobal("jest", { advanceTimersByTime: vitest.vi.advanceTimersByTime.bind(vitest.vi) });
|
|
116
|
+
return () => void (globalThis.jest = _jest);
|
|
117
|
+
};
|
|
118
|
+
const beforeEach = () => {
|
|
119
|
+
vitest.vi.useFakeTimers({ now: require_mockData.mockDate });
|
|
120
|
+
vitest.vi.setSystemTime(require_mockData.mockDate);
|
|
121
|
+
};
|
|
122
|
+
const afterEach = async () => {
|
|
123
|
+
(0, _testing_library_react.cleanup)();
|
|
124
|
+
vitest.vi.runOnlyPendingTimers();
|
|
125
|
+
vitest.vi.useRealTimers();
|
|
126
|
+
};
|
|
127
|
+
const afterAll = async () => {
|
|
128
|
+
window.localStorage = oldWindowLocalStorage;
|
|
129
|
+
window.location = oldWindowLocation;
|
|
130
|
+
window.sessionStorage = oldWindowSessionStorage;
|
|
131
|
+
react.default.useEffect.mockRestore();
|
|
132
|
+
vitest.vi.unstubAllGlobals();
|
|
133
|
+
};
|
|
134
|
+
const customRender = (ui, options = {}) => {
|
|
135
|
+
const { preloadedState = { users: { currentSession: {
|
|
136
|
+
token: require_mockData.token,
|
|
137
|
+
expiresAt: void 0
|
|
138
|
+
} } }, ...remainder } = options;
|
|
139
|
+
const store = options.store ?? (0, _reduxjs_toolkit.configureStore)({ preloadedState });
|
|
140
|
+
const AllTheProviders = ({ children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mui_material_styles.ThemeProvider, {
|
|
141
|
+
theme: require_utils.theme,
|
|
142
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_router_dom.MemoryRouter, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_redux.Provider, {
|
|
143
|
+
store,
|
|
144
|
+
children
|
|
145
|
+
}) })
|
|
146
|
+
});
|
|
147
|
+
return {
|
|
148
|
+
store,
|
|
149
|
+
...(0, _testing_library_react.render)(ui, {
|
|
150
|
+
wrapper: AllTheProviders,
|
|
151
|
+
...remainder
|
|
152
|
+
})
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
//#endregion
|
|
156
|
+
exports.TEST_LOCATION = TEST_LOCATION;
|
|
157
|
+
exports.__toESM = __toESM;
|
|
158
|
+
exports.afterAll = afterAll;
|
|
159
|
+
exports.afterEach = afterEach;
|
|
160
|
+
exports.beforeAll = beforeAll;
|
|
161
|
+
exports.beforeEach = beforeEach;
|
|
162
|
+
exports.mockAbortController = mockAbortController;
|
|
163
|
+
exports.render = customRender;
|
|
164
|
+
Object.keys(_testing_library_react).forEach(function(k) {
|
|
165
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
166
|
+
enumerable: true,
|
|
167
|
+
get: function() {
|
|
168
|
+
return _testing_library_react[k];
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
//# sourceMappingURL=setupTests.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupTests.cjs","names":["expect","vi","yes","mockToken","menderEnvironment","MessageChannel","React","mockDate","ThemeProvider","theme","MemoryRouter","Provider"],"sources":["../src/setupTests.tsx"],"sourcesContent":["// Copyright 2025 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//@ts-nocheck\nimport React from 'react';\nimport { Provider } from 'react-redux';\nimport { MemoryRouter } from 'react-router-dom';\n\nimport { createSerializer } from '@emotion/jest';\nimport { ThemeProvider } from '@mui/material/styles';\n\nimport { yes } from '@northern.tech/utils/helpers';\nimport { configureStore } from '@reduxjs/toolkit';\nimport '@testing-library/jest-dom/vitest';\nimport { cleanup, render } from '@testing-library/react';\nimport { expect, vi } from 'vitest';\nimport { MessageChannel } from 'worker_threads';\n\nimport { menderEnvironment, mockDate, token as mockToken } from './mockData';\nimport { theme } from './utils';\n\nexpect.addSnapshotSerializer(createSerializer({ includeStyles: true }));\n\nexport const TEST_LOCATION = 'localhost';\n\nexport const mockAbortController: { abort: () => void; signal: { addEventListener: () => void; removeEventListener: () => void } } = {\n abort: vi.fn(),\n signal: { addEventListener: () => {}, removeEventListener: () => {} }\n};\n\nconst oldWindowLocalStorage = window.localStorage;\nconst oldWindowLocation = window.location;\nconst oldWindowSessionStorage = window.sessionStorage;\n\nvi.mock('uuid', () => ({ v4: () => 'mock-uuid' }));\n\nconst storage = {};\nglobal.HTMLCanvasElement.prototype.getContext = vi.fn();\n\nexport const beforeAll = async () => {\n // Temporarily workaround for bug in @testing-library/react when use user-event with `vi.useFakeTimers()`\n\n // Enable the mocking in tests.\n delete window.location;\n window.location = {\n ...oldWindowLocation,\n hostname: TEST_LOCATION,\n origin: 'http://localhost',\n assign: vi.fn(),\n replace: vi.fn(),\n reload: vi.fn()\n };\n delete window.sessionStorage;\n window.sessionStorage = {\n ...oldWindowSessionStorage,\n getItem: vi.fn(yes),\n setItem: vi.fn(),\n removeItem: vi.fn()\n };\n delete window.localStorage;\n window.localStorage = {\n ...oldWindowLocalStorage,\n getItem: vi.fn(name => {\n if (name === 'JWT') {\n return JSON.stringify({ token: mockToken });\n }\n return storage[name];\n }),\n setItem: vi.fn(name => storage[name]),\n removeItem: vi.fn()\n };\n window.mender_environment = menderEnvironment;\n window.ENV = 'test';\n global.AbortController = vi.fn().mockImplementation(function () {\n return mockAbortController;\n });\n global.MessageChannel = MessageChannel;\n global.ResizeObserver = vi.fn().mockImplementation(function () {\n return {\n observe: vi.fn(),\n unobserve: vi.fn(),\n disconnect: vi.fn()\n };\n });\n window.RTCPeerConnection = () => ({\n createOffer: () => {},\n setLocalDescription: () => {},\n createDataChannel: () => {}\n });\n\n Object.defineProperty(navigator, 'appVersion', { value: 'Test', writable: true });\n const intersectionObserverMock = function () {\n return {\n observe: vi.fn(),\n disconnect: vi.fn()\n };\n };\n window.prompt = vi.fn();\n window.IntersectionObserver = vi.fn().mockImplementation(intersectionObserverMock);\n vi.spyOn(React, 'useEffect').mockImplementation(React.useLayoutEffect);\n\n //TODO: remove, once https://github.com/testing-library/react-testing-library/issues/1197 resolved\n const _jest = globalThis.jest;\n\n globalThis.jest = {\n ...globalThis.jest\n };\n\n vi.stubGlobal('jest', {\n advanceTimersByTime: vi.advanceTimersByTime.bind(vi)\n });\n return () => void (globalThis.jest = _jest);\n};\n\nexport const beforeEach = () => {\n vi.useFakeTimers({ now: mockDate });\n vi.setSystemTime(mockDate);\n};\n\nexport const afterEach = async () => {\n cleanup();\n vi.runOnlyPendingTimers();\n vi.useRealTimers();\n};\n\nexport const afterAll = async () => {\n // restore `window.location` etc. to the original `jsdom` `Location` object\n window.localStorage = oldWindowLocalStorage;\n window.location = oldWindowLocation;\n window.sessionStorage = oldWindowSessionStorage;\n React.useEffect.mockRestore();\n vi.unstubAllGlobals();\n};\n\nconst customRender = (ui, options = {}) => {\n const { preloadedState = { users: { currentSession: { token: mockToken, expiresAt: undefined } } }, ...remainder } = options;\n const store = options.store ?? configureStore({ preloadedState });\n const AllTheProviders = ({ children }) => (\n <ThemeProvider theme={theme}>\n <MemoryRouter>\n <Provider store={store}>{children}</Provider>\n </MemoryRouter>\n </ThemeProvider>\n );\n return { store, ...render(ui, { wrapper: AllTheProviders, ...remainder }) };\n};\n\nexport * from '@testing-library/react';\n// override render method\n\nexport { customRender as render };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+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,EAAE,gBAAgB;EAAE,OAAOJ,iBAAAA;EAAW,WAAW,KAAA;EAAW,EAAE,EAAE,EAAE,GAAG,cAAc;CACrH,MAAM,QAAQ,QAAQ,UAAA,GAAA,iBAAA,gBAAwB,EAAE,gBAAgB,CAAC;CACjE,MAAM,mBAAmB,EAAE,eACzB,iBAAA,GAAA,kBAAA,KAACK,qBAAAA,eAAD;EAAe,OAAOC,cAAAA;YACpB,iBAAA,GAAA,kBAAA,KAACC,iBAAAA,cAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAACC,YAAAA,UAAD;GAAiB;GAAQ;GAAoB,CAAA,EAChC,CAAA;EACD,CAAA;AAElB,QAAO;EAAE;EAAO,IAAA,GAAA,uBAAA,QAAU,IAAI;GAAE,SAAS;GAAiB,GAAG;GAAW,CAAC;EAAE"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as _$react_dom_client0 from "react-dom/client";
|
|
2
|
+
import * as _$pretty_format0 from "pretty-format";
|
|
3
|
+
import * as _$_testing_library_dom0 from "@testing-library/dom";
|
|
4
|
+
import React from "react";
|
|
5
|
+
export * from "@testing-library/react";
|
|
6
|
+
|
|
7
|
+
//#region src/setupTests.d.ts
|
|
8
|
+
declare const TEST_LOCATION = "localhost";
|
|
9
|
+
declare const mockAbortController: {
|
|
10
|
+
abort: () => void;
|
|
11
|
+
signal: {
|
|
12
|
+
addEventListener: () => void;
|
|
13
|
+
removeEventListener: () => void;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
declare const beforeAll: () => Promise<() => undefined>;
|
|
17
|
+
declare const beforeEach: () => void;
|
|
18
|
+
declare const afterEach: () => Promise<void>;
|
|
19
|
+
declare const afterAll: () => Promise<void>;
|
|
20
|
+
declare const customRender: (ui: any, options?: {}) => {
|
|
21
|
+
container: HTMLElement;
|
|
22
|
+
baseElement: HTMLElement;
|
|
23
|
+
debug: (baseElement?: _$react_dom_client0.Container | (Element | Document) | Array<_$react_dom_client0.Container | (Element | Document)> | undefined, maxLength?: number | undefined, options?: _$pretty_format0.OptionsReceived | undefined) => void;
|
|
24
|
+
rerender: (ui: React.ReactNode) => void;
|
|
25
|
+
unmount: () => void;
|
|
26
|
+
asFragment: () => DocumentFragment;
|
|
27
|
+
getByLabelText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement;
|
|
28
|
+
getAllByLabelText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
29
|
+
queryByLabelText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement | null;
|
|
30
|
+
queryAllByLabelText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
31
|
+
findByLabelText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
32
|
+
findAllByLabelText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
33
|
+
getByPlaceholderText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement;
|
|
34
|
+
getAllByPlaceholderText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
35
|
+
queryByPlaceholderText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement | null;
|
|
36
|
+
queryAllByPlaceholderText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
37
|
+
findByPlaceholderText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
38
|
+
findAllByPlaceholderText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
39
|
+
getByText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement;
|
|
40
|
+
getAllByText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
41
|
+
queryByText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement | null;
|
|
42
|
+
queryAllByText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
43
|
+
findByText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
44
|
+
findAllByText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
45
|
+
getByAltText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement;
|
|
46
|
+
getAllByAltText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
47
|
+
queryByAltText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement | null;
|
|
48
|
+
queryAllByAltText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
49
|
+
findByAltText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
50
|
+
findAllByAltText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
51
|
+
getByTitle: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement;
|
|
52
|
+
getAllByTitle: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
53
|
+
queryByTitle: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement | null;
|
|
54
|
+
queryAllByTitle: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
55
|
+
findByTitle: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
56
|
+
findAllByTitle: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
57
|
+
getByDisplayValue: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement;
|
|
58
|
+
getAllByDisplayValue: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
59
|
+
queryByDisplayValue: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement | null;
|
|
60
|
+
queryAllByDisplayValue: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
61
|
+
findByDisplayValue: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
62
|
+
findAllByDisplayValue: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
63
|
+
getByRole: (role: _$_testing_library_dom0.ByRoleMatcher, options?: _$_testing_library_dom0.ByRoleOptions | undefined) => HTMLElement;
|
|
64
|
+
getAllByRole: (role: _$_testing_library_dom0.ByRoleMatcher, options?: _$_testing_library_dom0.ByRoleOptions | undefined) => HTMLElement[];
|
|
65
|
+
queryByRole: (role: _$_testing_library_dom0.ByRoleMatcher, options?: _$_testing_library_dom0.ByRoleOptions | undefined) => HTMLElement | null;
|
|
66
|
+
queryAllByRole: (role: _$_testing_library_dom0.ByRoleMatcher, options?: _$_testing_library_dom0.ByRoleOptions | undefined) => HTMLElement[];
|
|
67
|
+
findByRole: (role: _$_testing_library_dom0.ByRoleMatcher, options?: _$_testing_library_dom0.ByRoleOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
68
|
+
findAllByRole: (role: _$_testing_library_dom0.ByRoleMatcher, options?: _$_testing_library_dom0.ByRoleOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
69
|
+
getByTestId: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement;
|
|
70
|
+
getAllByTestId: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
71
|
+
queryByTestId: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement | null;
|
|
72
|
+
queryAllByTestId: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
73
|
+
findByTestId: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
74
|
+
findAllByTestId: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
75
|
+
store: any;
|
|
76
|
+
};
|
|
77
|
+
//#endregion
|
|
78
|
+
export { TEST_LOCATION, afterAll, afterEach, beforeAll, beforeEach, mockAbortController, customRender as render };
|
|
79
|
+
//# sourceMappingURL=setupTests.d.cts.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as _$react_dom_client0 from "react-dom/client";
|
|
3
|
+
import * as _$pretty_format0 from "pretty-format";
|
|
4
|
+
import * as _$_testing_library_dom0 from "@testing-library/dom";
|
|
5
|
+
export * from "@testing-library/react";
|
|
6
|
+
|
|
7
|
+
//#region src/setupTests.d.ts
|
|
8
|
+
declare const TEST_LOCATION = "localhost";
|
|
9
|
+
declare const mockAbortController: {
|
|
10
|
+
abort: () => void;
|
|
11
|
+
signal: {
|
|
12
|
+
addEventListener: () => void;
|
|
13
|
+
removeEventListener: () => void;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
declare const beforeAll: () => Promise<() => undefined>;
|
|
17
|
+
declare const beforeEach: () => void;
|
|
18
|
+
declare const afterEach: () => Promise<void>;
|
|
19
|
+
declare const afterAll: () => Promise<void>;
|
|
20
|
+
declare const customRender: (ui: any, options?: {}) => {
|
|
21
|
+
container: HTMLElement;
|
|
22
|
+
baseElement: HTMLElement;
|
|
23
|
+
debug: (baseElement?: _$react_dom_client0.Container | (Element | Document) | Array<_$react_dom_client0.Container | (Element | Document)> | undefined, maxLength?: number | undefined, options?: _$pretty_format0.OptionsReceived | undefined) => void;
|
|
24
|
+
rerender: (ui: React.ReactNode) => void;
|
|
25
|
+
unmount: () => void;
|
|
26
|
+
asFragment: () => DocumentFragment;
|
|
27
|
+
getByLabelText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement;
|
|
28
|
+
getAllByLabelText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
29
|
+
queryByLabelText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement | null;
|
|
30
|
+
queryAllByLabelText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
31
|
+
findByLabelText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
32
|
+
findAllByLabelText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
33
|
+
getByPlaceholderText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement;
|
|
34
|
+
getAllByPlaceholderText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
35
|
+
queryByPlaceholderText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement | null;
|
|
36
|
+
queryAllByPlaceholderText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
37
|
+
findByPlaceholderText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
38
|
+
findAllByPlaceholderText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
39
|
+
getByText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement;
|
|
40
|
+
getAllByText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
41
|
+
queryByText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement | null;
|
|
42
|
+
queryAllByText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
43
|
+
findByText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
44
|
+
findAllByText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.SelectorMatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
45
|
+
getByAltText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement;
|
|
46
|
+
getAllByAltText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
47
|
+
queryByAltText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement | null;
|
|
48
|
+
queryAllByAltText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
49
|
+
findByAltText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
50
|
+
findAllByAltText: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
51
|
+
getByTitle: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement;
|
|
52
|
+
getAllByTitle: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
53
|
+
queryByTitle: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement | null;
|
|
54
|
+
queryAllByTitle: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
55
|
+
findByTitle: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
56
|
+
findAllByTitle: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
57
|
+
getByDisplayValue: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement;
|
|
58
|
+
getAllByDisplayValue: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
59
|
+
queryByDisplayValue: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement | null;
|
|
60
|
+
queryAllByDisplayValue: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
61
|
+
findByDisplayValue: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
62
|
+
findAllByDisplayValue: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
63
|
+
getByRole: (role: _$_testing_library_dom0.ByRoleMatcher, options?: _$_testing_library_dom0.ByRoleOptions | undefined) => HTMLElement;
|
|
64
|
+
getAllByRole: (role: _$_testing_library_dom0.ByRoleMatcher, options?: _$_testing_library_dom0.ByRoleOptions | undefined) => HTMLElement[];
|
|
65
|
+
queryByRole: (role: _$_testing_library_dom0.ByRoleMatcher, options?: _$_testing_library_dom0.ByRoleOptions | undefined) => HTMLElement | null;
|
|
66
|
+
queryAllByRole: (role: _$_testing_library_dom0.ByRoleMatcher, options?: _$_testing_library_dom0.ByRoleOptions | undefined) => HTMLElement[];
|
|
67
|
+
findByRole: (role: _$_testing_library_dom0.ByRoleMatcher, options?: _$_testing_library_dom0.ByRoleOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
68
|
+
findAllByRole: (role: _$_testing_library_dom0.ByRoleMatcher, options?: _$_testing_library_dom0.ByRoleOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
69
|
+
getByTestId: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement;
|
|
70
|
+
getAllByTestId: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
71
|
+
queryByTestId: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement | null;
|
|
72
|
+
queryAllByTestId: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined) => HTMLElement[];
|
|
73
|
+
findByTestId: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement>;
|
|
74
|
+
findAllByTestId: (id: _$_testing_library_dom0.Matcher, options?: _$_testing_library_dom0.MatcherOptions | undefined, waitForElementOptions?: _$_testing_library_dom0.waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
75
|
+
store: any;
|
|
76
|
+
};
|
|
77
|
+
//#endregion
|
|
78
|
+
export { TEST_LOCATION, afterAll, afterEach, beforeAll, beforeEach, mockAbortController, customRender as render };
|
|
79
|
+
//# sourceMappingURL=setupTests.d.ts.map
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { menderEnvironment, mockDate, token } from "./mockData.js";
|
|
2
|
+
import { theme } from "./utils.js";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Provider } from "react-redux";
|
|
5
|
+
import { MemoryRouter } from "react-router-dom";
|
|
6
|
+
import { createSerializer } from "@emotion/jest";
|
|
7
|
+
import { ThemeProvider } from "@mui/material/styles";
|
|
8
|
+
import { yes } from "@northern.tech/utils/helpers";
|
|
9
|
+
import { configureStore } from "@reduxjs/toolkit";
|
|
10
|
+
import "@testing-library/jest-dom/vitest";
|
|
11
|
+
import { cleanup, render } from "@testing-library/react";
|
|
12
|
+
import { expect, vi } from "vitest";
|
|
13
|
+
import { MessageChannel } from "worker_threads";
|
|
14
|
+
import { jsx } from "react/jsx-runtime";
|
|
15
|
+
export * from "@testing-library/react";
|
|
16
|
+
//#region src/setupTests.tsx
|
|
17
|
+
expect.addSnapshotSerializer(createSerializer({ includeStyles: true }));
|
|
18
|
+
const TEST_LOCATION = "localhost";
|
|
19
|
+
const mockAbortController = {
|
|
20
|
+
abort: vi.fn(),
|
|
21
|
+
signal: {
|
|
22
|
+
addEventListener: () => {},
|
|
23
|
+
removeEventListener: () => {}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const oldWindowLocalStorage = window.localStorage;
|
|
27
|
+
const oldWindowLocation = window.location;
|
|
28
|
+
const oldWindowSessionStorage = window.sessionStorage;
|
|
29
|
+
vi.mock("uuid", () => ({ v4: () => "mock-uuid" }));
|
|
30
|
+
const storage = {};
|
|
31
|
+
global.HTMLCanvasElement.prototype.getContext = vi.fn();
|
|
32
|
+
const beforeAll = async () => {
|
|
33
|
+
delete window.location;
|
|
34
|
+
window.location = {
|
|
35
|
+
...oldWindowLocation,
|
|
36
|
+
hostname: TEST_LOCATION,
|
|
37
|
+
origin: "http://localhost",
|
|
38
|
+
assign: vi.fn(),
|
|
39
|
+
replace: vi.fn(),
|
|
40
|
+
reload: vi.fn()
|
|
41
|
+
};
|
|
42
|
+
delete window.sessionStorage;
|
|
43
|
+
window.sessionStorage = {
|
|
44
|
+
...oldWindowSessionStorage,
|
|
45
|
+
getItem: vi.fn(yes),
|
|
46
|
+
setItem: vi.fn(),
|
|
47
|
+
removeItem: vi.fn()
|
|
48
|
+
};
|
|
49
|
+
delete window.localStorage;
|
|
50
|
+
window.localStorage = {
|
|
51
|
+
...oldWindowLocalStorage,
|
|
52
|
+
getItem: vi.fn((name) => {
|
|
53
|
+
if (name === "JWT") return JSON.stringify({ token });
|
|
54
|
+
return storage[name];
|
|
55
|
+
}),
|
|
56
|
+
setItem: vi.fn((name) => storage[name]),
|
|
57
|
+
removeItem: vi.fn()
|
|
58
|
+
};
|
|
59
|
+
window.mender_environment = menderEnvironment;
|
|
60
|
+
window.ENV = "test";
|
|
61
|
+
global.AbortController = vi.fn().mockImplementation(function() {
|
|
62
|
+
return mockAbortController;
|
|
63
|
+
});
|
|
64
|
+
global.MessageChannel = MessageChannel;
|
|
65
|
+
global.ResizeObserver = vi.fn().mockImplementation(function() {
|
|
66
|
+
return {
|
|
67
|
+
observe: vi.fn(),
|
|
68
|
+
unobserve: vi.fn(),
|
|
69
|
+
disconnect: vi.fn()
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
window.RTCPeerConnection = () => ({
|
|
73
|
+
createOffer: () => {},
|
|
74
|
+
setLocalDescription: () => {},
|
|
75
|
+
createDataChannel: () => {}
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(navigator, "appVersion", {
|
|
78
|
+
value: "Test",
|
|
79
|
+
writable: true
|
|
80
|
+
});
|
|
81
|
+
const intersectionObserverMock = function() {
|
|
82
|
+
return {
|
|
83
|
+
observe: vi.fn(),
|
|
84
|
+
disconnect: vi.fn()
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
window.prompt = vi.fn();
|
|
88
|
+
window.IntersectionObserver = vi.fn().mockImplementation(intersectionObserverMock);
|
|
89
|
+
vi.spyOn(React, "useEffect").mockImplementation(React.useLayoutEffect);
|
|
90
|
+
const _jest = globalThis.jest;
|
|
91
|
+
globalThis.jest = { ...globalThis.jest };
|
|
92
|
+
vi.stubGlobal("jest", { advanceTimersByTime: vi.advanceTimersByTime.bind(vi) });
|
|
93
|
+
return () => void (globalThis.jest = _jest);
|
|
94
|
+
};
|
|
95
|
+
const beforeEach = () => {
|
|
96
|
+
vi.useFakeTimers({ now: mockDate });
|
|
97
|
+
vi.setSystemTime(mockDate);
|
|
98
|
+
};
|
|
99
|
+
const afterEach = async () => {
|
|
100
|
+
cleanup();
|
|
101
|
+
vi.runOnlyPendingTimers();
|
|
102
|
+
vi.useRealTimers();
|
|
103
|
+
};
|
|
104
|
+
const afterAll = async () => {
|
|
105
|
+
window.localStorage = oldWindowLocalStorage;
|
|
106
|
+
window.location = oldWindowLocation;
|
|
107
|
+
window.sessionStorage = oldWindowSessionStorage;
|
|
108
|
+
React.useEffect.mockRestore();
|
|
109
|
+
vi.unstubAllGlobals();
|
|
110
|
+
};
|
|
111
|
+
const customRender = (ui, options = {}) => {
|
|
112
|
+
const { preloadedState = { users: { currentSession: {
|
|
113
|
+
token,
|
|
114
|
+
expiresAt: void 0
|
|
115
|
+
} } }, ...remainder } = options;
|
|
116
|
+
const store = options.store ?? configureStore({ preloadedState });
|
|
117
|
+
const AllTheProviders = ({ children }) => /* @__PURE__ */ jsx(ThemeProvider, {
|
|
118
|
+
theme,
|
|
119
|
+
children: /* @__PURE__ */ jsx(MemoryRouter, { children: /* @__PURE__ */ jsx(Provider, {
|
|
120
|
+
store,
|
|
121
|
+
children
|
|
122
|
+
}) })
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
store,
|
|
126
|
+
...render(ui, {
|
|
127
|
+
wrapper: AllTheProviders,
|
|
128
|
+
...remainder
|
|
129
|
+
})
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
//#endregion
|
|
133
|
+
export { TEST_LOCATION, afterAll, afterEach, beforeAll, beforeEach, mockAbortController, customRender as render };
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=setupTests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupTests.js","names":["mockToken"],"sources":["../src/setupTests.tsx"],"sourcesContent":["// Copyright 2025 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//@ts-nocheck\nimport React from 'react';\nimport { Provider } from 'react-redux';\nimport { MemoryRouter } from 'react-router-dom';\n\nimport { createSerializer } from '@emotion/jest';\nimport { ThemeProvider } from '@mui/material/styles';\n\nimport { yes } from '@northern.tech/utils/helpers';\nimport { configureStore } from '@reduxjs/toolkit';\nimport '@testing-library/jest-dom/vitest';\nimport { cleanup, render } from '@testing-library/react';\nimport { expect, vi } from 'vitest';\nimport { MessageChannel } from 'worker_threads';\n\nimport { menderEnvironment, mockDate, token as mockToken } from './mockData';\nimport { theme } from './utils';\n\nexpect.addSnapshotSerializer(createSerializer({ includeStyles: true }));\n\nexport const TEST_LOCATION = 'localhost';\n\nexport const mockAbortController: { abort: () => void; signal: { addEventListener: () => void; removeEventListener: () => void } } = {\n abort: vi.fn(),\n signal: { addEventListener: () => {}, removeEventListener: () => {} }\n};\n\nconst oldWindowLocalStorage = window.localStorage;\nconst oldWindowLocation = window.location;\nconst oldWindowSessionStorage = window.sessionStorage;\n\nvi.mock('uuid', () => ({ v4: () => 'mock-uuid' }));\n\nconst storage = {};\nglobal.HTMLCanvasElement.prototype.getContext = vi.fn();\n\nexport const beforeAll = async () => {\n // Temporarily workaround for bug in @testing-library/react when use user-event with `vi.useFakeTimers()`\n\n // Enable the mocking in tests.\n delete window.location;\n window.location = {\n ...oldWindowLocation,\n hostname: TEST_LOCATION,\n origin: 'http://localhost',\n assign: vi.fn(),\n replace: vi.fn(),\n reload: vi.fn()\n };\n delete window.sessionStorage;\n window.sessionStorage = {\n ...oldWindowSessionStorage,\n getItem: vi.fn(yes),\n setItem: vi.fn(),\n removeItem: vi.fn()\n };\n delete window.localStorage;\n window.localStorage = {\n ...oldWindowLocalStorage,\n getItem: vi.fn(name => {\n if (name === 'JWT') {\n return JSON.stringify({ token: mockToken });\n }\n return storage[name];\n }),\n setItem: vi.fn(name => storage[name]),\n removeItem: vi.fn()\n };\n window.mender_environment = menderEnvironment;\n window.ENV = 'test';\n global.AbortController = vi.fn().mockImplementation(function () {\n return mockAbortController;\n });\n global.MessageChannel = MessageChannel;\n global.ResizeObserver = vi.fn().mockImplementation(function () {\n return {\n observe: vi.fn(),\n unobserve: vi.fn(),\n disconnect: vi.fn()\n };\n });\n window.RTCPeerConnection = () => ({\n createOffer: () => {},\n setLocalDescription: () => {},\n createDataChannel: () => {}\n });\n\n Object.defineProperty(navigator, 'appVersion', { value: 'Test', writable: true });\n const intersectionObserverMock = function () {\n return {\n observe: vi.fn(),\n disconnect: vi.fn()\n };\n };\n window.prompt = vi.fn();\n window.IntersectionObserver = vi.fn().mockImplementation(intersectionObserverMock);\n vi.spyOn(React, 'useEffect').mockImplementation(React.useLayoutEffect);\n\n //TODO: remove, once https://github.com/testing-library/react-testing-library/issues/1197 resolved\n const _jest = globalThis.jest;\n\n globalThis.jest = {\n ...globalThis.jest\n };\n\n vi.stubGlobal('jest', {\n advanceTimersByTime: vi.advanceTimersByTime.bind(vi)\n });\n return () => void (globalThis.jest = _jest);\n};\n\nexport const beforeEach = () => {\n vi.useFakeTimers({ now: mockDate });\n vi.setSystemTime(mockDate);\n};\n\nexport const afterEach = async () => {\n cleanup();\n vi.runOnlyPendingTimers();\n vi.useRealTimers();\n};\n\nexport const afterAll = async () => {\n // restore `window.location` etc. to the original `jsdom` `Location` object\n window.localStorage = oldWindowLocalStorage;\n window.location = oldWindowLocation;\n window.sessionStorage = oldWindowSessionStorage;\n React.useEffect.mockRestore();\n vi.unstubAllGlobals();\n};\n\nconst customRender = (ui, options = {}) => {\n const { preloadedState = { users: { currentSession: { token: mockToken, expiresAt: undefined } } }, ...remainder } = options;\n const store = options.store ?? configureStore({ preloadedState });\n const AllTheProviders = ({ children }) => (\n <ThemeProvider theme={theme}>\n <MemoryRouter>\n <Provider store={store}>{children}</Provider>\n </MemoryRouter>\n </ThemeProvider>\n );\n return { store, ...render(ui, { wrapper: AllTheProviders, ...remainder }) };\n};\n\nexport * from '@testing-library/react';\n// override render method\n\nexport { customRender as render };\n"],"mappings":";;;;;;;;;;;;;;;;AA+BA,OAAO,sBAAsB,iBAAiB,EAAE,eAAe,MAAM,CAAC,CAAC;AAEvE,MAAa,gBAAgB;AAE7B,MAAa,sBAAwH;CACnI,OAAO,GAAG,IAAI;CACd,QAAQ;EAAE,wBAAwB;EAAI,2BAA2B;EAAI;CACtE;AAED,MAAM,wBAAwB,OAAO;A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GAAG,IAAI;AACvB,QAAO,uBAAuB,GAAG,IAAI,CAAC,mBAAmB,yBAAyB;AAClF,IAAG,MAAM,OAAO,YAAY,CAAC,mBAAmB,MAAM,gBAAgB;CAGtE,MAAM,QAAQ,WAAW;AAEzB,YAAW,OAAO,EAChB,GAAG,WAAW,MACf;AAED,IAAG,WAAW,QAAQ,EACpB,qBAAqB,GAAG,oBAAoB,KAAK,GAAG,EACrD,CAAC;AACF,cAAa,MAAM,WAAW,OAAO;;AAGvC,MAAa,mBAAmB;AAC9B,IAAG,cAAc,EAAE,KAAK,UAAU,CAAC;AACnC,IAAG,cAAc,SAAS;;AAG5B,MAAa,YAAY,YAAY;AACnC,UAAS;AACT,IAAG,sBAAsB;AACzB,IAAG,eAAe;;AAGpB,MAAa,WAAW,YAAY;AAElC,QAAO,eAAe;AACtB,QAAO,WAAW;AAClB,QAAO,iBAAiB;AACxB,OAAM,UAAU,aAAa;AAC7B,IAAG,kBAAkB;;AAGvB,MAAM,gBAAgB,IAAI,UAAU,EAAE,KAAK;CACzC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,gBAAgB;EAASA;EAAW,WAAW,KAAA;EAAW,EAAE,EAAE,EAAE,GAAG,cAAc;CACrH,MAAM,QAAQ,QAAQ,SAAS,eAAe,EAAE,gBAAgB,CAAC;CACjE,MAAM,mBAAmB,EAAE,eACzB,oBAAC,eAAD;EAAsB;YACpB,oBAAC,cAAD,EAAA,UACE,oBAAC,UAAD;GAAiB;GAAQ;GAAoB,CAAA,EAChC,CAAA;EACD,CAAA;AAElB,QAAO;EAAE;EAAO,GAAG,OAAO,IAAI;GAAE,SAAS;GAAiB,GAAG;GAAW,CAAC;EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"light.cjs","names":[],"sources":["../../src/theme/light.ts"],"sourcesContent":["// Copyright 2022 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { ThemeOptions } from '@mui/material';\nimport { PaletteOptions } from '@mui/material/styles';\n\nconst palette: PaletteOptions = {\n border: {\n main: '#e3e3e3'\n },\n background: {\n default: '#fff'\n }\n};\n\nexport const light: ThemeOptions = {\n palette\n};\n"],"mappings":";AAyBA,MAAa,QAAsB,EACjC,SAV8B;CAC9B,QAAQ,EACN,MAAM,WACP;CACD,YAAY,EACV,SAAS,QACV;CACF,EAIA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"light.js","names":[],"sources":["../../src/theme/light.ts"],"sourcesContent":["// Copyright 2022 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { ThemeOptions } from '@mui/material';\nimport { PaletteOptions } from '@mui/material/styles';\n\nconst palette: PaletteOptions = {\n border: {\n main: '#e3e3e3'\n },\n background: {\n default: '#fff'\n }\n};\n\nexport const light: ThemeOptions = {\n palette\n};\n"],"mappings":"AAyBA,MAAa,QAAsB,EACjC,SAV8B;CAC9B,QAAQ,EACN,MAAM,WACP;CACD,YAAY,EACV,SAAS,QACV;CACF,EAIA"}
|
|
File without changes
|