Skip to content

Commit

Permalink
Merge branch 'develop' into templates-e2e-test
Browse files Browse the repository at this point in the history
  • Loading branch information
dzonidoo committed May 21, 2024
2 parents 8f66653 + 8edb4ce commit 72d1929
Show file tree
Hide file tree
Showing 59 changed files with 966 additions and 537 deletions.
5 changes: 2 additions & 3 deletions e2e/client/playwright/authoring.correct.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ test('correcting with unsaved changes', async ({page}) => {

// publishing the article end

// TODO: should be 'monitoring-group=Sports / output'
await page.locator(
s('monitoring-group=Sports', 'article-item=test sports story'),
s('monitoring-group=Sports desk output', 'article-item=test sports story'),
).dblclick({timeout: 10000}); // need to wait until published item appears in output

await page.locator(s('authoring', 'authoring-topbar')).getByLabel('Correct').click();
Expand All @@ -51,7 +50,7 @@ test('correcting with unsaved changes', async ({page}) => {
await page.locator(s('authoring', 'authoring-topbar')).getByRole('button', {name: 'Send Correction'}).click();

await page.locator(
s('monitoring-group=Sports', 'article-item=test sports story [corrected]'),
s('monitoring-group=Sports desk output', 'article-item=test sports story [corrected]'),
).dblclick({timeout: 10000}); // need to wait until published item appears in output

// initialize correction only to make field editable and accessible using the same selector
Expand Down
1 change: 0 additions & 1 deletion e2e/client/playwright/desks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ test('desk notifications', async ({page}) => {
await page.goto('/#/workspace/monitoring');

await monitoring.selectDeskOrWorkspace('Sports');

await page.locator(
s('monitoring-group=Sports / Working Stage', 'article-item=test sports story'),
).dblclick();
Expand Down
208 changes: 208 additions & 0 deletions e2e/client/playwright/editor3.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
import {test, expect} from '@playwright/test';
import {Monitoring} from './page-object-models/monitoring';
import {restoreDatabaseSnapshot, s} from './utils';
import {getEditor3Paragraphs} from './utils/editor3';

test('accepting a spelling suggestion', async ({page}) => {
await restoreDatabaseSnapshot({snapshotName: 'spellchecker'});

await page.goto('/#/workspace/monitoring');

await page.locator(
s('monitoring-group=Sports / Working Stage', 'article-item=spellchecker test'),
).dblclick();

await expect(page.locator(s('authoring', 'authoring-field=body_html', 'spellchecker-warning'))).toHaveCount(2);

expect(await getEditor3Paragraphs(page.locator(s('authoring', 'authoring-field=body_html'))))
.toStrictEqual(['ghello world', 'ghello world']);

await page.locator(s('authoring', 'authoring-field=body_html', 'spellchecker-warning'))
.first()
.click({button: 'right'});

await page.locator(s('spellchecker-menu')).getByRole('button', {name: 'hello'}).click();

await expect(
(await page.locator(s('authoring', 'authoring-field=body_html', 'spellchecker-warning')).all()).length,
).toBe(1);

expect(await getEditor3Paragraphs(page.locator(s('authoring', 'authoring-field=body_html'))))
.toStrictEqual(['hello world', 'ghello world']);
});

test('adding word marked as a spellchecker issue to dictionary', async ({page}) => {
await restoreDatabaseSnapshot({snapshotName: 'spellchecker'});

await page.goto('/#/workspace/monitoring');

await page.locator(
s('monitoring-group=Sports / Working Stage', 'article-item=spellchecker test'),
).dblclick();

await expect(page.locator(s('authoring', 'authoring-field=body_html', 'spellchecker-warning'))).toHaveCount(2);

expect(await getEditor3Paragraphs(page.locator(s('authoring', 'authoring-field=body_html'))))
.toStrictEqual(['ghello world', 'ghello world']);

await page.locator(s('authoring', 'authoring-field=body_html', 'spellchecker-warning'))
.first()
.click({button: 'right'});

await page.locator(s('spellchecker-menu')).getByRole('button', {name: 'Add to dictionary'}).click();

/**
* it expects zero, because when a word is added to dictionary
* it should remove warnings for all instances of that word
* including nested editors (e.g. multi-line-quote)
*/
await expect(
page.locator(s('authoring', 'authoring-field=body_html', 'spellchecker-warning')),
).toHaveCount(0);

expect(await getEditor3Paragraphs(page.locator(s('authoring', 'authoring-field=body_html'))))
.toStrictEqual(['ghello world', 'ghello world']);
});

/**
* FYI undo/redo isn't working the same as in the main editor outside tables
* and it's not great that it's character based.
*/
test('tables maintaining cursor position at the start when executing "undo" action', async ({page}) => {
const monitoring = new Monitoring(page);

await restoreDatabaseSnapshot({snapshotName: 'editor3-tables'});

await page.goto('/#/workspace/monitoring');

await monitoring.selectDeskOrWorkspace('Sports');

await page.locator(
s('monitoring-group=Sports / Working Stage', 'article-item=test sports story'),
).dblclick();

await page.locator(
s('authoring', 'authoring-field=body_html', 'toolbar'),
).getByRole('button', {name: 'table'}).click();

await page.locator(s('authoring', 'authoring-field=body_html', 'table-block'))
.locator('[contenteditable]').first().pressSequentially('foo', {delay: 100});

await page.keyboard.press('ArrowLeft');
await page.keyboard.press('ArrowLeft');
await page.keyboard.press('ArrowLeft');
await page.keyboard.press('Control+z');

await page.locator(s('authoring', 'authoring-field=body_html', 'table-block'))
.locator('[contenteditable]').first().pressSequentially('bar', {delay: 100});

await expect(
page.locator(s('authoring', 'authoring-field=body_html', 'table-block')).locator('[contenteditable]').first(),
).toHaveText('barfo');
});

/**
* FYI undo/redo isn't working the same as in the main editor outside tables
* and it's not great that it's character based.
*/
test('tables maintaining cursor position in the middle when executing "undo" action', async ({page}) => {
const monitoring = new Monitoring(page);

await restoreDatabaseSnapshot({snapshotName: 'editor3-tables'});

await page.goto('/#/workspace/monitoring');

await monitoring.selectDeskOrWorkspace('Sports');

await page.locator(
s('monitoring-group=Sports / Working Stage', 'article-item=test sports story'),
).dblclick();

await page.locator(
s('authoring', 'authoring-field=body_html', 'toolbar'),
).getByRole('button', {name: 'table'}).click();

await page.locator(s('authoring', 'authoring-field=body_html', 'table-block'))
.locator('[contenteditable]').first().pressSequentially('foo', {delay: 100});

await page.keyboard.press('ArrowLeft');
await page.keyboard.press('ArrowLeft');
await page.keyboard.press('Control+z');
await page.keyboard.press('Control+z');

await page.locator(s('authoring', 'authoring-field=body_html', 'table-block'))
.locator('[contenteditable]').first().pressSequentially('bar', {delay: 100});

await expect(
page.locator(s('authoring', 'authoring-field=body_html', 'table-block')).locator('[contenteditable]').first(),
).toHaveText('fbar');
});

/**
* FYI undo/redo isn't working the same as in the main editor outside tables
* and it's not great that it's character based.
*/
test('tables maintaining cursor position at the end when executing "undo" action', async ({page}) => {
const monitoring = new Monitoring(page);

await restoreDatabaseSnapshot({snapshotName: 'editor3-tables'});

await page.goto('/#/workspace/monitoring');

await monitoring.selectDeskOrWorkspace('Sports');

await page.locator(
s('monitoring-group=Sports / Working Stage', 'article-item=test sports story'),
).dblclick();

await page.locator(
s('authoring', 'authoring-field=body_html', 'toolbar'),
).getByRole('button', {name: 'table'}).click();

await page.locator(s('authoring', 'authoring-field=body_html', 'table-block'))
.locator('[contenteditable]').first().pressSequentially('foo', {delay: 100});

await page.keyboard.press('Control+z'); // undo last character

await page.locator(s('authoring', 'authoring-field=body_html', 'table-block'))
.locator('[contenteditable]').first().pressSequentially('bar', {delay: 100});

await expect(
page.locator(s('authoring', 'authoring-field=body_html', 'table-block')).locator('[contenteditable]').first(),
).toHaveText('fobar');
});

/**
* FYI undo/redo isn't working the same as in the main editor outside tables
* and it's not great that it's character based.
*/
test('tables maintaining cursor position when executing "redo" action', async ({page}) => {
const monitoring = new Monitoring(page);

await restoreDatabaseSnapshot({snapshotName: 'editor3-tables'});

await page.goto('/#/workspace/monitoring');

await monitoring.selectDeskOrWorkspace('Sports');

await page.locator(
s('monitoring-group=Sports / Working Stage', 'article-item=test sports story'),
).dblclick();

await page.locator(
s('authoring', 'authoring-field=body_html', 'toolbar'),
).getByRole('button', {name: 'table'}).click();

await page.locator(s('authoring', 'authoring-field=body_html', 'table-block'))
.locator('[contenteditable]').first().pressSequentially('foo', {delay: 100});

await page.keyboard.press('Control+z');
await page.keyboard.press('Control+y');

await page.locator(s('authoring', 'authoring-field=body_html', 'table-block'))
.locator('[contenteditable]').first().pressSequentially('bar', {delay: 100});

await expect(
page.locator(s('authoring', 'authoring-field=body_html', 'table-block')).locator('[contenteditable]').first(),
).toHaveText('fobaro');
});
Loading

0 comments on commit 72d1929

Please sign in to comment.