Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Download/Preview Error Page #221

Merged
merged 8 commits into from
Aug 11, 2021
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
41 changes: 41 additions & 0 deletions cypress/integration/error400.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* eslint no-undef: 0 */

const message = "the weird backend message";
const dest = "/data/preview/4325/pdf.pdf";

describe("The error 400 page", () => {
it("goes to login if not logged in and then to correct dest", () => {
cy.visit(
"/error?message=" +
encodeURIComponent(message) +
"&dest=" +
encodeURIComponent(dest)
);

cy.get("h4").contains(message);

cy.get("a").contains("Try again").click();

cy.loginNow();

cy.url().should("include", dest);
});

it("goes to correct dest if logged in", () => {
cy.loginWithUrl("/");

cy.get("div.col-md-4.col-6 a").contains("Admin");

cy.visit(
"/error?message=" +
encodeURIComponent(message) +
"&dest=" +
encodeURIComponent(dest)
);

cy.get("h4").contains(message);

cy.get("a").contains("Try again").click();
cy.url().should("include", dest);
});
});
14 changes: 4 additions & 10 deletions cypress/integration/login_spec.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
/* eslint no-undef: 0 */

import "../support/index";

describe("The Home Page", () => {
it("successfully loads", () => {
cy.visit("/");
});

it("sets auth cookie when logging in via form submission", function () {
const username = "admin";
const password = "admin";

cy.get("input[id=formBasicUsername]").type(username);

// {enter} causes the form to submit
cy.get("input[id=formBasicPassword]").type(`${password}{enter}`);
cy.loginNow();

cy.get("span.navbar-link-description")
.contains("Health")
.click();
cy.get("span.navbar-link-description").contains("Health").click();

// UI should reflect this user being logged in
cy.get("h1").should("contain", "FileFighter");
Expand Down
32 changes: 19 additions & 13 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,29 @@
//
//
// -- This is a parent command --
Cypress.Commands.add('loginWithUrl', (path) => {
const user = {username:"Admin",password:"admin"}
Cypress.Commands.add("loginWithUrl", (path) => {
const user = { username: "Admin", password: "admin" };

cy.visit(path)
cy.get('input[id=formBasicUsername]')
.type(user.username)
cy.visit(path);
cy.get("input[id=formBasicUsername]").type(user.username);

cy.get('input[id=formBasicPassword]')
.type(`${user.password}{enter}`)
})
cy.get("input[id=formBasicPassword]").type(`${user.password}{enter}`);
});

Cypress.Commands.add('logout', () => {
const user = {username:"Admin",password:"admin"}
Cypress.Commands.add("loginNow", (path) => {
const user = { username: "Admin", password: "admin" };

cy.get("#basic-nav-dropdown").contains(user.username).click()
cy.get(".dropdown-item").contains("Logout").click()
})
cy.get("input[id=formBasicUsername]").type(user.username);

cy.get("input[id=formBasicPassword]").type(`${user.password}{enter}`);
});

Cypress.Commands.add("logout", () => {
const user = { username: "Admin", password: "admin" };

cy.get("#basic-nav-dropdown").contains(user.username).click();
cy.get(".dropdown-item").contains("Logout").click();
});

//
//
Expand Down
Loading