|
1 |
| -describe('Integration :: Player Search', () => { |
| 1 | +describe("Integration :: Player Search", () => { |
| 2 | + const url = Cypress.env("API_URL"); |
| 3 | + |
2 | 4 | beforeEach(() => {
|
3 |
| - cy.visit('http://localhost:3000') |
| 5 | + cy.visit("http://localhost:3000"); |
4 | 6 |
|
5 |
| - cy.get('button[data-testid="platform-psn"]').as('psnBtn') |
6 |
| - cy.get('button[data-testid="platform-xbl"]').as('xblBtn') |
7 |
| - cy.get('button[data-testid="platform-origin"]').as('pcBtn') |
| 7 | + cy.get('button[data-testid="platform-psn"]').as("psnBtn"); |
| 8 | + cy.get('button[data-testid="platform-xbl"]').as("xblBtn"); |
| 9 | + cy.get('button[data-testid="platform-origin"]').as("pcBtn"); |
8 | 10 |
|
9 |
| - cy.get('input[name="player-tag"]').as('playerHandleInput') |
| 11 | + cy.get('input[name="player-tag"]').as("playerHandleInput"); |
10 | 12 |
|
11 |
| - cy.get('button[data-testid="submit-btn"]').as('submitBtn') |
| 13 | + cy.get('button[data-testid="submit-btn"]').as("submitBtn"); |
12 | 14 |
|
13 |
| - cy.server({ delay: 50 }) |
14 |
| - }) |
| 15 | + cy.server({ delay: 50 }); |
| 16 | + }); |
15 | 17 |
|
16 |
| - it('Should not submit a player search with empty fields', () => { |
17 |
| - cy.get('@submitBtn').click() |
| 18 | + it("Should not submit a player search with empty fields", () => { |
| 19 | + cy.get("@submitBtn").click(); |
18 | 20 |
|
19 |
| - cy.get('.error-msg').contains('Please complete the form') |
20 |
| - }) |
| 21 | + cy.get(".error-msg").contains("Please complete the form"); |
| 22 | + }); |
21 | 23 |
|
22 |
| - it('Should not submit a player search with only a platform selected', () => { |
23 |
| - cy.get('@psnBtn').click() |
| 24 | + it("Should not submit a player search with only a platform selected", () => { |
| 25 | + cy.get("@psnBtn").click(); |
24 | 26 |
|
25 |
| - cy.get('@submitBtn').click() |
| 27 | + cy.get("@submitBtn").click(); |
26 | 28 |
|
27 |
| - cy.get('.error-msg').contains('Please complete the form') |
28 |
| - }) |
| 29 | + cy.get(".error-msg").contains("Please complete the form"); |
| 30 | + }); |
29 | 31 |
|
30 |
| - it('Should not submit a player search with only a player handle entered', () => { |
31 |
| - cy.get('@playerHandleInput').type('leroyjenkins') |
| 32 | + it("Should not submit a player search with only a player handle entered", () => { |
| 33 | + cy.get("@playerHandleInput").type("leroyjenkins"); |
32 | 34 |
|
33 |
| - cy.get('@submitBtn').click() |
| 35 | + cy.get("@submitBtn").click(); |
34 | 36 |
|
35 |
| - cy.get('.error-msg').contains('Please complete the form') |
36 |
| - }) |
| 37 | + cy.get(".error-msg").contains("Please complete the form"); |
| 38 | + }); |
37 | 39 |
|
38 |
| - it('Should submit a player search for Leroy Jenkins, and display no players found msg', () => { |
| 40 | + it("Should submit a player search for Leroy Jenkins, and display no players found msg", () => { |
39 | 41 | cy.route({
|
40 |
| - url: 'http://localhost:4000', |
41 |
| - method: 'POST', |
| 42 | + url, |
| 43 | + method: "POST", |
42 | 44 | response: { data: { searchPlayers: [] } }
|
43 |
| - }).as('searchLeroyJenkins') |
| 45 | + }).as("searchLeroyJenkins"); |
44 | 46 |
|
45 |
| - cy.get('@playerHandleInput').type('leroyjenkins') |
| 47 | + cy.get("@playerHandleInput").type("leroyjenkins"); |
46 | 48 |
|
47 |
| - cy.get('@psnBtn').click() |
| 49 | + cy.get("@psnBtn").click(); |
48 | 50 |
|
49 |
| - cy.get('@submitBtn').click() |
| 51 | + cy.get("@submitBtn").click(); |
50 | 52 |
|
51 |
| - cy.get('@submitBtn').contains('Loading...') |
| 53 | + cy.get("@submitBtn").contains("Loading..."); |
52 | 54 |
|
53 |
| - cy.wait('@searchLeroyJenkins') |
| 55 | + cy.wait("@searchLeroyJenkins"); |
54 | 56 |
|
55 |
| - cy.get('.error-msg').contains('No players were found with those details') |
56 |
| - }) |
| 57 | + cy.get(".error-msg").contains("No players were found with those details"); |
| 58 | + }); |
57 | 59 |
|
58 |
| - it('Should submit a player search for DiRTiG, and display results', () => { |
59 |
| - cy.fixture('player-search-DiRTiG').then(response => { |
| 60 | + it("Should submit a player search for DiRTiG, and display results", () => { |
| 61 | + cy.fixture("player-search-DiRTiG").then(response => { |
60 | 62 | cy.route({
|
61 |
| - method: 'POST', |
| 63 | + method: "POST", |
62 | 64 | response,
|
63 |
| - url: 'http://localhost:4000', |
64 |
| - }).as('searchDiRTiG') |
65 |
| - }) |
| 65 | + url |
| 66 | + }).as("searchDiRTiG"); |
| 67 | + }); |
66 | 68 |
|
67 |
| - cy.get('@playerHandleInput').type('DiRTiG') |
| 69 | + cy.get("@playerHandleInput").type("DiRTiG"); |
68 | 70 |
|
69 |
| - cy.get('@psnBtn').click() |
| 71 | + cy.get("@psnBtn").click(); |
70 | 72 |
|
71 |
| - cy.get('@submitBtn').click() |
| 73 | + cy.get("@submitBtn").click(); |
72 | 74 |
|
73 |
| - cy.get('@submitBtn').contains('Loading...') |
| 75 | + cy.get("@submitBtn").contains("Loading..."); |
74 | 76 |
|
75 |
| - cy.wait('@searchDiRTiG') |
| 77 | + cy.wait("@searchDiRTiG"); |
76 | 78 |
|
77 |
| - cy.get('ul[data-testid="search-results"]') |
| 79 | + cy.get('ul[data-testid="search-results"]'); |
78 | 80 |
|
79 | 81 | cy.get('li[data-testid="psn-dirtig"]')
|
80 |
| - .find('span[data-testid="user-handle"]').contains('dirtig') |
| 82 | + .find('span[data-testid="user-handle"]') |
| 83 | + .contains("dirtig"); |
81 | 84 |
|
82 | 85 | cy.get('li[data-testid="psn-dirtig"]')
|
83 |
| - .find('span[data-testid="user-platform"]').contains('psn') |
84 |
| - }) |
| 86 | + .find('span[data-testid="user-platform"]') |
| 87 | + .contains("psn"); |
| 88 | + }); |
85 | 89 |
|
86 |
| - it('Should allow user to click search result and redirect to /stats route', () => { |
87 |
| - cy.fixture('player-search-DiRTiG').then(response => { |
| 90 | + it("Should allow user to click search result and redirect to /stats route", () => { |
| 91 | + cy.fixture("player-search-DiRTiG").then(response => { |
88 | 92 | cy.route({
|
89 |
| - method: 'POST', |
| 93 | + method: "POST", |
90 | 94 | response,
|
91 |
| - url: 'http://localhost:4000', |
92 |
| - }).as('searchDiRTiG') |
93 |
| - }) |
| 95 | + url |
| 96 | + }).as("searchDiRTiG"); |
| 97 | + }); |
94 | 98 |
|
95 |
| - cy.get('@playerHandleInput').type('DiRTiG') |
| 99 | + cy.get("@playerHandleInput").type("DiRTiG"); |
96 | 100 |
|
97 |
| - cy.get('@psnBtn').click() |
| 101 | + cy.get("@psnBtn").click(); |
98 | 102 |
|
99 |
| - cy.get('@submitBtn').click() |
| 103 | + cy.get("@submitBtn").click(); |
100 | 104 |
|
101 |
| - cy.get('@submitBtn').contains('Loading...') |
| 105 | + cy.get("@submitBtn").contains("Loading..."); |
102 | 106 |
|
103 |
| - cy.wait('@searchDiRTiG') |
| 107 | + cy.wait("@searchDiRTiG"); |
104 | 108 |
|
105 |
| - cy.get('ul[data-testid="search-results"]') |
| 109 | + cy.get('ul[data-testid="search-results"]'); |
106 | 110 |
|
107 | 111 | // THE STACKING OF NETWORK STUBS IS UNPLEASANT, NICER SOLUTION REQUIRED
|
108 |
| - cy.fixture('player-stats-DiRTiG').then(response => { |
| 112 | + cy.fixture("player-stats-DiRTiG").then(response => { |
109 | 113 | cy.route({
|
110 |
| - method: 'POST', |
| 114 | + method: "POST", |
111 | 115 | response,
|
112 |
| - url: 'http://localhost:4000', |
113 |
| - }).as('DiRTiGStatsPage') |
114 |
| - }) |
115 |
| - |
116 |
| - cy.get('li[data-testid="psn-dirtig"]').click() |
| 116 | + url |
| 117 | + }).as("DiRTiGStatsPage"); |
| 118 | + }); |
117 | 119 |
|
| 120 | + cy.get('li[data-testid="psn-dirtig"]').click(); |
118 | 121 |
|
119 |
| - cy.wait('@DiRTiGStatsPage') |
120 |
| - }) |
121 |
| -}) |
| 122 | + cy.wait("@DiRTiGStatsPage"); |
| 123 | + }); |
| 124 | +}); |
0 commit comments