Skip to content

Commit

Permalink
Task 438 new app structure (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwebeck committed Apr 16, 2021
1 parent 89d040e commit 76ad3f4
Show file tree
Hide file tree
Showing 227 changed files with 1,168 additions and 1,101 deletions.
7 changes: 5 additions & 2 deletions cypress/fixtures/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/* eslint-disable @typescript-eslint/camelcase */

import { ContractType, WorkerGroup } from "../../src/common-models/worker-info.model";
import { ScheduleDataModel } from "../../src/common-models/schedule-data.model";
import { ScheduleDataModel } from "../../src/state/schedule-data/schedule-data.model";
import {
ContractType,
WorkerGroup,
} from "../../src/state/schedule-data/worker-info/worker-info.model";

export default {
schedule_info: { UUID: "0", month_number: 1, year: 2021 },
Expand Down
1 change: 1 addition & 0 deletions cypress/fixtures/worker-data/march-2021-raw-worker-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */


/**
Data completed based on schedules
marzec_2021_wersja_bazowa
Expand Down
4 changes: 2 additions & 2 deletions cypress/fixtures/worker-data/worker-data-preprocessor.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { ShiftCode } from "../../../src/common-models/shift-info.model";
import { ContractType } from "../../../src/common-models/worker-info.model";
import { MonthDataArray } from "../../../src/helpers/shifts.helper";
import { ShiftCode } from "../../../src/state/schedule-data/shifts-types/shift-types.model";
import { ContractType } from "../../../src/state/schedule-data/worker-info/worker-info.model";
import { monthWorkerData } from "./march-2021-raw-worker-data";

const MARCH_DAY_COUNT = 31;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

import { WorkerType } from "../../../../src/common-models/worker-info.model";
import { WorkerType } from "../../../../src/state/schedule-data/worker-info/worker-info.model";

const addWorker = (workerName: string, position: WorkerType): void => {
cy.get('[data-cy="btn-management-tab"]').click();
Expand Down Expand Up @@ -36,9 +36,9 @@ context("Schedule errors", () => {
addWorker(Cypress.env("REACT_APP_ERROR_WORKER"), WorkerType.NURSE);
cy.get('[data-cy="btn-schedule-tab"]').click({ force: true });
Cypress.on("uncaught:exception", () => {
cy.get('[data-cy="btn-ok-app-error"]').click();
cy.get('[data-cy="btn-reload-app-error"]').click();
cy.get('[data-cy="timetable-row"]').should("be.visible");
cy.get('[data-cy="btn-ok-app-error"]').click();
cy.get('[data-cy="btn-reload-app-error"]').click();
cy.get('[data-cy="restore-prev-version"]').click();
cy.contains("testUser");
return false;
Expand Down
5 changes: 3 additions & 2 deletions cypress/integration/e2e/table/load-schedule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

import { ShiftCode } from "../../../../src/common-models/shift-info.model";
import { shiftSectionDataCy } from "../../../../src/components/schedule-page/table/schedule/sections/worker-info-section/worker-info-section.models";

import { shiftSectionDataCy } from "../../../../src/components/schedule/worker-info-section/worker-info-section.models";
import { ShiftCode } from "../../../../src/state/schedule-data/shifts-types/shift-types.model";
import { FoundationInfoRowType } from "../../../support/commands";
//#region Test data
interface CheckFoundationInfoReadCorrectly {
Expand Down
5 changes: 3 additions & 2 deletions cypress/integration/e2e/table/range-selection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import * as _ from "lodash";
import { ShiftCode } from "../../../../src/common-models/shift-info.model";
import { shiftSectionDataCy } from "../../../../src/components/schedule-page/table/schedule/sections/worker-info-section/worker-info-section.models";
import { shiftSectionDataCy } from "../../../../src/components/schedule/worker-info-section/worker-info-section.models";
import { ShiftCode } from "../../../../src/state/schedule-data/shifts-types/shift-types.model";
import { GetWorkerShiftOptions } from "../../../support/commands";


const prevMonthDays = 6;

interface WorkerTestCase {
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/e2e/table/schedule-modes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { ShiftCode } from "../../../../src/common-models/shift-info.model";
import { ShiftCode } from "../../../../src/state/schedule-data/shifts-types/shift-types.model";

const testedCell = {
workerGroupIdx: 0,
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/e2e/table/undo-redo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// <reference path="../../../support/index.d.ts" />

import { GetWorkerShiftOptions } from "../../../support/commands";
import { ShiftCode } from "../../../../src/common-models/shift-info.model";
import { ShiftCode } from "../../../../src/state/schedule-data/shifts-types/shift-types.model";

interface TestCase {
testedShiftCell: GetWorkerShiftOptions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { ShiftCode } from "../../../../src/common-models/shift-info.model";
import { ShiftCode } from "../../../../src/state/schedule-data/shifts-types/shift-types.model";
import { GetWorkerShiftOptions, HoursInfo, HoursInfoCells } from "../../../support/commands";

const nurseInitialWorkHours: HoursInfo[] = [
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/unit/helpers/file.helper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { FileHelper } from "../../../../src/helpers/file.helper";
import { ScheduleDataModel } from "../../../../src/common-models/schedule-data.model";
import { ScheduleDataModel } from "../../../../src/state/schedule-data/schedule-data.model";
import schedule from "../../../fixtures/schedule";
import { cropScheduleDMToMonthDM } from "../../../../src/logic/schedule-container-convertion/schedule-container-convertion";
import { cropScheduleDMToMonthDM } from "../../../../src/logic/schedule-container-converter/schedule-container-converter";

describe("FileHelper", () => {
it(`Should properly create directory name based on filename`, () => {
Expand Down
20 changes: 12 additions & 8 deletions cypress/integration/unit/helpers/shift.helper.spec.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { VerboseDate } from "../../../../src/common-models/month-info.model";
import { ShiftCode, ShiftInfoModel, SHIFTS } from "../../../../src/common-models/shift-info.model";
import { VerboseDate } from "../../../../src/state/schedule-data/foundation-info/foundation-info.model";
import {
ShiftCode,
SHIFTS,
} from "../../../../src/state/schedule-data/shifts-types/shift-types.model";
import { ShiftHelper } from "../../../../src/helpers/shifts.helper";
import { WorkerHourInfo } from "../../../../src/helpers/worker-hours-info.model";
import { WorkerShiftsModel } from "../../../../src/state/schedule-data/workers-shifts/worker-shifts.model";

//#region getWorkersCount data
type GetWorkersCountTestCase = { arr: ShiftInfoModel; exp: Array<number> };
type GetWorkersCountTestCase = { arr: WorkerShiftsModel; exp: Array<number> };

const testData1: ShiftInfoModel = {
const testData1: WorkerShiftsModel = {
"0": ["R", "DN", "W"].map((d) => ShiftCode[d]),
"1": ["P", "D", "W"].map((d) => ShiftCode[d]),
"2": ["D", "W", "W"].map((d) => ShiftCode[d]),
};

const testData2: ShiftInfoModel = {
const testData2: WorkerShiftsModel = {
"0": ["W", "W", "W"].map((d) => ShiftCode[d]),
"1": ["W", "W", "W"].map((d) => ShiftCode[d]),
"2": ["W", "W", "W"].map((d) => ShiftCode[d]),
};

const testData3: ShiftInfoModel = {
const testData3: WorkerShiftsModel = {
"0": ["R", "R", "R"].map((d) => ShiftCode[d]),
"1": ["R", "R", "R"].map((d) => ShiftCode[d]),
"2": ["R", "R", "R"].map((d) => ShiftCode[d]),
};

const testData4: ShiftInfoModel = {
const testData4: WorkerShiftsModel = {
"0": ["R", "W", "R", "W"].map((d) => ShiftCode[d]),
"1": ["R", "R", "R", "W"].map((d) => ShiftCode[d]),
"2": ["R", "W", "R", "R"].map((d) => ShiftCode[d]),
};
const testData5: ShiftInfoModel = {
const testData5: WorkerShiftsModel = {
"0": ["R", "W", "R", "W"].map((d) => ShiftCode[d]),
"1": ["R", "R", "R", "W"].map((d) => ShiftCode[d]),
"2": ["P", "R", "R", "R"].map((d) => ShiftCode[d]),
Expand Down
23 changes: 6 additions & 17 deletions cypress/integration/unit/helpers/worker-hours-info.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import * as _ from "lodash";
import {
NotWorkingShift,
NotWorkingShiftType,
Shift,
ShiftCode,
SHIFTS,
} from "../../../../src/common-models/shift-info.model";
import { ContractType } from "../../../../src/common-models/worker-info.model";
import { MonthDataArray, ShiftHelper } from "../../../../src/helpers/shifts.helper";
import {
DEFAULT_NORM_SUBTRACTION,
WorkerHourInfo,
} from "../../../../src/helpers/worker-hours-info.model";
import {
workerTestData,
WorkerTestDataInstance,
} from "../../../fixtures/worker-data/worker-data-preprocessor";
import { ShiftHelper, MonthDataArray } from "../../../../src/helpers/shifts.helper";
import { DEFAULT_NORM_SUBTRACTION, WorkerHourInfo } from "../../../../src/helpers/worker-hours-info.model";
import { SHIFTS, ShiftCode, Shift, NotWorkingShift, NotWorkingShiftType } from "../../../../src/state/schedule-data/shifts-types/shift-types.model";
import { ContractType } from "../../../../src/state/schedule-data/worker-info/worker-info.model";
import { workerTestData, WorkerTestDataInstance } from "../../../fixtures/worker-data/worker-data-preprocessor";


describe("Worker hours info", () => {
workerTestData.forEach((workerInstance) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

import { WorkingTimeHelper } from "../../../../src/components/namestable/working-time.helper";
import { WorkingTimeHelper } from "../../../../src/helpers/working-time.helper";

describe("WorkingTimeHelper", () => {
describe("fromHoursToFraction", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
/* eslint-disable @typescript-eslint/camelcase */
/// <reference types="cypress" />
import { ScheduleParser } from "../../../../../src/logic/schedule-parser/schedule.parser";
// import { ScheduleDataModel } from "../../../../../src/common-models/schedule-data.model";
import { ShiftCode, ShiftInfoModel } from "../../../../../src/common-models/shift-info.model";
import { WorkersInfoModel, WorkerType } from "../../../../../src/common-models/worker-info.model";
import { ShiftCode } from "../../../../../src/state/schedule-data/shifts-types/shift-types.model";
import {
WorkersInfoModel,
WorkerType,
} from "../../../../../src/state/schedule-data/worker-info/worker-info.model";
import { WorkerShiftsModel } from "../../../../../src/state/schedule-data/workers-shifts/worker-shifts.model";
// import { ScheduleDataModel } from "../../../../../src/schedule-data.model";

function fillWorkerInfo(
shifts: ShiftInfoModel,
shifts: WorkerShiftsModel,
employeeInfo: WorkersInfoModel,
section: string[][],
sectionType: WorkerType
Expand Down Expand Up @@ -47,7 +51,7 @@ const exampleData = [
babysitterSection,
];

const shifts: ShiftInfoModel = {};
const shifts: WorkerShiftsModel = {};
const employee_info: WorkersInfoModel = { type: {}, time: {}, workerGroup: {} };

fillWorkerInfo(shifts, employee_info, nurseSection, WorkerType.NURSE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// import { DataRowParser } from "../../../../../src/logic/schedule-parser/data-row.parser";
// import { MetaDataParser } from "../../../../../src/logic/schedule-parser/metadata.parser";
// import { ShiftsInfoParser } from "../../../../../src/logic/schedule-parser/shifts-info.parser";
// import { WorkerType } from "../../../../../src/common-models/worker-info.model";
// import { WorkerType } from "../../../../../src/worker-info.model";

//#region data declaration

Expand Down Expand Up @@ -48,11 +48,11 @@ const metaData: MetaDataParser = new MetaDataParser(2020, 10, [

describe("ShifstInfo parser", () => {
//todo update test
// context("Testing detection of errors", () => {
// context("Testing detection of error-list", () => {
// TestCases.forEach((element) => {
// const shiftsInfoParser = new ShiftsInfoParser(WorkerType.OTHER, metaData, element.data);
// const result = shiftsInfoParser.errors;
// it(`should have exaclty ${element.errorCount} errors`, () => {
// const result = shiftsInfoParser.error-list;
// it(`should have exaclty ${element.errorCount} error-list`, () => {
// expect(result).have.lengthOf(element.errorCount);
// });
// });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { ScheduleKey } from "../../../../../src/api/persistance-store.model";
import { ScheduleKey } from "../../../../../src/logic/data-access/persistance-store.model";
import { MonthHelper } from "../../../../../src/helpers/month.helper";

interface TestCase {
Expand Down
43 changes: 25 additions & 18 deletions cypress/integration/unit/validation/month-info-validation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,81 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import * as _ from "lodash";
import { MonthInfoModel, validateMonthInfo } from "../../../../src/common-models/month-info.model";
import {
ScheduleContainerType,
validateFoundationInfo,
FoundationInfoModel,
} from "../../../../src/state/schedule-data/foundation-info/foundation-info.model";
import {
SCHEDULE_CONTAINERS_LENGTH,
} from "../../../../src/common-models/schedule-data.model";

ScheduleContainerType,
} from "../../../../src/state/schedule-data/schedule-data.model";
describe("Month info validation", () => {
it("Should throw when length of dates in month info model is not allowed length for schedule data model", () => {
const invalidScheduleLenghth = SCHEDULE_CONTAINERS_LENGTH.SCHEDULE_DM[0] + 1;
const invalidScheduleModel = createMonthInfoModel(invalidScheduleLenghth);
const invalidScheduleModel = createFoundationInfoModel(invalidScheduleLenghth);
const action = (): void =>
validateMonthInfo(invalidScheduleModel, ScheduleContainerType.SCHEDULE_DM);
validateFoundationInfo(invalidScheduleModel, ScheduleContainerType.SCHEDULE_DM);
expect(action).to.throw();
});

it("Should throw when length of dates in month info model is not allowed length for month data model ", () => {
const invalidMOnthDayCount = 32;
const invalidMonthModel = createMonthInfoModel(invalidMOnthDayCount);
const action = (): void => validateMonthInfo(invalidMonthModel, ScheduleContainerType.MONTH_DM);
const invalidMonthModel = createFoundationInfoModel(invalidMOnthDayCount);
const action = (): void =>
validateFoundationInfo(invalidMonthModel, ScheduleContainerType.MONTH_DM);
expect(action).to.throw();
});

it("Should not throw when dates have valid length and defined", () => {
const validMonthDayCount = SCHEDULE_CONTAINERS_LENGTH.SCHEDULE_DM[0];
const validMonthModel = createMonthInfoModel(validMonthDayCount);
const validMonthModel = createFoundationInfoModel(validMonthDayCount);
const action = (): void =>
validateMonthInfo(validMonthModel, ScheduleContainerType.SCHEDULE_DM);
validateFoundationInfo(validMonthModel, ScheduleContainerType.SCHEDULE_DM);
expect(action).to.not.throw();
});

it("Should throw when length of children info is different than length of dates in schedule data model", () => {
const validLength = SCHEDULE_CONTAINERS_LENGTH.SCHEDULE_DM[0];
const invalidChildrenCount = validLength - 1;
const invalidMonthInfoModel = createMonthInfoModel(validLength, invalidChildrenCount);
const invalidFoundationInfoModel = createFoundationInfoModel(validLength, invalidChildrenCount);
const action = (): void =>
validateMonthInfo(invalidMonthInfoModel, ScheduleContainerType.SCHEDULE_DM);
validateFoundationInfo(invalidFoundationInfoModel, ScheduleContainerType.SCHEDULE_DM);
expect(action).to.throw();
});

it("Should throw when length of extra worker info is different than length of dates in schedule data model", () => {
const validLength = SCHEDULE_CONTAINERS_LENGTH.SCHEDULE_DM[0];
const invalidExtraWorkersCount = validLength - 1;
const invalidMonthInfoModel = createMonthInfoModel(
const invalidFoundationInfoModel = createFoundationInfoModel(
validLength,
validLength,
invalidExtraWorkersCount
);
const action = (): void =>
validateMonthInfo(invalidMonthInfoModel, ScheduleContainerType.SCHEDULE_DM);
validateFoundationInfo(invalidFoundationInfoModel, ScheduleContainerType.SCHEDULE_DM);
expect(action).to.throw();
});

it("Should not throw when month info is valid", () => {
const validLength = SCHEDULE_CONTAINERS_LENGTH.SCHEDULE_DM[0];
const invalidMonthInfoModel = createMonthInfoModel(validLength, validLength, validLength);
const invalidFoundationInfoModel = createFoundationInfoModel(
validLength,
validLength,
validLength
);
const action = (): void =>
validateMonthInfo(invalidMonthInfoModel, ScheduleContainerType.SCHEDULE_DM);
validateFoundationInfo(invalidFoundationInfoModel, ScheduleContainerType.SCHEDULE_DM);
expect(action).to.throw();
});
});

//#region Helper functions
/* eslint-disable @typescript-eslint/camelcase */
const createMonthInfoModel = (
const createFoundationInfoModel = (
dayCount: number,
childrenCount?: number,
extraWorkersCount?: number
): MonthInfoModel => ({
): FoundationInfoModel => ({
dates: _.range(1, dayCount + 1),
children_number: !_.isNil(childrenCount) ? _.range(1, childrenCount + 1) : undefined,
extra_workers: !_.isNil(extraWorkersCount) ? _.range(1, extraWorkersCount) : undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import * as _ from "lodash";
import { ScheduleKey } from "../../../../src/api/persistance-store.model";
import { ScheduleKey } from "../../../../src/logic/data-access/persistance-store.model";

describe("Schedule key validation", () => {
const validYear = 2020;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { ShiftCode } from "../../../src/common-models/shift-info.model";
import { shiftSectionDataCy } from "../../../src/components/schedule-page/table/schedule/sections/worker-info-section/worker-info-section.models";
import { shiftSectionDataCy } from "../../../src/components/schedule/worker-info-section/worker-info-section.models";
import { ShiftCode } from "../../../src/state/schedule-data/shifts-types/shift-types.model";

context("Display schedule", () => {
it("Should be able to load and display schedule", () => {
Expand Down
Loading

0 comments on commit 76ad3f4

Please sign in to comment.