0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/apps/admin-x-settings/test/acceptance/growth/tips-and-donations.test.ts
Kevin Ansfield f08e4d4728 Hid tips and donation settings when Stripe is disabled
closes https://linear.app/tryghost/issue/PLG-178

- updated conditional to ensure we're ready for GA by showing when Stripe is enabled rather than only when the feature flag is enabled
2024-08-21 16:12:00 +01:00

40 lines
1.8 KiB
TypeScript

import {expect, test} from '@playwright/test';
import {globalDataRequests} from '../../utils/acceptance';
import {mockApi, settingsWithStripe, toggleLabsFlag} from '@tryghost/admin-x-framework/test/acceptance';
test.describe('Tips and donations', () => {
test.beforeEach(async () => {
toggleLabsFlag('tipsAndDonations', true);
});
test('Is not shown when Stripe is disabled', async ({page}) => {
await mockApi({page, requests: {...globalDataRequests}});
await page.goto('/');
await expect(page.locator('[data-setting-nav-item] #tips-and-donations')).not.toBeVisible();
await expect(page.getByTestId('tips-and-donations')).not.toBeVisible();
});
test('Shows suggested amount and shareable link when Stripe is enabled', async ({page}) => {
await mockApi({page, requests: {
...globalDataRequests,
browseSettings: {...globalDataRequests.browseSettings, response: settingsWithStripe}
}});
await page.goto('/');
const section = page.getByTestId('tips-and-donations');
await expect(page.locator('[data-setting-nav-item] #tips-and-donations')).toBeVisible();
await expect(section).toBeVisible();
await expect(section.getByTestId('suggested-amount')).toHaveText(/\$5/);
await expect(section.getByTestId('donate-url')).toHaveText('http://test.com/#/portal/support');
await expect(section.getByTestId('preview-shareable-link')).not.toBeVisible();
await expect(section.getByTestId('copy-shareable-link')).not.toBeVisible();
await section.getByTestId('donate-url').hover();
await expect(section.getByTestId('preview-shareable-link')).toBeVisible();
await expect(section.getByTestId('copy-shareable-link')).toBeVisible();
});
});