Skip to content

Commit

Permalink
Merge branch 'develop' into custom-fileds-e2e-test
Browse files Browse the repository at this point in the history
  • Loading branch information
dzonidoo committed Jun 12, 2024
2 parents d7ac521 + 4edaa29 commit c31874f
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 73 deletions.
49 changes: 49 additions & 0 deletions e2e/client/playwright/authoring.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,52 @@ test('save button from unsaved changes modal', async ({page}) => {
await expect(page.locator(s('authoring'))).not.toBeVisible();
await expect(page.locator(s('monitoring-view', 'article-item=new article'))).toBeVisible();
});

test('setting embargo', async ({page}) => {
const monitoring = new Monitoring(page);

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

await monitoring.selectDeskOrWorkspace('Sports');

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

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

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

await page.locator(s('authoring', 'open-send-publish-pane')).click();

const embargoDate = '09/09/' + ((new Date()).getFullYear() + 1);
const embargoTime = '04:00';

await page.locator(
s('authoring', 'interactive-actions-panel', 'embargo', 'date-input'),
).pressSequentially(embargoDate);

await page.locator(
s('authoring', 'interactive-actions-panel', 'embargo', 'time-input'),
).pressSequentially(embargoTime);

await page.locator(s('authoring', 'interactive-actions-panel')).getByRole('button', {name: 'Close'}).click();

await page.locator(s('authoring-topbar', 'save')).click();

// make sure label appears inside article item in the monitoring list
await expect(page.locator(
s('monitoring-group=Sports / Working Stage', 'article-item=test sports story'),
)).toContainText('Embargo');

// make sure label appears inside metadata widget
await page.locator(s('authoring-widget=Info')).click();
await expect(page.locator(
s('authoring-widget-panel=Info'),
)).toContainText('embargo');
});
20 changes: 0 additions & 20 deletions e2e/client/specs/content_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,26 +218,6 @@ describe('content', () => {
element(by.id('closeAuthoringBtn')).click();
});

it('can display embargo in metadata when set', () => {
workspace.editItem('item3', 'SPORTS');

el(['open-send-publish-pane']).click();

setEmbargo();

authoring.closeSendAndPublish();

authoring.save();
element(by.id('closeAuthoringBtn')).click();

content.previewItem('item3');
element(by.css('[ng-click="vm.current_tab = \'metadata\'"]')).click();

expect(element(by.css('[datetime="item.embargo"]')).isDisplayed()).toBe(true);

content.closePreview();
});

it('can set embargo and send', () => {
// Initial steps before proceeding, to get initial state of send buttons.
workspace.editItem('item3', 'SPORTS');
Expand Down
16 changes: 0 additions & 16 deletions e2e/client/specs/search_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,22 +266,6 @@ describe('search', () => {
authoring.close();
});

it('can display embargo item when set', () => {
expect(globalSearch.getItems().count()).toBe(16);
globalSearch.actionOnItem('Edit', 'item1');
authoring.sendToButton.click();
authoring.setEmbargo();
authoring.closeSendAndPublish();
authoring.save();
authoring.close();

const embargoElement = globalSearch.getItem(0).element(by.className('state_embargo'));

browser.wait(ECE.visibilityOf(embargoElement));

expect(embargoElement.getText()).toEqual('EMBARGO');
});

it('can search scheduled', () => {
globalSearch.waitForItemCount(16);
globalSearch.actionOnItem('Edit', 'item9');
Expand Down
26 changes: 18 additions & 8 deletions scripts/api/article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,30 @@ export const isIngested = (item: IArticle) =>
item.state === ITEM_STATE.INGESTED;

function canPublish(item: IArticle): boolean {
const deskId = item?.task?.desk;

if (deskId == null) {
if (
sdApi.user.hasPrivilege('publish') !== true
|| item.flags?.marked_for_not_publication === true
|| item.state === 'draft'
) {
return false;
}

const desk = sdApi.desks.getAllDesks().get(deskId);
const $location = ng.get('$location');

if (desk.desk_type === 'authoring' && appConfig?.features?.noPublishOnAuthoringDesk === true) {
if ($location.path() === '/workspace/personal' && appConfig?.features?.publishFromPersonal !== true) {
return false;
}
} else {
const deskId = item?.task?.desk;

if (sdApi.user.hasPrivilege('publish') !== true) {
return false;
if (deskId == null) {
return false;
}

const desk = sdApi.desks.getAllDesks().get(deskId);

if (desk.desk_type === 'authoring' && appConfig?.features?.noPublishOnAuthoringDesk === true) {
return false;
}
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {addInternalEventListener, dispatchInternalEvent} from 'core/internal-eve
import {appConfig} from 'appConfig';
import {ITEM_STATE} from 'apps/archive/constants';
import {IArticleActionInteractive} from 'core/interactive-article-actions-panel/interfaces';
import {sdApi} from 'api';

/**
* @ngdoc directive
Expand Down Expand Up @@ -62,10 +63,14 @@ export function AuthoringTopbarDirective(
function getAvailableTabs(): Array<IArticleActionInteractive> {
if (scope.isCorrection(scope.item)) {
return ['send_to', 'correct'];
} else if (scope.item.flags?.marked_for_not_publication === true) {
return ['send_to'];
} else {
return ['send_to', 'publish'];
const result: Array<IArticleActionInteractive> = ['send_to'];

if (sdApi.article.canPublish(scope.item)) {
result.push('publish');
}

return result;
}
}

Expand Down
15 changes: 1 addition & 14 deletions scripts/apps/search/controllers/get-multi-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,7 @@ export function getMultiActions(
}

function canPublishItem() {
return getSelectedItems().every((item) => {
const desk = desks.getCurrentDesk();

if (privileges.userHasPrivileges({publish: 1})
&& !(desk.desk_type === 'authoring' && appConfig?.features?.noPublishOnAuthoringDesk)) {
if (item.state !== 'draft' && $location.path() !== '/workspace/personal') {
return true;
} else if (item.state !== 'draft' && $location.path() === '/workspace/personal') {
return appConfig?.features?.publishFromPersonal;
}
}

return false;
});
return getSelectedItems().every((item) => sdApi.article.canPublish(item));
}

/**
Expand Down
13 changes: 1 addition & 12 deletions scripts/core/interactive-article-actions-panel/index-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,11 @@ export class InteractiveArticleActionsPanel
const markupV2 = authoringReactViewEnabled && this.props.markupV2 === true;
const handleUnsavedChanges = this.props.handleUnsavedChanges ?? handleUnsavedChangesDefault;

const filteredTabs = tabs.filter((tab) => {
if (tab === 'publish') {
const item = items[0]; // only one item is supported in publishing tab
const notForPublication = item?.flags?.marked_for_not_publication ?? false;

return notForPublication !== true;
} else {
return true;
}
});

const panelHeader = (
<PanelHeader markupV2={markupV2}>
<div className="space-between" style={{width: '100%', paddingInlineEnd: 10}}>
<TabList
tabs={filteredTabs.map((id) => ({id, label: getTabLabel(id)}))}
tabs={tabs.map((id) => ({id, label: getTabLabel(id)}))}
selectedTabId={activeTab}
onChange={(tab: IArticleActionInteractive) => {
this.setState({
Expand Down

0 comments on commit c31874f

Please sign in to comment.