Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:superdesk/superdesk-client-core …
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
fritzSF committed Aug 19, 2024
2 parents 7d5f04e + 28e0e26 commit 87cbc2a
Show file tree
Hide file tree
Showing 57 changed files with 577 additions and 292 deletions.
49 changes: 49 additions & 0 deletions e2e/client/playwright/content-profile.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {test, expect} from '@playwright/test';
import {Monitoring} from './page-object-models/monitoring';
import {restoreDatabaseSnapshot, s} from './utils';

test('content profile icon', async ({page}) => {
const monitoring = new Monitoring(page);

await restoreDatabaseSnapshot();

// expect an article to have a regular text icon

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

await expect(
page.locator(s(
'monitoring-group=Sports / Working Stage',
'article-item=test sports story',
'type-icon',
)),
).toHaveAttribute('data-test-value', 'text');


// go to content profile and set icon to "map-marker"

await page.goto('/#/settings/content-profiles');
await page.locator(s('content-profile=Story', 'content-profile-actions')).click();
await page.locator(s('content-profile-actions--options')).getByRole('button', {name: 'Edit'}).click();

await page.locator(s('content-profile-edit-view')).getByLabel('Icon').getByRole('button').click();
await page.getByRole('button', {name: 'map-marker'}).click();
await page.locator(s('content-profile-edit-view--footer')).getByRole('button', {name: 'Save'}).click();

await expect(page.locator(s('content-profile=Story', 'icon'))).toHaveAttribute('data-test-value', 'map-marker');


// go back to monitoring and test whether the newly set icon is being used

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

await expect(
page.locator(s(
'monitoring-group=Sports / Working Stage',
'article-item=test sports story',
'type-icon',
)),
).toHaveAttribute('data-test-value', 'map-marker', {timeout: 10000});
});
41 changes: 41 additions & 0 deletions e2e/client/playwright/editor3.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,47 @@ import {restoreDatabaseSnapshot, s} from './utils';
import {getEditor3FormattingOptions, getEditor3Paragraphs} from './utils/editor3';
import {TreeSelectDriver} from './utils/tree-select-driver';

test('can add embeds', async ({page}) => {
await restoreDatabaseSnapshot();

const monitoring = new Monitoring(page);

const requestRoute = 'https://sourcefabric.org';

await page.route(
`https://iframe.ly/api/oembed?callback=?&url=
${requestRoute}
&api_key="mock_api_key"
&omit_script=true&iframe=true`,
(route) => {
route.fulfill({
body: JSON.stringify([{
title: 'Open Source Software for Journalism',
description: 'Sourcefabric is Europe\'s largest developer of '
+ 'open source tools for news media, powering news and media organisations around the world.',
}]),
});
},
);
await page.goto('/#/workspace/monitoring');

await monitoring.selectDeskOrWorkspace('Sports');

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

page.locator(s('toolbar')).getByRole('button', {name: 'Embed'}).click();

await page.locator(s('embed-form')).getByPlaceholder('Enter URL or code to embed')
.fill('https://sourcefabric.org');

await page.locator(s('embed-controls', 'submit')).click();
await expect(
page.locator(s('authoring', 'authoring-field=body_html')).getByText('https://sourcefabric.org'),
).toBeDefined();
});

test('accepting a spelling suggestion', async ({page}) => {
const monitoring = new Monitoring(page);

Expand Down
21 changes: 13 additions & 8 deletions e2e/client/playwright/multiedit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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';
import {clearInput} from './utils/inputs';

test.describe('Multiedit', async () => {
test('editing articles in multi-edit mode', async ({page}) => {
Expand All @@ -15,21 +16,25 @@ test.describe('Multiedit', async () => {

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 clearInput(
page,
page.locator(s('multiedit-screen', 'multiedit-article=test sports story', 'field--headline'))
.getByRole('textbox'),
);

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 clearInput(
page,
page.locator(s('multiedit-screen', 'multiedit-article=story 2', 'field--headline'))
.getByRole('textbox'),
);

await page
.locator(s('multiedit-screen', 'multiedit-article=story 2', 'field--headline'))
.getByRole('textbox')
Expand Down
10 changes: 10 additions & 0 deletions e2e/client/playwright/utils/inputs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {Page, Locator} from '@playwright/test';

/**
* .clear method from playwright doesn't work in a stable manner for editor3 inputs
*/
export async function clearInput(page: Page, textInputLocator: Locator): Promise<void> {
await textInputLocator.focus();
await page.keyboard.press('Meta+A');
await page.keyboard.press('Backspace');
}
24 changes: 9 additions & 15 deletions e2e/client/specs/authoring_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ describe('authoring', () => {

it('authoring operations', () => {
// allows to create a new empty package
el(['content-create']).click();
el(['content-create-dropdown', 'create-package']).click();
monitoring.createItem('Create package');

expect(element(by.className('packaging-screen')).isDisplayed()).toBe(true);
authoring.close();
Expand Down Expand Up @@ -615,8 +614,8 @@ describe('authoring', () => {

it('Not modifying crops will not trigger an article change', () => {
workspace.selectDesk('XEditor3 Desk'); // has media gallery in content profile
el(['content-create']).click();
el(['content-create-dropdown']).element(by.buttonText('editor3 template')).click();
monitoring.createItem('editor3 template');

browser.wait(ECE.visibilityOf(
element(by.css(s('authoring-field=Image gallery 33', 'media-gallery--upload-placeholder'))),
));
Expand Down Expand Up @@ -645,15 +644,16 @@ describe('authoring', () => {

it('Can add an image with default crops to media gallery', () => {
workspace.selectDesk('XEditor3 Desk'); // has media gallery in content profile
el(['content-create']).click();
el(['content-create-dropdown']).element(by.buttonText('editor3 template')).click();
monitoring.createItem('editor3 template');

browser.wait(ECE.visibilityOf(
element(by.css(s('authoring-field=Image gallery 33', 'media-gallery--upload-placeholder'))),
));
expect(ECE.hasElementCount(

browser.wait(ECE.hasElementCount(
element.all(by.css(s('authoring-field=Image gallery 33', 'media-gallery-image'))),
0,
)()).toBe(true);
));

uploadMedia(getAbsoluteFilePath('test-files/image-big.jpg'));

Expand All @@ -666,13 +666,7 @@ describe('authoring', () => {
it('Can remove an image from media gallery', () => {
workspace.selectDesk('XEditor3 Desk'); // has media gallery in content profile

el(['content-create']).click();

const templateBtn = el(['content-create-dropdown']).element(by.buttonText('editor3 template'));

browser.wait(ECE.elementToBeClickable(templateBtn));

templateBtn.click();
monitoring.createItem('editor3 template');

browser.wait(ECE.visibilityOf(
element(by.css(s('authoring-field=Image gallery 33', 'media-gallery--upload-placeholder'))),
Expand Down
4 changes: 2 additions & 2 deletions e2e/client/specs/content_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {element, browser, protractor, by} from 'protractor';
import {workspace} from './helpers/workspace';
import {content} from './helpers/content';
import {authoring} from './helpers/authoring';
import {monitoring} from './helpers/monitoring';
import {multiAction} from './helpers/actions';
import {ECE, el} from '@superdesk/end-to-end-testing-helpers';
import {TreeSelectDriver} from './helpers/tree-select-driver';
Expand Down Expand Up @@ -164,8 +165,7 @@ describe('content', () => {
workspace.switchToDesk('SPORTS DESK');
content.setListView();

el(['content-create']).click();
el(['content-create-dropdown', 'create-package']).click();
monitoring.createItem('Create package');

element.all(by.model('item.headline')).first().sendKeys('Empty Package');
authoring.save();
Expand Down
2 changes: 1 addition & 1 deletion e2e/client/specs/editor3_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('editor3', () => {
monitoring.openMonitoring();
monitoring.selectDesk('xeditor3');
monitoring.createFromDeskTemplate();
browser.wait(ECE.presenceOf(editors.get(0)));
browser.wait(ECE.presenceOf(editors.get(0)), 2000);
});

it('can edit headline', () => {
Expand Down
8 changes: 5 additions & 3 deletions e2e/client/specs/helpers/authoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {waitHidden, waitFor, click} from './utils';
import {ECE, els, el} from '@superdesk/end-to-end-testing-helpers';
import {PLAIN_TEXT_TEMPLATE_NAME} from './constants';
import {TreeSelectDriver} from './tree-select-driver';
import {monitoring} from './monitoring';

class Authoring {
lock: any;
Expand Down Expand Up @@ -337,11 +338,12 @@ class Authoring {
* @param {String} name
*/
this.createTextItemFromTemplate = (name) => {
el(['content-create']).click();
el(['content-create-dropdown'], by.buttonText('More templates...')).click();
monitoring.createItem('More templates...');

el(['content-create-dropdown', 'search']).sendKeys(name);
el(['content-create-dropdown'], by.buttonText(name)).click();
browser.wait(ECE.presenceOf(el(['authoring'])));

browser.wait(ECE.presenceOf(el(['authoring'])), 2000);
};

this.close = function() {
Expand Down
22 changes: 20 additions & 2 deletions e2e/client/specs/helpers/monitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Monitoring {
showSpiked: () => void;
showPersonal: () => void;
showSearch: () => void;
createItem: (template: string) => void;
createFromDeskTemplate: () => any;
getGroup: (group: number) => any;
getGroups: () => any;
Expand Down Expand Up @@ -171,8 +172,14 @@ class Monitoring {
* Create new item using desk template
*/
this.createFromDeskTemplate = () => {
el(['content-create']).click();
el(['content-create-dropdown', 'default-desk-template']).click();
const createButton = el(['content-create']);
const templateButton = el(['content-create-dropdown', 'default-desk-template']);

browser.wait(ECE.elementToBeClickable(createButton), 1000);
createButton.click();

browser.wait(ECE.elementToBeClickable(templateButton), 1000);
templateButton.click();
};

this.getGroup = function(group: number) {
Expand Down Expand Up @@ -992,6 +999,17 @@ class Monitoring {
this.getPackageItemLabel = function(index) {
return element.all(by.id('package-item-label')).get(index);
};

this.createItem = (buttonText: string) => {
const plusButton = el(['content-create']);
const itemButton = el(['content-create-dropdown']).element(by.buttonText(buttonText));

browser.wait(ECE.elementToBeClickable(plusButton), 2000);
plusButton.click();

browser.wait(ECE.elementToBeClickable(itemButton), 2000, `Button '${buttonText}' is not clickable`);
itemButton.click();
};
}
}

Expand Down
2 changes: 2 additions & 0 deletions e2e/client/specs/helpers/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ class GlobalSearch {
this.itemClick = function(index) {
var itemElem = this.getItem(index);

browser.wait(ECE.elementToBeClickable(itemElem), 1000);

itemElem.click();

browser.wait(ECE.attributeContains(itemElem, 'class', 'active'), 2000);
Expand Down
3 changes: 1 addition & 2 deletions e2e/client/specs/monitoring_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,7 @@ describe('monitoring', () => {
it('can start content upload', () => {
monitoring.openMonitoring();

el(['content-create']).click();
el(['content-create-dropdown', 'upload-media']).click();
monitoring.createItem('Upload media');

expect(monitoring.uploadModal.isDisplayed()).toBeTruthy();
});
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions scripts/api/content-profiles.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {IContentProfile} from 'superdesk-api';
import ng from 'core/services/ng';
import {dataStore} from 'data-store';

interface IContentProfilesApi {
get(id: IContentProfile['_id']): Promise<IContentProfile>;
get(id: IContentProfile['_id']): IContentProfile;
}

export const contentProfiles: IContentProfilesApi = {
get: (id) => ng.get('content').getType(id),
get: (id) => dataStore.contentProfiles.get(id),
};
12 changes: 12 additions & 0 deletions scripts/appConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ if (appConfig.shortTimeFormat == null) {
appConfig.shortTimeFormat = 'HH:mm'; // 24h format
}

if (appConfig.view.dateformat == null) {
appConfig.view.dateformat = 'MM/DD';
}

if (appConfig.view.timeformat == null) {
appConfig.view.timeformat = 'hh:mm';
}

if (appConfig.longDateFormat == null) {
appConfig.longDateFormat = 'LLL';
}

if (appConfig.ui == null) {
appConfig.ui = {};

Expand Down
6 changes: 3 additions & 3 deletions scripts/apps/authoring-react/data-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {getArticleAdapter} from './article-adapter';
import {gettext} from 'core/utils';
import {PACKAGE_ITEMS_FIELD_ID} from './fields/package-items';
import {description_text} from './field-adapters/description_text';
import moment from 'moment';
import {formatDateTime} from 'core/get-superdesk-api-implementation';

export function getArticleContentProfile<T>(
item: IArticle,
Expand Down Expand Up @@ -421,8 +421,8 @@ export const authoringStorageIArticleCorrect: IAuthoringStorage<IArticle> = {
newItem.sms_message = '';

const {override_ednote_for_corrections, override_ednote_template} = appConfig;
const date = moment(newItem.versioncreated)
.format(appConfig.view.dateformat + ' ' + appConfig.view.timeformat);

const date = formatDateTime(newItem.versioncreated);

if (override_ednote_for_corrections && override_ednote_template == null) {
const lineBreak = '\r\n\r\n';
Expand Down
1 change: 0 additions & 1 deletion scripts/apps/desks/views/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ <h2 class="sd-page__page-heading" translate>Desk management</h2>
<button
ng-click="openDesk('general', desk)"
title="{{:: 'Edit desk'| translate }}"
data-test-id="desk-actions--edit"
>
<i class="icon-pencil"></i>
{{:: 'Edit'| translate}}
Expand Down
Loading

0 comments on commit 87cbc2a

Please sign in to comment.