Skip to content

Commit a0d860c

Browse files
committed
update 03
1 parent 2f06913 commit a0d860c

40 files changed

Lines changed: 5536 additions & 18824 deletions

05-testing/03-e2e/03-stub-requests/.babelrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

05-testing/03-e2e/03-stub-requests/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ We will start from `02-selectors`.
1212
npm install
1313
```
1414

15-
- We will create `hotel-collection` specs:
15+
We will create `hotel-collection` specs:
1616

17-
### ./cypress/e2e/hotel-collection.spec.ts
17+
_./cypress/e2e/hotel-collection.spec.ts_
1818

1919
```javascript
2020
describe('Hotel collection specs', () => {
@@ -26,9 +26,9 @@ describe('Hotel collection specs', () => {
2626
});
2727
```
2828

29-
- Update spec:
29+
Update spec:
3030

31-
### ./cypress/e2e/hotel-collection.spec.ts
31+
_./cypress/e2e/hotel-collection.spec.ts_
3232

3333
```diff
3434
describe('Hotel collection specs', () => {
@@ -45,7 +45,7 @@ describe('Hotel collection specs', () => {
4545

4646
```
4747

48-
- Maybe we could expect `have length greater than`:
48+
Maybe we could expect `have length greater than`:
4949

5050
```diff
5151
+ it('should fetch hotel list greater than 0 when visit /hotel-collection url', () => {
@@ -59,9 +59,9 @@ describe('Hotel collection specs', () => {
5959
+ });
6060
```
6161

62-
- But in some scenarios, maybe we need to simulate this fetch. How can we simulate, fetching 2 hotels?:
62+
But in some scenarios, maybe we need to simulate this fetch. How can we simulate, fetching 2 hotels?:
6363

64-
### ./cypress/e2e/hotel-collection.spec.ts
64+
_./cypress/e2e/hotel-collection.spec.ts_
6565

6666
```diff
6767
+ import { HotelEntityApi } from '../../src/pods/hotel-collection/api';
@@ -106,9 +106,9 @@ describe('Hotel collection specs', () => {
106106
>
107107
> Mock data, 404 responses, etc
108108
109-
- This is a common task that we will have to do, so cypress provide the `fixtures` approach:
109+
This is a common task that we will have to do, so cypress provide the `fixtures` approach:
110110

111-
### ./cypress/fixtures/hotels.json
111+
_./cypress/fixtures/hotels.json_
112112

113113
```json
114114
[
@@ -133,9 +133,9 @@ describe('Hotel collection specs', () => {
133133
]
134134
```
135135

136-
- Update spec:
136+
Update spec:
137137

138-
### ./cypress/e2e/hotel-collection.spec.ts
138+
_./cypress/e2e/hotel-collection.spec.ts_
139139

140140
```diff
141141
- import { HotelEntityApi } from '../../src/pods/hotel-collection/api';
@@ -176,9 +176,9 @@ describe('Hotel collection specs', () => {
176176

177177
```
178178

179-
- Or a shorted way:
179+
Or a shorted way:
180180

181-
### ./cypress/e2e/hotel-collection.spec.ts
181+
_./cypress/e2e/hotel-collection.spec.ts_
182182

183183
```diff
184184
it('should fetch two hotels when visit /hotel-collection url', () => {

05-testing/03-e2e/03-stub-requests/config/webpack/base.js

Lines changed: 0 additions & 43 deletions
This file was deleted.

05-testing/03-e2e/03-stub-requests/config/webpack/dev.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

05-testing/03-e2e/03-stub-requests/config/webpack/helpers.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

05-testing/03-e2e/03-stub-requests/config/webpack/prod.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

05-testing/03-e2e/03-stub-requests/cypress/e2e/hotel-collection.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('Hotel collection specs', () => {
2020

2121
it('should fetch two hotels when visit /hotel-collection url', () => {
2222
// Arrange
23-
cy.intercept('GET', '/api/hotels', { fixture: 'hotels.json' });
23+
cy.intercept('GET', '/api/hotels', { fixture: 'hotels' });
2424

2525
// Act
2626
cy.visit('/hotel-collection');

05-testing/03-e2e/03-stub-requests/cypress/e2e/login.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ describe('Login specs', () => {
88

99
// Act
1010
cy.visit('/');
11-
cy.findByLabelText('Name').click();
11+
cy.findByRole('textbox').click();
1212

1313
// Assert
14-
cy.findByLabelText('Name').should('have.focus');
14+
cy.findByRole('textbox').should('have.focus');
1515
});
1616

1717
it('should show an alert with a message when type invalid credentials', () => {
@@ -22,7 +22,7 @@ describe('Login specs', () => {
2222

2323
// Act
2424
cy.visit('/');
25-
cy.findByLabelText('Name').as('userInput');
25+
cy.findByRole('textbox').as('userInput');
2626
cy.findByLabelText('Password').as('passwordInput');
2727

2828
cy.get('@userInput').type(user);
@@ -53,6 +53,6 @@ describe('Login specs', () => {
5353
cy.findByRole('button', { name: 'Login' }).click();
5454

5555
// Assert
56-
cy.url().should('eq', 'http://localhost:8080/#/hotel-collection');
56+
cy.url().should('equal', 'http://localhost:8080/#/hotel-collection');
5757
});
5858
});

05-testing/03-e2e/03-stub-requests/dev.env

Lines changed: 0 additions & 1 deletion
This file was deleted.

05-testing/03-e2e/03-stub-requests/src/index.html renamed to 05-testing/03-e2e/03-stub-requests/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
</head>
88
<body>
99
<div id="root"></div>
10+
<script type="module" src="/src/index.tsx"></script>
1011
</body>
1112
</html>

0 commit comments

Comments
 (0)