diff --git a/frontend/ui-tests/playwright.config.js b/frontend/ui-tests/playwright.config.js index 7940ca3..757ade2 100644 --- a/frontend/ui-tests/playwright.config.js +++ b/frontend/ui-tests/playwright.config.js @@ -8,7 +8,7 @@ module.exports = { retries: 0, expect: { toMatchSnapshot: { - maxDiffPixelRatio: 0.02, + maxDiffPixelRatio: 0.005, }, } }; diff --git a/frontend/ui-tests/tests/ui.test.ts b/frontend/ui-tests/tests/ui.test.ts index 2ee3e69..a6661da 100644 --- a/frontend/ui-tests/tests/ui.test.ts +++ b/frontend/ui-tests/tests/ui.test.ts @@ -1,5 +1,13 @@ -import { expect, test } from '@playwright/test'; +import { expect, test, Page } from '@playwright/test'; +async function login(page: Page, user: string) { + await page.goto('hub/login'); + await page.getByText('Sign in'); + await page.getByLabel('Username:').fill(user); + await page.getByLabel('Password:').fill('123'); + await page.getByRole('button', { name: 'Sign in' }).click(); + await page.getByRole('link', { name: 'JupyterHub logo' }); +} test.describe('tljh_repo2docker UI Tests', () => { test.beforeEach(({ page }) => { page.setDefaultTimeout(60000); @@ -14,4 +22,29 @@ test.describe('tljh_repo2docker UI Tests', () => { await page.getByText('Sign in'); expect(await page.screenshot()).toMatchSnapshot(); }); + + test('Log in with admin account', async ({ page }) => { + await login(page, 'alice'); + expect(await page.screenshot()).toMatchSnapshot(); + }); + + test('Log in with user account', async ({ page }) => { + await login(page, 'user'); + expect(await page.screenshot()).toMatchSnapshot(); + }); + test('Render servers page', async ({ page }) => { + await login(page, 'alice'); + await page.getByRole('link', { name: 'Servers' }).click(); + // await page.getByRole('button', { name: 'Create new Server' }); + await page.waitForTimeout(1000) + await page.getByText('No servers are running'); + expect(await page.screenshot()).toMatchSnapshot(); + }); + test('Render environments page', async ({ page }) => { + await login(page, 'alice'); + await page.getByRole('link', { name: 'Environments' }).click(); + await page.waitForTimeout(1000) + await page.getByText('No environment available'); + expect(await page.screenshot()).toMatchSnapshot(); + }); }); diff --git a/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Log-in-with-admin-account-1-linux.png b/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Log-in-with-admin-account-1-linux.png new file mode 100644 index 0000000..64f828b Binary files /dev/null and b/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Log-in-with-admin-account-1-linux.png differ diff --git a/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Log-in-with-user-account-1-linux.png b/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Log-in-with-user-account-1-linux.png new file mode 100644 index 0000000..03cb468 Binary files /dev/null and b/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Log-in-with-user-account-1-linux.png differ diff --git a/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Render-Login-1-linux.png b/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Render-Login-1-linux.png index ac9342d..c8b1c69 100644 Binary files a/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Render-Login-1-linux.png and b/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Render-Login-1-linux.png differ diff --git a/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Render-environments-page-1-linux.png b/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Render-environments-page-1-linux.png new file mode 100644 index 0000000..149ba83 Binary files /dev/null and b/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Render-environments-page-1-linux.png differ diff --git a/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Render-servers-page-1-linux.png b/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Render-servers-page-1-linux.png new file mode 100644 index 0000000..488a24c Binary files /dev/null and b/frontend/ui-tests/tests/ui.test.ts-snapshots/tljh-repo2docker-UI-Tests-Render-servers-page-1-linux.png differ