Skip to content

Commit 673f35f

Browse files
committed
Make small fixes to part5d
1 parent 1244215 commit 673f35f

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

src/content/5/en/part5d.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,9 @@ export { loginWith, createNote } // highlight-line
912912
The tests are simplified as follows:
913913
914914
```js
915+
const { test, describe, expect, beforeEach } = require('@playwright/test')
916+
const { createNote, loginWith } = require('./helper') // highlight-line
917+
915918
describe('Note app', () => {
916919
// ...
917920

@@ -995,7 +998,7 @@ Let's change the initialization block of the test so that it creates two notes i
995998
```js
996999
describe('when logged in', () => {
9971000
// ...
998-
describe('and several notes exists', () => {
1001+
describe('and several notes exists', () => { // highlight-line
9991002
beforeEach(async ({ page }) => {
10001003
// highlight-start
10011004
await createNote(page, 'first note')
@@ -1051,7 +1054,7 @@ One way to fix the problem is as follows:
10511054
```js
10521055
test('one of those can be made nonimportant', async ({ page }) => {
10531056
const otherNoteText = page.getByText('first note') // highlight-line
1054-
const otherNoteElement = await otherNoteText.locator('..') // highlight-line
1057+
const otherNoteElement = otherNoteText.locator('..') // highlight-line
10551058

10561059
await otherNoteElement.getByRole('button', { name: 'make not important' }).click()
10571060
await expect(otherNoteElement.getByText('make important')).toBeVisible()
@@ -1083,16 +1086,16 @@ describe('when logged in', () => {
10831086
await expect(page.getByText('a note created by playwright')).toBeVisible()
10841087
})
10851088

1086-
describe('and a note exists', () => {
1089+
describe('and several notes exists', () => {
10871090
beforeEach(async ({ page }) => {
10881091
await createNote(page, 'first note')
10891092
await createNote(page, 'second note')
10901093
await createNote(page, 'third note') // highlight-line
10911094
})
10921095

1093-
test('importance can be changed', async ({ page }) => {
1096+
test('one of those can be made nonimportant', async ({ page }) => {
10941097
const otherNoteText = page.getByText('second note') // highlight-line
1095-
const otherNoteElement = await otherNoteText.locator('..')
1098+
const otherNoteElement = otherNoteText.locator('..')
10961099

10971100
await otherNoteElement.getByRole('button', { name: 'make not important' }).click()
10981101
await expect(otherNoteElement.getByText('make important')).toBeVisible()
@@ -1110,7 +1113,7 @@ If, and when the tests don't pass and you suspect that the fault is in the tests
11101113
The following command runs the problematic test in debug mode:
11111114
11121115
```
1113-
npm test -- -g'importance can be changed' --debug
1116+
npm test -- -g'one of those can be made nonimportant' --debug
11141117
```
11151118
11161119
Playwright-inspector shows the progress of the tests step by step. The arrow-dot button at the top takes the tests one step further. The elements found by the locators and the interaction with the browser are visualized in the browser:
@@ -1140,7 +1143,7 @@ describe('Note app', () => {
11401143
test('one of those can be made nonimportant', async ({ page }) => {
11411144
await page.pause() // highlight-line
11421145
const otherNoteText = page.getByText('second note')
1143-
const otherNoteElement = await otherNoteText.locator('..')
1146+
const otherNoteElement = otherNoteText.locator('..')
11441147

11451148
await otherNoteElement.getByRole('button', { name: 'make not important' }).click()
11461149
await expect(otherNoteElement.getByText('make important')).toBeVisible()

src/content/5/fi/osa5d.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -867,9 +867,12 @@ const createNote = async (page, content) => {
867867
export { loginWith, createNote } // highlight-line
868868
```
869869
870-
Testi yksinkertaistuu seuraavasti:
870+
Testit yksinkertaistuvat seuraavasti:
871871
872872
```js
873+
const { test, describe, expect, beforeEach } = require('@playwright/test')
874+
const { createNote, loginWith } = require('./helper') // highlight-line
875+
873876
describe('Note app', () => {
874877
// ...
875878

@@ -879,13 +882,13 @@ describe('Note app', () => {
879882
})
880883

881884
test('a new note can be created', async ({ page }) => {
882-
await createNote(page, 'a note created by playwright')
885+
await createNote(page, 'a note created by playwright') // highlight-line
883886
await expect(page.getByText('a note created by playwright')).toBeVisible()
884887
})
885888

886889
describe('and a note exists', () => {
887890
beforeEach(async ({ page }) => {
888-
await createNote(page, 'another note by playwright')
891+
await createNote(page, 'another note by playwright') // highlight-line
889892
})
890893

891894
test('importance can be changed', async ({ page }) => {
@@ -953,7 +956,7 @@ Muutetaan testin alustuslohkoa siten, että se luo yhden sijaan kaksi muistiinpa
953956
```js
954957
describe('when logged in', () => {
955958
// ...
956-
describe('and several notes exists', () => {
959+
describe('and several notes exists', () => { // highlight-line
957960
beforeEach(async ({ page }) => {
958961
// highlight-start
959962
await createNote(page, 'first note', true)
@@ -1009,10 +1012,10 @@ Eräs tapa korjata ongelma on seuraavassa:
10091012
```js
10101013
test('one of those can be made nonimportant', async ({ page }) => {
10111014
const otherNoteText = page.getByText('first note') // highlight-line
1012-
const otherdNoteElement = await otherNoteText.locator('..') // highlight-line
1015+
const otherNoteElement = otherNoteText.locator('..') // highlight-line
10131016

1014-
await otherdNoteElement.getByRole('button', { name: 'make not important' }).click()
1015-
await expect(otherdNoteElement.getByText('make important')).toBeVisible()
1017+
await otherNoteElement.getByRole('button', { name: 'make not important' }).click()
1018+
await expect(otherNoteElement.getByText('make important')).toBeVisible()
10161019
})
10171020
```
10181021
@@ -1041,19 +1044,19 @@ describe('when logged in', () => {
10411044
await expect(page.getByText('a note created by playwright')).toBeVisible()
10421045
})
10431046

1044-
describe('and a note exists', () => {
1047+
describe('and several notes exists', () => {
10451048
beforeEach(async ({ page }) => {
10461049
await createNote(page, 'first note', true)
10471050
await createNote(page, 'second note', true)
10481051
await createNote(page, 'third note', true) // highlight-line
10491052
})
10501053

1051-
test('importance can be changed', async ({ page }) => {
1054+
test('one of those can be made nonimportant', async ({ page }) => {
10521055
const otherNoteText = page.getByText('second note') // highlight-line
1053-
const otherdNoteElement = await otherNoteText.locator('..')
1056+
const otherNoteElement = otherNoteText.locator('..')
10541057

1055-
await otherdNoteElement.getByRole('button', { name: 'make not important' }).click()
1056-
await expect(otherdNoteElement.getByText('make important')).toBeVisible()
1058+
await otherNoteElement.getByRole('button', { name: 'make not important' }).click()
1059+
await expect(otherNoteElement.getByText('make important')).toBeVisible()
10571060
})
10581061
})
10591062
})
@@ -1068,7 +1071,7 @@ Jos/kun testit eivät mene läpi ja herää epäilys, että vika on koodin sijaa
10681071
Seuraava komento suorittaa ongelmallisen testin debug-moodissa:
10691072
10701073
```
1071-
npm test -- -g'importance can be changed' --debug
1074+
npm test -- -g'one of those can be made nonimportant' --debug
10721075
```
10731076
10741077
Playwright-inspector näyttää testien etenemisen askel askeleelta. Yläreunan nuoli-piste-painike vie testejä yhden askeleen eteenpäin. Lokaattorien löytämät elementit sekä selaimen kanssa käyty interaktio visualisoituvat selaimeen:
@@ -1098,10 +1101,10 @@ describe('Note app', () => {
10981101
test('one of those can be made unimportant', async ({ page }) => {
10991102
await page.pause() // highlight-line
11001103
const otherNoteText = page.getByText('second note')
1101-
const otherdNoteElement = await otherNoteText.locator('..')
1104+
const otherNoteElement = otherNoteText.locator('..')
11021105

1103-
await otherdNoteElement.getByRole('button', { name: 'make not important' }).click()
1104-
await expect(otherdNoteElement.getByText('make important')).toBeVisible()
1106+
await otherNoteElement.getByRole('button', { name: 'make not important' }).click()
1107+
await expect(otherNoteElement.getByText('make important')).toBeVisible()
11051108
})
11061109
})
11071110
})

0 commit comments

Comments
 (0)