0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Fixed broken playwright tests

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

- playwright tests were broken due to state changes based on prev tests that were not accounted for
- in case of multiple newsletters, portal tests expected another step between stripe checkout for newsletter selection
- site settings test was disabling members, but not re-enabling it back
This commit is contained in:
Rishabh 2022-12-12 14:50:34 +05:30
parent 8b92b49363
commit 4e766e2584
3 changed files with 19 additions and 3 deletions

View file

@ -14,6 +14,10 @@ const changeSubscriptionAccess = async (page, access) => {
// Save settings
await page.locator('[data-test-button="save-settings"]').click();
await page.getByRole('button', {name: 'Saved'}).waitFor({
state: 'visible',
timeout: 1000
});
};
const checkPortalScriptLoaded = async (page, loaded = true) => {
@ -66,6 +70,9 @@ test.describe('Site Settings', () => {
await page.locator('[data-test-button="publish-flow"]').click();
await expect(page.locator('[data-test-setting="publish-type"] > button')).toHaveCount(0);
await expect(page.locator('[data-test-setting="email-recipients"]')).toHaveCount(0);
// reset back to all
await page.goto('/ghost');
await changeSubscriptionAccess(page, 'all');
});
});
});

View file

@ -31,7 +31,10 @@ test.describe('Portal', () => {
await portalFrame.locator('#input-name').fill('Testy McTesterson');
await portalFrame.locator('#input-email').fill('testy@example.com');
await portalFrame.getByRole('button', {name: 'Start 14-day free trial'}).click();
const hasContinueBtn = await portalFrame.locator('text="Continue"').isVisible();
if (hasContinueBtn) {
await portalFrame.getByRole('button', {name: 'Continue'}).click();
}
await completeStripeSubscription(page);
await page.waitForSelector('h1.site-title', {state: 'visible'});
@ -75,7 +78,10 @@ test.describe('Portal', () => {
await portalFrame.locator('#input-name').fill('Testy McTesterson');
await portalFrame.locator('#input-email').fill('testy@example.com');
await portalFrame.getByRole('button', {name: 'Continue'}).click();
const hasContinueBtn = await portalFrame.locator('text="Continue"').isVisible();
if (hasContinueBtn) {
await portalFrame.getByRole('button', {name: 'Continue'}).click();
}
await completeStripeSubscription(page);
await page.waitForSelector('h1.site-title', {state: 'visible'});

View file

@ -18,7 +18,10 @@ test.describe('Portal', () => {
await portalFrame.locator('[data-test-input="input-name"]').fill('Testy McTesterson');
await portalFrame.locator('[data-test-input="input-email"]').fill('testy@example.com');
await portalFrame.locator('[data-test-button="select-tier"]').nth(1).click();
const hasContinueBtn = await portalFrame.locator('text="Continue"').isVisible();
if (hasContinueBtn) {
await portalFrame.getByRole('button', {name: 'Continue'}).click();
}
// complete the stripe checkout flow
await completeStripeSubscription(page);