Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiedit e2e tests #4464

Merged
merged 52 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
8107b0e
playwright integration
tomaskikutis Oct 26, 2023
ad3628b
make playwright run on the same build to reduce the time required for…
tomaskikutis Jan 12, 2024
0c08b60
implement DB restoring, login, port one test from protractor
tomaskikutis Jan 15, 2024
a0b7d34
move e2e test "can create a new user" to playwright
tomaskikutis Jan 15, 2024
9e83b2a
add page object models
tomaskikutis Jan 16, 2024
af73abb
move "can apply macro" test to playwright
tomaskikutis Jan 16, 2024
38f884a
improve docs
tomaskikutis Jan 17, 2024
3b94416
Merge branch 'develop' into playwright-integration-to-develop
tomaskikutis Jan 19, 2024
32aa136
don't use legacy database snapshot for playwright tests
tomaskikutis Jan 19, 2024
ae1e300
update readme on testing
tomaskikutis Jan 19, 2024
1e9ee8c
fix json
tomaskikutis Jan 19, 2024
c6af19a
rename initial dump to main
tomaskikutis Jan 22, 2024
59b18ca
start e2e with admin user logged in already
tomaskikutis Jan 22, 2024
448ace4
fix duplicate declaration after merge
tomaskikutis Jan 22, 2024
2d127a2
add empty main record so full dump can be restored indirectly
tomaskikutis Jan 23, 2024
e2b924a
fix desk selection helper
tomaskikutis Jan 23, 2024
67c7054
add missing await
tomaskikutis Jan 23, 2024
07aaae5
update helper to select desk
tomaskikutis Jan 24, 2024
a3be574
Merge branch 'develop' into playwright-tests
dzonidoo Jan 25, 2024
d4f509c
update e2e dump to have workspace
tomaskikutis Feb 5, 2024
c826fd5
Merge remote-tracking branch 'Tomas/update-e2e-dump-to-have-workspace…
dzonidoo Feb 5, 2024
f3f71ec
custom workspace part 1
dzonidoo Feb 5, 2024
9609613
use describe in custom
dzonidoo Feb 5, 2024
837c419
personal space part 1
dzonidoo Feb 5, 2024
a36f42e
Merge branch 'develop' into playwright-tests
dzonidoo Feb 28, 2024
4cd291f
fix test
dzonidoo Feb 28, 2024
503a708
fix test
dzonidoo Feb 29, 2024
4d55e60
fix tests
dzonidoo Feb 29, 2024
f30fd8c
add timeout
tomaskikutis Mar 4, 2024
f94ade3
enable linting of playwright tests
tomaskikutis Mar 4, 2024
8f48494
fix an issue with selecting a workspace
tomaskikutis Mar 4, 2024
3b1303c
changes after review part 1
dzonidoo Mar 6, 2024
27a30f8
fix lint
dzonidoo Mar 6, 2024
5ea9cad
improve executeActionOnMonitoringItem helper
tomaskikutis Mar 6, 2024
d77802e
improve executeActionOnMonitoringItem helper v2
tomaskikutis Mar 7, 2024
c247495
changes after review part 2
dzonidoo Mar 7, 2024
fe2074e
improve naming and structure
tomaskikutis Mar 8, 2024
2c4afab
changes after review part 3
dzonidoo Mar 12, 2024
8a4c664
Merge branch 'develop' into playwright-tests
dzonidoo Mar 13, 2024
61e2e39
Merge branch 'develop' into playwright-tests
dzonidoo Mar 13, 2024
fadf80c
Merge branch 'develop' into multiedit-e2e-tests
dzonidoo Apr 2, 2024
7f29834
multiedit tests
dzonidoo Apr 2, 2024
63d85f6
Merge branch 'develop' into multiedit-e2e-tests
dzonidoo Jul 1, 2024
c3e8399
changes after review
dzonidoo Jul 2, 2024
96d7f83
Merge branch 'develop' into multiedit-e2e-tests
dzonidoo Jul 9, 2024
4431c3c
add selecting a desk in removing article from multiedit vriew test
dzonidoo Jul 9, 2024
da919fe
Merge branch 'develop' into multiedit-e2e-tests
dzonidoo Jul 10, 2024
f99b519
fix failed tests
dzonidoo Jul 16, 2024
9ba80ce
Merge branch 'develop' into multiedit-e2e-tests
dzonidoo Jul 18, 2024
3c666ae
changes after review
dzonidoo Aug 1, 2024
9a8fa14
improve naming
tomaskikutis Aug 1, 2024
6e7cbf7
move hovering into save fn
tomaskikutis Aug 1, 2024
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
84 changes: 84 additions & 0 deletions e2e/client/playwright/multiedit.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import {test, expect} from '@playwright/test';
import {Monitoring} from './page-object-models/monitoring';
import {Authoring} from './page-object-models/authoring';
import {MultiEdit} from './page-object-models/multiedit';
import {restoreDatabaseSnapshot, s} from './utils';

test.describe('Multiedit', async () => {
test('editing articles in multi-edit mode', async ({page}) => {
const monitoring = new Monitoring(page);
const multiedit = new MultiEdit(page);

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

await monitoring.executeBulkAction('Multi-edit', ['test sports story', 'story 2']);

await page
.locator(s('multiedit-screen', 'multiedit-article=test sports story', 'field--headline'))
.getByRole('textbox')
.clear();
await page
.locator(s('multiedit-screen', 'multiedit-article=test sports story', 'field--headline'))
.getByRole('textbox')
.fill('test sports story 1.1');

await multiedit.save('test sports story');

await page
.locator(s('multiedit-screen', 'multiedit-article=story 2', 'field--headline'))
.getByRole('textbox')
.clear();
await page
.locator(s('multiedit-screen', 'multiedit-article=story 2', 'field--headline'))
.getByRole('textbox')
.fill('story 2.1');

await multiedit.save('story 2');

await page.locator(s('multiedit-subnav')).getByRole('button', {name: 'exit'}).click();

await monitoring.executeActionOnMonitoringItem(
page.locator(s('article-item=test sports story 1.1')),
'Edit',
);
await expect(
page.locator(s('authoring', 'field--headline')).getByRole('textbox'),
).toHaveText('test sports story 1.1');

await monitoring.executeActionOnMonitoringItem(
page.locator(s('article-item=story 2.1')),
'Edit',
);
await expect(
page.locator(s('authoring', 'field--headline')).getByRole('textbox'),
).toHaveText('story 2.1');
});

test('removing an article from multi-edit view', async ({page}) => {
const monitoring = new Monitoring(page);
const authoring = new Authoring(page);

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

await monitoring.selectDeskOrWorkspace('Sports');

await monitoring.executeActionOnMonitoringItem(
page.locator(s('article-item=test sports story')),
'Edit',
);
await authoring.executeActionInEditor(
'Multiedit',
'OK',
);

await page.locator(s('multiedit-screen', 'multiedit-article=test sports story')).hover();
await page
.locator(s('multiedit-screen', 'multiedit-article=test sports story'))
.getByRole('button', {name: 'remove item'})
.click();
await expect(page.locator(s('multiedit-screen', 'multiedit-article=test sports story'))).not.toBeVisible();
});
});
9 changes: 9 additions & 0 deletions e2e/client/playwright/page-object-models/monitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ export class Monitoring {
.click();
}

async executeBulkAction(action: string, articleNames: Array<string>): Promise<void> {
for (const selectedArticle of articleNames) {
await this.page.locator(s(`article-item=${selectedArticle}`, 'item-type-and-multi-select')).hover();
await this.page.locator(s(`article-item=${selectedArticle}`, 'multi-select-checkbox')).check();
}

await this.page.locator(s('multi-action-bar', 'multi-actions-inline', action)).click();
}

async createArticleFromTemplate(template: string, options?: {slugline?:string, body_html?: string}): Promise<void> {
await this.page.locator(s('content-create')).click();
await this.page.locator(s('content-create-dropdown')).getByRole('button', {name: 'More Templates...'}).click();
Expand Down
19 changes: 19 additions & 0 deletions e2e/client/playwright/page-object-models/multiedit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {Page} from '@playwright/test';
import {s} from '../utils';

export class MultiEdit {
private page: Page;

constructor(page: Page) {
this.page = page;
}

async save(article: string): Promise<void> {
await this.page.locator(s('multiedit-screen', `multiedit-article=${article}`)).hover();

await this.page
.locator(s('multiedit-screen', `multiedit-article=${article}`))
.getByRole('button', {name: 'save'})
.click();
}
}
4 changes: 2 additions & 2 deletions scripts/apps/authoring/multiedit/views/multiedit.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="subnav subnav--top">
<div class="subnav subnav--top" data-test-id="multiedit-subnav">
<h2 class="page-nav-title" translate>Multiedit</h2>
<button class="btn btn--hollow sd-margin-end--1" ng-click="closeMulti()" translate>Exit</button>
</div>
<div class="multiedit-screen main-section">
<div class="multiedit-screen main-section" data-test-id="multiedit-screen">
<div class="boards-list">
<div ng-repeat="board in boards"
class="board"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<article class="main-article" tabindex="0" ng-class="{locked: isLocked}">
<article class="main-article" tabindex="0" ng-class="{locked: isLocked}" data-test-id="multiedit-article" data-test-value="{{item.slugline}}">
<div class="main-article__form">
<div class="main-article__editbar">
<button class="btn btn--hollow main-article__editbar-button"
Expand Down
2 changes: 1 addition & 1 deletion scripts/apps/search/views/multi-action-bar.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="multi-action-bar" ng-if="multi.count && display">
<div class="multi-action-bar" ng-if="multi.count && display" data-test-id="multi-action-bar">
<button class="btn btn--hollow btn--icon-only btn--icon-only-circle me-1" ng-click="toggleDisplay()"><i class="icon-chevron-up-thin"></i></button>
<button class="btn" ng-click="multi.reset()">cancel</button>
<span id="multi-select-count"
Expand Down
Loading