Added Playwright "Post visibility" tests

Refs https://github.com/TryGhost/Team/issues/2371

- Tests whether the post access selection of public, members, or paid-members matches the expected post visibility on the frontend.
This commit is contained in:
Sanne de Vries 2022-12-08 11:26:44 +07:00
parent 460b031969
commit 0ebb3cbefe
2 changed files with 66 additions and 0 deletions

View File

@ -5,6 +5,7 @@
@optionLabelPath="label"
@optionTargetPath="name"
@update={{action "updateVisibility"}}
@data-test-select="post-visibility"
/>
{{svg-jar "arrow-down-small"}}
</span>

View File

@ -172,3 +172,68 @@ test.describe('Publishing', () => {
});
});
});
test.describe('Updating post access', () => {
test.describe('Change post visibility to members-only', () => {
test('Only logged-in members (free or paid) can see', async ({page}) => {
await page.goto('/ghost');
// Create a post
await createPost(page);
// Open the Post Settings Menu
await page.locator('[data-test-psm-trigger]').click();
// Change the Post access setting to 'Members only'
await page.locator('[data-test-select="post-visibility"]').selectOption('members');
// Publish the post
const frontendPage = await publishPost(page);
// Check if content gate for members is present on front-end
await expect(frontendPage.locator('.gh-post-upgrade-cta-content h2')).toHaveText('This post is for subscribers only');
});
});
test.describe('Change post visibility to paid-members-only', () => {
test('Only logged-in, paid members can see', async ({page}) => {
await page.goto('/ghost');
// Create a post
await createPost(page);
// Open the Post Settings Menu
await page.locator('[data-test-psm-trigger]').click();
// Change the Post access setting to 'Paid-members only'
await page.locator('[data-test-select="post-visibility"]').selectOption('paid');
// Publish the post
const frontendPage = await publishPost(page);
// Check if content gate for paid members is present on front-end
await expect(frontendPage.locator('.gh-post-upgrade-cta-content h2')).toHaveText('This post is for paying subscribers only');
});
});
test.describe('Change post visibility to public', () => {
test('Everyone can see', async ({page}) => {
await page.goto('/ghost');
// Create a post
await createPost(page);
// Open the Post Settings Menu
await page.locator('[data-test-psm-trigger]').click();
// Change the Post access setting to 'Public'
await page.locator('[data-test-select="post-visibility"]').selectOption('public');
// Publish the post
const frontendPage = await publishPost(page);
// Check if post content is publicly visible on front-end
await expect(frontendPage.locator('.gh-content.gh-canvas > p')).toHaveText('This is my post body.');
});
});
});