2023-04-25 18:15:14 +00:00
|
|
|
import { test, expect } from '@playwright/test';
|
2023-06-03 15:21:28 +00:00
|
|
|
import { loginUser } from './fixtures/fixtures';
|
2023-06-01 21:25:12 +00:00
|
|
|
import { clearDatabase } from './helpers/db';
|
2023-04-25 18:15:14 +00:00
|
|
|
|
|
|
|
test.beforeEach(async ({ page, isMobile }) => {
|
2023-06-01 21:25:12 +00:00
|
|
|
await clearDatabase();
|
2023-06-03 15:21:28 +00:00
|
|
|
await loginUser(page);
|
2023-04-25 18:15:14 +00:00
|
|
|
|
|
|
|
if (isMobile) {
|
2023-06-03 15:21:28 +00:00
|
|
|
// TODO: Fix mobile accessibility for the dropdown menu
|
|
|
|
// await page.getByRole('button', { name: 'Menu' }).click();
|
|
|
|
await page.goto('/app-store');
|
|
|
|
} else {
|
|
|
|
await page.getByRole('link', { name: 'App store' }).click();
|
2023-04-25 18:15:14 +00:00
|
|
|
}
|
2023-06-03 15:21:28 +00:00
|
|
|
|
2023-04-25 18:15:14 +00:00
|
|
|
await page.getByPlaceholder('Search').fill('hello');
|
|
|
|
await page.getByRole('link', { name: 'Hello World' }).click();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('user can install and uninstall app', async ({ page, context }) => {
|
|
|
|
// Install app
|
|
|
|
await page.getByRole('button', { name: 'Install' }).click();
|
|
|
|
|
|
|
|
await expect(page.getByText('Install Hello World')).toBeVisible();
|
|
|
|
|
|
|
|
await page.getByRole('button', { name: 'Install' }).click();
|
|
|
|
|
|
|
|
await expect(page.getByText('Installing')).toBeVisible();
|
|
|
|
await expect(page.getByText('Running')).toBeVisible({ timeout: 60000 });
|
|
|
|
await expect(page.getByText('App installed successfully')).toBeVisible();
|
|
|
|
|
2023-06-07 20:12:49 +00:00
|
|
|
await page.getByTestId('app-details').getByRole('button', { name: 'Open' }).press('ArrowDown');
|
|
|
|
const [newPage] = await Promise.all([context.waitForEvent('page'), await page.getByRole('menuitem', { name: `${process.env.SERVER_IP}:8000` }).click()]);
|
2023-04-25 18:15:14 +00:00
|
|
|
|
|
|
|
await newPage.waitForLoadState();
|
|
|
|
await expect(newPage.getByText('Hello World')).toBeVisible();
|
|
|
|
await newPage.close();
|
|
|
|
|
|
|
|
// Stop app
|
|
|
|
await page.getByRole('button', { name: 'Stop' }).click();
|
|
|
|
await expect(page.getByText('Stop Hello World')).toBeVisible();
|
|
|
|
|
|
|
|
await page.getByRole('button', { name: 'Stop' }).click();
|
|
|
|
|
|
|
|
await expect(page.getByText('Stopping')).toBeVisible();
|
|
|
|
await expect(page.getByText('App stopped successfully')).toBeVisible({ timeout: 60000 });
|
|
|
|
|
|
|
|
// Uninstall app
|
|
|
|
await page.getByRole('button', { name: 'Remove' }).click();
|
2023-04-25 18:16:26 +00:00
|
|
|
await expect(page.getByText('Uninstall Hello World?')).toBeVisible();
|
2023-04-25 18:15:14 +00:00
|
|
|
|
|
|
|
await page.getByRole('button', { name: 'Uninstall' }).click();
|
|
|
|
|
|
|
|
await expect(page.getByText('Uninstalling')).toBeVisible();
|
|
|
|
await expect(page.getByText('App uninstalled successfully')).toBeVisible({ timeout: 60000 });
|
|
|
|
});
|