Skip to content

Commit

Permalink
I guess that one is no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 committed Jul 15, 2024
1 parent 867b48c commit 50d7760
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
21 changes: 13 additions & 8 deletions tests/frontend/cypress/e2e/sample.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,27 @@ describe("Sample view test - mwdb-core", function () {
it("Sample view test - existent and non-existent md5 and sha256 hashes", function () {
requestLogin(Cypress.env("user"), Cypress.env("password"));

const fileName = "TEST";
const method = "POST";
const apiUrl = "/api/file";

const fileType = "text/plain";

const addedFile = new Cypress.Promise((resolve) => {
const fileName = "TEST";
const method = "POST";
const apiUrl = "/api/file";

const fileType = "text/plain";

cy.get("@token").then((token) => {
cy.fixture(fileName).then((bin) => {
const blob = Cypress.Blob.binaryStringToBlob(bin, fileType);
const formData = new FormData();
formData.set("file", blob, fileName);

cy.formRequest(method, apiUrl, formData, token).then((response) => {
cy.request({
url: apiUrl,
method,
headers: {"Authorization": "Bearer " + token},
body: formData,
}).then((response) => {
expect(response.status).to.eq(200);
resolve(response.response.body);
resolve(response.body);
});
});
});
Expand Down
14 changes: 0 additions & 14 deletions tests/frontend/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,3 @@
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

Cypress.Commands.add("formRequest", (method, url, formData, token) => {
return cy
.intercept(method, url)
.as("formRequest")
.window()
.then((win) => {
let xhr = new win.XMLHttpRequest();
xhr.open(method, url);
xhr.setRequestHeader("Authorization", "Bearer " + token);
xhr.send(formData);
})
.wait("@formRequest");
});

0 comments on commit 50d7760

Please sign in to comment.