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

Commit 616c58d

Browse files
authored
Merge pull request #221 from FileFighter/feature/download-error-page
Download/Preview Error Page
2 parents adc8366 + cd9be79 commit 616c58d

File tree

18 files changed

+627
-557
lines changed

18 files changed

+627
-557
lines changed

cypress/integration/error400.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* eslint no-undef: 0 */
2+
3+
const message = "the weird backend message";
4+
const dest = "/data/preview/4325/pdf.pdf";
5+
6+
describe("The error 400 page", () => {
7+
it("goes to login if not logged in and then to correct dest", () => {
8+
cy.visit(
9+
"/error?message=" +
10+
encodeURIComponent(message) +
11+
"&dest=" +
12+
encodeURIComponent(dest)
13+
);
14+
15+
cy.get("h4").contains(message);
16+
17+
cy.get("a").contains("Try again").click();
18+
19+
cy.loginNow();
20+
21+
cy.url().should("include", dest);
22+
});
23+
24+
it("goes to correct dest if logged in", () => {
25+
cy.loginWithUrl("/");
26+
27+
cy.get("div.col-md-4.col-6 a").contains("Admin");
28+
29+
cy.visit(
30+
"/error?message=" +
31+
encodeURIComponent(message) +
32+
"&dest=" +
33+
encodeURIComponent(dest)
34+
);
35+
36+
cy.get("h4").contains(message);
37+
38+
cy.get("a").contains("Try again").click();
39+
cy.url().should("include", dest);
40+
});
41+
});

cypress/integration/login_spec.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
/* eslint no-undef: 0 */
22

3+
import "../support/index";
4+
35
describe("The Home Page", () => {
46
it("successfully loads", () => {
57
cy.visit("/");
68
});
79

810
it("sets auth cookie when logging in via form submission", function () {
9-
const username = "admin";
10-
const password = "admin";
11-
12-
cy.get("input[id=formBasicUsername]").type(username);
13-
14-
// {enter} causes the form to submit
15-
cy.get("input[id=formBasicPassword]").type(`${password}{enter}`);
11+
cy.loginNow();
1612

17-
cy.get("span.navbar-link-description")
18-
.contains("Health")
19-
.click();
13+
cy.get("span.navbar-link-description").contains("Health").click();
2014

2115
// UI should reflect this user being logged in
2216
cy.get("h1").should("contain", "FileFighter");

cypress/support/commands.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,29 @@
1010
//
1111
//
1212
// -- This is a parent command --
13-
Cypress.Commands.add('loginWithUrl', (path) => {
14-
const user = {username:"Admin",password:"admin"}
13+
Cypress.Commands.add("loginWithUrl", (path) => {
14+
const user = { username: "Admin", password: "admin" };
1515

16-
cy.visit(path)
17-
cy.get('input[id=formBasicUsername]')
18-
.type(user.username)
16+
cy.visit(path);
17+
cy.get("input[id=formBasicUsername]").type(user.username);
1918

20-
cy.get('input[id=formBasicPassword]')
21-
.type(`${user.password}{enter}`)
22-
})
19+
cy.get("input[id=formBasicPassword]").type(`${user.password}{enter}`);
20+
});
2321

24-
Cypress.Commands.add('logout', () => {
25-
const user = {username:"Admin",password:"admin"}
22+
Cypress.Commands.add("loginNow", (path) => {
23+
const user = { username: "Admin", password: "admin" };
2624

27-
cy.get("#basic-nav-dropdown").contains(user.username).click()
28-
cy.get(".dropdown-item").contains("Logout").click()
29-
})
25+
cy.get("input[id=formBasicUsername]").type(user.username);
26+
27+
cy.get("input[id=formBasicPassword]").type(`${user.password}{enter}`);
28+
});
29+
30+
Cypress.Commands.add("logout", () => {
31+
const user = { username: "Admin", password: "admin" };
32+
33+
cy.get("#basic-nav-dropdown").contains(user.username).click();
34+
cy.get(".dropdown-item").contains("Logout").click();
35+
});
3036

3137
//
3238
//

0 commit comments

Comments
 (0)