0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Tested upgrading to a paid subscription from comped

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

Note that the "Choose" button is "Continue" when running this test
standalone so currently it needs to run with the full suite.
This commit is contained in:
Fabien "egg" O'Carroll 2022-12-08 19:44:20 +07:00
parent 88c8bf7dbc
commit 0f9ed54a6f

View file

@ -84,5 +84,52 @@ test.describe('Portal', () => {
await portalFrame.getByRole('button', {name: 'Confirm'}).click();
await expect(await portalFrame.getByText('/year')).toBeVisible();
});
test('allows comped member to upgrade to paid tier', async ({page}) => {
// create a new free member
await createMember(page, {
name: 'Testy McTest',
email: 'testy+upgradecompedportal@example.com',
note: 'Testy McTest is a test member'
});
//get the url of the current member on admin
const memberUrl = await page.url();
// Give member comped subscription
await page.locator('[data-test-button="add-complimentary"]').click();
await page.locator('[data-test-button="save-comp-tier"]').first().click();
// open member impersonation modal
await page.locator('[data-test-button="member-actions"]').click();
await page.locator('[data-test-button="impersonate"]').click();
await page.locator('[data-test-button="copy-impersonate-link"]').click();
await page.waitForSelector('[data-test-button="copy-impersonate-link"] span:has-text("Link copied")');
// get impersonation link from input and redirect to it
const link = await page.locator('[data-test-input="member-signin-url"]').inputValue();
await page.goto(link);
const portalTriggerButton = page.frameLocator('#ghost-portal-root iframe.gh-portal-triggerbtn-iframe').locator('div').nth(1);
const portalFrame = page.frameLocator('#ghost-portal-root div iframe');
// open portal, go to plans and click continue to select the first plan(yearly)
await portalTriggerButton.click();
await portalFrame.getByRole('button', {name: 'Change'}).click();
await portalFrame.getByRole('button', {name: 'Choose'}).first().click();
// complete stripe checkout
await completeStripeSubscription(page);
// open portal and check that member has been upgraded to paid tier
await portalTriggerButton.click();
await expect(portalFrame.getByText('$50.00/year')).toBeVisible();
await expect(portalFrame.getByRole('heading', {name: 'Billing info'})).toBeVisible();
await expect(portalFrame.getByText('**** **** **** 4242')).toBeVisible();
// check that member has been upgraded in admin and a tier exists for them
await page.goto(memberUrl);
await expect(page.locator('[data-test-tier]').first()).toBeVisible();
});
});
});