diff --git a/SAS/TMSS/frontend/tmss_webapp/package-lock.json b/SAS/TMSS/frontend/tmss_webapp/package-lock.json index cdf8a683d7708b03ee6f101e611b9df5605559e7..a2c441933f00023cdbc7f2b82b678a1fbabd67d2 100644 --- a/SAS/TMSS/frontend/tmss_webapp/package-lock.json +++ b/SAS/TMSS/frontend/tmss_webapp/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "tmss", - "version": "0.9.9", + "version": "1.0.0", "hasInstallScript": true, "license": "GPLv2", "dependencies": { @@ -92,6 +92,7 @@ "jest-mock-console": "^2.0.0", "jest-coverage-badge": "^1.0.0", "@testing-library/user-event": "^14.5.2", + "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "cheerio": "^1.0.0-rc.12", "babel-jest": "^29.7.0", "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.23.3", @@ -1782,6 +1783,18 @@ "node": ">=6.0.0" } }, + "node_modules/@babel/preset-env/node_modules/@babel/plugin-proposal-private-property-in-object": { + "version": "7.21.0-placeholder-for-preset-env.2", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", + "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", + "dev": true, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/workbox-broadcast-update": { "version": "6.6.0", "dev": true, @@ -7119,9 +7132,17 @@ "license": "ISC" }, "node_modules/@babel/plugin-proposal-private-property-in-object": { - "version": "7.21.0-placeholder-for-preset-env.2", + "version": "7.21.11", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.11.tgz", + "integrity": "sha512-0QZ8qP/3RLDVBwBFoWAwCtgcDZJVwA5LUJRZU8x2YFfKNuFq161wK3cuGrALu5yiPu+vzwTAg/sMWVNeWeNyaw==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead.", "dev": true, - "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-create-class-features-plugin": "^7.21.0", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5" + }, "engines": { "node": ">=6.9.0" }, diff --git a/SAS/TMSS/frontend/tmss_webapp/package.json b/SAS/TMSS/frontend/tmss_webapp/package.json index 05d58646b6b3a3b2762e68c76394c6a7ee4e4730..6d374880144107de58252f5f032c2ad3700eda57 100644 --- a/SAS/TMSS/frontend/tmss_webapp/package.json +++ b/SAS/TMSS/frontend/tmss_webapp/package.json @@ -137,6 +137,7 @@ }, "devDependencies": { "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.23.3", + "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@babel/plugin-transform-private-property-in-object": "7.23.4", "@babel/preset-env": "^7.23.8", "@testing-library/jest-dom": "^6.2.0", diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.list.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.list.js index d27f97ad2e825c02b1840a03b85ef4ebf63abdd2..fa3679d6d7b202fa34d2d1ced044930e616182ec 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.list.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.list.js @@ -786,7 +786,6 @@ export class ReservationList extends Component { */ onConnect() { try { - console.log("WS Opened"); const userDets = localStorage.getItem("user"); if (userDets) { this.websocket.sendMessage(JSON.stringify({ "token": JSON.parse(userDets).websocket_token })); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.view.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.view.js index 286019a56931c88ddad712c89ff3527a1a24da87..9de93b1e84ad6074d954dbe69f5fdc389ef6ddec 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.view.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Reservation/reservation.view.js @@ -171,7 +171,6 @@ export class ReservationView extends Component { */ onConnect() { try{ - console.log("WS Opened"); const userDets = localStorage.getItem("user"); if (userDets) { this.websocket.sendMessage(JSON.stringify({"token": JSON.parse(userDets).websocket_token})); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/SchedulingUnitList.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/SchedulingUnitList.js index 897befde0e468822f151aa39e4d85fb3347443cb..da8c13b7f2d004c3b2f9d5841266536ae1c5bc79 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/SchedulingUnitList.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/SchedulingUnitList.js @@ -2419,7 +2419,6 @@ class SchedulingUnitList extends Component{ */ onConnect() { try{ - console.log("WS Opened"); const userDets = localStorage.getItem("user"); if (userDets) { this.websocket.sendMessage(JSON.stringify({"token": JSON.parse(userDets).websocket_token})); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.test.js index 338bb3ea8d404f6c559e6202a3a011301608c5b7..c7d0758b56881ebfd15893dc0da8b368ba38b1dc 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/excelview.schedulingset.test.js @@ -134,20 +134,7 @@ describe('Scheduling Units Excel View create page with an observation strategy t let scheduleSetListSpy, scheduleSetByIdSpy; beforeEach(async () => { - createStandardPageMocks(); - scheduleSetListSpy = jest.spyOn(ScheduleService, 'getSchedulingSets').mockImplementation((filter) => { - let allSUSets = SUServiceMock.scheduleSetList; - let project = filter.replace("project=", ""); - return Promise.resolve(allSUSets.filter(set => set.project_id === project)); - }); - - scheduleSetByIdSpy = jest.spyOn(ScheduleService, 'getSchedulingBySet').mockImplementation(() => { - return Promise.resolve(SUServiceMock.getSchedulingBySet()) - }); - pageContent = await renderPage(<SchedulingSetCreate location={{pathname: '/schedulingunit/'}}/>); - - await setMultiSelectValue(pageContent, "project", "high") - await setMultiSelectValue(pageContent, "schedSet", "Test Scheduling Set") + ({ scheduleSetListSpy, scheduleSetByIdSpy, pageContent } = await prepareations(scheduleSetListSpy, scheduleSetByIdSpy, pageContent)); }) afterEach(() => { @@ -159,10 +146,7 @@ describe('Scheduling Units Excel View create page with an observation strategy t }); - function skipper(observationStrategy) { - if (observationStrategy.name=="IM LBA LoDSS - 5 Beams" && observationStrategy.state=="legacy" && observationStrategy.version===45 ) return true - return observationStrategy.name=="IM LBA Survey - 3 Beams" && observationStrategy.state=="legacy" && observationStrategy.version===28; - } + test.each(OBSERVATION_STRATEGY_TEMPLATES)(`Correctly creates and checks headers for template '$name: $purpose, $state, v$version'`, async (observationStrategy) => { @@ -194,7 +178,14 @@ describe('Scheduling Units Excel View create page with an observation strategy t expect(saveSUFromStrategySpy).not.toHaveBeenCalled(); expect(pageContent.getByRole('dialog')).toBeInTheDocument(); //pop-up indicating errored SU }); +}); +describe('Scheduling Units Excel View Column Checker', () => { + let pageContent; + let scheduleSetListSpy, scheduleSetByIdSpy; + beforeEach(async () => { + ({ scheduleSetListSpy, scheduleSetByIdSpy, pageContent } = await prepareations(scheduleSetListSpy, scheduleSetByIdSpy, pageContent)); + }) test.each(OBSERVATION_STRATEGY_TEMPLATES)(`Checks column types for template '$name: $purpose, $state, v$version'`, async (observationStrategy) => { if (skipper(observationStrategy)) return true; @@ -213,9 +204,37 @@ describe('Scheduling Units Excel View create page with an observation strategy t for (const type of uniqueColumnTypes) { expect(knownColumnTypes, `A template in the back-end defined a column type that is not implemented in the front-end: ${type}`).toContain(type); } + + }); + afterEach(() => { + jest.clearAllMocks(); + cleanup() }); - }); +async function prepareations(scheduleSetListSpy, scheduleSetByIdSpy, pageContent) { + createStandardPageMocks(); + scheduleSetListSpy = jest.spyOn(ScheduleService, 'getSchedulingSets').mockImplementation((filter) => { + let allSUSets = SUServiceMock.scheduleSetList; + let project = filter.replace("project=", ""); + return Promise.resolve(allSUSets.filter(set => set.project_id === project)); + }); + + scheduleSetByIdSpy = jest.spyOn(ScheduleService, 'getSchedulingBySet').mockImplementation(() => { + return Promise.resolve(SUServiceMock.getSchedulingBySet()); + }); + pageContent = await renderPage(<SchedulingSetCreate location={{ pathname: '/schedulingunit/' }} />); + + await setMultiSelectValue(pageContent, "project", "high"); + await setMultiSelectValue(pageContent, "schedSet", "Test Scheduling Set"); + return { scheduleSetListSpy, scheduleSetByIdSpy, pageContent }; +} + + +function skipper(observationStrategy) { + if (observationStrategy.name=="IM LBA LoDSS - 5 Beams" && observationStrategy.state=="legacy" && observationStrategy.version===45 ) return true + return observationStrategy.name=="IM LBA Survey - 3 Beams" && observationStrategy.state=="legacy" && observationStrategy.version===28; +} + diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.js index d1d4c61f4856f8b1b0046f10a68c6da8e698f04b..21316f847d570c1aefab93cd73add106a4606d58 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.js @@ -10,7 +10,7 @@ import { useEffect, useState } from 'react'; const TaskEdit = ({ history,match,taskId,location}) => { - + const isDebugLogginOn =false const [isLoading, setIsLoading] = useState(true); const [userrole, setUserrole] = useState({}); const [requistedTaskId, setRequistedTaskId] = useState(""); @@ -18,7 +18,7 @@ const TaskEdit = ({ history,match,taskId,location}) => { const init = async () => { let calculatedTaskId = match.params?.id ?? taskId ?? location.state?.taskId ?? null; let permission = await AuthUtil.getUserPermissionByModuleId('task_draft', calculatedTaskId); - console.log("Load Permissions",permission,calculatedTaskId) + if (isDebugLogginOn) console.log("Load Permissions",permission,calculatedTaskId) setRequistedTaskId(calculatedTaskId); setUserrole(permission); setIsLoading(false); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.secure.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.secure.js index 3095bd630845783ad8bf4ac5b025b99a45f66aed..029e0cdc917b637178e81c04cbb0bddb529f5178 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.secure.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/edit.secure.js @@ -222,7 +222,6 @@ export class TaskEditSecure extends Component { } async init() { - console.log("Init Secure") this.setState({ isLoading: true }); TaskService.getTaskTemplates() diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/list.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/list.js index e2464be0121b28c0736509a2254a5039c8f99810..20e3ade6606dba693faf19fcaeb10bd4d2b799f5 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/list.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/list.js @@ -1307,7 +1307,6 @@ export class TaskList extends Component { */ onConnect() { try{ - console.log("WS Opened"); const userDets = localStorage.getItem("user"); if (userDets) { this.websocket.sendMessage(JSON.stringify({"token": JSON.parse(userDets).websocket_token})); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/view.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/view.js index cfb78999d14a5d6ba67cd68a5abeea39a7e8dbfb..ac170993a55ad3d81cdb3b5d6b538420880aaead 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/view.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Task/view.js @@ -843,7 +843,6 @@ export class TaskView extends Component { */ onConnect() { try{ - console.log("WS Opened"); const userDets = localStorage.getItem("user"); if (userDets) { this.websocket.sendMessage(JSON.stringify({"token": JSON.parse(userDets).websocket_token})); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/User/UserOverView.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/User/UserOverView.test.js index b647492f75b0909dafaed540f98c1341362de4a5..99eabb8408d7b15501bdd060efe04aad0ff4a312 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/User/UserOverView.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/User/UserOverView.test.js @@ -1,5 +1,6 @@ import { MockAxiosSecurity,MockAxiosBadSecurity } from "../../tests/axiosmocks."; +import { remove404Errors } from "../../utils/test.helper"; import UserOverView from "./UserOverView" import renderer, { act } from 'react-test-renderer'; @@ -9,6 +10,7 @@ import renderer, { act } from 'react-test-renderer'; describe('UserOverView Render Contents', () => { it("UserOverView renders without errors without data", () => { + remove404Errors(); const page = renderer .create(<UserOverView> </UserOverView>) .toJSON(); @@ -30,7 +32,7 @@ describe('UserOverView Render Contents', () => { it('UserOverView renders correctly with Server Error', async () => { - + remove404Errors(); MockAxiosBadSecurity(); let page; await act(async () => { diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Workflow/index.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Workflow/index.js index 8fec1205ce3447eb37ba558363f4ef3b45235b19..b266504a9659270cac05b5c16eb2b65c38758cef 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Workflow/index.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Workflow/index.js @@ -351,7 +351,6 @@ const WorkflowView = (props) => { */ const onConnect = async () => { try { - console.log("WS Opened"); const userDets = localStorage.getItem("user"); if (userDets) { websocket.sendMessage(JSON.stringify({ "token": JSON.parse(userDets).websocket_token })); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/tests/AffectedTasksSelector.test.js b/SAS/TMSS/frontend/tmss_webapp/src/tests/AffectedTasksSelector.test.js index b1a0dfcb65f2d2b617a2ee5f33e8c045beef4e56..be799e40710c5efcabaa7bdb871f44e71a5432e5 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/tests/AffectedTasksSelector.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/tests/AffectedTasksSelector.test.js @@ -20,19 +20,16 @@ function MakePrimaryMock() { jest.setSystemTime(new Date('2023-08-06T00:00:00Z')); let mock = new MockAdapter(axios); mock.onGet("/api/util/utc").reply(200, "2023-12-24T22:58:22.413683"); - return mock - -} - -function SecondaryMock(mock) { + mock.onGet("/api/task_blueprint/?fields=id&limit=1").reply(200,{ "count": 103, "results": [ { "id": 26 } ] },{"access-control-allow-methods":"GET, POST, PUT, PATCH, DELETE, cancel, copy_to_new_blueprint, copy_to_new_draft, create_subtasks, mark_as_obsolete, predecessors, restart_when_on_hold, schedule_independent_subtasks, successors, system_events"} ); mock.onGet("/api/task_blueprint/?expand=scheduling_unit_blueprint,scheduling_unit_blueprint.draft.scheduling_set,subtasks&fields=id,name,short_description,on_sky_start_time,on_sky_stop_time,scheduling_unit_blueprint.id,scheduling_unit_blueprint.draft.scheduling_set.project_id,scheduling_unit_blueprint.name,subtasks.id,subtasks.primary&scheduling_unit_blueprint=123&name=observation&ordering=id&limit=103&offset=0").reply(200, blueprintsearchresult); mock.onGet("/api/task_blueprint/?expand=scheduling_unit_blueprint,scheduling_unit_blueprint.draft.scheduling_set,subtasks&fields=id,name,short_description,on_sky_start_time,on_sky_stop_time,scheduling_unit_blueprint.id,scheduling_unit_blueprint.draft.scheduling_set.project_id,scheduling_unit_blueprint.name,subtasks.id,subtasks.primary&scheduling_unit_blueprint=123&name=observation&ordering=id&limit=0&offset=0").reply(200, blueprintsearchresult); - mock.onGet("/api/task_blueprint/?fields=id&limit=1").reply(200,{ "count": 103, "results": [ { "id": 26 } ] },{"access-control-allow-methods":"GET, POST, PUT, PATCH, DELETE, cancel, copy_to_new_blueprint, copy_to_new_draft, create_subtasks, mark_as_obsolete, predecessors, restart_when_on_hold, schedule_independent_subtasks, successors, system_events"} ); - return mock; + + return mock + } -describe('AffectedTasksSelector ', () => { +describe('AffectedTasksSelector ', () => { it('Gets Suid from correct Node', async () => { let { component,mock} = await RenderAffectedTasksSelector(true,true,{ suId:"456",searchBy:'SUB',startTime:'01-01-2024',stopTime:'01-0-2024'}); let searchInputText = screen.getByTestId("SuidInputText") @@ -40,8 +37,6 @@ describe('AffectedTasksSelector ', () => { await act(async () => fireEvent.change(searchInputText,{ target: { value: '123'} })); expect(searchInputText).toHaveValue("123") - SecondaryMock(mock) - let radioinput = screen.getByTestId("taskradiobutton") await act(async () => fireEvent.click(radioinput)); @@ -56,7 +51,7 @@ describe('AffectedTasksSelector ', () => { }); - + it('AffectedTasksSelector renders correctly without security', async () => { let mock= new MockAdapter(axios); @@ -70,7 +65,7 @@ describe('AffectedTasksSelector ', () => { component.unmount(); }); - + it('AffectedTasksSelector correctly with data but no security ', async () => { remove404Errors(); let { component } = await RenderAffectedTasksSelector(true); @@ -82,9 +77,10 @@ describe('AffectedTasksSelector ', () => { }); - it('AffectedTasksSelector correctly with data and security', async () => { - let { instance, component,mock } = await RenderAffectedTasksSelector(true,true); + + + let { instance, component } = await RenderAffectedTasksSelector(true,true); expect(component.asFragment()).toMatchSnapshot(); let searchInputText = screen.getByTestId("SuidInputText") @@ -97,7 +93,6 @@ describe('AffectedTasksSelector ', () => { await act(()=>instance.doSearch()); expect(component.asFragment()).toMatchSnapshot("After Search No Result"); - SecondaryMock(mock) await act(()=>instance.doSearch()); expect(component.asFragment()).toMatchSnapshot("After Search With Result"); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/tests/__snapshots__/AffectedTasksSelector.test.js.snap b/SAS/TMSS/frontend/tmss_webapp/src/tests/__snapshots__/AffectedTasksSelector.test.js.snap index 2f223df53b472dc19fceda7491caea6f4916b7a7..31070db1b069c417058e2c424691676769b96ef1 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/tests/__snapshots__/AffectedTasksSelector.test.js.snap +++ b/SAS/TMSS/frontend/tmss_webapp/src/tests/__snapshots__/AffectedTasksSelector.test.js.snap @@ -1854,7 +1854,7 @@ exports[`AffectedTasksSelector AffectedTasksSelector correctly with data and s > <label> - Total records (0) + Total records (1) </label> </div> </div> @@ -2385,7 +2385,108 @@ exports[`AffectedTasksSelector AffectedTasksSelector correctly with data and s </thead> <tbody role="rowgroup" - /> + > + <tr + class="" + data-testid="tablerow" + role="row" + style="display: flex; flex: 1 0 auto; min-width: 600px;" + > + <td + class="fixed-column-td" + > + <div> + <input + attr-id="70" + style="width: 15px; height: 15px;" + title="Toggle Row Selected" + type="checkbox" + /> + </div> + </td> + <td + class="notfixed-column-td-ObservationStartTime" + > + <div + style="box-sizing: border-box; flex: 150 0 auto; min-width: 60px; width: 150px;" + > + 2030-01-01 08:44:00 + </div> + </td> + <td + class="notfixed-column-td-ObservationEndTime" + > + <div + style="box-sizing: border-box; flex: 150 0 auto; min-width: 60px; width: 150px;" + > + 2030-01-01 08:46:00 + </div> + </td> + <td + class="notfixed-column-td-Project" + > + <div + style="box-sizing: border-box; flex: 150 0 auto; min-width: 60px; width: 150px;" + > + low + </div> + </td> + <td + class="notfixed-column-td-SchedulingUnitId" + > + <div + style="box-sizing: border-box; flex: 150 0 auto; min-width: 60px; width: 150px;" + > + 18 + </div> + </td> + <td + class="notfixed-column-td-SchedulingUnitName" + > + <div + style="box-sizing: border-box; flex: 150 0 auto; min-width: 60px; width: 150px;" + > + + </div> + </td> + <td + class="notfixed-column-td-TaskId" + > + <div + style="box-sizing: border-box; flex: 150 0 auto; min-width: 60px; width: 150px;" + > + 70 + </div> + </td> + <td + class="notfixed-column-td-ShortDescription" + > + <div + style="box-sizing: border-box; flex: 150 0 auto; min-width: 60px; width: 150px;" + > + + </div> + </td> + <td + class="notfixed-column-td-Name" + > + <div + style="box-sizing: border-box; flex: 150 0 auto; min-width: 60px; width: 150px;" + > + Combined Observation + </div> + </td> + <td + class="notfixed-column-td-ControlId" + > + <div + style="box-sizing: border-box; flex: 150 0 auto; min-width: 60px; width: 150px;" + > + + </div> + </td> + </tr> + </tbody> </table> </div> <div /> @@ -2396,7 +2497,7 @@ exports[`AffectedTasksSelector AffectedTasksSelector correctly with data and s class="total_records_bottom_label" > <label> - Total records (0) + Total records (1) </label> </div> <div> @@ -2456,7 +2557,16 @@ exports[`AffectedTasksSelector AffectedTasksSelector correctly with data and s <span class="p-paginator-pages" data-pc-section="pages" - /> + > + <button + aria-label="Page" + class="p-paginator-page p-paginator-element p-link p-paginator-page-start p-paginator-page-end p-highlight" + data-pc-section="pagebutton" + type="button" + > + 1 + </button> + </span> <button aria-label="Next Page" class="p-paginator-next p-paginator-element p-link p-disabled" @@ -2506,7 +2616,7 @@ exports[`AffectedTasksSelector AffectedTasksSelector correctly with data and s </svg> </button> <div - class="p-dropdown p-component p-inputwrapper p-disabled p-inputwrapper-filled" + class="p-dropdown p-component p-inputwrapper p-inputwrapper-filled" data-pc-name="dropdown" data-pc-section="root" > @@ -2518,7 +2628,6 @@ exports[`AffectedTasksSelector AffectedTasksSelector correctly with data and s aria-haspopup="listbox" aria-label="Choose" data-pc-section="input" - disabled="" readonly="" type="text" /> diff --git a/SAS/TMSS/frontend/tmss_webapp/src/tests/__snapshots__/login.test.js.snap b/SAS/TMSS/frontend/tmss_webapp/src/tests/__snapshots__/login.test.js.snap index cb4f549c9ee7d1a97a185469a7649c1a80444d27..b34b40625ff2109228e6c2f0ec2c3ceaa9c60b87 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/tests/__snapshots__/login.test.js.snap +++ b/SAS/TMSS/frontend/tmss_webapp/src/tests/__snapshots__/login.test.js.snap @@ -1051,11 +1051,6 @@ exports[`Login System Login Good Login: Good Login 1`] = ` </a> </div> </div> - <div - class="row error" - > - Unable to login. Please try with a different username and/or password. - </div> </div> </div> </div> diff --git a/SAS/TMSS/frontend/tmss_webapp/src/tests/__snapshots__/station.test.js.snap b/SAS/TMSS/frontend/tmss_webapp/src/tests/__snapshots__/station.test.js.snap index 3173e6d03741fb2573ec9abcabce752a193fbd78..b21bf5a7dcdd84e571d4cbe27372f36053fe984c 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/tests/__snapshots__/station.test.js.snap +++ b/SAS/TMSS/frontend/tmss_webapp/src/tests/__snapshots__/station.test.js.snap @@ -1121,7 +1121,7 @@ exports[`Station View Station View renders correctly 1`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0;" tabindex="0" > @@ -1148,7 +1148,7 @@ exports[`Station View Station View renders correctly 1`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0;" tabindex="0" > @@ -1202,7 +1202,7 @@ exports[`Station View Station View renders correctly 1`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0;" tabindex="0" > @@ -1229,7 +1229,7 @@ exports[`Station View Station View renders correctly 1`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0;" tabindex="0" > @@ -1256,7 +1256,7 @@ exports[`Station View Station View renders correctly 1`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0;" tabindex="0" > @@ -1283,7 +1283,7 @@ exports[`Station View Station View renders correctly 1`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0;" tabindex="0" > @@ -1310,7 +1310,7 @@ exports[`Station View Station View renders correctly 1`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0;" tabindex="0" > @@ -1418,7 +1418,7 @@ exports[`Station View Station View renders correctly 1`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0;" tabindex="0" > @@ -1553,7 +1553,7 @@ exports[`Station View Station View renders correctly 1`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: -1px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: -1px; top: 0px; z-index: 0;" tabindex="0" > @@ -1634,7 +1634,7 @@ exports[`Station View Station View renders correctly 1`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0;" tabindex="0" > @@ -1661,7 +1661,7 @@ exports[`Station View Station View renders correctly 1`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0;" tabindex="0" > @@ -1715,7 +1715,7 @@ exports[`Station View Station View renders correctly 1`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: -1px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: -1px; top: 0px; z-index: 0;" tabindex="0" > @@ -3720,7 +3720,7 @@ exports[`Station View Station View renders correctly 2`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" tabindex="0" > @@ -3747,7 +3747,7 @@ exports[`Station View Station View renders correctly 2`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" tabindex="0" > @@ -3801,7 +3801,7 @@ exports[`Station View Station View renders correctly 2`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" tabindex="0" > @@ -3828,7 +3828,7 @@ exports[`Station View Station View renders correctly 2`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" tabindex="0" > @@ -3855,7 +3855,7 @@ exports[`Station View Station View renders correctly 2`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" tabindex="0" > @@ -3882,7 +3882,7 @@ exports[`Station View Station View renders correctly 2`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" tabindex="0" > @@ -3909,7 +3909,7 @@ exports[`Station View Station View renders correctly 2`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" tabindex="0" > @@ -4017,7 +4017,7 @@ exports[`Station View Station View renders correctly 2`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" tabindex="0" > @@ -4152,7 +4152,7 @@ exports[`Station View Station View renders correctly 2`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: -1px; top: 0px; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: -1px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" tabindex="0" > @@ -4233,7 +4233,7 @@ exports[`Station View Station View renders correctly 2`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" tabindex="0" > @@ -4260,7 +4260,7 @@ exports[`Station View Station View renders correctly 2`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" tabindex="0" > @@ -4314,7 +4314,7 @@ exports[`Station View Station View renders correctly 2`] = ` <div class="leaflet-marker-icon custom-marker-icon leaflet-zoom-hide leaflet-interactive" role="button" - style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: -1px; top: 0px; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0;" + style="margin-left: -6px; margin-top: -6px; width: 12px; height: 12px; left: -1px; top: 0px; z-index: 0; z-index: 0; z-index: 0;" tabindex="0" > @@ -5256,6 +5256,7 @@ exports[`Station constraint View StationConstraintView View renders correctl <div> <img alt="Constraint" + src="mocked-url" /> </div> </div> @@ -5322,6 +5323,7 @@ exports[`Station constraint View StationConstraintView View renders correctl <div> <img alt="Constraint" + src="mocked-url" /> </div> </div> diff --git a/SAS/TMSS/frontend/tmss_webapp/src/tests/login.test.js b/SAS/TMSS/frontend/tmss_webapp/src/tests/login.test.js index 190b5becdf0b962a325be08c1a4d2054dea6d8bd..d94c4dc3eae232ccd5dabf8ee9cbfe4264290659 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/tests/login.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/tests/login.test.js @@ -3,25 +3,26 @@ import MockAdapter from 'axios-mock-adapter'; import { render, act, fireEvent } from '@testing-library/react'; import { MemoryRouter } from "react-router-dom"; import { Login } from "../authenticate/login"; +import { remove404Errors } from "../utils/test.helper"; function MakePrimaryMock() { let mock = new MockAdapter(axios); - mock.onPost("/api/token-auth/",200, { "non_field_errors":["Unable to log in with provided credentials."]}); + mock.onPost("/api/token-auth/").reply(400, { "non_field_errors":["Unable to log in with provided credentials."]}); return mock } function MakeGoodMock(){ let mock = new MockAdapter(axios); - mock.onPost("/api/token-auth/",200, {"token":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}); + mock.onPost("/api/token-auth/").reply(200, {"token":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}); } describe('Login', () => { it('Renders Login', async () => { MakePrimaryMock(); - let component = await RenderLogin(); + let {component} = await RenderLogin(); expect(component.asFragment()).toMatchSnapshot(); component.unmount(); @@ -29,8 +30,9 @@ describe('Login', () => { it('System Login Bad Login', async () => { + remove404Errors(); MakePrimaryMock(); - const component = await DoLogin(); + let {component } = await DoLogin(); expect(component.asFragment()).toMatchSnapshot("Bad Login"); component.unmount(); }); @@ -38,14 +40,15 @@ describe('Login', () => { it('System Login Good Login', async () => { MakeGoodMock() - const component = await DoLogin(); + let {component,mocklogin} = await DoLogin(); expect(component.asFragment()).toMatchSnapshot("Good Login"); + expect(mocklogin).toHaveBeenCalled(); component.unmount(); }); it('KeyCloack Login Redirect', async () => { MakeGoodMock() - let component = await RenderLogin(); + let {component} = await RenderLogin(); const submitloginbutton = component?.container.querySelector('#KeyCloakLoginButton'); await act(async () => { fireEvent.click(submitloginbutton); }); @@ -62,7 +65,7 @@ describe('Login', () => { }); async function DoLogin() { - let component = await RenderLogin(); + let { component ,mocklogin} = await RenderLogin(); let aswitch = component?.queryAllByRole('switch'); await act(async () => { fireEvent.click(aswitch[0]); }); @@ -81,14 +84,15 @@ async function DoLogin() { expect(submitloginbutton).not.toBeDisabled(); await act(async () => { fireEvent.click(submitloginbutton); }); - return component; + return { component,mocklogin} } async function RenderLogin () { let component - await act(async () => { component = render(<MemoryRouter><Login history={{}} location="/login/" /></MemoryRouter>) }); - return component + let mocklogin=jest.fn(); + await act(async () => { component = render(<MemoryRouter><Login onLogin={mocklogin} history={{}} location="/login/" /></MemoryRouter>) }); + return { component,mocklogin} } diff --git a/SAS/TMSS/frontend/tmss_webapp/src/tests/station.test.js b/SAS/TMSS/frontend/tmss_webapp/src/tests/station.test.js index 37baa708ea9a9192d10b078c40e22fad3cdf1520..d1ea4d7baed32a51f089e8d5c8e24b68f9e32579 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/tests/station.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/tests/station.test.js @@ -8,11 +8,9 @@ import StationConstraintView from '../routes/Station/StationConstraintView'; function MakePrimaryMock() { let mock = new MockAdapter(axios); - mock.onGet("/api/scheduling_unit_blueprint_slim_with_tasks/?process_start_time_before=2023-12-22 23:59:59&process_stop_time_after=2023-12-16 00:00:00&id=&limit=50&offset=12").reply(200, SchedulingUnitBlueprintSlimWithTask); mock.onGet("/api/scheduling_unit_blueprint_slim_with_tasks/?process_start_time_before=2023-12-22 23:59:59&process_stop_time_after=2023-12-16 00:00:00&id=").reply(200, SchedulingUnitBlueprintSlimWithTask); mock.onGet("/api/scheduling_unit_blueprint/1/scheduling_constraints_plot/CS002/12:00").reply(200, {}); - mock.onGet("/api/util/stations").reply(200, Stations); return mock @@ -21,11 +19,8 @@ function MakePrimaryMock() { describe('Station View ', () => { it('Station View renders correctly ', async () => { - - - - - + jest.useFakeTimers() + jest.setSystemTime(new Date('2023-12-16')); MakePrimaryMock(); let component await act(async () => { component = render(<StationView />); }); @@ -47,8 +42,10 @@ describe('Station View ', () => { describe('Station constraint View ', () => { it('StationConstraintView View renders correctly ', async () => { + jest.useFakeTimers() + jest.setSystemTime(new Date('2023-12-22')); MakePrimaryMock(); - + URL.createObjectURL = jest.fn(() => 'mocked-url'); let station = "CS002" let selectedBluePrint = [ @@ -69,9 +66,6 @@ describe('Station constraint View ', () => { }); const componentSnapshotWithToast = component.asFragment(); expect(componentSnapshotWithToast).toMatchSnapshot("With Toast"); - - - component.unmount(); }); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/tests/systemevent.list.test.js b/SAS/TMSS/frontend/tmss_webapp/src/tests/systemevent.list.test.js index a290b95ad2539f21d3067bce559054bc72c7de82..9d4e9b48c1622ad991f29a3489b21b078a15b4e1 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/tests/systemevent.list.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/tests/systemevent.list.test.js @@ -12,7 +12,7 @@ import systemeventseverity from '../__mocks__/system_event_severity.json' import systemeventsstatus from '../__mocks__/system_event.status.json' import systemeventlist from '../__mocks__/system_event_list.json' - +import { remove404Errors } from "../utils/test.helper"; import { MockAxiosSecurity } from './axiosmocks.' import { MemoryRouter } from "react-router-dom"; @@ -46,6 +46,7 @@ describe('Systen Event List ', () => { it('System Event List renders correctly without security', async () => { new MockAdapter(axios); let component + remove404Errors(); await act(async () => { component = render(<MemoryRouter><SystemEventList history={{}} location="/systemevent/list/" /></MemoryRouter>) }); const componentSnapshot = component.asFragment(); expect(componentSnapshot).toMatchSnapshot(); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/tests/systemeventview.test.js b/SAS/TMSS/frontend/tmss_webapp/src/tests/systemeventview.test.js index 9dde8ba0b3b8f3afcefadd5725dc9267673eb7fc..c172c43b257fbaf6ddccafbc7efae4e88914a2e9 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/tests/systemeventview.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/tests/systemeventview.test.js @@ -3,7 +3,7 @@ import axios from "axios"; import MockAdapter from 'axios-mock-adapter'; import { render, act, fireEvent } from '@testing-library/react'; - +import { remove404Errors } from "../utils/test.helper"; import systemeventview from '../__mocks__/system_event.view.json' import systemeventviewtemplate from '../__mocks__/system_event.view.template.json' @@ -34,6 +34,7 @@ describe('Systen Event View ', () => { it('Systen Event View renders correctly without security', async () => { let mock= new MockAdapter(axios); + remove404Errors(); mock.onGet("/").reply(404); let { component } = await RenderView(false); const componentSnapshot = component.asFragment(); @@ -44,6 +45,7 @@ describe('Systen Event View ', () => { it('Systen Event View correctly with data but no security to view and list', async () => { let { component } = await RenderView(true); + remove404Errors(); expect(giveConsistentNodes(component.container.outerHTML)).toMatchSnapshot(); component.unmount(); diff --git a/SAS/TMSS/frontend/tmss_webapp/src/utils/test.helper.js b/SAS/TMSS/frontend/tmss_webapp/src/utils/test.helper.js index c6f8b2c85167059c41733f7e2c06da774a3e1ba9..d5cbae8c580b2c2354f872fbc6ac6059c0888e4f 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/utils/test.helper.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/utils/test.helper.js @@ -4,7 +4,7 @@ import {BrowserRouter as Router} from "react-router-dom"; import { load} from 'cheerio'; import beautify from 'js-beautify'; -const TIMEOUT = 100 +const TIMEOUT = 10 export async function clickItem(item, timeout = TIMEOUT) { await act(async () => { @@ -34,7 +34,7 @@ export async function renderPage(pageComponent) { let content; await act(async () => { content = render(<Router>{pageComponent}</Router>); - await new Promise((r) => setTimeout(r, 100)); + await new Promise((r) => setTimeout(r, 10)); }); return content; } @@ -53,8 +53,8 @@ export function removeReact18ConsoleErrors() { // remove 404 errors who are un purpose due to testing 404 :) export function remove404Errors() { - jest.spyOn(global.console, 'error').mockImplementation((message,error) => { - if (! ( message == "Request failed with status code 404" || error?.message=="Request failed with status code 404" || error?.message=="Network Error" || error?.message=="Request failed with status code 500")) { + jest.spyOn(global.console, 'error').mockImplementation((error,message) => { + if (! ( error?.message=="Request failed with status code 400" || error == "Request failed with status code 404" || error?.message=="Request failed with status code 404" || error?.message=="Network Error" || error?.message=="Request failed with status code 500")) { global.console.info(message); } });