Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tests/e2e/page-objects/base_editor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Page, Locator, expect, FrameLocator } from '@playwright/test'
import { Page, Locator, test, expect, FrameLocator } from '@playwright/test'
import Toolbar from '../enums/toolbar'
import type Equation from '../interfaces/equation'
import TrackChangesOptions from '../enums/track_changes_options'
Expand Down Expand Up @@ -507,6 +507,7 @@ export default abstract class BaseEditor extends BasePage {

const equationElement = this.getEquationElement(equation)
let editDivElement: Locator
const isCkeditor5Firefox = this.getName() === 'ckeditor5' && test.info().project.name === 'firefox'

if (this.iframe) {
editDivElement = this.page.frameLocator(this.iframe).locator(this.editField)
Expand All @@ -519,11 +520,13 @@ export default abstract class BaseEditor extends BasePage {

if (equationBox && editDivBox) {
await this.page.mouse.move(equationBox.x + equationBox.width / 2, equationBox.y + equationBox.height / 2)
//await this.page.mouse.click(equationBox.x + equationBox.width / 2, equationBox.y + equationBox.height / 2)
await this.pause(500)
await this.page.mouse.down()
await this.pause(500)
await this.page.mouse.move(editDivBox.x, editDivBox.y)
await this.page.mouse.move(
isCkeditor5Firefox ? editDivBox.x + 5 : editDivBox.x,
isCkeditor5Firefox ? editDivBox.y + 5 : editDivBox.y
)
await this.pause(500)
await this.page.mouse.up()
}
Expand Down
19 changes: 6 additions & 13 deletions tests/e2e/tests/editor/copy_cut_drop.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ for (const editorName of editors) { // TODO: review some flaky tests
}, () => {
test(`MTHTML-95 Copy-paste math formula with ${editorName} editor`, async ({ page }) => {
const { editor, wirisEditor } = await setupEditor(page, editorName)

await editor.open()
await editor.clear()
await editor.openWirisEditor(Toolbar.MATH)
Expand All @@ -24,15 +24,15 @@ for (const editorName of editors) { // TODO: review some flaky tests
await editor.copyAllEditorContent()
await editor.clear()
await editor.paste()

const equationsInHTMLEditor = await editor.getEquations()
const isEquationCopied = equationsInHTMLEditor.every((equation: Equation) => equation.altText === Equations.singleNumber.altText) && (equationsInHTMLEditor.length === 1)
expect(isEquationCopied).toBeTruthy()
})

test(`MTHTML-96 Cut-paste math formula with ${editorName} editor`, async ({ page }) => {
const { editor, wirisEditor } = await setupEditor(page, editorName)

await editor.open()
await editor.clear()
await editor.openWirisEditor(Toolbar.MATH)
Expand All @@ -43,22 +43,15 @@ for (const editorName of editors) { // TODO: review some flaky tests

await editor.cutAllEditorContent()
await editor.paste()

const equationsInHTMLEditor = await editor.getEquations()
const isEquationCut = equationsInHTMLEditor.every((equation: Equation) => equation.altText === Equations.singleNumber.altText) && (equationsInHTMLEditor.length === 1)
expect(isEquationCut).toBeTruthy()
})

test(`MTHTML-86 Drag-drop math formula with ${editorName} editor`, async ({ page }) => {
test.fixme((editorName === 'ckeditor5' || editorName === 'generic') && test.info().project.name === 'firefox', `Drag and drop not working for ${editorName} in Firefox`) // TODO: fix drag and drop in Firefox for ckeditor5 and generic editor

const unsupportedEditors = ['ckeditor4', 'tinymce5', 'tinymce6', 'tinymce7', 'tinymce8'] // WIP

// Skip test for unsupported editors
test.skip(unsupportedEditors.includes(editorName), `Drag and drop not supported for ${editorName}`)

const { editor, wirisEditor } = await setupEditor(page, editorName)

await editor.open()
await editor.clear()
const textToType = 'The equation will be relocated from after this text to before it'
Expand All @@ -75,4 +68,4 @@ for (const editorName of editors) { // TODO: review some flaky tests
expect(isTextAfterEquation).toBeTruthy()
})
})
}
}
Loading