mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-26 19:07:40 +00:00 
			
		
		
		
	| @@ -107,12 +107,14 @@ export function AuthenticationForm() { | ||||
|             <TextInput | ||||
|               required | ||||
|               label={t`Username`} | ||||
|               aria-label='login-username' | ||||
|               placeholder={t`Your username`} | ||||
|               {...classicForm.getInputProps('username')} | ||||
|             /> | ||||
|             <PasswordInput | ||||
|               required | ||||
|               label={t`Password`} | ||||
|               aria-label='login-password' | ||||
|               placeholder={t`Your password`} | ||||
|               {...classicForm.getInputProps('password')} | ||||
|             /> | ||||
| @@ -228,12 +230,14 @@ export function RegistrationForm() { | ||||
|             <TextInput | ||||
|               required | ||||
|               label={t`Username`} | ||||
|               aria-label='register-username' | ||||
|               placeholder={t`Your username`} | ||||
|               {...registrationForm.getInputProps('username')} | ||||
|             /> | ||||
|             <TextInput | ||||
|               required | ||||
|               label={t`Email`} | ||||
|               aria-label='register-email' | ||||
|               description={t`This will be used for a confirmation`} | ||||
|               placeholder='email@example.org' | ||||
|               {...registrationForm.getInputProps('email')} | ||||
| @@ -241,12 +245,14 @@ export function RegistrationForm() { | ||||
|             <PasswordInput | ||||
|               required | ||||
|               label={t`Password`} | ||||
|               aria-label='register-password' | ||||
|               placeholder={t`Your password`} | ||||
|               {...registrationForm.getInputProps('password1')} | ||||
|             /> | ||||
|             <PasswordInput | ||||
|               required | ||||
|               label={t`Password repeat`} | ||||
|               aria-label='register-password-repeat' | ||||
|               placeholder={t`Repeat password`} | ||||
|               {...registrationForm.getInputProps('password2')} | ||||
|             /> | ||||
|   | ||||
| @@ -1,54 +0,0 @@ | ||||
| import { expect, test } from './baseFixtures.js'; | ||||
| import { baseUrl, user } from './defaults.js'; | ||||
| import { doLogin, doQuickLogin } from './login.js'; | ||||
|  | ||||
| test('Basic Login Test', async ({ page }) => { | ||||
|   await doLogin(page); | ||||
|  | ||||
|   // Check that the username is provided | ||||
|   await page.getByText(user.username); | ||||
|  | ||||
|   await expect(page).toHaveTitle(/^InvenTree/); | ||||
|  | ||||
|   // Go to the dashboard | ||||
|   await page.goto(baseUrl); | ||||
|   await page.waitForURL('**/platform'); | ||||
|  | ||||
|   await page.getByText('InvenTree Demo Server -').waitFor(); | ||||
|  | ||||
|   // Check that the username is provided | ||||
|   await page.getByText(user.username); | ||||
|  | ||||
|   await expect(page).toHaveTitle(/^InvenTree/); | ||||
|  | ||||
|   // Go to the dashboard | ||||
|   await page.goto(baseUrl); | ||||
|   await page.waitForURL('**/platform'); | ||||
|  | ||||
|   // Logout (via menu) | ||||
|   await page.getByRole('button', { name: 'Ally Access' }).click(); | ||||
|   await page.getByRole('menuitem', { name: 'Logout' }).click(); | ||||
|  | ||||
|   await page.waitForURL('**/platform/login'); | ||||
|   await page.getByLabel('username'); | ||||
| }); | ||||
|  | ||||
| test('Quick Login Test', async ({ page }) => { | ||||
|   await doQuickLogin(page); | ||||
|  | ||||
|   // Check that the username is provided | ||||
|   await page.getByText(user.username); | ||||
|  | ||||
|   await expect(page).toHaveTitle(/^InvenTree/); | ||||
|  | ||||
|   // Go to the dashboard | ||||
|   await page.goto(baseUrl); | ||||
|   await page.waitForURL('**/platform'); | ||||
|  | ||||
|   await page.getByText('InvenTree Demo Server - ').waitFor(); | ||||
|  | ||||
|   // Logout (via URL) | ||||
|   await page.goto(`${baseUrl}/logout/`); | ||||
|   await page.waitForURL('**/platform/login'); | ||||
|   await page.getByLabel('username'); | ||||
| }); | ||||
							
								
								
									
										97
									
								
								src/frontend/tests/pui_login.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								src/frontend/tests/pui_login.spec.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,97 @@ | ||||
| import { expect, test } from './baseFixtures.js'; | ||||
| import { baseUrl, logoutUrl, user } from './defaults.js'; | ||||
| import { doLogin, doQuickLogin } from './login.js'; | ||||
|  | ||||
| test('Login - Basic Test', async ({ page }) => { | ||||
|   await doLogin(page); | ||||
|  | ||||
|   // Check that the username is provided | ||||
|   await page.getByText(user.username); | ||||
|  | ||||
|   await expect(page).toHaveTitle(/^InvenTree/); | ||||
|  | ||||
|   // Go to the dashboard | ||||
|   await page.goto(baseUrl); | ||||
|   await page.waitForURL('**/platform'); | ||||
|  | ||||
|   await page.getByText('InvenTree Demo Server -').waitFor(); | ||||
|  | ||||
|   // Check that the username is provided | ||||
|   await page.getByText(user.username); | ||||
|  | ||||
|   await expect(page).toHaveTitle(/^InvenTree/); | ||||
|  | ||||
|   // Go to the dashboard | ||||
|   await page.goto(baseUrl); | ||||
|   await page.waitForURL('**/platform'); | ||||
|  | ||||
|   // Logout (via menu) | ||||
|   await page.getByRole('button', { name: 'Ally Access' }).click(); | ||||
|   await page.getByRole('menuitem', { name: 'Logout' }).click(); | ||||
|  | ||||
|   await page.waitForURL('**/platform/login'); | ||||
|   await page.getByLabel('username'); | ||||
| }); | ||||
|  | ||||
| test('Login - Quick Test', async ({ page }) => { | ||||
|   await doQuickLogin(page); | ||||
|  | ||||
|   // Check that the username is provided | ||||
|   await page.getByText(user.username); | ||||
|  | ||||
|   await expect(page).toHaveTitle(/^InvenTree/); | ||||
|  | ||||
|   // Go to the dashboard | ||||
|   await page.goto(baseUrl); | ||||
|   await page.waitForURL('**/platform'); | ||||
|  | ||||
|   await page.getByText('InvenTree Demo Server - ').waitFor(); | ||||
|  | ||||
|   // Logout (via URL) | ||||
|   await page.goto(`${baseUrl}/logout/`); | ||||
|   await page.waitForURL('**/platform/login'); | ||||
|   await page.getByLabel('username'); | ||||
| }); | ||||
|  | ||||
| /** | ||||
|  * Test various types of login failure | ||||
|  */ | ||||
| test('Login - Failures', async ({ page }) => { | ||||
|   const loginWithError = async () => { | ||||
|     await page.getByRole('button', { name: 'Log In' }).click(); | ||||
|     await page.getByText('Login failed').waitFor(); | ||||
|     await page.getByText('Check your input and try again').waitFor(); | ||||
|     await page.locator('#login').getByRole('button').click(); | ||||
|   }; | ||||
|  | ||||
|   // Navigate to the 'login' page | ||||
|   await page.goto(logoutUrl); | ||||
|   await expect(page).toHaveTitle(/^InvenTree.*$/); | ||||
|   await page.waitForURL('**/platform/login'); | ||||
|  | ||||
|   // Attempt login with invalid credentials | ||||
|   await page.getByLabel('login-username').fill('invalid user'); | ||||
|   await page.getByLabel('login-password').fill('invalid password'); | ||||
|  | ||||
|   await loginWithError(); | ||||
|  | ||||
|   // Attempt login with valid (but disabled) user | ||||
|   await page.getByLabel('login-username').fill('ian'); | ||||
|   await page.getByLabel('login-password').fill('inactive'); | ||||
|  | ||||
|   await loginWithError(); | ||||
|  | ||||
|   // Attempt login with no username | ||||
|   await page.getByLabel('login-username').fill(''); | ||||
|   await page.getByLabel('login-password').fill('hunter2'); | ||||
|  | ||||
|   await loginWithError(); | ||||
|  | ||||
|   // Attempt login with no password | ||||
|   await page.getByLabel('login-username').fill('ian'); | ||||
|   await page.getByLabel('login-password').fill(''); | ||||
|  | ||||
|   await loginWithError(); | ||||
|  | ||||
|   await page.waitForTimeout(2500); | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user