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

Added playwright test for updating atier

refs TryGhost/Team#2371

- Tests that tier details can be updated
- Tests that the updates are reflected in Portal
This commit is contained in:
Djordje Vlaisavljevic 2022-12-08 17:40:25 +01:00
parent 6af149120a
commit 82aa9522dc
3 changed files with 65 additions and 1 deletions

View file

@ -82,7 +82,7 @@
@classNames="gh-tier-actions-menu dropdown-menu dropdown-triangle-top-right"
>
<li>
<button class="mr2" type="button" {{on "click" (fn this.openEditTier @tier)}}>
<button class="mr2" type="button" data-test-button="edit-tier" {{on "click" (fn this.openEditTier @tier)}}>
<span>Edit</span>
</button>
</li>

View file

@ -85,6 +85,7 @@
@type="number"
@input={{action (mut this.stripeMonthlyAmount) value="target.value"}}
@focus-out={{this.validateStripePlans}}
data-test-input="monthly-price"
/>
<span class="gh-input-append"><span class="ttu">{{this.currency}}</span>/month</span>
</div>
@ -97,6 +98,7 @@
@focus-out={{this.validateStripePlans}}
@placeholder=''
data-test-title-input={{true}}
data-test-input="yearly-price"
/>
<span class="gh-input-append"><span class="ttu">{{this.currency}}</span>/year</span>
</div>

View file

@ -47,5 +47,67 @@ test.describe('Admin', () => {
// Make sure newly created tier is in not selected
expect(await page.locator('[data-test-tier-at-signup] > label > input').last().isChecked()).toBeFalsy();
});
test('Can update Tier', async ({page}) => {
await page.goto('/ghost');
const tierName = 'New Test Tier';
const updatedTierName = 'Updated Test Tier Name';
const updatedMonthlyPrice = '66';
const updatedYearlyPrice = '666';
const updatedDescription = 'Updated description text';
const enableInPortal = true;
await createTier(page, {
name: tierName,
monthlyPrice: 5,
yearlyPrice: 50
}, enableInPortal);
// Open Membership settings
await page.locator('.gh-nav a[href="#/settings/"]').click();
await page.locator('.gh-setting-group').filter({hasText: 'Membership'}).click();
// Expand the premium tier list
await page.locator('[data-test-toggle-pub-info]').click({
delay: 500 // TODO: Figure out how to prevent this from opening with an empty list without using delay
});
// Find the new tier
await page.locator('[data-test-tier-card]').filter({hasText: tierName}).first().isVisible();
const tierCard = page.locator('[data-test-tier-card]').filter({hasText: tierName}).first();
// Enter edit mode
await tierCard.locator('[data-test-button="tiers-actions"]').click();
await tierCard.locator('[data-test-button="edit-tier"]').click();
const modal = page.locator('.modal-content');
// Edit tier information
await modal.locator('[data-test-input="tier-name"]').first().fill(updatedTierName);
await modal.locator('[data-test-input="tier-description"]').first().fill(updatedDescription);
await modal.locator('[data-test-input="monthly-price"]').fill(updatedMonthlyPrice);
await modal.locator('[data-test-input="yearly-price"]').fill(updatedYearlyPrice);
await modal.locator('[data-test-button="save-tier"]').click();
// Go to website and open portal
await page.goto('/');
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');
await portalTriggerButton.click();
// Find the updated tier card
await portalFrame.locator('[data-test-tier="paid"]').filter({hasText: updatedTierName}).first().isVisible();
const portalTierCard = portalFrame.locator('[data-test-tier="paid"]').filter({hasText: updatedTierName}).first();
await expect(portalTierCard).toBeVisible();
// Check if the details are updated
// Check yearly price
await expect(portalTierCard.locator('.amount').first()).toHaveText(updatedYearlyPrice);
// Check description
await expect(portalTierCard.locator('.gh-portal-product-description').first()).toHaveText(updatedDescription);
// Check monthly price
await portalFrame.locator('[data-test-button="switch-monthly"]').click();
await expect(await portalTierCard.getByText('/month')).toBeVisible();
await expect(portalTierCard.locator('.amount').first()).toHaveText(updatedMonthlyPrice);
});
});
});