Skip to content

Commit 9497239

Browse files
committed
cypress test for fetch status
1 parent 66a0524 commit 9497239

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

cypress/e2e/fetch-status.cy.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
describe("Fetch Status", () => {
2+
3+
it("Fetch data with no authenticated user", () => {
4+
5+
cy.visit("/");
6+
7+
// Go immediately to query
8+
cy.contains("Mixed book query").click();
9+
10+
// Open the sources and verify
11+
cy.get('[aria-label="Sources info"]').click();
12+
cy.get('[aria-label="Verify source"]').each(($button) => {
13+
cy.wrap($button).click();
14+
});
15+
16+
// Check if the public and restricted sources appear
17+
cy.contains("http://localhost:8080/example/favourite-books");
18+
cy.contains("http://localhost:8080/example/wish-list");
19+
20+
// Check if the correct icons appear
21+
cy.get('[aria-label="Authentication required"]').should("exist");
22+
cy.get('[aria-label="Fetch failed"]').should("exist");
23+
cy.get('[aria-label="Verification failed"]').should("exist")
24+
25+
cy.get('[aria-label="No authentication required"]').should("exist");
26+
cy.get('[aria-label="Fetch was succesful"]').should("exist");
27+
cy.get('[aria-label="Verification succeeded"]').should("exist");
28+
29+
// Checking that a non-authorized book is not appearing
30+
cy.contains("It Ends With Us").should("not.exist");
31+
32+
// Checking that a book that we may see appears
33+
cy.contains("Too Late");
34+
35+
});
36+
37+
it("Fetch data with authenticated user", () => {
38+
39+
cy.visit("/");
40+
41+
// Login as user 'example'
42+
cy.get('[aria-label="Profile"]').click();
43+
cy.contains('[role="menuitem"]', "Login").click();
44+
45+
cy.get('input[name="idp"]').clear();
46+
cy.get('input[name="idp"]').type("http://localhost:8080");
47+
cy.contains("Login").click();
48+
49+
cy.get("input#email").type("hello@example.com");
50+
cy.get("input#password").type("abc123");
51+
cy.contains("button", "Log in").click();
52+
cy.contains("button", "Authorize").click();
53+
54+
cy.url().should("eq", "http://localhost:5173/");
55+
56+
// Go to the mixed book query
57+
cy.contains("Mixed book query").click();
58+
59+
// Open the sources and verify
60+
cy.get('[aria-label="Sources info"]').click();
61+
cy.get('[aria-label="Verify source"]').each(($button) => {
62+
cy.wrap($button).click();
63+
});
64+
65+
// Check if the public and restricted sources appear
66+
cy.contains("http://localhost:8080/example/favourite-books");
67+
cy.contains("http://localhost:8080/example/wish-list");
68+
69+
// Check if the correct icons appear
70+
cy.get('[aria-label="Authentication required"]').should("exist");
71+
cy.get('[aria-label="Fetch Failed"]').should("not.exist");
72+
cy.get('[aria-label="Verification failed"]').should("not.exist");
73+
74+
cy.get('[aria-label="No authentication required"]').should("exist");
75+
cy.get('[aria-label="Fetch was succesful"]').should("exist");
76+
cy.get('[aria-label="Verification succeeded"]').should("exist");
77+
78+
// Checking that you see authorized books
79+
cy.contains("It Ends With Us");
80+
cy.contains("Too Late");
81+
});
82+
83+
})
84+
85+
86+
87+
/*
88+
it(" ", () => {
89+
90+
91+
});
92+
93+
*/

0 commit comments

Comments
 (0)