Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement ability for e2e tests to patch appConfig #4548

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions e2e/client/playwright/authoring.publish.embargo.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {test, expect} from '@playwright/test';
import {Monitoring} from './page-object-models/monitoring';
import {restoreDatabaseSnapshot, s} from './utils';
import {getStorageState} from './utils/storage-state';

test.use({
storageState: getStorageState({ui: {publishEmbargo: false}}),
});

test('disabling publish embargo by adjusting instance configuration', async ({page}) => {
await restoreDatabaseSnapshot();

const monitoring = new Monitoring(page);

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

await monitoring.selectDeskOrWorkspace('Sports');

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();

// "target" section is not relevant for this test
// but is used as a control to make sure panel content has finished loading
await expect(
page.locator(s('authoring', 'interactive-actions-panel')).getByRole('button', {name: 'Target'}),
).toBeVisible();

await expect(
page.locator(s('authoring', 'interactive-actions-panel')).getByRole('button', {name: 'Embargo'}),
).not.toBeVisible();
});
16 changes: 16 additions & 0 deletions e2e/client/playwright/utils/storage-state.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {BrowserContextOptions} from '@playwright/test';
import {ISuperdeskGlobalConfig} from 'superdesk-api';
import storageState from '../.auth/user.json';

type StorageState = BrowserContextOptions['storageState'];

/**
* Allows to set custom application configs while preserving values defined in .auth/user.json
*/
export function getStorageState(appConfigPatch: Partial<ISuperdeskGlobalConfig>): StorageState {
const storageStateCopy = JSON.parse(JSON.stringify(storageState));

storageStateCopy['origins'][0].localStorage.push({name: 'TEST_APP_CONFIG', value: JSON.stringify(appConfigPatch)});

return storageStateCopy;
}
4 changes: 4 additions & 0 deletions scripts/appConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {merge} from 'lodash';
import {ISuperdeskGlobalConfig, IExtensions, IUser} from 'superdesk-api';

/* globals __SUPERDESK_CONFIG__: true */
Expand Down Expand Up @@ -27,6 +28,9 @@ if (appConfig.features.autorefreshContent == null) {
appConfig.features.autorefreshContent = true; // default to true
}

// allow e2e tests to overwrite appConfig via local storage
Object.assign(appConfig, merge(appConfig, JSON.parse(localStorage.getItem('TEST_APP_CONFIG') ?? '{}')));

export const dashboardRoute = '/workspace';
export const IDENTITY_KEY = 'sess:user';
export const extensions: IExtensions = {};
Expand Down
Loading