2023-10-13 14:42:39 +03:00
|
|
|
const {expect} = require('@playwright/test');
|
|
|
|
const test = require('../fixtures/ghost-test');
|
2022-12-07 16:32:09 +03:00
|
|
|
|
|
|
|
test.describe('Site Settings', () => {
|
|
|
|
test.describe('Privacy setting', () => {
|
2023-10-16 18:32:13 +03:00
|
|
|
test('A site set to private should require a password to access it', async ({sharedPage, browser}) => {
|
2022-12-07 16:32:09 +03:00
|
|
|
// set private mode in admin "on"
|
2023-10-16 18:32:13 +03:00
|
|
|
await sharedPage.goto('/ghost');
|
2022-12-07 16:32:09 +03:00
|
|
|
|
2023-10-16 18:32:13 +03:00
|
|
|
await sharedPage.locator('[data-test-nav="settings"]').click();
|
2022-12-07 16:32:09 +03:00
|
|
|
|
2023-10-16 18:32:13 +03:00
|
|
|
const section = sharedPage.getByTestId('locksite');
|
2023-10-09 10:12:46 +03:00
|
|
|
|
|
|
|
await section.getByRole('button', {name: 'Edit'}).click();
|
|
|
|
|
|
|
|
await section.getByLabel(/Enable password protection/).check();
|
|
|
|
await section.getByLabel('Site password').fill('password');
|
2022-12-07 16:32:09 +03:00
|
|
|
|
|
|
|
// save changes
|
2023-10-09 10:12:46 +03:00
|
|
|
await section.getByRole('button', {name: 'Save'}).click();
|
|
|
|
await expect(section.getByLabel('Site password')).toHaveCount(0);
|
2022-12-07 16:32:09 +03:00
|
|
|
|
|
|
|
// copy site password
|
2023-03-10 14:53:35 +03:00
|
|
|
//const passwordInput = await page.locator('[data-test-password-input]');
|
|
|
|
//const sitePassword = await passwordInput.inputValue();
|
2022-12-07 16:32:09 +03:00
|
|
|
|
|
|
|
// frontend needs new context to store cookies
|
|
|
|
const frontendContext = await browser.newContext();
|
|
|
|
const frontendPage = await frontendContext.newPage();
|
|
|
|
|
|
|
|
// check the site is protected by a password
|
|
|
|
await frontendPage.goto('/');
|
|
|
|
await expect(frontendPage.getByRole('button', {name: 'Access site →'})).toBeVisible();
|
|
|
|
|
|
|
|
// @NOTE: site access doesn't not work because Playwright ignores cookies set
|
|
|
|
// during the redirect response. Possibly related to https://github.com/microsoft/playwright/issues/5236
|
|
|
|
// assert /private/?r=%2F
|
|
|
|
// assert should not see the site front page
|
|
|
|
// await frontendPage.getByPlaceholder('Password').fill(sitePassword);
|
|
|
|
// await frontendPage.getByRole('button', {name: 'Access site →'}).click();
|
|
|
|
// await frontendPage.waitForSelector('.site-title');
|
|
|
|
// await expect(frontendPage.locator('.site-title')).toHaveText('The Local Test');
|
|
|
|
|
2023-10-09 10:12:46 +03:00
|
|
|
// set private mode in admin "off"
|
|
|
|
await section.getByRole('button', {name: 'Edit'}).click();
|
|
|
|
|
|
|
|
await section.getByLabel(/Enable password protection/).uncheck();
|
2022-12-07 16:32:09 +03:00
|
|
|
|
|
|
|
// save changes
|
2023-10-09 10:12:46 +03:00
|
|
|
await section.getByRole('button', {name: 'Save'}).click();
|
|
|
|
await expect(section.getByLabel('Site password')).toHaveCount(0);
|
2022-12-07 16:32:09 +03:00
|
|
|
|
|
|
|
// check the site is publicly accessible
|
2023-10-09 10:12:46 +03:00
|
|
|
await expect(async () => {
|
|
|
|
await frontendPage.goto('/');
|
|
|
|
await expect(frontendPage.locator('.gh-navigation-brand')).toHaveText('The Local Test');
|
|
|
|
}).toPass();
|
2022-12-07 16:32:09 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|