Skip to content

Commit

Permalink
changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
dzonidoo committed Apr 8, 2024
1 parent 4afc77d commit 7a6ec1c
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 139 deletions.
24 changes: 24 additions & 0 deletions e2e/client/playwright/page-object-models/authoring.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {Page} from '@playwright/test';
import {s} from '../utils';

export class Authoring {
private page: Page;

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

async executeActionInEditor(...actionPath: Array<string>): Promise<void> {
await this.page.locator(s('authoring-topbar', 'actions-button')).click();

const actionsWithoutLast = actionPath.slice(0, actionPath.length - 1);

for (const action of actionsWithoutLast) {
await this.page.locator(s('actions-list')).getByRole('button', {name: action}).hover();
}

await this.page.locator(s('actions-list'))
.getByRole('button', {name: actionPath[actionPath.length - 1]})
.click();
}
}
14 changes: 0 additions & 14 deletions e2e/client/playwright/page-object-models/monitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,4 @@ export class Monitoring {
}
}
}

async executeActionInEditor(...actionPath: Array<string>): Promise<void> {
await this.page.locator(s('authoring-topbar', 'actions-button')).click();

const actionsWithoutLast = actionPath.slice(0, actionPath.length - 1);

for (const action of actionsWithoutLast) {
await this.page.locator(s('actions-list')).getByRole('button', {name: action}).hover();
}

await this.page.locator(s('actions-list'))
.getByRole('button', {name: actionPath[actionPath.length - 1]})
.click();
}
}
40 changes: 22 additions & 18 deletions e2e/client/playwright/templates.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {test, expect} from '@playwright/test';
import {Monitoring} from './page-object-models/monitoring';
import {Authoring} from './page-object-models/authoring';
import {restoreDatabaseSnapshot, s} from './utils';

test('creating new template', async ({page}) => {
Expand All @@ -9,35 +10,35 @@ test('creating new template', async ({page}) => {
await page.locator(s('template-header')).getByRole('button', {name: 'Add new'}).click();

await page.locator(s('template-edit-view')).getByPlaceholder('template name').fill('Template 1');
await page.locator(s('template-edit-view', 'select-content-profile')).selectOption({label: 'Story'});
await page.locator(s('template-edit-view')).getByLabel('Content Profile').selectOption({label: 'Story'});
await page.locator(s('template-edit-view')).getByRole('button', {name: 'Save'}).click();

await expect(page.locator(s('template-content', 'content-template--template 1'))).toBeVisible();
await expect(page.locator(s('template-content', 'content-template=template 1'))).toBeVisible();
});

test('editing template', async ({page}) => {
test('editing template name', async ({page}) => {
await restoreDatabaseSnapshot();
await page.goto('/#/settings/templates');

await page.locator(s('template-content', 'content-template--story', 'template-actions')).click();
await page.locator(s('template-content', 'content-template=story', 'template-actions')).click();
await page.locator(s('template-actions--options')).getByRole('button', {name: 'Edit'}).click();
await page.locator(s('template-edit-view')).getByPlaceholder('template name').fill('story 1.1');
await page.locator(s('template-edit-view')).getByRole('button', {name: 'Save'}).click();

await expect(page.locator(s('template-content', 'content-template--story 1.1'))).toBeVisible();
await expect(page.locator(s('template-content', 'content-template=story 1.1'))).toBeVisible();
});

test('removing template', async ({page}) => {
await restoreDatabaseSnapshot();
await page.goto('/#/settings/templates');

await page.locator(s('template-content', 'content-template--story 2', 'template-actions')).click();
await page.locator(s('template-content', 'content-template=story 2', 'template-actions')).click();
await page.locator(s('template-actions--options')).getByRole('button', {name: 'Remove'}).click();
await page.locator(s('modal-confirm')).getByRole('button', {name: 'Ok'}).click();
await expect(page.locator(s('template-content', 'content-template--story 2'))).not.toBeVisible();
await expect(page.locator(s('template-content', 'content-template=story 2'))).not.toBeVisible();
});

test('Assign template to a desk', async ({page}) => {
test('assigning template to a desk', async ({page}) => {
const monitoring = new Monitoring(page);

await restoreDatabaseSnapshot();
Expand All @@ -46,30 +47,32 @@ test('Assign template to a desk', async ({page}) => {

await page.locator(s('content-create')).click();
await page.locator(s('content-create-dropdown')).getByRole('button', {name: 'More Templates...'}).click();
await page.locator(s('content-create-dropdown', 'search')).fill('Story 2');
await expect(page.locator(s('content-create-dropdown')).getByRole('button', {name: 'Story 2'})).not.toBeVisible();

// assign template to the desk
await page.goto('/#/settings/templates');
await page.locator(s('template-content', 'content-template--story 2', 'template-actions')).click();
await page.locator(s('template-content', 'content-template=story 2', 'template-actions')).click();
await page.locator(s('template-actions--options')).getByRole('button', {name: 'Edit'}).click();
await page.locator(s('template-edit-view', 'desks', 'desk--Finances')).first().click();
await page.locator(s('template-edit-view', 'desks', 'desk--Finances')).click();
await page.locator(s('template-edit-view')).getByRole('button', {name: 'Save'}).click();

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

await page.locator(s('content-create')).click();
await page.locator(s('content-create-dropdown')).getByRole('button', {name: 'More Templates...'}).click();
await expect(page.locator(s('content-create-dropdown')).getByRole('button', {name: 'Story 2'})).toBeVisible();
});

test('Default content template', async ({page}) => {
test('default content template', async ({page}) => {
const monitoring = new Monitoring(page);

await restoreDatabaseSnapshot();
await page.goto('/#/settings/desks');

await page.locator(s('desk--Sports', 'desk-actions')).click();
await page.locator(s('actions--options')).getByRole('button', {name: 'Edit'}).click();
await page.locator(s('desk-actions--options')).getByRole('button', {name: 'Edit'}).click();
await page.locator(s('desk-config-modal', 'field--default-content-template')).selectOption({label: 'story 2'});
await page.locator(s('desk-config-modal')).getByRole('button', {name: 'done'}).click();

Expand All @@ -79,7 +82,7 @@ test('Default content template', async ({page}) => {
await expect(page.locator(s('content-create-dropdown', 'default-desk-template'))).toHaveText('story 2');
});

test('Prefill template', async ({page}) => {
test('new article prefilling with content set in template', async ({page}) => {
const monitoring = new Monitoring(page);

await restoreDatabaseSnapshot();
Expand All @@ -91,23 +94,24 @@ test('Prefill template', async ({page}) => {
await expect(page.locator(s('authoring', 'field-slugline'))).toHaveValue('article 1');
});

test('Save as template', async ({page}) => {
test('performing "save as" action on a template', 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.createArticleFromTemplate('story 2', {slugline: 'article 1'});

await monitoring.executeActionInEditor(
await authoring.executeActionInEditor(
'Save as template',
);

await page.locator(s('modal-save-as-template', 'name-input')).fill('story 2.1');
await page.locator(s('modal-save-as-template', 'select-desk')).selectOption({label: 'Sports'});
await page.locator(s('modal-save-as-template')).getByLabel('Desk').selectOption({label: 'Sports'});
await page.locator(s('modal-save-as-template')).getByRole('button', {name: 'Save'}).click();

await page.goto('/#/settings/templates');
await expect(page.locator(s('template-content', 'content-template--story 2.1'))).toBeVisible();
await expect(page.locator(s('template-content', 'content-template=story 2.1'))).toBeVisible();
});
7 changes: 5 additions & 2 deletions e2e/client/specs/monitoring_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1089,8 +1089,11 @@ xdescribe('marked for me filter in monitoring', () => {

nav('/settings/templates');

el(['content-template--testing', 'template-actions']).click();
el(['content-template--testing', 'template-actions--options'], by.buttonText('Edit')).click();
element(
by.css('[data-test-id="content-template"][data-test-value="testing"] [data-test-id="template-actions"]'),
).click();
// eslint-disable-next-line
element(by.css('[data-test-id="content-template"][data-test-value="testing"] [data-test-id="template-actions--options"]')).element(by.buttonText('Edit')).click();
browser.sleep(1000);

el(['template-edit-view', 'desks', 'desk--Multiple sources']).click();
Expand Down
Loading

0 comments on commit 7a6ec1c

Please sign in to comment.