Browse Source

Add my cypress testing functions

eliam.ruiz 2 years ago
parent
commit
c4e6fad61f
1 changed files with 48 additions and 0 deletions
  1. 48
    0
      cypress/e2e/eliam.cy.ts

+ 48
- 0
cypress/e2e/eliam.cy.ts View File

@@ -1,2 +1,50 @@
1 1
 // I will E2E test the article page.
2 2
 // User visits home -> User clicks on "laws or advice" -> Article page contains the title
3
+
4
+
5
+describe("Our app", () => {
6
+    beforeEach(() => {
7
+      cy.intercept(
8
+        { pathname: "/api/getTopicList" },
9
+        {
10
+          fixture: "topics",
11
+        }
12
+      ).as("getTopicList");
13
+  
14
+      cy.intercept(
15
+        { pathname: "/api/getTopic" },
16
+        {
17
+          fixture: "article",
18
+        }
19
+      ).as("getTopic");
20
+  
21
+      cy.viewport("iphone-x");
22
+      cy.visit("/");
23
+    });
24
+
25
+    it("shows the home page", () => {
26
+        cy.visit("/");
27
+        cy.contains("Bienvenidos");
28
+    });
29
+
30
+    it("clicks and loads the advice tab", () => {
31
+        cy.get("#tab-button-advice").first().click();
32
+        cy.wait("@getTopicList");
33
+    })
34
+    it("clicks and loads advice info", () => {
35
+        cy.get("#tab-button-advice").first().click();
36
+        cy.wait("@getTopicList");
37
+        cy.get(".item").first().click();
38
+        cy.wait("@getTopic");
39
+        cy.contains("Adopción");
40
+        cy.contains("Enmendado en el 1939");
41
+    })
42
+    it("clicks and loads law info", () => {
43
+        cy.get("#tab-button-laws").first().click();
44
+        cy.wait("@getTopicList");
45
+        cy.get(".item").first().click();
46
+        cy.wait("@getTopic");
47
+        cy.contains("Adopción");
48
+        cy.contains("Enmendado en el 1939");
49
+    })
50
+})