|
| 1 | +import { expect, test } from '@playwright/test'; |
| 2 | +import { login, logout, waitPageLoading } from '../utils.js'; |
| 3 | + |
| 4 | +// Reset storage state for this file to avoid being authenticated |
| 5 | +test.use({ storageState: { cookies: [], origins: [] } }); |
| 6 | + |
| 7 | +test('User without profile', async ({ page }) => { |
| 8 | + const randomValue = Math.random().toString(36).substring(7); |
| 9 | + const randomEmail = `${randomValue}@example.com`; |
| 10 | + |
| 11 | + await test.step('Login as admin and create test user', async () => { |
| 12 | + await login(page, '[email protected]', '1234'); |
| 13 | + await page.goto('/v2/admin/users/register'); |
| 14 | + await waitPageLoading(page); |
| 15 | + await page.getByRole('textbox', { name: 'E-mail' }).fill(randomEmail); |
| 16 | + await page.getByRole('textbox', { name: 'Password', exact: true }).fill('1234'); |
| 17 | + await page.getByRole('textbox', { name: 'Confirm password' }).fill('1234'); |
| 18 | + await page.getByRole('textbox', { name: 'Project dir' }).fill('/tmp'); |
| 19 | + |
| 20 | + // Unset the profile |
| 21 | + await page |
| 22 | + .getByRole('combobox', { name: 'Select resource' }) |
| 23 | + .selectOption('Select resource...'); |
| 24 | + await expect(page.getByRole('combobox', { name: 'Select profile' })).toBeDisabled(); |
| 25 | + await expect(page.getByRole('combobox', { name: 'Select profile' })).toHaveValue(''); |
| 26 | + |
| 27 | + await page.getByRole('button', { name: 'Save' }).first().click(); |
| 28 | + await page.waitForURL(/\/v2\/admin\/users\/\d+\/edit/); |
| 29 | + }); |
| 30 | + |
| 31 | + await test.step('Login as test user', async () => { |
| 32 | + await logout(page, '[email protected]'); |
| 33 | + |
| 34 | + await page.goto('/auth/login'); |
| 35 | + await waitPageLoading(page); |
| 36 | + await page.getByRole('button', { name: 'Log in with username & password' }).click(); |
| 37 | + await page.getByLabel('Email address').fill(randomEmail); |
| 38 | + await page.getByLabel('Password').fill('1234'); |
| 39 | + await page.getByRole('button', { name: 'Log in', exact: true }).click(); |
| 40 | + |
| 41 | + await page.waitForURL('/'); |
| 42 | + |
| 43 | + await expect( |
| 44 | + page.getByText(/This user is not authorized to use this Fractal instance/) |
| 45 | + ).toBeVisible(); |
| 46 | + |
| 47 | + await logout(page, randomEmail); |
| 48 | + }); |
| 49 | +}); |
0 commit comments