From 3fc9f7ab146c1c2944736ade50eb40a2b71d6fd8 Mon Sep 17 00:00:00 2001 From: Simone Date: Mon, 14 Jul 2025 10:07:27 +0200 Subject: [PATCH] fix: add Introduction step in the Single collection Edit view (#23943) --- .../admin/src/pages/EditView/EditViewPage.tsx | 8 +++- .../create-relation-and-publish.spec.ts | 41 +++++++++++++++++++ .../create-relation-and-save.spec.ts | 33 +-------------- 3 files changed, 50 insertions(+), 32 deletions(-) create mode 100644 tests/e2e/tests/content-manager/relations-on-the-fly/create-relation-and-publish.spec.ts diff --git a/packages/core/content-manager/admin/src/pages/EditView/EditViewPage.tsx b/packages/core/content-manager/admin/src/pages/EditView/EditViewPage.tsx index f8737a6089..c7734170dd 100644 --- a/packages/core/content-manager/admin/src/pages/EditView/EditViewPage.tsx +++ b/packages/core/content-manager/admin/src/pages/EditView/EditViewPage.tsx @@ -10,7 +10,7 @@ import { useQueryParams, unstable_tours, } from '@strapi/admin/strapi-admin'; -import { Grid, Main, Tabs } from '@strapi/design-system'; +import { Grid, Main, Tabs, Box } from '@strapi/design-system'; import { useIntl } from 'react-intl'; import { useLocation, useParams } from 'react-router-dom'; import { styled } from 'styled-components'; @@ -140,6 +140,12 @@ const EditViewPage = () => { return (
{pageTitle} + {isSingleType && ( + + {/* Invisible Anchor */} + + + )}
{ + test.beforeEach(async ({ page }) => { + await resetDatabaseAndImportDataFromPath('with-admin.tar'); + await page.goto('/admin'); + }); + + test('I want to create a new relation, publish the related document and check if the new relation is added to the parent document', async ({ + page, + }) => { + // Step 0. Login as admin + await login({ page }); + // Step 1. Got to Article collection-type and open one article + await clickAndWait(page, page.getByRole('link', { name: 'Content Manager' })); + await clickAndWait(page, page.getByRole('link', { name: 'Article' })); + await clickAndWait(page, page.getByRole('gridcell', { name: 'West Ham post match analysis' })); + + // Step 2. Open the relation modal + await page.getByRole('combobox', { name: 'authors' }).click(); + await page.getByRole('option', { name: 'Create a relation' }).click(); + + // Step 3. Edit the form + const name = page.getByRole('textbox', { name: 'name' }); + await expect(name).toHaveValue(''); + await name.fill('Mr. Fred Passo'); + await expect(name).toHaveValue('Mr. Fred Passo'); + + // Step 4. Publish the related document + await clickAndWait(page, page.getByRole('button', { name: 'Publish' })); + await expect(name).toHaveValue('Mr. Fred Passo'); + await expect(page.getByRole('status', { name: 'Published' }).first()).toBeVisible(); + + // Step 5. Close the relation modal to see the updated relation on the root document + await page.getByRole('button', { name: 'Close modal' }).click(); + await expect(page.getByRole('button', { name: 'Mr. Fred Passo' })).toBeVisible(); + }); +}); diff --git a/tests/e2e/tests/content-manager/relations-on-the-fly/create-relation-and-save.spec.ts b/tests/e2e/tests/content-manager/relations-on-the-fly/create-relation-and-save.spec.ts index 3fa5d891c9..4271ff1101 100644 --- a/tests/e2e/tests/content-manager/relations-on-the-fly/create-relation-and-save.spec.ts +++ b/tests/e2e/tests/content-manager/relations-on-the-fly/create-relation-and-save.spec.ts @@ -38,37 +38,8 @@ test.describe('Relations on the fly - Create a Relation and Save', () => { // Step 5. Close the relation modal to see the updated relation on the root document await page.getByRole('button', { name: 'Close modal' }).click(); - await expect(page.getByRole('button', { name: 'Mr. Plop' })).toBeVisible({ timeout: 20000 }); - }); - - test('I want to create a new relation, publish the related document and check if the new relation is added to the parent document', async ({ - page, - }) => { - // Step 0. Login as admin - await login({ page }); - // Step 1. Got to Article collection-type and open one article - await clickAndWait(page, page.getByRole('link', { name: 'Content Manager' })); - await clickAndWait(page, page.getByRole('link', { name: 'Article' })); - await clickAndWait(page, page.getByRole('gridcell', { name: 'West Ham post match analysis' })); - - // Step 2. Open the relation modal - await page.getByRole('combobox', { name: 'authors' }).click(); - await page.getByRole('option', { name: 'Create a relation' }).click(); - - // Step 3. Edit the form - const name = page.getByRole('textbox', { name: 'name' }); - await expect(name).toHaveValue(''); - await name.fill('Mr. Fred Passo'); - await expect(name).toHaveValue('Mr. Fred Passo'); - - // Step 4. Publish the related document - await clickAndWait(page, page.getByRole('button', { name: 'Publish' })); - await expect(name).toHaveValue('Mr. Fred Passo'); - await expect(page.getByRole('status', { name: 'Published' }).first()).toBeVisible(); - - // Step 5. Close the relation modal to see the updated relation on the root document - await page.getByRole('button', { name: 'Close modal' }).click(); - await expect(page.getByRole('button', { name: 'Mr. Fred Passo' })).toBeVisible(); + await page.waitForSelector('button:has-text("Mr. Plop")', { timeout: 20000 }); + await expect(page.getByRole('button', { name: 'Mr. Plop' })).toBeVisible(); }); test('I want to create a relation inside a component, and save', async ({ page }) => {