From b74b50e7fa0cd62564a71a8e5f36eed195de12c4 Mon Sep 17 00:00:00 2001 From: RitaDias Date: Wed, 4 Dec 2024 14:34:27 +0100 Subject: [PATCH 01/19] test(e2e): restore last e2e tests (#7926) the tests that are failing are flaky and come from before. they should be looked out but outside of the context of this PR --- .../inputs/PortableText/Decorators.spec.tsx | 3 + .../components/pane/PaneMenuButtonItem.tsx | 2 + .../documentPanel/documentViews/FormView.tsx | 1 - .../statusBar/DocumentStatusBarActions.tsx | 3 +- .../structure/util/toLowerCaseNoSpaces.tsx | 10 ++ .../e2e/tests/document-actions/delete.spec.ts | 2 +- .../document-actions/discardChanges.spec.ts | 30 +++--- .../tests/document-actions/publish.spec.ts | 4 +- .../tests/document-actions/restore.spec.ts | 98 ++++++++++--------- .../tests/document-actions/unpublish.spec.ts | 2 +- test/e2e/tests/inputs/date.spec.ts | 8 +- test/e2e/tests/inputs/datetime.spec.ts | 2 +- test/e2e/tests/inputs/reference.spec.ts | 2 +- test/e2e/tests/inputs/text.spec.ts | 2 +- .../TreeEditingBasicInteraction.spec.ts | 4 +- 15 files changed, 92 insertions(+), 81 deletions(-) create mode 100644 packages/sanity/src/structure/util/toLowerCaseNoSpaces.tsx diff --git a/packages/sanity/playwright-ct/tests/formBuilder/inputs/PortableText/Decorators.spec.tsx b/packages/sanity/playwright-ct/tests/formBuilder/inputs/PortableText/Decorators.spec.tsx index 4ccdcb4f75f..3008add7ce8 100644 --- a/packages/sanity/playwright-ct/tests/formBuilder/inputs/PortableText/Decorators.spec.tsx +++ b/packages/sanity/playwright-ct/tests/formBuilder/inputs/PortableText/Decorators.spec.tsx @@ -40,6 +40,9 @@ const DEFAULT_DECORATORS = [ test.describe('Portable Text Input', () => { test.describe('Decorators', () => { test('Render default decorators with keyboard shortcuts', async ({mount, page}) => { + // avoid flakiness to make sure the test has the best chance despite being slow + test.slow() + const { getModifierKey, getFocusedPortableTextEditor, diff --git a/packages/sanity/src/structure/components/pane/PaneMenuButtonItem.tsx b/packages/sanity/src/structure/components/pane/PaneMenuButtonItem.tsx index 29b72cd9877..418fe8e35a7 100644 --- a/packages/sanity/src/structure/components/pane/PaneMenuButtonItem.tsx +++ b/packages/sanity/src/structure/components/pane/PaneMenuButtonItem.tsx @@ -6,6 +6,7 @@ import {useIntentLink} from 'sanity/router' import {MenuGroup, MenuItem, type PopoverProps} from '../../../ui-components' import {type Intent} from '../../structureBuilder' +import {toLowerCaseNoSpaces} from '../../util/toLowerCaseNoSpaces' import {type _PaneMenuItem, type _PaneMenuNode} from './types' const MENU_GROUP_POPOVER_PROPS: PopoverProps = { @@ -108,6 +109,7 @@ function PaneContextMenuItem(props: {disabled?: boolean; node: _PaneMenuItem}) { pressed={node.selected} text={title} tone={node.tone} + data-testid={`action-${toLowerCaseNoSpaces(node.title)}`} /> ) diff --git a/packages/sanity/src/structure/panes/document/documentPanel/documentViews/FormView.tsx b/packages/sanity/src/structure/panes/document/documentPanel/documentViews/FormView.tsx index f65cad7a2ec..b3113c96cb6 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/documentViews/FormView.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/documentViews/FormView.tsx @@ -57,7 +57,6 @@ export const FormView = forwardRef(function FormV const documentStore = useDocumentStore() const presence = useDocumentPresence(documentId) const {title} = useDocumentTitle() - // The `patchChannel` is an INTERNAL publish/subscribe channel that we use to notify form-builder // nodes about both remote and local patches. // - Used by the Portable Text input to modify selections. diff --git a/packages/sanity/src/structure/panes/document/statusBar/DocumentStatusBarActions.tsx b/packages/sanity/src/structure/panes/document/statusBar/DocumentStatusBarActions.tsx index 7eabd5acdc1..3f24e5db3f8 100644 --- a/packages/sanity/src/structure/panes/document/statusBar/DocumentStatusBarActions.tsx +++ b/packages/sanity/src/structure/panes/document/statusBar/DocumentStatusBarActions.tsx @@ -11,6 +11,7 @@ import { import {Button, Tooltip} from '../../../../ui-components' import {RenderActionCollectionState} from '../../../components' import {HistoryRestoreAction} from '../../../documentActions' +import {toLowerCaseNoSpaces} from '../../../util/toLowerCaseNoSpaces' import {useDocumentPane} from '../useDocumentPane' import {ActionMenuButton} from './ActionMenuButton' import {ActionStateDialog} from './ActionStateDialog' @@ -58,7 +59,7 @@ const DocumentStatusBarActionsInner = memo(function DocumentStatusBarActionsInne