From 360077bf659457d923cf79af45f0e5f692e4cb31 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Mon, 25 Mar 2024 11:54:13 +0000 Subject: [PATCH] Add Suspense to test element container (#17520) GitOrigin-RevId: 0d7702289870a1074cdf4bd907b55fa6f32b8457 --- .../review-panel/review-panel.spec.tsx | 18 ++-- .../codemirror-editor-autocomplete.spec.tsx | 82 +++++++++---------- .../codemirror-editor-close-brackets.spec.tsx | 10 +-- .../codemirror-editor-cursor.spec.tsx | 11 +-- ...> codemirror-editor-figure-modal.spec.tsx} | 9 +- .../codemirror-editor-fundamentals.spec.tsx | 10 +-- .../codemirror-editor-shortcuts.spec.tsx | 18 ++-- .../codemirror-editor-spellchecker.spec.tsx | 10 +-- ...codemirror-editor-table-generator.spec.tsx | 10 +-- ...ror-editor-visual-command-tooltip.spec.tsx | 10 +-- .../codemirror-editor-visual-floats.spec.tsx | 10 +-- .../codemirror-editor-visual-list.spec.tsx | 10 +-- ...demirror-editor-visual-paste-html.spec.tsx | 10 +-- ...codemirror-editor-visual-readonly.spec.tsx | 9 +- .../codemirror-editor-visual-toolbar.spec.tsx | 24 +++--- ...codemirror-editor-visual-tooltips.spec.tsx | 10 +-- .../codemirror-editor-visual.spec.tsx | 9 +- .../components/codemirror-editor.spec.tsx | 66 +++++++-------- .../source-editor/helpers/test-container.tsx | 12 +++ 19 files changed, 147 insertions(+), 201 deletions(-) rename services/web/test/frontend/features/source-editor/components/{figure-modal.spec.tsx => codemirror-editor-figure-modal.spec.tsx} (99%) create mode 100644 services/web/test/frontend/features/source-editor/helpers/test-container.tsx diff --git a/services/web/test/frontend/features/review-panel/review-panel.spec.tsx b/services/web/test/frontend/features/review-panel/review-panel.spec.tsx index 16e2ebf0f2..26f6b2ccf5 100644 --- a/services/web/test/frontend/features/review-panel/review-panel.spec.tsx +++ b/services/web/test/frontend/features/review-panel/review-panel.spec.tsx @@ -1,15 +1,7 @@ import CodeMirrorEditor from '../../../../frontend/js/features/source-editor/components/codemirror-editor' import { EditorProviders } from '../../helpers/editor-providers' import { mockScope } from '../source-editor/helpers/mock-scope' - -type ContainerProps = { - children: React.ReactNode - className?: string -} - -function Container(props: ContainerProps) { - return
-} +import { TestContainer } from '../source-editor/helpers/test-container' describe('', function () { beforeEach(function () { @@ -27,11 +19,11 @@ describe('', function () { cy.wrap(scope).as('scope') cy.mount( - + - + ) cy.findByTestId('review-panel').as('review-panel') @@ -103,11 +95,11 @@ describe('', function () { scope.editor.wantTrackChanges = true cy.mount( - + - + ) cy.findByTestId('review-panel').within(() => { diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-autocomplete.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-autocomplete.spec.tsx index c1f43f4182..d18fd3ddda 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-autocomplete.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-autocomplete.spec.tsx @@ -1,4 +1,3 @@ -import { FC } from 'react' import { Folder } from '../../../../../types/folder' import { docId, mockDocContent } from '../helpers/mock-doc' import { Metadata } from '../../../../../types/metadata' @@ -7,10 +6,7 @@ import { EditorProviders } from '../../../helpers/editor-providers' import CodeMirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' import { activeEditorLine } from '../helpers/active-editor-line' import { User, UserId } from '../../../../../types/user' - -const Container: FC = ({ children }) => ( -
{children}
-) +import { TestContainer } from '../helpers/test-container' describe('autocomplete', { scrollBehavior: false }, function () { beforeEach(function () { @@ -93,7 +89,7 @@ describe('autocomplete', { scrollBehavior: false }, function () { scope.project.rootFolder = rootFolder cy.mount( - + - + ) cy.get('.cm-editor').as('editor') @@ -268,7 +264,7 @@ describe('autocomplete', { scrollBehavior: false }, function () { scope.$root._references.keys = ['foo'] cy.mount( - + - + ) cy.get('.cm-editor').as('editor') @@ -386,7 +382,7 @@ describe('autocomplete', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) cy.get('.cm-editor').as('editor') @@ -461,7 +457,7 @@ describe('autocomplete', { scrollBehavior: false }, function () { scope.$root._references.keys = ['ref-1', 'ref-2', 'ref-3'] cy.mount( - + - + ) cy.get('.cm-editor').as('editor') @@ -531,7 +527,7 @@ describe('autocomplete', { scrollBehavior: false }, function () { scope.project.rootFolder = rootFolder cy.mount( - + - + ) cy.get('.cm-editor').as('editor') @@ -573,11 +569,11 @@ describe('autocomplete', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) // put the cursor on a blank line to type in @@ -619,11 +615,11 @@ describe('autocomplete', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) // put the cursor on a blank line to type in @@ -654,11 +650,11 @@ describe('autocomplete', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) // put the cursor on a blank line to type in @@ -689,11 +685,11 @@ describe('autocomplete', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) cy.get('.cm-editor').as('editor') @@ -728,11 +724,11 @@ describe('autocomplete', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) cy.get('.cm-editor').as('editor') @@ -764,11 +760,11 @@ describe('autocomplete', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) cy.get('.cm-editor').as('editor') @@ -837,11 +833,11 @@ describe('autocomplete', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) cy.get('.cm-editor').as('editor') @@ -865,11 +861,11 @@ describe('autocomplete', { scrollBehavior: false }, function () { email: 'testuser@example.com', } as User cy.mount( - + - + ) // put the cursor on a blank line to type in cy.get('.cm-line').eq(16).as('line') @@ -897,11 +893,11 @@ describe('autocomplete', { scrollBehavior: false }, function () { email: 'testuser@example.com', } cy.mount( - + - + ) // put the cursor on a blank line to type in cy.get('.cm-line').eq(16).as('line') @@ -921,11 +917,11 @@ describe('autocomplete', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) // Put the cursor on a blank line to type in @@ -945,11 +941,11 @@ describe('autocomplete', { scrollBehavior: false }, function () { const scope = mockScope(mockDocContent('\\begin{}')) cy.mount( - + - + ) // Put the cursor on a blank line above target line @@ -968,11 +964,11 @@ describe('autocomplete', { scrollBehavior: false }, function () { const scope = mockScope(mockDocContent('\\begin{')) cy.mount( - + - + ) // Put the cursor on a blank line above target line @@ -1026,7 +1022,7 @@ describe('autocomplete', { scrollBehavior: false }, function () { scope.project.rootFolder = rootFolder cy.mount( - + - + ) // Put the cursor on a blank line and type @@ -1090,11 +1086,11 @@ describe('autocomplete', { scrollBehavior: false }, function () { const scope = mockScope(mockDocContent('')) cy.mount( - + - + ) cy.get('.cm-line').eq(21).type('\\fff \\ff') diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-close-brackets.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-close-brackets.spec.tsx index 5b4ef5c647..39712d0b85 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-close-brackets.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-close-brackets.spec.tsx @@ -1,11 +1,7 @@ -import { FC } from 'react' import { mockScope } from '../helpers/mock-scope' import { EditorProviders } from '../../../helpers/editor-providers' import CodeMirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' - -const Container: FC = ({ children }) => ( -
{children}
-) +import { TestContainer } from '../helpers/test-container' describe('close brackets', { scrollBehavior: false }, function () { beforeEach(function () { @@ -16,11 +12,11 @@ describe('close brackets', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) cy.get('.cm-line').eq(20).as('active-line') diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-cursor.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-cursor.spec.tsx index fd9c222b84..ac02f8f8c1 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-cursor.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-cursor.spec.tsx @@ -1,14 +1,9 @@ -import { FC } from 'react' import { EditorProviders } from '../../../helpers/editor-providers' import CodemirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' import { mockScope } from '../helpers/mock-scope' - +import { TestContainer } from '../helpers/test-container' const isMac = /Mac/.test(window.navigator?.platform) -const Container: FC = ({ children }) => ( -
{children}
-) - describe('Cursor and active line highlight', function () { const content = `line 1 @@ -30,11 +25,11 @@ ${'long line '.repeat(200)}` const scope = mockScope(content) cy.mount( - + - + ) }) diff --git a/services/web/test/frontend/features/source-editor/components/figure-modal.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-figure-modal.spec.tsx similarity index 99% rename from services/web/test/frontend/features/source-editor/components/figure-modal.spec.tsx rename to services/web/test/frontend/features/source-editor/components/codemirror-editor-figure-modal.spec.tsx index 0a868f8733..8d0696aab3 100644 --- a/services/web/test/frontend/features/source-editor/components/figure-modal.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-figure-modal.spec.tsx @@ -4,10 +4,7 @@ import { mockScope, rootFolderId } from '../helpers/mock-scope' import { FC } from 'react' import { FileTreePathContext } from '@/features/file-tree/contexts/file-tree-path' import { ExposedSettings } from '../../../../../types/exposed-settings' - -const Container: FC = ({ children }) => ( -
{children}
-) +import { TestContainer } from '../helpers/test-container' const clickToolbarButton = (text: string) => { cy.findByLabelText(text).click() @@ -63,11 +60,11 @@ describe('', function () { ) cy.mount( - + - + ) } diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-fundamentals.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-fundamentals.spec.tsx index fdb34acde1..40e37d965e 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-fundamentals.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-fundamentals.spec.tsx @@ -1,11 +1,7 @@ -import { FC } from 'react' import { EditorProviders } from '../../../helpers/editor-providers' import CodemirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' import { mockScope } from '../helpers/mock-scope' - -const Container: FC = ({ children }) => ( -
{children}
-) +import { TestContainer } from '../helpers/test-container' describe(' fundamentals', function () { const content = ` @@ -19,11 +15,11 @@ test const scope = mockScope(content) cy.mount( - + - + ) cy.get('.cm-line').eq(0).as('first-line') diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx index 5dcc75b1bc..a8bfbd20ae 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx @@ -2,12 +2,8 @@ import { mockScope } from '../helpers/mock-scope' import { EditorProviders } from '../../../helpers/editor-providers' import CodeMirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' import { metaKey } from '../helpers/meta-key' -import { FC } from 'react' import { activeEditorLine } from '../helpers/active-editor-line' - -const Container: FC = ({ children }) => ( -
{children}
-) +import { TestContainer } from '../helpers/test-container' const CHARACTERS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\\0123456789' @@ -21,11 +17,11 @@ describe('keyboard shortcuts', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) cy.get('.cm-line').eq(16).as('line') @@ -143,11 +139,11 @@ contentLine3 const userSettings = { mode: 'emacs' } cy.mount( - + - + ) cy.get('.cm-line').eq(1).as('line') cy.get('@line').scrollIntoView() @@ -248,11 +244,11 @@ contentLine3 const userSettings = { mode: 'vim' } cy.mount( - + - + ) cy.get('.cm-line').eq(1).as('line') cy.get('@line').scrollIntoView() diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-spellchecker.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-spellchecker.spec.tsx index 194e6e45e3..906120177e 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-spellchecker.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-spellchecker.spec.tsx @@ -1,11 +1,7 @@ import { mockScope } from '../helpers/mock-scope' import { EditorProviders } from '../../../helpers/editor-providers' import CodeMirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' -import { FC } from 'react' - -const Container: FC = ({ children }) => ( -
{children}
-) +import { TestContainer } from '../helpers/test-container' describe('Spellchecker', function () { const content = ` @@ -31,11 +27,11 @@ describe('Spellchecker', function () { const scope = mockScope(content) cy.mount( - + - + ) cy.get('.cm-line').eq(13).as('line') diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-table-generator.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-table-generator.spec.tsx index 63f835de31..a002f2d289 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-table-generator.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-table-generator.spec.tsx @@ -1,14 +1,10 @@ // Needed since eslint gets confused by mocha-each /* eslint-disable mocha/prefer-arrow-callback */ -import { FC } from 'react' import { EditorProviders } from '../../../helpers/editor-providers' import CodemirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' import { mockScope } from '../helpers/mock-scope' import forEach from 'mocha-each' - -const Container: FC = ({ children }) => ( -
{children}
-) +import { TestContainer } from '../helpers/test-container' const mountEditor = (content: string | string[]) => { if (Array.isArray(content)) { @@ -21,11 +17,11 @@ const mountEditor = (content: string | string[]) => { scope.editor.showVisual = true cy.viewport(1000, 800) cy.mount( - + - + ) // wait for the content to be parsed and revealed diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-command-tooltip.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-command-tooltip.spec.tsx index 42694719d2..837f90a64a 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-command-tooltip.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-command-tooltip.spec.tsx @@ -1,22 +1,18 @@ -import { FC } from 'react' import { EditorProviders } from '../../../helpers/editor-providers' import CodemirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' import { mockScope } from '../helpers/mock-scope' - -const Container: FC = ({ children }) => ( -
{children}
-) +import { TestContainer } from '../helpers/test-container' const mountEditor = (content: string) => { const scope = mockScope(content) scope.editor.showVisual = true cy.mount( - + - + ) // wait for the content to be parsed and revealed diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-floats.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-floats.spec.tsx index 23fb27bee4..87f66cb07c 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-floats.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-floats.spec.tsx @@ -1,22 +1,18 @@ -import { FC } from 'react' import { EditorProviders } from '../../../helpers/editor-providers' import CodemirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' import { mockScope } from '../helpers/mock-scope' - -const Container: FC = ({ children }) => ( -
{children}
-) +import { TestContainer } from '../helpers/test-container' const mountEditor = (content: string) => { const scope = mockScope(content) scope.editor.showVisual = true cy.mount( - + - + ) // wait for the content to be parsed and revealed diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-list.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-list.spec.tsx index e29fd313a3..a54f4b1def 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-list.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-list.spec.tsx @@ -1,24 +1,20 @@ -import { FC } from 'react' import { EditorProviders } from '../../../helpers/editor-providers' import CodemirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' import { mockScope } from '../helpers/mock-scope' +import { TestContainer } from '../helpers/test-container' const isMac = /Mac/.test(window.navigator?.platform) -const Container: FC = ({ children }) => ( -
{children}
-) - const mountEditor = (content: string) => { const scope = mockScope(content) scope.editor.showVisual = true cy.mount( - + - + ) // wait for the content to be parsed and revealed diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-paste-html.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-paste-html.spec.tsx index 697ab96de2..5717e9405d 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-paste-html.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-paste-html.spec.tsx @@ -1,22 +1,18 @@ -import { FC } from 'react' import { EditorProviders } from '../../../helpers/editor-providers' import CodemirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' import { mockScope } from '../helpers/mock-scope' - -const Container: FC = ({ children }) => ( -
{children}
-) +import { TestContainer } from '../helpers/test-container' const mountEditor = (content = '') => { const scope = mockScope(content) scope.editor.showVisual = true cy.mount( - + - + ) // wait for the content to be parsed and revealed diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-readonly.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-readonly.spec.tsx index 92d061323b..6d7e4a7d6c 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-readonly.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-readonly.spec.tsx @@ -3,10 +3,7 @@ import { EditorProviders } from '../../../helpers/editor-providers' import CodemirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' import { FC, ComponentProps } from 'react' import { FileTreePathContext } from '@/features/file-tree/contexts/file-tree-path' - -const Container: FC = ({ children }) => ( -
{children}
-) +import { TestContainer } from '../helpers/test-container' const mountEditor = ( content: string, @@ -17,11 +14,11 @@ const mountEditor = ( scope.editor.showVisual = true cy.mount( - + - + ) // wait for the content to be parsed and revealed diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-toolbar.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-toolbar.spec.tsx index 63b8fd97a2..b69e7f76ae 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-toolbar.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-toolbar.spec.tsx @@ -1,7 +1,7 @@ -import { FC } from 'react' import { EditorProviders } from '../../../helpers/editor-providers' import CodemirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' import { mockScope } from '../helpers/mock-scope' +import { TestContainer } from '../helpers/test-container' const isMac = /Mac/.test(window.navigator?.platform) @@ -12,25 +12,21 @@ const selectAll = () => { ) } -const clickToolbarButton = (text: string) => { - cy.findByLabelText(text).click() - cy.findByLabelText(text).trigger('mouseout') +const clickToolbarButton = (name: string) => { + cy.findByRole('button', { name }).click() + cy.findByRole('button', { name }).trigger('mouseout') } -const Container: FC = ({ children }) => ( -
{children}
-) - const mountEditor = (content: string) => { const scope = mockScope(content) scope.editor.showVisual = true cy.mount( - + - + ) // wait for the content to be parsed and revealed @@ -126,6 +122,7 @@ describe(' toolbar in Rich Text mode', function () { mountEditor('test') selectAll() + clickToolbarButton('More') clickToolbarButton('Bullet List') cy.get('.cm-content').should('have.text', ' test') @@ -138,6 +135,7 @@ describe(' toolbar in Rich Text mode', function () { mountEditor('test') selectAll() + clickToolbarButton('More') clickToolbarButton('Numbered List') cy.get('.cm-content').should('have.text', ' test') @@ -150,6 +148,7 @@ describe(' toolbar in Rich Text mode', function () { mountEditor('test') selectAll() + clickToolbarButton('More') clickToolbarButton('Numbered List') // expose the markup @@ -182,6 +181,7 @@ describe(' toolbar in Rich Text mode', function () { mountEditor('test') selectAll() + clickToolbarButton('More') clickToolbarButton('Numbered List') // expose the markup @@ -206,6 +206,7 @@ describe(' toolbar in Rich Text mode', function () { mountEditor('test\ntest') selectAll() + clickToolbarButton('More') clickToolbarButton('Numbered List') // expose the markup @@ -242,6 +243,7 @@ describe(' toolbar in Rich Text mode', function () { cy.get('.cm-line').eq(1).click() + clickToolbarButton('More') clickToolbarButton('Numbered List') cy.get('.cm-line').eq(0).type('{upArrow}') @@ -262,6 +264,7 @@ describe(' toolbar in Rich Text mode', function () { mountEditor('test\ntest') selectAll() + clickToolbarButton('More') clickToolbarButton('Numbered List') // expose the markup @@ -298,6 +301,7 @@ describe(' toolbar in Rich Text mode', function () { cy.get('.cm-line').eq(0).click() + clickToolbarButton('More') clickToolbarButton('Numbered List') // expose the markup diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-tooltips.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-tooltips.spec.tsx index 4fa1669711..c6e28f9eee 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-tooltips.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual-tooltips.spec.tsx @@ -1,11 +1,7 @@ import { mockScope } from '../helpers/mock-scope' import { EditorProviders } from '../../../helpers/editor-providers' import CodemirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' -import { FC } from 'react' - -const Container: FC = ({ children }) => ( -
{children}
-) +import { TestContainer } from '../helpers/test-container' describe(' tooltips in Visual mode', function () { beforeEach(function () { @@ -18,11 +14,11 @@ describe(' tooltips in Visual mode', function () { scope.editor.showVisual = true cy.mount( - + - + ) // wait for the content to be parsed and revealed diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual.spec.tsx index eb13ffacec..b664474407 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-visual.spec.tsx @@ -6,10 +6,7 @@ import CodemirrorEditor from '../../../../../frontend/js/features/source-editor/ import { mockScope } from '../helpers/mock-scope' import forEach from 'mocha-each' import { FileTreePathContext } from '@/features/file-tree/contexts/file-tree-path' - -const Container: FC = ({ children }) => ( -
{children}
-) +import { TestContainer } from '../helpers/test-container' describe(' in Visual mode', function () { beforeEach(function () { @@ -41,11 +38,11 @@ describe(' in Visual mode', function () { ) cy.mount( - + - + ) // wait for the content to be parsed and revealed diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor.spec.tsx index c77165670d..9e60444e77 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor.spec.tsx @@ -1,14 +1,10 @@ import CodeMirrorEditor from '../../../../../frontend/js/features/source-editor/components/codemirror-editor' import { EditorProviders } from '../../../helpers/editor-providers' -import { FC } from 'react' import { mockScope } from '../helpers/mock-scope' import { metaKey } from '../helpers/meta-key' import { docId } from '../helpers/mock-doc' import { activeEditorLine } from '../helpers/active-editor-line' - -const Container: FC = ({ children }) => ( -
{children}
-) +import { TestContainer } from '../helpers/test-container' describe('', { scrollBehavior: false }, function () { beforeEach(function () { @@ -21,11 +17,11 @@ describe('', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) // put the cursor on a blank line to type in @@ -46,11 +42,11 @@ describe('', { scrollBehavior: false }, function () { cy.clock() cy.mount( - + - + ) cy.tick(1000) @@ -94,11 +90,11 @@ describe('', { scrollBehavior: false }, function () { cy.clock() cy.mount( - + - + ) cy.tick(1000) @@ -113,11 +109,11 @@ describe('', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) cy.contains('Your introduction goes here!') @@ -127,11 +123,11 @@ describe('', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) // put the cursor on a blank line to type in @@ -146,11 +142,11 @@ describe('', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) // put the cursor on a blank line to type in @@ -167,11 +163,11 @@ describe('', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) // put the cursor on a blank line to type in @@ -214,11 +210,11 @@ describe('', { scrollBehavior: false }, function () { } cy.mount( - + - + ) cy.get('.ol-cm-cursorHighlight').should('have.length', 3) @@ -230,11 +226,11 @@ describe('', { scrollBehavior: false }, function () { scope.permissions.write = false cy.mount( - + - + ) // Handling the thrown error on failing to type text @@ -257,11 +253,11 @@ describe('', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) // put the cursor on a blank line to type in @@ -280,11 +276,11 @@ describe('', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) // select foldable line @@ -324,11 +320,11 @@ describe('', { scrollBehavior: false }, function () { const userSettings = { mode: 'vim' } cy.mount( - + - + ) // Compile on initial load @@ -356,11 +352,11 @@ describe('', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) cy.get('.cm-line').eq(16).as('line') @@ -483,11 +479,11 @@ describe('', { scrollBehavior: false }, function () { const scope = mockScope() cy.mount( - + - + ) // Open the search panel @@ -568,11 +564,11 @@ describe('', { scrollBehavior: false }, function () { ) cy.mount( - + - + ) activeEditorLine() diff --git a/services/web/test/frontend/features/source-editor/helpers/test-container.tsx b/services/web/test/frontend/features/source-editor/helpers/test-container.tsx new file mode 100644 index 0000000000..8de4dcdc55 --- /dev/null +++ b/services/web/test/frontend/features/source-editor/helpers/test-container.tsx @@ -0,0 +1,12 @@ +import { FC, ComponentProps, Suspense } from 'react' + +const style = { width: 785, height: 785 } + +export const TestContainer: FC> = ({ + children, + ...rest +}) => ( +
+ {children} +
+)