Skip to content

Commit 5287e71

Browse files
migrate edit existing post
1 parent d60a0b3 commit 5287e71

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

e2e/admin_basic.spec.ts

+23-22
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import util from 'node:util'
33
const exec = util.promisify(require('node:child_process').exec)
44
import { expect } from '@playwright/test'
55

6+
import { sleep } from '../lib/sleep'
7+
68
import { test } from './helper'
79

810
test.beforeAll(async () => {
@@ -51,7 +53,6 @@ test.describe('CRUD post operation', () => {
5153

5254
await page.getByTestId('submit-btn').click()
5355

54-
await page.getByTestId('snackbar').waitFor()
5556
await expect(page.getByTestId('snackbar')).toHaveText('New Post Created!')
5657

5758
await expect(page.locator('main h1')).toContainText('from platwright')
@@ -69,34 +70,34 @@ test.describe('CRUD post operation', () => {
6970

7071
await page.getByTestId('submit-btn').click()
7172

72-
await page.getByTestId('snackbar').waitFor()
73+
await sleep(1000) // wait fadeout past snackbar
7374
await expect(page.getByTestId('snackbar')).toHaveText('New Post Created!')
7475

7576
await expect(page.locator('main h1')).toContainText('from platwright dash')
7677
await expect(page.locator('main article')).toContainText('testing now dash')
7778
await expect(page.locator('[data-testid=edit-btn]')).toBeVisible()
7879
})
7980

80-
// it('edit existing post', () => {
81-
// cy.login()
82-
// cy.visit('http://localhost:3000/')
83-
// cy.logger('Open post that creaed prev test.')
84-
// cy.$('single-post-page-link-1').contains('from cypress').click()
85-
// cy.url().should('eq', 'http://localhost:3000/post/72')
86-
// cy.get('main h1').contains('from cypress')
87-
// cy.get('main article').contains('testing now')
88-
// cy.logger('Click Edit button and modify contents.')
89-
// cy.$('edit-btn').contains('Edit').click()
90-
// cy.$('edit-title-input').type('Edit Title!')
91-
// cy.$('edit-body-input').type('Edit Post Contents!')
92-
// cy.logger(
93-
// 'Edit complete then click Update button, after page transition single post page.',
94-
// )
95-
// cy.$('update-btn').contains('Update').click()
96-
// cy.url().should('eq', 'http://localhost:3000/post/72')
97-
// cy.get('main h1').contains('Edit Title!')
98-
// cy.get('main article').contains('Edit Post Contents!')
99-
// })
81+
test('edit existing post', async ({ authenticated: page }) => {
82+
await page.goto('http://localhost:3000/')
83+
await expect(page.getByTestId('single-post-page-link-1')).toHaveText(
84+
'from platwright dash',
85+
)
86+
await page.getByTestId('single-post-page-link-1').click()
87+
await expect(page).toHaveURL('http://localhost:3000/post/72')
88+
await expect(page.locator('main h1')).toContainText('from platwright dash')
89+
await expect(page.locator('main article')).toContainText('testing now dash')
90+
await page.locator('[data-testid=edit-btn]').click()
91+
await page.getByTestId('edit-title-input').fill('Edit Title!')
92+
await page.getByTestId('edit-body-input').fill('Edit Post Contents!')
93+
94+
await page.getByTestId('update-btn').click()
95+
await expect(page).toHaveURL('http://localhost:3000/post/72')
96+
await expect(page.locator('main h1')).toContainText('Edit Title!')
97+
await expect(page.locator('main article')).toContainText(
98+
'Edit Post Contents!',
99+
)
100+
})
100101

101102
// it('delete post', () => {
102103
// cy.login()

0 commit comments

Comments
 (0)