summaryrefslogtreecommitdiffhomepage
path: root/gui/test
diff options
context:
space:
mode:
authorHank <hank@mullvad.net>2022-09-21 12:54:42 +0200
committerOskar Nyberg <oskar@mullvad.net>2024-06-25 10:51:01 +0200
commitffee01d7ce1a3579dceaaedbcdbf38424802148f (patch)
tree7d08b7089a6f135e2511b582fe55e2c0d193b963 /gui/test
parentbd105e6ade664ffa51a73674d403cf94e9d8187c (diff)
downloadmullvadvpn-ffee01d7ce1a3579dceaaedbcdbf38424802148f.tar.xz
mullvadvpn-ffee01d7ce1a3579dceaaedbcdbf38424802148f.zip
Add e2e test for account expiry notifications
Diffstat (limited to 'gui/test')
-rw-r--r--gui/test/e2e/mocked/notifications.spec.ts52
1 files changed, 52 insertions, 0 deletions
diff --git a/gui/test/e2e/mocked/notifications.spec.ts b/gui/test/e2e/mocked/notifications.spec.ts
new file mode 100644
index 0000000000..7af0d1297a
--- /dev/null
+++ b/gui/test/e2e/mocked/notifications.spec.ts
@@ -0,0 +1,52 @@
+import { expect, test } from '@playwright/test';
+import { Page } from 'playwright';
+
+import { colors } from '../../../src/config.json';
+import { IAccountData } from '../../../src/shared/daemon-rpc-types';
+import { getBackgroundColor } from '../utils';
+import { MockedTestUtils, startMockedApp } from './mocked-utils';
+
+let page: Page;
+let util: MockedTestUtils;
+
+test.beforeAll(async () => {
+ ({ page, util } = await startMockedApp());
+});
+
+test.afterAll(async () => {
+ await page.close();
+});
+
+/**
+ * Expires soon
+ */
+test('App should notify user about account expiring soon', async () => {
+ await util.sendMockIpcResponse<IAccountData>({
+ channel: 'account-',
+ response: { expiry: new Date(Date.now() + 2 * 24 * 60 * 60 * 1000).toISOString() },
+ });
+
+ const title = page.getByTestId('notificationTitle');
+ await expect(title).toContainText(/account credit expires soon/i);
+
+ let subTitle = page.getByTestId('notificationSubTitle');
+ await expect(subTitle).toContainText(/1 day left\. buy more credit\./i);
+
+ const indicator = page.getByTestId('notificationIndicator');
+ const indicatorColor = await getBackgroundColor(indicator);
+ expect(indicatorColor).toBe(colors.yellow);
+
+ await util.sendMockIpcResponse<IAccountData>({
+ channel: 'account-',
+ response: { expiry: new Date(Date.now() + 3 * 24 * 60 * 60 * 1000).toISOString() },
+ });
+ subTitle = page.getByTestId('notificationSubTitle');
+ await expect(subTitle).toContainText(/2 days left\. buy more credit\./i);
+
+ await util.sendMockIpcResponse<IAccountData>({
+ channel: 'account-',
+ response: { expiry: new Date(Date.now() + 1 * 24 * 60 * 60 * 1000).toISOString() },
+ });
+ subTitle = page.getByTestId('notificationSubTitle');
+ await expect(subTitle).toContainText(/less than a day left\. buy more credit\./i);
+});