Skip to content

Commit

Permalink
Updated portal-settings test to be more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdwinden committed Dec 18, 2024
1 parent 076218f commit afc4003
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions ghost/core/test/e2e-browser/admin/portal-settings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,68 +19,68 @@ test.describe('Portal Settings', () => {
test('can open portal on default page', async ({sharedPage}) => {
const modal = await openPortalLinks(sharedPage);

// fetch portal default url from input
const portalUrl = await modal.getByLabel('Default:').inputValue();
await sharedPage.goto(portalUrl);

const portalFrame = sharedPage.locator('[data-testid="portal-popup-frame"]');

// check portal popup is opened
// Wait for frame to be attached and visible
await expect(portalFrame).toBeVisible();
});

test('can open portal on signin page', async ({sharedPage}) => {
const modal = await openPortalLinks(sharedPage);

// fetch portal signin url from input
const portalUrl = await modal.getByLabel('Sign in').inputValue();
await sharedPage.goto(portalUrl);

const portalFrame = sharedPage.locator('[data-testid="portal-popup-frame"]');
const portalFrameLocator = sharedPage.frameLocator('[data-testid="portal-popup-frame"]');

// check portal popup is opened

// Wait for frame to be attached and visible first
await expect(portalFrame).toBeVisible();
// check signin page is opened in portal
await expect(portalFrameLocator.getByRole('heading', {name: 'Sign in'})).toBeVisible();

const portalFrameLocator = sharedPage.frameLocator('[data-testid="portal-popup-frame"]');

// Wait for the frame content to be loaded
await expect(portalFrameLocator.locator('.gh-portal-signin')).toBeVisible({timeout: 15000});
await expect(portalFrameLocator.getByRole('heading', {name: 'Sign in'})).toBeVisible({timeout: 15000});
});

test('can open portal on signup page', async ({sharedPage}) => {
const modal = await openPortalLinks(sharedPage);

// fetch portal signup url from input
const portalUrl = await modal.getByLabel('Sign up').inputValue();
await sharedPage.goto(portalUrl);

const portalFrame = sharedPage.locator('[data-testid="portal-popup-frame"]');
const portalFrameLocator = sharedPage.frameLocator('[data-testid="portal-popup-frame"]');

// check portal popup is opened

// Wait for frame to be attached and visible first
await expect(portalFrame).toBeVisible();
// check signup page is opened in portal
await expect(portalFrameLocator.locator('.gh-portal-signup')).toBeVisible();

const portalFrameLocator = sharedPage.frameLocator('[data-testid="portal-popup-frame"]');

// Wait for the frame content to be loaded
await expect(portalFrameLocator.locator('.gh-portal-signup')).toBeVisible({timeout: 15000});
});

test('can open portal directly on monthly signup', async ({sharedPage}) => {
const modal = await openPortalLinks(sharedPage);

// fetch and go to portal directly monthly signup url
const portalUrl = await modal.getByLabel('Signup / Monthly').inputValue();
await sharedPage.goto(portalUrl);

// expect stripe checkout to have opeened
await sharedPage.waitForURL(/^https:\/\/checkout.stripe.com/);
// Wait longer for Stripe checkout to load
await sharedPage.waitForURL(/^https:\/\/checkout.stripe.com/, {timeout: 15000});
});

test('can open portal directly on yearly signup', async ({sharedPage}) => {
const modal = await openPortalLinks(sharedPage);

// fetch and go to portal directly yearly signup url
const portalUrl = await modal.getByLabel('Signup / Yearly').inputValue();
await sharedPage.goto(portalUrl);

// expect stripe checkout to have opeened
await sharedPage.waitForURL(/^https:\/\/checkout.stripe.com/);
// Wait longer for Stripe checkout to load
await sharedPage.waitForURL(/^https:\/\/checkout.stripe.com/, {timeout: 15000});
});
});
});

0 comments on commit afc4003

Please sign in to comment.