Skip to content

Commit

Permalink
LPD-37782 Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
markocikos authored and brianchandotcom committed Oct 24, 2024
1 parent 1d7196b commit 330ea76
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
liferay-sample-editor-config-contributor
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/

import {test} from '@playwright/test';

import {CKEditorSamplePage} from '../pages/CKEditorSamplePage';

const ckeditorSamplePageTest = test.extend<{
ckeditorSamplePage: CKEditorSamplePage;
}>({
ckeditorSamplePage: async ({page}, use) => {
await use(new CKEditorSamplePage(page));
},
});

export {ckeditorSamplePageTest};
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/

import {Page} from '@playwright/test';

import {ApiHelpers} from '../../../helpers/ApiHelpers';
import {liferayConfig} from '../../../liferay.config';
import getRandomString from '../../../utils/getRandomString';
import getPageDefinition from '../../layout-content-page-editor-web/utils/getPageDefinition';
import getWidgetDefinition from '../../layout-content-page-editor-web/utils/getWidgetDefinition';

export class CKEditorSamplePage {
readonly apiHelpers: ApiHelpers;
readonly page: Page;

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

async createAndGotoSitePage({site}: {site: Site}) {
const widgetDefinition = getWidgetDefinition({
id: getRandomString(),
widgetName:
'com_liferay_editor_ckeditor_sample_web_internal_portlet_CKEditorSamplePortlet',
});

const title = getRandomString();

await this.apiHelpers.headlessDelivery.createSitePage({
pageDefinition: getPageDefinition([widgetDefinition]),
siteId: site.id,
title,
});

await this.page.goto(
`${liferayConfig.environment.baseUrl}/web${site.friendlyUrlPath}/${title}`
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/

import {expect, mergeTests} from '@playwright/test';

import {apiHelpersTest} from '../../fixtures/apiHelpersTest';
import {featureFlagsTest} from '../../fixtures/featureFlagsTest';
import {isolatedSiteTest} from '../../fixtures/isolatedSiteTest';
import {loginTest} from '../../fixtures/loginTest';
import {ckeditorSamplePageTest} from './fixtures/ckeditorSamplePageTest';

export const test = mergeTests(
apiHelpersTest,
featureFlagsTest({
'LPS-178052': true,
}),
isolatedSiteTest,
loginTest(),
ckeditorSamplePageTest
);

test.beforeEach(async ({ckeditorSamplePage, page, site}) => {
await ckeditorSamplePage.createAndGotoSitePage({site});

const reactTab = page.getByRole('tab', {
name: 'React',
});

await reactTab.click();

expect(
page.getByText('Classic Editor used from a React component')
).toBeVisible();
});

test(
'Editor configuration object must not be mutated',
{tag: '@LPD-37782'},
async ({page}) => {
const iframe = page.frameLocator(
'iframe[title$="sampleReactClassicEditor"]'
);

expect(
iframe.getByText('Editor configuration object was not mutated.')
).toBeVisible();
}
);

0 comments on commit 330ea76

Please sign in to comment.