From cf008057eb6936b3f3f80ce503f263998e6cc3c7 Mon Sep 17 00:00:00 2001 From: Rita Date: Wed, 8 Jan 2025 15:24:19 +0100 Subject: [PATCH] test(e2e): update test for when weak property is set up in schema --- .../schema/debug/simpleReferences.js | 8 +++ test/e2e/tests/inputs/reference.spec.ts | 52 ++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/dev/test-studio/schema/debug/simpleReferences.js b/dev/test-studio/schema/debug/simpleReferences.js index e373c2bc4d3..dc9708c8b34 100644 --- a/dev/test-studio/schema/debug/simpleReferences.js +++ b/dev/test-studio/schema/debug/simpleReferences.js @@ -20,5 +20,13 @@ export const simpleReferences = { type: 'reference', to: [{type: 'simpleReferences'}], }, + { + name: 'referenceFieldWeak', + title: 'Reference field', + description: 'A simple reference field where weak is set to true', + type: 'reference', + weak: true, + to: [{type: 'simpleReferences'}], + }, ], } diff --git a/test/e2e/tests/inputs/reference.spec.ts b/test/e2e/tests/inputs/reference.spec.ts index 143d9b0f64e..5e19dc92be5 100644 --- a/test/e2e/tests/inputs/reference.spec.ts +++ b/test/e2e/tests/inputs/reference.spec.ts @@ -114,8 +114,8 @@ withDefaultClient((context) => { page.getByTestId('string-input').fill(originalTitle) /** create reference */ - await expect(page.getByRole('button', {name: 'Create…'})).toBeVisible() - page.getByRole('button', {name: 'Create…'}).click() + await expect(page.getByRole('button', {name: 'Create…'}).first()).toBeVisible() + page.getByRole('button', {name: 'Create…'}).first().click() // wait for the reference document to open await expect(page.getByTestId('document-panel-document-title').nth(1)).toContainText( @@ -147,4 +147,52 @@ withDefaultClient((context) => { ).not.toBeVisible() await expect(page.getByText('referenceField._weak_weak:true')).not.toBeVisible() }) + + test(`when reference is set to weak: true, it shouldn't strength on publish`, async ({ + page, + createDraftDocument, + }) => { + // this is in a situation where the _strengthenOnPublish.weak is not set + + test.slow() + const originalTitle = 'Initial Doc' + const documentStatus = page.getByTestId('pane-footer-document-status') + + await createDraftDocument('/test/content/input-debug;simpleReferences') + page.getByTestId('string-input').fill(originalTitle) + + /** create reference */ + await expect(page.getByRole('button', {name: 'Create…'}).nth(1)).toBeVisible() + page.getByRole('button', {name: 'Create…'}).nth(1).click() + + // wait for the reference document to open + await expect(page.getByTestId('document-panel-document-title').nth(1)).toContainText( + 'New Simple references test', + ) + + // update and publish the reference + page.getByTestId('string-input').nth(1).fill('Reference test') + await expect(page.getByTestId('document-panel-document-title').nth(1)).toContainText( + 'Reference test', + ) + page.getByTestId('action-publish').nth(1).click() // publish reference + await expect(documentStatus.nth(1)).toContainText('Published just now') + + /** --- IN ORIGINAL DOC --- */ + page.getByRole('button', {name: originalTitle}).click() + + page.getByTestId('action-publish').first().click() // publish reference + + await expect(documentStatus.first()).toContainText('Published just now') + + // open the context menu + page.getByTestId('pane-context-menu-button').first().click() + page.getByTestId('action-inspect').click() + + /** Checks that the properties were added when a weak reference is added */ + await expect( + page.getByText('referenceField._strengthenOnPublish_strengthenOnPublish:{…} 3 properties'), + ).not.toBeVisible() + await expect(page.getByText('referenceField._weak_weak:true')).toBeVisible() + }) })