2024-08-20 11:33:31 +01:00
|
|
|
import {expect, test} from '@playwright/test';
|
|
|
|
import {globalDataRequests} from '../../utils/acceptance';
|
2024-09-03 13:57:30 +01:00
|
|
|
import {mockApi, settingsWithStripe} from '@tryghost/admin-x-framework/test/acceptance';
|
2024-08-20 11:33:31 +01:00
|
|
|
|
|
|
|
test.describe('Tips and donations', () => {
|
2024-08-20 18:37:40 +01:00
|
|
|
test('Is not shown when Stripe is disabled', async ({page}) => {
|
2024-08-20 11:33:31 +01:00
|
|
|
await mockApi({page, requests: {...globalDataRequests}});
|
|
|
|
await page.goto('/');
|
|
|
|
|
2024-08-20 18:37:40 +01:00
|
|
|
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('/');
|
|
|
|
|
2024-08-20 11:33:31 +01:00
|
|
|
const section = page.getByTestId('tips-and-donations');
|
|
|
|
|
2024-08-20 18:37:40 +01:00
|
|
|
await expect(page.locator('[data-setting-nav-item] #tips-and-donations')).toBeVisible();
|
|
|
|
await expect(section).toBeVisible();
|
|
|
|
|
2024-08-20 11:33:31 +01:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|