-
Notifications
You must be signed in to change notification settings - Fork 384
/
Copy pathexpired-account-error-view.spec.ts
46 lines (38 loc) · 1.62 KB
/
expired-account-error-view.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { Page } from 'playwright';
import { MockedTestUtils, startMockedApp } from './mocked-utils';
import { expect, test } from '@playwright/test';
import { IAccountData } from '../../../src/shared/daemon-rpc-types';
import { getBackgroundColor } from '../utils';
import { colors } from '../../../src/config.json';
import { RoutePath } from '../../../src/renderer/lib/routes';
let page: Page;
let util: MockedTestUtils;
test.beforeEach(async () => {
({ page, util } = await startMockedApp());
});
test.afterEach(async () => {
await page.close();
});
test('App should show Expired Account Error View', async () => {
await util.sendMockIpcResponse<IAccountData>({
channel: 'account-',
response: { expiry: new Date(Date.now() - 10 * 24 * 60 * 60 * 1000).toISOString() },
});
await expect(page.locator('text=Out of time')).toBeVisible();
const buyMoreButton = page.locator('button:has-text("Buy more credit")');
await expect(buyMoreButton).toBeVisible();
expect(await getBackgroundColor(buyMoreButton)).toBe(colors.green);
const redeemVoucherButton = page.locator('button:has-text("Redeem voucher")');
await expect(redeemVoucherButton).toBeVisible();
expect(await getBackgroundColor(redeemVoucherButton)).toBe(colors.green);
});
test('App should show out of time view after running out of time', async () => {
const expiryDate = new Date();
expiryDate.setSeconds(expiryDate.getSeconds() + 2);
expect(await util.waitForNavigation(async () => {
await util.sendMockIpcResponse<IAccountData>({
channel: 'account-',
response: { expiry: expiryDate.toISOString() },
});
})).toEqual(RoutePath.expired);
});