mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
Extracted Playwright tests into separate files
- we should start to keep tests grouped by their area, so first we split by Admin tests and then Portal tests, and within that we split into setup/Tiers/Offers etc
This commit is contained in:
parent
b68686fe9c
commit
97e5ca1de6
@ -1,42 +0,0 @@
|
||||
const {expect, test} = require('@playwright/test');
|
||||
const {setupGhost, createTier, createOffer} = require('./utils');
|
||||
|
||||
test.describe('Ghost Admin', () => {
|
||||
test('Loads admin', async ({page}) => {
|
||||
const response = await page.goto('/ghost');
|
||||
expect(response.status()).toEqual(200);
|
||||
});
|
||||
|
||||
test('Is setup correctly', async ({page}) => {
|
||||
await page.goto('/ghost');
|
||||
await expect(page.locator('.gh-nav-menu-details-sitetitle')).toHaveText(/The Local Test/);
|
||||
});
|
||||
|
||||
test('Has a set of posts', async ({page}) => {
|
||||
await page.goto('/ghost');
|
||||
await page.locator('.gh-nav a[href="#/posts/"]').click();
|
||||
await page.locator('.gh-post-list-title').first().click();
|
||||
await page.locator('.settings-menu-toggle').click();
|
||||
await expect(page.getByPlaceholder('YYYY-MM-DD')).toHaveValue(/[0-9]{4}-[0-9]{2}-[0-9]{2}/);
|
||||
});
|
||||
|
||||
test('Can create a tier and offer', async ({page}) => {
|
||||
await page.goto('/ghost');
|
||||
const tierName = 'New Test Tier';
|
||||
await createTier(page, {
|
||||
name: tierName,
|
||||
monthlyPrice: 5,
|
||||
yearlyPrice: 50
|
||||
});
|
||||
const offerName = await createOffer(page, {
|
||||
name: 'Get 5% Off!',
|
||||
tierName,
|
||||
percentOff: 5
|
||||
});
|
||||
|
||||
await page.locator('.gh-nav a[href="#/offers/"]').click();
|
||||
await page.locator('.gh-offers-list').waitFor({state: 'visible', timeout: 1000});
|
||||
await expect(page.locator('.gh-offers-list')).toContainText(tierName);
|
||||
await expect(page.locator('.gh-offers-list')).toContainText(offerName);
|
||||
});
|
||||
});
|
11
ghost/core/test/e2e-browser/admin/posts.spec.js
Normal file
11
ghost/core/test/e2e-browser/admin/posts.spec.js
Normal file
@ -0,0 +1,11 @@
|
||||
const {expect, test} = require('@playwright/test');
|
||||
|
||||
test.describe('Posts', () => {
|
||||
test('Has a set of posts', async ({page}) => {
|
||||
await page.goto('/ghost');
|
||||
await page.locator('.gh-nav a[href="#/posts/"]').click();
|
||||
await page.locator('.gh-post-list-title').first().click();
|
||||
await page.locator('.settings-menu-toggle').click();
|
||||
await expect(page.getByPlaceholder('YYYY-MM-DD')).toHaveValue(/[0-9]{4}-[0-9]{2}-[0-9]{2}/);
|
||||
});
|
||||
});
|
13
ghost/core/test/e2e-browser/admin/setup.spec.js
Normal file
13
ghost/core/test/e2e-browser/admin/setup.spec.js
Normal file
@ -0,0 +1,13 @@
|
||||
const {expect, test} = require('@playwright/test');
|
||||
|
||||
test.describe('Setup', () => {
|
||||
test('Loads Admin', async ({page}) => {
|
||||
const response = await page.goto('/ghost');
|
||||
expect(response.status()).toEqual(200);
|
||||
});
|
||||
|
||||
test('Is setup correctly', async ({page}) => {
|
||||
await page.goto('/ghost');
|
||||
await expect(page.locator('.gh-nav-menu-details-sitetitle')).toHaveText(/The Local Test/);
|
||||
});
|
||||
});
|
24
ghost/core/test/e2e-browser/admin/tiers.spec.js
Normal file
24
ghost/core/test/e2e-browser/admin/tiers.spec.js
Normal file
@ -0,0 +1,24 @@
|
||||
const {expect, test} = require('@playwright/test');
|
||||
const {createTier, createOffer} = require('../utils');
|
||||
|
||||
test.describe('Tiers', () => {
|
||||
test('Can create a Tier and Offer', async ({page}) => {
|
||||
await page.goto('/ghost');
|
||||
const tierName = 'New Test Tier';
|
||||
await createTier(page, {
|
||||
name: tierName,
|
||||
monthlyPrice: 5,
|
||||
yearlyPrice: 50
|
||||
});
|
||||
const offerName = await createOffer(page, {
|
||||
name: 'Get 5% Off!',
|
||||
tierName,
|
||||
percentOff: 5
|
||||
});
|
||||
|
||||
await page.locator('.gh-nav a[href="#/offers/"]').click();
|
||||
await page.locator('.gh-offers-list').waitFor({state: 'visible', timeout: 1000});
|
||||
await expect(page.locator('.gh-offers-list')).toContainText(tierName);
|
||||
await expect(page.locator('.gh-offers-list')).toContainText(offerName);
|
||||
});
|
||||
});
|
@ -1,48 +0,0 @@
|
||||
const {expect, test} = require('@playwright/test');
|
||||
const {setupGhost, deleteAllMembers, createTier, createOffer, completeStripeSubscription} = require('./utils');
|
||||
|
||||
test.describe('Ghost Frontend', () => {
|
||||
test.describe('Basic frontend', () => {
|
||||
test('Loads the homepage', async ({page}) => {
|
||||
const response = await page.goto('/');
|
||||
expect(response.status()).toEqual(200);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Portal flows', () => {
|
||||
test('Uses an offer successfully', async ({page}) => {
|
||||
page.goto('/ghost');
|
||||
await deleteAllMembers(page);
|
||||
const tierName = 'Portal Tier';
|
||||
await createTier(page, {
|
||||
name: tierName,
|
||||
monthlyPrice: 6,
|
||||
yearlyPrice: 60
|
||||
});
|
||||
const offerName = await createOffer(page, {
|
||||
name: 'Black Friday Special',
|
||||
tierName: tierName,
|
||||
percentOff: 10
|
||||
});
|
||||
|
||||
await page.locator('.gh-offers-list .gh-list-row').filter({hasText: offerName}).click();
|
||||
const portalUrl = await page.locator('input#url').inputValue();
|
||||
|
||||
await page.goto(portalUrl);
|
||||
const portalFrame = page.frameLocator('#ghost-portal-root div iframe');
|
||||
await portalFrame.locator('#input-name').fill('Testy McTesterson');
|
||||
await portalFrame.locator('#input-email').fill('testy@example.com');
|
||||
await portalFrame.getByRole('button', {name: 'Continue'}).click();
|
||||
|
||||
await completeStripeSubscription(page);
|
||||
|
||||
await page.waitForSelector('h1.site-title', {state: 'visible'});
|
||||
await page.goto('/ghost');
|
||||
await page.locator('.gh-nav a[href="#/members/"]').click();
|
||||
|
||||
// 1 member, should be Testy, on Portal Tier
|
||||
await expect(page.getByRole('link', {name: 'Testy McTesterson testy@example.com'}), 'Should have 1 paid member').toBeVisible();
|
||||
await expect(page.getByRole('link', {name: tierName}), `Paid member should be on ${tierName}`).toBeVisible();
|
||||
});
|
||||
});
|
||||
});
|
8
ghost/core/test/e2e-browser/portal/frontend.spec.js
Normal file
8
ghost/core/test/e2e-browser/portal/frontend.spec.js
Normal file
@ -0,0 +1,8 @@
|
||||
const {expect, test} = require('@playwright/test');
|
||||
|
||||
test.describe('Frontend', () => {
|
||||
test('Loads the homepage', async ({page}) => {
|
||||
const response = await page.goto('/');
|
||||
expect(response.status()).toEqual(200);
|
||||
});
|
||||
});
|
39
ghost/core/test/e2e-browser/portal/offers.spec.js
Normal file
39
ghost/core/test/e2e-browser/portal/offers.spec.js
Normal file
@ -0,0 +1,39 @@
|
||||
const {expect, test} = require('@playwright/test');
|
||||
const {deleteAllMembers, createTier, createOffer, completeStripeSubscription} = require('../utils');
|
||||
|
||||
test.describe('Offers', () => {
|
||||
test('Uses an offer successfully', async ({page}) => {
|
||||
page.goto('/ghost');
|
||||
await deleteAllMembers(page);
|
||||
const tierName = 'Portal Tier';
|
||||
await createTier(page, {
|
||||
name: tierName,
|
||||
monthlyPrice: 6,
|
||||
yearlyPrice: 60
|
||||
});
|
||||
const offerName = await createOffer(page, {
|
||||
name: 'Black Friday Special',
|
||||
tierName: tierName,
|
||||
percentOff: 10
|
||||
});
|
||||
|
||||
await page.locator('.gh-offers-list .gh-list-row').filter({hasText: offerName}).click();
|
||||
const portalUrl = await page.locator('input#url').inputValue();
|
||||
|
||||
await page.goto(portalUrl);
|
||||
const portalFrame = page.frameLocator('#ghost-portal-root div iframe');
|
||||
await portalFrame.locator('#input-name').fill('Testy McTesterson');
|
||||
await portalFrame.locator('#input-email').fill('testy@example.com');
|
||||
await portalFrame.getByRole('button', {name: 'Continue'}).click();
|
||||
|
||||
await completeStripeSubscription(page);
|
||||
|
||||
await page.waitForSelector('h1.site-title', {state: 'visible'});
|
||||
await page.goto('/ghost');
|
||||
await page.locator('.gh-nav a[href="#/members/"]').click();
|
||||
|
||||
// 1 member, should be Testy, on Portal Tier
|
||||
await expect(page.getByRole('link', {name: 'Testy McTesterson testy@example.com'}), 'Should have 1 paid member').toBeVisible();
|
||||
await expect(page.getByRole('link', {name: tierName}), `Paid member should be on ${tierName}`).toBeVisible();
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user