Skip to content

Commit 06ee01e

Browse files
Copiloteos87
andauthored
Migrate initial Protractor e2e specs to Playwright (#5181)
* chore: record baseline e2e setup Agent-Logs-Url: https://github.com/superdesk/superdesk-client-core/sessions/d3f35282-bf9b-42d6-bdbd-8360c01fcd7d Co-authored-by: eos87 <124766+eos87@users.noreply.github.com> * migrate(e2e): workspace from Protractor to Playwright Agent-Logs-Url: https://github.com/superdesk/superdesk-client-core/sessions/d3f35282-bf9b-42d6-bdbd-8360c01fcd7d Co-authored-by: eos87 <124766+eos87@users.noreply.github.com> * migrate(e2e): vocabularies from Protractor to Playwright Agent-Logs-Url: https://github.com/superdesk/superdesk-client-core/sessions/d3f35282-bf9b-42d6-bdbd-8360c01fcd7d Co-authored-by: eos87 <124766+eos87@users.noreply.github.com> * migrate(e2e): subscribers from Protractor to Playwright Agent-Logs-Url: https://github.com/superdesk/superdesk-client-core/sessions/d3f35282-bf9b-42d6-bdbd-8360c01fcd7d Co-authored-by: eos87 <124766+eos87@users.noreply.github.com> * migrate(e2e): suggest from Protractor to Playwright Agent-Logs-Url: https://github.com/superdesk/superdesk-client-core/sessions/d3f35282-bf9b-42d6-bdbd-8360c01fcd7d Co-authored-by: eos87 <124766+eos87@users.noreply.github.com> * chore: update migration report and validation fixes Agent-Logs-Url: https://github.com/superdesk/superdesk-client-core/sessions/d3f35282-bf9b-42d6-bdbd-8360c01fcd7d Co-authored-by: eos87 <124766+eos87@users.noreply.github.com> * chore: address review feedback on subscribers migration Agent-Logs-Url: https://github.com/superdesk/superdesk-client-core/sessions/d3f35282-bf9b-42d6-bdbd-8360c01fcd7d Co-authored-by: eos87 <124766+eos87@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: eos87 <124766+eos87@users.noreply.github.com>
1 parent 4362b4a commit 06ee01e

11 files changed

Lines changed: 147 additions & 113 deletions

File tree

e2e/MIGRATION_REPORT.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# E2E consolidation on Playwright — migration report
2+
3+
## Frameworks found in this repo
4+
- Protractor (count: 30)
5+
6+
## Totals
7+
- Original non-Playwright specs: 30
8+
- Migrated: 4
9+
- Blocked: 1 (see below)
10+
- Obsolete: 0 (see below)
11+
- Flaky: 0 (see below)
12+
- Redundant: 0 (see below)
13+
14+
## Migrated specs
15+
- Protractor `e2e/client/specs/workspace_spec.ts` -> `e2e/client/playwright/workspace.spec.ts` [65a6ef935] — Given the authenticated user is on the dashboard, when they use the workspace hotkeys, then the app switches to monitoring, spiked, personal, search, and back to dashboard.
16+
- Protractor `e2e/client/specs/vocabularies_spec.ts` -> `e2e/client/playwright/vocabularies.spec.ts` [4b719937a] — Given the vocabularies settings page is open, when the user edits the Categories vocabulary name and cancels, then the original vocabulary data is restored.
17+
- Protractor `e2e/client/specs/subscribers_spec.ts` -> `e2e/client/playwright/subscribers.spec.ts` [a50a98854] — Given the publish settings page is open, when the user inspects and edits the default subscriber row from the snapshot, then the list shows that subscriber and the save button only enables after changing the target type and destination format.
18+
- Protractor `e2e/client/specs/suggest_spec.ts` -> `e2e/client/playwright/suggest.spec.ts` [df73cc578] — Given an authenticated user opens a new text item, when they open Live suggestions before changing the body, then the suggestions list is empty.
19+
20+
## Blocked
21+
- Protractor `e2e/client/specs/notifications_spec.ts` — create a user mention and verify the mentioned user's unread badge clears after sign-in — current `main` snapshot no longer accepts the legacy `admin1` / `admin` credentials used by the spec, so migrating this scenario needs a maintained secondary-user test fixture or snapshot update.
22+
23+
## Obsolete
24+
- None yet.
25+
26+
## Flaky
27+
- None yet.
28+
29+
## Redundant
30+
- None yet.
31+
32+
## Product source changes
33+
- `scripts/apps/publish/views/subscribers.html``data-test-id` added to subscriber list rows — for `e2e/client/playwright/subscribers.spec.ts`
34+
- `scripts/apps/authoring/suggest/SuggestView.html``data-test-id` added to the live suggestions list and items — for `e2e/client/playwright/suggest.spec.ts`
35+
36+
## Frameworks removed
37+
- None yet.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {test, expect} from '@playwright/test';
2+
import {restoreDatabaseSnapshot, s} from './utils';
3+
4+
test.describe('subscribers', () => {
5+
test.beforeEach(async ({page}) => {
6+
await restoreDatabaseSnapshot();
7+
await page.goto('/#/settings/publish');
8+
});
9+
10+
test('lists the default subscriber', async ({page}) => {
11+
const subscriberItems = page.locator(s('subscriber-item'));
12+
13+
await expect(subscriberItems).toHaveCount(1);
14+
await expect(subscriberItems.first()).toBeVisible();
15+
});
16+
17+
test('save button is disabled until subscriber type changes', async ({page}) => {
18+
const subscriberItem = page.locator(s('subscriber-item')).first();
19+
20+
await subscriberItem.click();
21+
await subscriberItem.locator(s('edit-subscriber-button')).click();
22+
23+
const saveButton = page.getByRole('button', {name: 'Save'});
24+
25+
await expect(saveButton).toBeDisabled();
26+
27+
await page.locator('#subType').selectOption('string:wire');
28+
await page.locator('#destination-format').selectOption('nitf');
29+
30+
await expect(saveButton).toBeEnabled();
31+
await page.getByRole('button', {name: 'Cancel'}).click();
32+
});
33+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {test, expect} from '@playwright/test';
2+
import {Monitoring} from './page-object-models/monitoring';
3+
import {Authoring} from './page-object-models/authoring';
4+
import {restoreDatabaseSnapshot, s} from './utils';
5+
6+
test('live suggestions opens with no items', async ({page}) => {
7+
const monitoring = new Monitoring(page);
8+
const authoring = new Authoring(page);
9+
10+
await restoreDatabaseSnapshot();
11+
await page.goto('/#/workspace/monitoring');
12+
await monitoring.selectDeskOrWorkspace('Sports');
13+
14+
await monitoring.createArticleFromTemplate('story');
15+
await authoring.executeActionInEditor('Live suggestions');
16+
17+
await expect(page.locator(s('live-suggestions'))).toBeVisible();
18+
await expect(page.locator(s('live-suggestions', 'suggestion-item'))).toHaveCount(0);
19+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {test, expect} from '@playwright/test';
2+
import {restoreDatabaseSnapshot, s} from './utils';
3+
4+
test('can restore vocabulary data when editing is cancelled', async ({page}) => {
5+
const originalName = 'Categories';
6+
const updatedName = 'Categories test';
7+
const originalVocabularyItemSelector = s('metadata-content', `vocabulary-item=${originalName}`);
8+
9+
await restoreDatabaseSnapshot();
10+
await page.goto('/#/settings/vocabularies');
11+
12+
const vocabularyItem = page.locator(originalVocabularyItemSelector);
13+
14+
await expect(vocabularyItem).toBeVisible();
15+
await vocabularyItem.hover();
16+
await vocabularyItem.locator(s('vocabulary-item--start-editing')).click();
17+
18+
await page.locator(s('vocabulary-edit-field--name')).fill(updatedName);
19+
await expect(page.locator(s('vocabulary-edit-field--name'))).toHaveValue(updatedName);
20+
21+
await page.locator(s('vocabulary-edit-modal--cancel')).click();
22+
await expect(
23+
page.locator(originalVocabularyItemSelector).locator(s('vocabulary-item--name')),
24+
).toHaveText(originalName);
25+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {test, expect} from '@playwright/test';
2+
import {restoreDatabaseSnapshot, s} from './utils';
3+
4+
test('can switch views by keyboard', async ({page}) => {
5+
await restoreDatabaseSnapshot();
6+
await page.goto('/#/workspace');
7+
8+
await expect(page.locator(s('dashboard'))).toBeVisible();
9+
10+
await page.keyboard.press('Alt+m');
11+
await expect(page).toHaveURL(/.*\/#\/workspace\/monitoring/);
12+
13+
await page.keyboard.press('Control+Alt+k');
14+
await expect(page).toHaveURL(/.*\/#\/workspace\/spike-monitoring/);
15+
16+
await page.keyboard.press('Alt+p');
17+
await expect(page).toHaveURL(/.*\/#\/workspace\/personal/);
18+
19+
await page.keyboard.press('Control+Alt+f');
20+
await expect(page).toHaveURL(/.*\/#\/search/);
21+
22+
await page.keyboard.press('Control+Alt+b');
23+
await expect(page).toHaveURL(/.*\/#\/workspace$/);
24+
});

e2e/client/specs/subscribers_spec.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

e2e/client/specs/suggest_spec.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

e2e/client/specs/vocabularies_spec.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

e2e/client/specs/workspace_spec.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

scripts/apps/authoring/suggest/SuggestView.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
<div class="live-suggest">
1+
<div class="live-suggest" data-test-id="live-suggestions">
22
<div ng-show="showItem === null" class="item-list">
33
<div class="live-suggest__header subnav">
44
<h3 class="subnav__page-title" translate>Live Suggestions</h3>
55
<a class="close" ng-click="ctrl.close()"><i class="icon-close-small"></i></a>
66
</div>
77
<div class="live-suggest__body">
88
<h6 class="no-suggestions" ng-hide="items" translate>Suggestions will appear here once the article's body starts changing...</h6>
9-
<ul sd-list-view class="list-view compact-view" data-items="items" ng-show="items">
10-
<li class="media-box" ng-click="ctrl.showItem(item)">
9+
<ul sd-list-view class="list-view compact-view" data-items="items" ng-show="items" data-test-id="suggestions-list">
10+
<li class="media-box" ng-click="ctrl.showItem(item)" data-test-id="suggestion-item">
1111
<div class="line item-info">
1212
<i sd-filetype-icon data-item="item"></i>
1313
<span class="keyword">{{ item.slugline || '-' }}</span>

0 commit comments

Comments
 (0)