|
| 1 | +import { expect, test } from '@playwright/test' |
| 2 | +import { AdminUrlUtil } from 'helpers/adminUrlUtil.js' |
| 3 | +import { reInitializeDB } from 'helpers/reInitializeDB.js' |
| 4 | +import { lexicalFullyFeaturedSlug } from 'lexical/slugs.js' |
| 5 | +import path from 'path' |
| 6 | +import { fileURLToPath } from 'url' |
| 7 | + |
| 8 | +import { ensureCompilationIsDone } from '../../../helpers.js' |
| 9 | +import { initPayloadE2ENoConfig } from '../../../helpers/initPayloadE2ENoConfig.js' |
| 10 | +import { TEST_TIMEOUT_LONG } from '../../../playwright.config.js' |
| 11 | +import { LexicalHelpers } from './utils.js' |
| 12 | +const filename = fileURLToPath(import.meta.url) |
| 13 | +const currentFolder = path.dirname(filename) |
| 14 | +const dirname = path.resolve(currentFolder, '../../') |
| 15 | + |
| 16 | +const { beforeAll, beforeEach, describe } = test |
| 17 | + |
| 18 | +// Unlike the other suites, this one runs in parallel, as they run on the `lexical-fully-featured/create` URL and are "pure" tests |
| 19 | +test.describe.configure({ mode: 'parallel' }) |
| 20 | + |
| 21 | +const { serverURL } = await initPayloadE2ENoConfig({ |
| 22 | + dirname, |
| 23 | +}) |
| 24 | + |
| 25 | +describe('Lexical Fully Featured', () => { |
| 26 | + beforeAll(async ({ browser }, testInfo) => { |
| 27 | + testInfo.setTimeout(TEST_TIMEOUT_LONG) |
| 28 | + process.env.SEED_IN_CONFIG_ONINIT = 'false' // Makes it so the payload config onInit seed is not run. Otherwise, the seed would be run unnecessarily twice for the initial test run - once for beforeEach and once for onInit |
| 29 | + const page = await browser.newPage() |
| 30 | + await ensureCompilationIsDone({ page, serverURL }) |
| 31 | + await page.close() |
| 32 | + }) |
| 33 | + beforeEach(async ({ page }) => { |
| 34 | + await reInitializeDB({ |
| 35 | + serverURL, |
| 36 | + snapshotKey: 'fieldsTest', |
| 37 | + uploadsDir: [ |
| 38 | + path.resolve(dirname, './collections/Upload/uploads'), |
| 39 | + path.resolve(dirname, './collections/Upload2/uploads2'), |
| 40 | + ], |
| 41 | + }) |
| 42 | + const url = new AdminUrlUtil(serverURL, lexicalFullyFeaturedSlug) |
| 43 | + const lexical = new LexicalHelpers(page) |
| 44 | + await page.goto(url.create) |
| 45 | + await lexical.editor.first().focus() |
| 46 | + }) |
| 47 | + test('prevent extra paragraph when inserting decorator blocks like blocks or upload node', async ({ |
| 48 | + page, |
| 49 | + }) => { |
| 50 | + const lexical = new LexicalHelpers(page) |
| 51 | + await lexical.slashCommand('block') |
| 52 | + await lexical.slashCommand('relationship') |
| 53 | + await lexical.drawer.locator('.list-drawer__header').getByText('Create New').click() |
| 54 | + await lexical.save('drawer') |
| 55 | + await expect(lexical.decorator).toHaveCount(2) |
| 56 | + await lexical.slashCommand('upload') |
| 57 | + await lexical.drawer.locator('.list-drawer__header').getByText('Create New').click() |
| 58 | + await lexical.drawer.getByText('Paste URL').click() |
| 59 | + await lexical.drawer |
| 60 | + .locator('.file-field__remote-file') |
| 61 | + .fill('https://payloadcms.com/images/universal-truth.jpg') |
| 62 | + await lexical.drawer.getByText('Add file').click() |
| 63 | + await lexical.save('drawer') |
| 64 | + await expect(lexical.decorator).toHaveCount(3) |
| 65 | + const paragraph = lexical.editor.locator('> p') |
| 66 | + await expect(paragraph).toHaveText('') |
| 67 | + }) |
| 68 | +}) |
0 commit comments