forked from freeCodeCamp/publish
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e, playwright) editor components (freeCodeCamp#362)
Co-authored-by: yoko <[email protected]>
- Loading branch information
Showing
3 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto("/posts/2"); | ||
}); | ||
|
||
|
||
test("it should be possible to type in the editor", async ({ page }) => { | ||
const textToType = 'Hello World'; | ||
await page.getByTestId('editor').fill(textToType); | ||
|
||
const wordCount = await page.getByTestId('word-count').innerText(); | ||
expect(wordCount).toBe(textToType.split(' ').length.toString() + ' words'); | ||
}); | ||
|
||
|
||
test("it should have eleven buttons in the toolbar", async ({ page }) => { | ||
const buttons = page.locator('#toolbar > button'); | ||
expect(await buttons.count()).toBe(10); | ||
|
||
const addImageButton = page.locator('#toolbar > label > button'); | ||
expect(await addImageButton.count()).toBe(1); | ||
}); | ||
|
||
test("it should be possible to edit the title", async ({ page }) => { | ||
page.getByTestId('post-title').click(); | ||
|
||
const titleField = page.getByTestId('post-title-field'); | ||
await titleField.fill('New Title'); | ||
await page.keyboard.press('Enter'); | ||
|
||
const newTitle = await page.getByTestId('post-title').innerText(); | ||
expect(newTitle).toBe('New Title'); | ||
}) |