chore: added iframe content test for live-preview test (#5476)

This commit is contained in:
Paul
2024-03-26 15:03:18 -03:00
committed by GitHub
parent 3d1378ab77
commit f4acc74eee
3 changed files with 24 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ import type { Page as PageType } from '../../../../test/live-preview/payload-typ
import { PAYLOAD_SERVER_URL } from '../../_api/serverURL.js' import { PAYLOAD_SERVER_URL } from '../../_api/serverURL.js'
import { Blocks } from '../../_components/Blocks/index.js' import { Blocks } from '../../_components/Blocks/index.js'
import { Gutter } from '../../_components/Gutter/index.js'
import { Hero } from '../../_components/Hero/index.js' import { Hero } from '../../_components/Hero/index.js'
export const PageClient: React.FC<{ export const PageClient: React.FC<{
@@ -20,6 +21,9 @@ export const PageClient: React.FC<{
return ( return (
<React.Fragment> <React.Fragment>
<Gutter>
<h1 id="page-title">{data.title}</h1>
</Gutter>
<Hero {...data?.hero} /> <Hero {...data?.hero} />
<Blocks <Blocks
blocks={[ blocks={[

View File

@@ -92,6 +92,10 @@ p {
} }
} }
#page-title {
@extend %h6;
}
ul, ul,
ol { ol {
padding-left: var(--base); padding-left: var(--base);

View File

@@ -85,11 +85,25 @@ describe('Live Preview', () => {
await expect(iframe).toBeVisible() await expect(iframe).toBeVisible()
}) })
test('collection - can edit fields', async () => { test('collection - can edit fields and can preview updated value', async () => {
await goToCollectionPreview(page) await goToCollectionPreview(page)
const titleValue = 'Title 1'
const field = page.locator('#field-title') const field = page.locator('#field-title')
const frame = page.frameLocator('iframe.live-preview-iframe').first()
await expect(field).toBeVisible() await expect(field).toBeVisible()
await field.fill('Title 1')
// Forces the test to wait for the nextjs route to render before we try editing a field
await expect(() => expect(frame.locator('#page-title')).toBeVisible()).toPass({
timeout: 45000,
})
await field.fill(titleValue)
await expect(() => expect(frame.locator('#page-title')).toHaveText(titleValue)).toPass({
timeout: 45000,
})
await saveDocAndAssert(page) await saveDocAndAssert(page)
}) })