@@ -3,6 +3,8 @@ import util from 'node:util'
3
3
const exec = util . promisify ( require ( 'node:child_process' ) . exec )
4
4
import { expect } from '@playwright/test'
5
5
6
+ import { sleep } from '../lib/sleep'
7
+
6
8
import { test } from './helper'
7
9
8
10
test . beforeAll ( async ( ) => {
@@ -51,7 +53,6 @@ test.describe('CRUD post operation', () => {
51
53
52
54
await page . getByTestId ( 'submit-btn' ) . click ( )
53
55
54
- await page . getByTestId ( 'snackbar' ) . waitFor ( )
55
56
await expect ( page . getByTestId ( 'snackbar' ) ) . toHaveText ( 'New Post Created!' )
56
57
57
58
await expect ( page . locator ( 'main h1' ) ) . toContainText ( 'from platwright' )
@@ -69,34 +70,34 @@ test.describe('CRUD post operation', () => {
69
70
70
71
await page . getByTestId ( 'submit-btn' ) . click ( )
71
72
72
- await page . getByTestId ( 'snackbar' ) . waitFor ( )
73
+ await sleep ( 1000 ) // wait fadeout past snackbar
73
74
await expect ( page . getByTestId ( 'snackbar' ) ) . toHaveText ( 'New Post Created!' )
74
75
75
76
await expect ( page . locator ( 'main h1' ) ) . toContainText ( 'from platwright dash' )
76
77
await expect ( page . locator ( 'main article' ) ) . toContainText ( 'testing now dash' )
77
78
await expect ( page . locator ( '[data-testid=edit-btn]' ) ) . toBeVisible ( )
78
79
} )
79
80
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
+ } )
100
101
101
102
// it('delete post', () => {
102
103
// cy.login()
0 commit comments