2023-10-13 14:42:39 +03:00
|
|
|
|
const {expect} = require('@playwright/test');
|
|
|
|
|
const test = require('../fixtures/ghost-test');
|
2022-12-08 15:58:38 +03:00
|
|
|
|
const {createMember, deleteAllMembers} = require('../utils/e2e-browser-utils');
|
2022-12-08 12:30:32 +03:00
|
|
|
|
const fs = require('fs');
|
2022-12-07 08:35:16 +03:00
|
|
|
|
|
|
|
|
|
test.describe('Admin', () => {
|
|
|
|
|
test.describe('Members', () => {
|
2023-10-13 14:42:39 +03:00
|
|
|
|
test.describe.configure({retries: 1, mode: 'serial'});
|
2023-10-16 18:32:13 +03:00
|
|
|
|
test('A member can be created', async ({sharedPage}) => {
|
|
|
|
|
await sharedPage.goto('/ghost');
|
|
|
|
|
await sharedPage.locator('.gh-nav a[href="#/members/"]').click();
|
|
|
|
|
await sharedPage.waitForSelector('a[href="#/members/new/"] span');
|
|
|
|
|
await sharedPage.locator('a[href="#/members/new/"] span:has-text("New member")').click();
|
|
|
|
|
await sharedPage.waitForSelector('input[name="name"]');
|
2022-12-07 08:35:16 +03:00
|
|
|
|
let name = 'Test Member';
|
|
|
|
|
let email = 'tester@testmember.com';
|
|
|
|
|
let note = 'This is a test member';
|
2022-12-07 11:45:00 +03:00
|
|
|
|
let label = 'Test Label';
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await sharedPage.fill('input[name="name"]', name);
|
|
|
|
|
await sharedPage.fill('input[name="email"]', email);
|
|
|
|
|
await sharedPage.fill('textarea[name="note"]', note);
|
|
|
|
|
await sharedPage.locator('label:has-text("Labels") + div').click();
|
|
|
|
|
await sharedPage.keyboard.type(label);
|
|
|
|
|
await sharedPage.keyboard.press('Tab');
|
|
|
|
|
await sharedPage.locator('button span:has-text("Save")').click();
|
|
|
|
|
await sharedPage.waitForSelector('button span:has-text("Saved")');
|
|
|
|
|
await sharedPage.locator('.gh-nav a[href="#/members/"]').click();
|
2022-12-12 15:51:31 +03:00
|
|
|
|
|
|
|
|
|
// check number of members
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await expect(sharedPage.locator('[data-test-list="members-list-item"]')).toHaveCount(1);
|
2022-12-12 15:51:31 +03:00
|
|
|
|
|
2023-10-16 18:32:13 +03:00
|
|
|
|
const member = sharedPage.locator('tbody > tr > a > div > div > h3').nth(0);
|
2022-12-07 08:35:16 +03:00
|
|
|
|
await expect(member).toHaveText(name);
|
2023-10-16 18:32:13 +03:00
|
|
|
|
const memberEmail = sharedPage.locator('tbody > tr > a > div > div > p').nth(0);
|
2022-12-07 08:35:16 +03:00
|
|
|
|
await expect(memberEmail).toHaveText(email);
|
|
|
|
|
});
|
2022-12-07 09:02:48 +03:00
|
|
|
|
|
2023-10-16 18:32:13 +03:00
|
|
|
|
test('A member cannot be created with invalid email', async ({sharedPage}) => {
|
|
|
|
|
await sharedPage.goto('/ghost');
|
|
|
|
|
await sharedPage.locator('.gh-nav a[href="#/members/"]').click();
|
|
|
|
|
await sharedPage.waitForSelector('a[href="#/members/new/"] span');
|
|
|
|
|
await sharedPage.locator('a[href="#/members/new/"] span:has-text("New member")').click();
|
|
|
|
|
await sharedPage.waitForSelector('input[name="name"]');
|
2022-12-16 14:17:52 +03:00
|
|
|
|
let name = 'Test Member';
|
|
|
|
|
let email = 'tester+invalid@testmember.com<6F>';
|
|
|
|
|
let note = 'This is a test member';
|
|
|
|
|
let label = 'Test Label';
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await sharedPage.fill('input[name="name"]', name);
|
|
|
|
|
await sharedPage.fill('input[name="email"]', email);
|
|
|
|
|
await sharedPage.fill('textarea[name="note"]', note);
|
|
|
|
|
await sharedPage.locator('label:has-text("Labels") + div').click();
|
|
|
|
|
await sharedPage.keyboard.type(label);
|
|
|
|
|
await sharedPage.keyboard.press('Tab');
|
|
|
|
|
await sharedPage.locator('button span:has-text("Save")').click();
|
|
|
|
|
await sharedPage.waitForSelector('button span:has-text("Retry")');
|
2022-12-16 14:17:52 +03:00
|
|
|
|
|
|
|
|
|
// check we are unable to save member with invalid email
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await expect(sharedPage.locator('button span:has-text("Retry")')).toBeVisible();
|
|
|
|
|
await expect(sharedPage.locator('text=Invalid Email')).toBeVisible();
|
2022-12-16 14:17:52 +03:00
|
|
|
|
});
|
|
|
|
|
|
2023-10-16 18:32:13 +03:00
|
|
|
|
test('A member can be edited', async ({sharedPage}) => {
|
|
|
|
|
await sharedPage.goto('/ghost');
|
|
|
|
|
await sharedPage.locator('.gh-nav a[href="#/members/"]').click();
|
|
|
|
|
await sharedPage.locator('tbody > tr > a').nth(0).click();
|
|
|
|
|
await sharedPage.waitForSelector('input[name="name"]');
|
2022-12-07 09:02:48 +03:00
|
|
|
|
let name = 'Test Member Edited';
|
|
|
|
|
let email = 'tester.edited@example.com';
|
|
|
|
|
let note = 'This is an edited test member';
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await sharedPage.fill('input[name="name"]', name);
|
|
|
|
|
await sharedPage.fill('input[name="email"]', email);
|
|
|
|
|
await sharedPage.fill('textarea[name="note"]', note);
|
|
|
|
|
await sharedPage.locator('label:has-text("Labels") + div').click();
|
|
|
|
|
await sharedPage.keyboard.press('Backspace');
|
|
|
|
|
await sharedPage.locator('body').click(); // this is to close the dropdown & lose focus
|
|
|
|
|
await sharedPage.locator('input[name="subscribed"] + span').click();
|
|
|
|
|
await sharedPage.locator('button span:has-text("Save")').click();
|
|
|
|
|
await sharedPage.waitForSelector('button span:has-text("Saved")');
|
|
|
|
|
await sharedPage.locator('.gh-nav a[href="#/members/"]').click();
|
2022-12-12 15:51:31 +03:00
|
|
|
|
|
|
|
|
|
// check number of members
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await expect(sharedPage.locator('[data-test-list="members-list-item"]')).toHaveCount(1);
|
2022-12-12 15:51:31 +03:00
|
|
|
|
|
2023-10-16 18:32:13 +03:00
|
|
|
|
const member = sharedPage.locator('tbody > tr > a > div > div > h3').nth(0);
|
2022-12-07 09:02:48 +03:00
|
|
|
|
await expect(member).toHaveText(name);
|
2023-10-16 18:32:13 +03:00
|
|
|
|
const memberEmail = sharedPage.locator('tbody > tr > a > div > div > p').nth(0);
|
2022-12-07 09:02:48 +03:00
|
|
|
|
await expect(memberEmail).toHaveText(email);
|
|
|
|
|
});
|
2022-12-07 12:58:23 +03:00
|
|
|
|
|
2023-10-16 18:32:13 +03:00
|
|
|
|
test('A member can be impersonated', async ({sharedPage}) => {
|
|
|
|
|
await sharedPage.goto('/ghost');
|
|
|
|
|
await sharedPage.locator('.gh-nav a[href="#/members/"]').click();
|
|
|
|
|
await sharedPage.locator('tbody > tr > a').nth(0).click();
|
|
|
|
|
await sharedPage.waitForSelector('[data-test-button="member-actions"]');
|
|
|
|
|
await sharedPage.locator('[data-test-button="member-actions"]').click();
|
|
|
|
|
await sharedPage.getByRole('button', {name: 'Impersonate'}).click();
|
|
|
|
|
await sharedPage.getByRole('button', {name: 'Copy link'}).click();
|
|
|
|
|
await sharedPage.waitForSelector('button span:has-text("Link copied")');
|
2022-12-07 15:11:55 +03:00
|
|
|
|
// get value from input because we don't have access to the clipboard during headless testing
|
2023-10-16 18:32:13 +03:00
|
|
|
|
const elem = await sharedPage.$('input[name="member-signin-url"]');
|
2022-12-07 15:11:55 +03:00
|
|
|
|
const link = await elem.inputValue();
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await sharedPage.goto(link);
|
|
|
|
|
await sharedPage.frameLocator('#ghost-portal-root iframe[title="portal-trigger"]').locator('div').nth(1).click();
|
|
|
|
|
const title = await sharedPage.frameLocator('#ghost-portal-root div iframe[title="portal-popup"]').locator('h2').innerText();
|
2022-12-07 15:11:55 +03:00
|
|
|
|
await expect(title).toEqual('Your account'); // this is the title of the popup when member is logged in
|
|
|
|
|
});
|
|
|
|
|
|
2023-10-16 18:32:13 +03:00
|
|
|
|
test('A member can be deleted', async ({sharedPage}) => {
|
|
|
|
|
await sharedPage.goto('/ghost');
|
|
|
|
|
await sharedPage.locator('.gh-nav a[href="#/members/"]').click();
|
|
|
|
|
await sharedPage.locator('tbody > tr > a').nth(0).click();
|
|
|
|
|
await sharedPage.waitForSelector('[data-test-button="member-actions"]');
|
|
|
|
|
await sharedPage.locator('[data-test-button="member-actions"]').click();
|
|
|
|
|
await sharedPage.getByRole('button', {name: 'Delete member'}).click();
|
|
|
|
|
await sharedPage.locator('button[data-test-button="confirm"] span:has-text("Delete member")').click();
|
2022-12-07 12:58:23 +03:00
|
|
|
|
// should have no members now, so we should see the empty state
|
2023-10-16 18:32:13 +03:00
|
|
|
|
expect(await sharedPage.locator('div h4:has-text("Start building your audience")')).not.toBeNull();
|
2022-12-07 12:58:23 +03:00
|
|
|
|
});
|
2022-12-08 08:27:41 +03:00
|
|
|
|
|
|
|
|
|
const membersFixture = [
|
|
|
|
|
{
|
|
|
|
|
name: 'Test Member 1',
|
|
|
|
|
email: 'test@member1.com',
|
|
|
|
|
note: 'This is a test member',
|
2022-12-09 08:40:40 +03:00
|
|
|
|
label: 'old'
|
2022-12-08 08:27:41 +03:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Test Member 2',
|
|
|
|
|
email: 'test@member2.com',
|
|
|
|
|
note: 'This is a test member',
|
2022-12-09 08:40:40 +03:00
|
|
|
|
label: 'old'
|
2022-12-08 08:27:41 +03:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Test Member 3',
|
|
|
|
|
email: 'test@member3.com',
|
|
|
|
|
note: 'This is a test member',
|
2022-12-09 08:40:40 +03:00
|
|
|
|
label: 'old'
|
2022-12-08 12:30:32 +03:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Sashi',
|
|
|
|
|
email: 'test@member4.com',
|
|
|
|
|
note: 'This is a test member',
|
|
|
|
|
label: 'dog'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Mia',
|
|
|
|
|
email: 'test@member5.com',
|
|
|
|
|
note: 'This is a test member',
|
|
|
|
|
label: 'dog'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Minki',
|
|
|
|
|
email: 'test@member6.com',
|
|
|
|
|
note: 'This is a test member',
|
|
|
|
|
label: 'dog'
|
2022-12-08 08:27:41 +03:00
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
2023-10-16 18:32:13 +03:00
|
|
|
|
test('All members can be exported', async ({sharedPage}) => {
|
2022-12-08 12:30:32 +03:00
|
|
|
|
// adds 6 members, 3 with the same label
|
2022-12-08 08:27:41 +03:00
|
|
|
|
for (let member of membersFixture) {
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await createMember(sharedPage, member);
|
2022-12-08 08:27:41 +03:00
|
|
|
|
}
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await sharedPage.goto('/ghost');
|
|
|
|
|
await sharedPage.locator('.gh-nav a[href="#/members/"]').click();
|
|
|
|
|
await sharedPage.waitForSelector('button[data-test-button="members-actions"]');
|
|
|
|
|
await sharedPage.locator('button[data-test-button="members-actions"]').click();
|
|
|
|
|
await sharedPage.waitForSelector('button[data-test-button="export-members"]');
|
2022-12-08 08:27:41 +03:00
|
|
|
|
const [download] = await Promise.all([
|
2023-10-16 18:32:13 +03:00
|
|
|
|
sharedPage.waitForEvent('download'),
|
|
|
|
|
sharedPage.locator('button[data-test-button="export-members"]').click()
|
2022-12-08 08:27:41 +03:00
|
|
|
|
]);
|
|
|
|
|
const filename = await download.suggestedFilename();
|
|
|
|
|
expect(filename).toContain('.csv');
|
2022-12-08 12:30:32 +03:00
|
|
|
|
const csv = await download.path();
|
|
|
|
|
let csvContents = await fs.readFileSync(csv).toString();
|
|
|
|
|
expect(csvContents).toMatch(/id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,tiers/);
|
|
|
|
|
membersFixture.forEach((member) => {
|
|
|
|
|
expect(csvContents).toMatch(member.name);
|
|
|
|
|
expect(csvContents).toMatch(member.email);
|
|
|
|
|
expect(csvContents).toMatch(member.note);
|
|
|
|
|
expect(csvContents).toMatch(member.label);
|
|
|
|
|
});
|
|
|
|
|
// expect(csvContents).toMatch('Test Label'); we deleted the label in a previous test so it's not in this the export
|
|
|
|
|
const countIds = csvContents.match(/[a-z0-9]{24}/gm).length;
|
|
|
|
|
expect(countIds).toEqual(6);
|
|
|
|
|
const countTimestamps = csvContents.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/gm).length;
|
|
|
|
|
expect(countTimestamps).toEqual(6);
|
|
|
|
|
const countRows = csvContents.match(/(?:"(?:[^"]|"")*"|[^,\n]*)(?:,(?:"(?:[^"]|"")*"|[^,\n]*))*\n/g).length;
|
|
|
|
|
expect(countRows).toEqual(6);
|
|
|
|
|
const csvRegex = /^[^",]+((?<=[,\n])|(?=[,\n]))|[^",]+/gm;
|
|
|
|
|
expect(csvContents).toMatch(csvRegex);
|
2022-12-08 08:27:41 +03:00
|
|
|
|
});
|
2022-12-08 09:18:25 +03:00
|
|
|
|
|
2023-10-16 18:32:13 +03:00
|
|
|
|
test('A filtered list of members can be exported', async ({sharedPage}) => {
|
|
|
|
|
await sharedPage.goto('/ghost');
|
|
|
|
|
await sharedPage.locator('.gh-nav a[href="#/members/"]').click();
|
|
|
|
|
await sharedPage.waitForSelector('button[data-test-button="members-actions"]');
|
|
|
|
|
await sharedPage.locator('button[data-test-button="members-actions"]').click();
|
|
|
|
|
await sharedPage.waitForSelector('div[data-test-button="members-filter-actions"]');
|
|
|
|
|
await sharedPage.locator('div[data-test-button="members-filter-actions"]').click();
|
|
|
|
|
await sharedPage.locator('select[data-test-select="members-filter"]').click();
|
|
|
|
|
await sharedPage.locator('select[data-test-select="members-filter"]').selectOption('label');
|
|
|
|
|
await sharedPage.locator('div[data-test-members-filter="0"] > div > div').click();
|
|
|
|
|
await sharedPage.locator('span[data-test-label-filter="dog"]').click();
|
|
|
|
|
await sharedPage.keyboard.press('Tab');
|
|
|
|
|
await sharedPage.locator('button[data-test-button="members-apply-filter"]').click();
|
|
|
|
|
await sharedPage.locator('button[data-test-button="members-actions"]').click();
|
|
|
|
|
const exportButton = await sharedPage.locator('button[data-test-button="export-members"] > span').innerText();
|
2022-12-08 09:18:25 +03:00
|
|
|
|
expect(exportButton).toEqual('Export selected members (3)');
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await sharedPage.waitForSelector('button[data-test-button="export-members"]');
|
2022-12-08 09:18:25 +03:00
|
|
|
|
const [download] = await Promise.all([
|
2023-10-16 18:32:13 +03:00
|
|
|
|
sharedPage.waitForEvent('download'),
|
|
|
|
|
sharedPage.locator('button[data-test-button="export-members"]').click()
|
2022-12-08 09:18:25 +03:00
|
|
|
|
]);
|
|
|
|
|
const filename = await download.suggestedFilename();
|
|
|
|
|
expect(filename).toContain('.csv');
|
2022-12-08 12:30:32 +03:00
|
|
|
|
const csv = await download.path();
|
|
|
|
|
let csvContents = await fs.readFileSync(csv).toString();
|
|
|
|
|
expect(csvContents).toMatch(/id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,tiers/);
|
|
|
|
|
// filter memberFixtures to only include members with the label 'dog'
|
|
|
|
|
const filteredMembersFixture = membersFixture.filter((member) => {
|
|
|
|
|
return member.label === 'dog';
|
|
|
|
|
});
|
|
|
|
|
filteredMembersFixture.forEach((member) => {
|
|
|
|
|
expect(csvContents).toMatch(member.name);
|
|
|
|
|
expect(csvContents).toMatch(member.email);
|
|
|
|
|
expect(csvContents).toMatch(member.note);
|
|
|
|
|
expect(csvContents).toMatch('dog');
|
|
|
|
|
});
|
|
|
|
|
const countIds = csvContents.match(/[a-z0-9]{24}/gm).length;
|
|
|
|
|
expect(countIds).toEqual(3);
|
|
|
|
|
const countTimestamps = csvContents.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/gm).length;
|
|
|
|
|
expect(countTimestamps).toEqual(3);
|
|
|
|
|
const countRows = csvContents.match(/(?:"(?:[^"]|"")*"|[^,\n]*)(?:,(?:"(?:[^"]|"")*"|[^,\n]*))*\n/g).length;
|
|
|
|
|
expect(countRows).toEqual(3);
|
|
|
|
|
const csvRegex = /^[^",]+((?<=[,\n])|(?=[,\n]))|[^",]+/gm;
|
|
|
|
|
expect(csvContents).toMatch(csvRegex);
|
2022-12-08 09:18:25 +03:00
|
|
|
|
});
|
2022-12-08 15:58:38 +03:00
|
|
|
|
|
2023-01-06 09:36:13 +03:00
|
|
|
|
// saves time by going directly to the members page with the label filter applied
|
|
|
|
|
let labelFilterUrl;
|
|
|
|
|
|
2023-10-16 18:32:13 +03:00
|
|
|
|
test('A filtered list of members can have a label added to them', async ({sharedPage}) => {
|
|
|
|
|
await sharedPage.goto('/ghost');
|
|
|
|
|
await sharedPage.locator('.gh-nav a[href="#/members/"]').click();
|
|
|
|
|
await sharedPage.waitForSelector('button[data-test-button="members-actions"]');
|
|
|
|
|
await sharedPage.locator('button[data-test-button="members-actions"]').click();
|
|
|
|
|
await sharedPage.waitForSelector('div[data-test-button="members-filter-actions"]');
|
|
|
|
|
await sharedPage.locator('div[data-test-button="members-filter-actions"]').click();
|
|
|
|
|
await sharedPage.locator('select[data-test-select="members-filter"]').click();
|
|
|
|
|
await sharedPage.locator('select[data-test-select="members-filter"]').selectOption('label');
|
|
|
|
|
await sharedPage.locator('div[data-test-members-filter="0"] > div > div').click();
|
|
|
|
|
await sharedPage.locator('span[data-test-label-filter="old"]').click(); // this label should only be on 3 members
|
|
|
|
|
await sharedPage.keyboard.press('Tab');
|
|
|
|
|
await sharedPage.locator('button[data-test-button="members-apply-filter"]').click();
|
|
|
|
|
await sharedPage.waitForSelector('button[data-test-button="members-actions"]');
|
|
|
|
|
await sharedPage.locator('button[data-test-button="members-actions"]').click();
|
|
|
|
|
await sharedPage.locator('button[data-test-button="add-label-selected"]').click();
|
|
|
|
|
await sharedPage.locator('div[data-test-state="add-label-unconfirmed"] > span > select').selectOption({label: 'Test Label'});
|
|
|
|
|
const members = await sharedPage.locator('div[data-test-state="add-label-unconfirmed"] > p > span[data-test-text="member-count"]').innerText();
|
2022-12-09 08:40:40 +03:00
|
|
|
|
expect(members).toEqual('3 members');
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await sharedPage.locator('button[data-test-button="confirm"]').click();
|
|
|
|
|
await sharedPage.waitForSelector('div[data-test-state="add-complete"]');
|
|
|
|
|
const success = await sharedPage.locator('div[data-test-state="add-complete"] > div > p').innerText();
|
2022-12-09 08:40:40 +03:00
|
|
|
|
expect(success).toEqual('Label added to 3 members successfully');
|
2023-10-16 18:32:13 +03:00
|
|
|
|
labelFilterUrl = await sharedPage.url();
|
2023-01-06 09:36:13 +03:00
|
|
|
|
});
|
|
|
|
|
|
2023-10-16 18:32:13 +03:00
|
|
|
|
test('A filtered list of members can have a label removed from them', async ({sharedPage}) => {
|
|
|
|
|
await sharedPage.goto(labelFilterUrl);
|
|
|
|
|
await sharedPage.waitForSelector('button[data-test-button="members-actions"]');
|
|
|
|
|
await sharedPage.locator('button[data-test-button="members-actions"]').click();
|
|
|
|
|
await sharedPage.waitForSelector('button[data-test-button="remove-label-selected"]');
|
|
|
|
|
await sharedPage.locator('button[data-test-button="remove-label-selected"]').click();
|
|
|
|
|
await sharedPage.locator('div[data-test-state="remove-label-unconfirmed"] > span > select').selectOption({label: 'old'});
|
|
|
|
|
await sharedPage.locator('button[data-test-button="confirm"]').click();
|
|
|
|
|
const success = await sharedPage.locator('div[data-test-state="remove-complete"] > div > p').innerText();
|
2023-01-06 09:36:13 +03:00
|
|
|
|
expect(success).toEqual('Label removed from 3 members successfully');
|
2022-12-09 08:40:40 +03:00
|
|
|
|
});
|
|
|
|
|
|
2023-10-16 18:32:13 +03:00
|
|
|
|
test('A member can be granted a comp in admin', async ({sharedPage}) => {
|
|
|
|
|
await sharedPage.goto('/ghost');
|
|
|
|
|
await deleteAllMembers(sharedPage);
|
2022-12-08 15:58:38 +03:00
|
|
|
|
|
|
|
|
|
// create a new member with a comped plan
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await createMember(sharedPage, {
|
2022-12-08 15:58:38 +03:00
|
|
|
|
name: 'Test Member 1',
|
|
|
|
|
email: 'test@member1.com',
|
|
|
|
|
note: 'This is a test member',
|
|
|
|
|
label: 'Test Label',
|
|
|
|
|
compedPlan: 'The Local Test'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// open the impersonate modal
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await sharedPage.locator('[data-test-button="member-actions"]').click();
|
|
|
|
|
await sharedPage.getByRole('button', {name: 'Impersonate'}).click();
|
|
|
|
|
await sharedPage.getByRole('button', {name: 'Copy link'}).click();
|
|
|
|
|
await sharedPage.waitForSelector('button span:has-text("Link copied")');
|
2022-12-08 15:58:38 +03:00
|
|
|
|
|
|
|
|
|
// get value from input because we don't have access to the clipboard during headless testing
|
2023-10-16 18:32:13 +03:00
|
|
|
|
const elem = await sharedPage.$('input[name="member-signin-url"]');
|
2022-12-08 15:58:38 +03:00
|
|
|
|
const link = await elem.inputValue();
|
|
|
|
|
|
|
|
|
|
// go to the frontend with the impersonate link
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await sharedPage.goto(link);
|
2022-12-08 15:58:38 +03:00
|
|
|
|
|
|
|
|
|
// click the paid-only post
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await sharedPage.locator('.gh-card-link[href="/sell/"]').click();
|
2022-12-08 15:58:38 +03:00
|
|
|
|
|
|
|
|
|
// check for content CTA and expect it to be zero
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await expect(sharedPage.locator('.gh-post-upgrade-cta')).toHaveCount(0);
|
2022-12-08 15:58:38 +03:00
|
|
|
|
});
|
2022-12-16 14:17:52 +03:00
|
|
|
|
|
2023-10-16 18:32:13 +03:00
|
|
|
|
test('An existing member cannot be saved with invalid email address', async ({sharedPage}) => {
|
|
|
|
|
await sharedPage.goto('/ghost');
|
|
|
|
|
await sharedPage.locator('.gh-nav a[href="#/members/"]').click();
|
|
|
|
|
await sharedPage.waitForSelector('a[href="#/members/new/"] span');
|
|
|
|
|
await sharedPage.locator('a[href="#/members/new/"] span:has-text("New member")').click();
|
|
|
|
|
await sharedPage.waitForSelector('input[name="name"]');
|
2022-12-16 14:17:52 +03:00
|
|
|
|
let name = 'Test Member';
|
|
|
|
|
let email = 'tester+invalid@example.com';
|
|
|
|
|
let note = 'This is a test member';
|
|
|
|
|
let label = 'Test Label';
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await sharedPage.fill('input[name="name"]', name);
|
|
|
|
|
await sharedPage.fill('input[name="email"]', email);
|
|
|
|
|
await sharedPage.fill('textarea[name="note"]', note);
|
|
|
|
|
await sharedPage.locator('label:has-text("Labels") + div').click();
|
|
|
|
|
await sharedPage.keyboard.type(label);
|
|
|
|
|
await sharedPage.keyboard.press('Tab');
|
|
|
|
|
await sharedPage.locator('button span:has-text("Save")').click();
|
|
|
|
|
await sharedPage.waitForSelector('button span:has-text("Saved")');
|
2022-12-16 14:17:52 +03:00
|
|
|
|
|
|
|
|
|
// Update email to invalid and try saving
|
|
|
|
|
let updatedEmail = 'tester+invalid@example.com<6F>';
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await sharedPage.fill('input[name="email"]', updatedEmail);
|
|
|
|
|
await sharedPage.waitForSelector('button span:has-text("Save")');
|
|
|
|
|
await sharedPage.locator('button span:has-text("Save")').click();
|
|
|
|
|
await sharedPage.waitForSelector('button span:has-text("Retry")');
|
2022-12-16 14:17:52 +03:00
|
|
|
|
|
|
|
|
|
// check we are unable to save member with invalid email
|
2023-10-16 18:32:13 +03:00
|
|
|
|
await expect(sharedPage.locator('button span:has-text("Retry")')).toBeVisible();
|
|
|
|
|
await expect(sharedPage.locator('text=Invalid Email')).toBeVisible();
|
2022-12-16 14:17:52 +03:00
|
|
|
|
});
|
2022-12-07 08:35:16 +03:00
|
|
|
|
});
|
|
|
|
|
});
|