0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00
ghost/apps/comments-ui/test/e2e/labs.test.ts
Ronald Langeveld 6d3317fcfc
Added feature flagging system for Comments UI (#20984)
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
2024-09-12 18:36:37 +09:00

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