mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
6d3317fcfc
ref PLG-229 - Previously we had no way of using Ghost labs flags in Comments UI. - With this change, we now get Labs data from the existing content settings endpoint. - Additionally, we have a `useLabs` hook that can be accessed from anywhere in the App to put those awesome new features behind a flag for staging - And we can pass labs params to the initialiser for testing. For more details: https://ghost.slack.com/archives/C06TQR9SHSM/p1726133527960489
44 lines
No EOL
1.2 KiB
TypeScript
44 lines
No EOL
1.2 KiB
TypeScript
import {MockedApi, initialize} from '../utils/e2e';
|
|
import {expect, test} from '@playwright/test';
|
|
|
|
test.describe('Labs', async () => {
|
|
test('Can toggle content based on Lab settings', async ({page}) => {
|
|
const mockedApi = new MockedApi({});
|
|
mockedApi.setMember({});
|
|
|
|
mockedApi.addComment({
|
|
html: '<p>This is comment 1</p>'
|
|
});
|
|
|
|
const {frame} = await initialize({
|
|
mockedApi,
|
|
page,
|
|
publication: 'Publisher Weekly',
|
|
labs: {
|
|
testFlag: true
|
|
}
|
|
});
|
|
|
|
await expect(frame.getByTestId('this-comes-from-a-flag')).toHaveCount(1);
|
|
});
|
|
|
|
test('test div is hidden if flag is not set', async ({page}) => {
|
|
const mockedApi = new MockedApi({});
|
|
mockedApi.setMember({});
|
|
|
|
mockedApi.addComment({
|
|
html: '<p>This is comment 1</p>'
|
|
});
|
|
|
|
const {frame} = await initialize({
|
|
mockedApi,
|
|
page,
|
|
publication: 'Publisher Weekly',
|
|
labs: {
|
|
testFlag: false
|
|
}
|
|
});
|
|
|
|
await expect(frame.getByTestId('this-comes-from-a-flag')).not.toBeVisible();
|
|
});
|
|
}); |