From 0a21c147ec317888eebc3b480a9bca72f734ebda Mon Sep 17 00:00:00 2001 From: Tomas Kikutis Date: Fri, 25 Aug 2023 13:53:48 +0200 Subject: [PATCH 01/67] batch 1 --- e2e/client/specs/archived_spec.ts | 3 ++- e2e/client/specs/content_spec.ts | 7 +++--- e2e/client/specs/helpers/authoring.ts | 24 +++++++------------ e2e/client/specs/helpers/constants.ts | 1 + e2e/client/specs/helpers/monitoring.ts | 12 ++++------ e2e/client/specs/legal_archive_spec.ts | 2 +- e2e/client/specs/monitoring_spec.ts | 6 +++-- e2e/client/specs/users_spec.ts | 16 ++++++------- .../content-create-dropdown.tsx | 1 + .../dropdown-option.tsx | 2 ++ .../content-create-dropdown/initial-view.tsx | 3 +++ .../more-templates.tsx | 1 + 12 files changed, 40 insertions(+), 38 deletions(-) create mode 100644 e2e/client/specs/helpers/constants.ts diff --git a/e2e/client/specs/archived_spec.ts b/e2e/client/specs/archived_spec.ts index 9fb56996eb..3df82ad8d5 100644 --- a/e2e/client/specs/archived_spec.ts +++ b/e2e/client/specs/archived_spec.ts @@ -3,6 +3,7 @@ import {globalSearch} from './helpers/search'; import {authoring} from './helpers/authoring'; import {content} from './helpers/content'; import {monitoring} from './helpers/monitoring'; +import {element, by} from 'protractor'; describe('archived', () => { beforeEach(() => { @@ -31,7 +32,7 @@ describe('archived', () => { expect(authoring.edit_correct_button.isDisplayed()).toBe(false); expect(authoring.edit_kill_button.isDisplayed()).toBe(false); expect(authoring.edit_takedown_button.isDisplayed()).toBe(false); - expect(authoring.navbarMenuBtn.isPresent()).toBe(false); + expect(element(by.css('[data-test-id="authoring-create]')).isPresent()).toBe(false); expect(authoring.sendToButton.isDisplayed()).toBe(false); authoring.showInfo(); expect(authoring.isPublishedState()).toBe(true); diff --git a/e2e/client/specs/content_spec.ts b/e2e/client/specs/content_spec.ts index 7b8a5d255f..402bf11b2f 100644 --- a/e2e/client/specs/content_spec.ts +++ b/e2e/client/specs/content_spec.ts @@ -150,8 +150,7 @@ describe('content', () => { workspace.switchToDesk('SPORTS DESK'); content.setListView(); - element(by.className('sd-create-btn')).click(); - element(by.id('create_text_article')).click(); + authoring.createTextItem(); authoring.writeText('Words'); authoring.save(); @@ -164,8 +163,8 @@ describe('content', () => { workspace.switchToDesk('SPORTS DESK'); content.setListView(); - element(by.className('sd-create-btn')).click(); - element(by.id('create_package')).click(); + el(['authoring-create']).click(); + el(['content-create-dropdown', 'create-package']).click(); element.all(by.model('item.headline')).first().sendKeys('Empty Package'); authoring.save(); diff --git a/e2e/client/specs/helpers/authoring.ts b/e2e/client/specs/helpers/authoring.ts index d87977be8f..845109c923 100644 --- a/e2e/client/specs/helpers/authoring.ts +++ b/e2e/client/specs/helpers/authoring.ts @@ -3,6 +3,7 @@ import {element, by, browser, protractor} from 'protractor'; import {waitHidden, waitFor, click} from './utils'; import {ECE, els, el} from '@superdesk/end-to-end-testing-helpers'; +import {PLAIN_TEXT_TEMPLATE_NAME} from './constants'; class Authoring { lock: any; @@ -20,8 +21,6 @@ class Authoring { edit_correct_button: any; edit_kill_button: any; edit_takedown_button: any; - navbarMenuBtn: any; - newPlainArticleLink: any; newEmptyPackageLink: any; infoIconsBox: any; sendToButton: any; @@ -180,6 +179,7 @@ class Authoring { openCompareVersionsInnerDropdown: (index: any) => void; getInnerDropdownItemVersions: (index: any) => any; openItemVersionInBoard: (board: any, index: any) => void; + createPlainTextArticle: () => void; constructor() { this.lock = element(by.css('[ng-click="lock()"]')); @@ -198,8 +198,6 @@ class Authoring { this.edit_kill_button = element(by.css('[title="Kill"]')); this.edit_takedown_button = element(by.css('[title="Takedown"]')); - this.navbarMenuBtn = element(by.css('.dropdown__toggle.sd-create-btn')); - this.newPlainArticleLink = element(by.id('create_text_article')); this.newEmptyPackageLink = element(by.id('create_package')); this.infoIconsBox = element(by.css('.info-icons')); @@ -345,10 +343,8 @@ class Authoring { return element(by.className('svg-icon-add-to-list')).click(); }; - this.createTextItem = function() { - return element(by.className('sd-create-btn')) - .click() - .then(() => element(by.id('create_text_article')).click()); + this.createTextItem = () => { + this.createTextItemFromTemplate(PLAIN_TEXT_TEMPLATE_NAME); }; /** @@ -357,13 +353,11 @@ class Authoring { * @param {String} name */ this.createTextItemFromTemplate = (name) => { - element(by.className('sd-create-btn')).click(); - element(by.id('more_templates')).click(); - let templates = element.all(by.repeater('template in templates track by template._id')); - - templates.all(by.css('[ng-click="select({template: template})"]')) - .filter((elem) => elem.getText().then((text) => text.toUpperCase().indexOf(name.toUpperCase()) > -1)) - .click(); + el(['authoring-create']).click(); + el(['content-create-dropdown'], by.buttonText('More templates...')).click(); + el(['content-create-dropdown', 'search']).sendKeys(name); + el(['content-create-dropdown'], by.buttonText(name)).click(); + browser.wait(ECE.presenceOf(el(['authoring']))); }; this.close = function() { diff --git a/e2e/client/specs/helpers/constants.ts b/e2e/client/specs/helpers/constants.ts new file mode 100644 index 0000000000..fd2eec0ef5 --- /dev/null +++ b/e2e/client/specs/helpers/constants.ts @@ -0,0 +1 @@ +export const PLAIN_TEXT_TEMPLATE_NAME = 'plain text'; diff --git a/e2e/client/specs/helpers/monitoring.ts b/e2e/client/specs/helpers/monitoring.ts index f20358ff7c..d32052bd1c 100644 --- a/e2e/client/specs/helpers/monitoring.ts +++ b/e2e/client/specs/helpers/monitoring.ts @@ -98,7 +98,6 @@ class Monitoring { openSendMenu: () => void; publish: () => void; getPublishButtonText: any; - startUpload: () => void; uploadModal: ElementFinder; openFetchAsOptions: (group: any, item: any) => void; clickOnFetchButton: any; @@ -177,7 +176,10 @@ class Monitoring { /** * Create new item using desk template */ - this.createFromDeskTemplate = () => this.createItemAction('create_text_article'); + this.createFromDeskTemplate = () => { + el(['authoring-create']).click(); + el(['content-create-dropdown', 'default-desk-template']).click(); + }; this.getGroup = function(group: number) { return this.getGroups().get(group); @@ -717,7 +719,7 @@ class Monitoring { }; this.openCreateMenu = function() { - element(by.className('sd-create-btn')).click(); + element(by.css('[data-test-id="authoring-create"]')).click(); browser.sleep(100); }; @@ -733,10 +735,6 @@ class Monitoring { this.getPublishButtonText = () => element(by.css('[ng-click="publish()"]')).getText(); - this.startUpload = function() { - element(by.id('start-upload-btn')).click(); - }; - this.uploadModal = element(by.className('upload-media')); this.openFetchAsOptions = function(group, item) { diff --git a/e2e/client/specs/legal_archive_spec.ts b/e2e/client/specs/legal_archive_spec.ts index fd0ae6f285..7c144030bb 100644 --- a/e2e/client/specs/legal_archive_spec.ts +++ b/e2e/client/specs/legal_archive_spec.ts @@ -79,7 +79,7 @@ describe('legal_archive', () => { expect(authoring.edit_button.isPresent()).toBe(false); expect(authoring.edit_correct_button.isPresent()).toBe(false); expect(authoring.edit_kill_button.isPresent()).toBe(false); - expect(authoring.navbarMenuBtn.isPresent()).toBe(false); + expect(element(by.css('[data-test-id="authoring-create]')).isPresent()).toBe(false); expect(authoring.sendToButton.isDisplayed()).toBe(false); authoring.showInfo(); diff --git a/e2e/client/specs/monitoring_spec.ts b/e2e/client/specs/monitoring_spec.ts index 450c97e7ea..2563e20d7c 100644 --- a/e2e/client/specs/monitoring_spec.ts +++ b/e2e/client/specs/monitoring_spec.ts @@ -473,8 +473,10 @@ describe('monitoring', () => { it('can start content upload', () => { monitoring.openMonitoring(); - monitoring.openCreateMenu(); - monitoring.startUpload(); + + el(['authoring-create']).click(); + el(['content-create-dropdown', 'upload-media']).click(); + expect(monitoring.uploadModal.isDisplayed()).toBeTruthy(); }); diff --git a/e2e/client/specs/users_spec.ts b/e2e/client/specs/users_spec.ts index dfc2d5cc80..689f95d665 100644 --- a/e2e/client/specs/users_spec.ts +++ b/e2e/client/specs/users_spec.ts @@ -246,8 +246,9 @@ describe('users', () => { // navigate to Workspace and create a new article workspace.openContent(); - authoring.navbarMenuBtn.click(); - authoring.newPlainArticleLink.click(); + + + authoring.createTextItem(); // authoring opened, click the set category menu and see what // categories are offered @@ -275,8 +276,7 @@ describe('users', () => { // navigate to Workspace and create a new article monitoring.openMonitoring(); - authoring.navbarMenuBtn.click(); - authoring.newPlainArticleLink.click(); + authoring.createTextItem(); browser.sleep(100); // Open subject metadata dropdown field @@ -354,19 +354,19 @@ describe('users', () => { }); it('while creating a new user', () => { - var buttonCreate = element(by.className('sd-create-btn')); + var buttonCreate = element(by.css('[data-test-id="create-user-button"]')); buttonCreate.click(); - expect(element(by.id('user_default_desk')).isPresent()).toBe(false); + expect(element(by.css('[data-test-id="default-desk-template"]')).isPresent()).toBe(false); }); it('while pre-viewing and user clicks on create new user', () => { - var buttonCreate = element(by.className('sd-create-btn')); + var buttonCreate = element(by.css('[data-test-id="create-user-button"]')); element.all(by.repeater('users')).first().click(); buttonCreate.click(); - expect(element(by.id('user_default_desk')).isPresent()).toBe(false); + expect(element(by.css('[data-test-id="default-desk-template"]')).isPresent()).toBe(false); }); }); diff --git a/scripts/core/ui/components/content-create-dropdown/content-create-dropdown.tsx b/scripts/core/ui/components/content-create-dropdown/content-create-dropdown.tsx index e40b6cff2e..a3d4607d14 100644 --- a/scripts/core/ui/components/content-create-dropdown/content-create-dropdown.tsx +++ b/scripts/core/ui/components/content-create-dropdown/content-create-dropdown.tsx @@ -18,6 +18,7 @@ const defaultButton = ({onClick}: IPropsAddContentCustomButton) => ( shape="round" iconOnly={true} onClick={onClick} + data-test-id="authoring-create" /> ); diff --git a/scripts/core/ui/components/content-create-dropdown/dropdown-option.tsx b/scripts/core/ui/components/content-create-dropdown/dropdown-option.tsx index 66dc63fd9f..9759af342c 100644 --- a/scripts/core/ui/components/content-create-dropdown/dropdown-option.tsx +++ b/scripts/core/ui/components/content-create-dropdown/dropdown-option.tsx @@ -7,6 +7,7 @@ interface IProps { icon?: {name: string, color?: string}; privateTag?: boolean; onClick: (event: React.MouseEvent) => void; + 'data-test-id'?: string; } export class DropdownOption extends React.PureComponent { @@ -17,6 +18,7 @@ export class DropdownOption extends React.PureComponent { - @@ -173,9 +179,11 @@