-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
122 additions
and
53 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
37 changes: 0 additions & 37 deletions
37
cypress/integration/e2e/table/load-exported-schedule.spec.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* 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 { WorkerType } from "../../../../src/common-models/worker-info.model"; | ||
|
||
context("Load schedule", () => { | ||
it("Shoud be able to load schedule after clicking save with empty state to database", () => { | ||
cy.visit(Cypress.env("baseUrl")); | ||
cy.get("[data-cy=nurseShiftsTable]", { timeout: 10000 }).should("not.exist"); | ||
cy.get("[data-cy=edit-mode-button]").click(); | ||
cy.saveToDatabase(); | ||
cy.get("[data-cy=leave-edit-mode]").click(); | ||
cy.loadSchedule("example_2.xlsx"); | ||
cy.checkWorkerShift({ | ||
workerType: WorkerType.NURSE, | ||
workerIdx: 0, | ||
shiftIdx: 0, | ||
desiredShiftCode: ShiftCode.N, | ||
}); | ||
}); | ||
|
||
it("Shoud be able to save file to database and after that load new schedule", () => { | ||
const cell = { | ||
workerType: WorkerType.NURSE, | ||
workerIdx: 0, | ||
shiftIdx: 0, | ||
}; | ||
cy.loadSchedule("example.xlsx"); | ||
cy.checkWorkerShift({ | ||
...cell, | ||
desiredShiftCode: ShiftCode.DN, | ||
}); | ||
cy.enterEditMode(); | ||
cy.saveToDatabase(); | ||
cy.leaveEditMode(); | ||
cy.loadSchedule("example_2.xlsx"); | ||
cy.checkWorkerShift({ | ||
...cell, | ||
desiredShiftCode: ShiftCode.N, | ||
}); | ||
}); | ||
|
||
it("Should be able to save file and load the exported file", () => { | ||
cy.loadSchedule(); | ||
|
||
cy.get("[data-cy=export-schedule-button]").click(); | ||
|
||
cy.get("a[download]") | ||
.then( | ||
(anchor) => | ||
new Cypress.Promise((resolve) => { | ||
const xhr = new XMLHttpRequest(); | ||
xhr.open("GET", anchor.prop("href"), true); | ||
xhr.responseType = "blob"; | ||
xhr.onload = (): void => { | ||
if (xhr.status === 200) { | ||
const blob = xhr.response; | ||
const reader = new FileReader(); | ||
reader.onload = (): void => { | ||
resolve(reader.result); | ||
}; | ||
reader.readAsBinaryString(blob); | ||
} | ||
}; | ||
xhr.send(); | ||
}) | ||
) | ||
.then((file: string) => { | ||
cy.writeFile("cypress/fixtures/grafik.xlsx", file, "binary"); | ||
cy.get('[data-cy="file-input"]').attachFile("grafik.xlsx"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters