Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions test/public/eosReport/ecs-creation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const EorReasonRepository = require('../../../lib/database/repositories/EorReaso
const { ShiftTypes } = require('../../../lib/domain/enums/ShiftTypes.js');
const { eosReportService } = require('../../../lib/server/services/eosReport/EosReportService.js');
const { SHIFT_DURATION } = require('../../../lib/server/services/shift/getShiftFromTimestamp.js');
const { shiftService } = require('../../../lib/server/services/shift/ShiftService.js');

module.exports = () => {
let page;
Expand All @@ -60,13 +61,16 @@ module.exports = () => {
});

it('Should successfully create an ECS EoS report when submitting the form and redirect to the corresponding log', async () => {
// The pending shift depends on the time of the day, so all the fixtures are derived from it
const pendingShift = await shiftService.getUserPendingShiftOrFail({ userId: 1 });

for (const environment of customizedECSEosReport.typeSpecific.environments) {
await createEnvironment({
...environment,
});
await createEnvironmentHistoryItem({
status: 'DONE',
timestamp: new Date(),
timestamp: new Date(pendingShift.start + 1000),
timestampNano: 0,
environmentId: environment.id,
});
Expand All @@ -92,7 +96,7 @@ module.exports = () => {
}

// Create the expected previous EoS report
const past = new Date(Date.now() - SHIFT_DURATION);
const past = new Date(pendingShift.start - SHIFT_DURATION + 1000);
const info = 'Important information for the next tester';
const request = {
...emptyECSEosReportRequest,
Expand Down
8 changes: 6 additions & 2 deletions test/public/eosReport/qc-pdp-creation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const { createRun } = require('../../../lib/server/services/run/createRun.js');
const EorReasonRepository = require('../../../lib/database/repositories/EorReasonRepository.js');
const { ShiftTypes } = require('../../../lib/domain/enums/ShiftTypes.js');
const { customizedQcPdpEosReport } = require('../../mocks/mock-qc-pdp-eos-report.js');
const { shiftService } = require('../../../lib/server/services/shift/ShiftService.js');
const { updateRunDetector } = require('../../../lib/server/services/runDetector/updateRunDetector.js');

module.exports = () => {
Expand Down Expand Up @@ -55,13 +56,16 @@ module.exports = () => {
});

it('Should successfully create a QC/PDP EoS report when submitting the form and redirect to the corresponding log', async () => {
// The pending shift depends on the time of the day, so the runs must be created inside of it
const pendingShift = await shiftService.getUserPendingShiftOrFail({ userId: 1 });

for (const runs of Object.values(customizedQcPdpEosReport.typeSpecific.runs)) {
for (const run of runs) {
const runId = await createRun(
{
...run,
timeTrgStart: new Date(),
timeTrgEnd: new Date(),
timeTrgStart: new Date(pendingShift.start + 1000),
timeTrgEnd: new Date(pendingShift.start + 1000),
},
{ detectors: run.detectors },
);
Expand Down
8 changes: 5 additions & 3 deletions test/public/eosReport/shift-leader-creation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@ module.exports = () => {
});

it('Should successfully create a Shift Leader EoS report when submitting the form and redirect to the corresponding log', async () => {
// The pending shift depends on the time of the day, so the runs must be created inside of it
const currentShift = await shiftService.getUserPendingShiftOrFail({ userId: 1 });

for (const runs of Object.values(customizedQcPdpEosReport.typeSpecific.runs)) {
for (const run of runs) {
await createRun(
{
...run,
timeTrgStart: new Date(),
timeTrgEnd: new Date(),
timeTrgStart: new Date(currentShift.start + 1000),
timeTrgEnd: new Date(currentShift.start + 1000),
},
{ detectors: run.detectors },
);
Expand All @@ -77,7 +80,6 @@ module.exports = () => {

await reloadPage(page);

const currentShift = await shiftService.getUserPendingShiftOrFail({ userId: 1 });
const magnetStart = formatShiftDate(currentShift.start, { time: true });

const { formatTimestampForDateTimeInput } = await import('../../../lib/public/utilities/formatting/dateTimeInputFormatters.mjs');
Expand Down
Loading