mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	[UI] Search Improvements (#9137)
* Harden playwright tests * Refactor search drawer - Allow result groups to collapse * Add tooltip * Fix menu position * Navigate through to complete list of results * Refactor table headers * Add index pages for SupplierPart and ManufacturerPart models * backend: allow split search by company type * Fix panel naming bug * Fix model URLs * Split company results by company type - Allows better routing to results list * Remove debug msg * Fix 'button within button' issue * Additional playwright tests
This commit is contained in:
		| @@ -97,4 +97,5 @@ export const globalSearch = async (page, query) => { | ||||
|   await page.getByLabel('global-search-input').clear(); | ||||
|   await page.getByPlaceholder('Enter search text').fill(query); | ||||
|   await page.waitForTimeout(300); | ||||
|   await page.waitForLoadState('networkidle'); | ||||
| }; | ||||
|   | ||||
							
								
								
									
										40
									
								
								src/frontend/tests/pages/pui_company.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/frontend/tests/pages/pui_company.spec.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| import { test } from '../baseFixtures.js'; | ||||
| import { navigate } from '../helpers.js'; | ||||
| import { doQuickLogin } from '../login.js'; | ||||
|  | ||||
| test('Company', async ({ page }) => { | ||||
|   await doQuickLogin(page); | ||||
|  | ||||
|   await navigate(page, 'company/1/details'); | ||||
|   await page.getByLabel('Details').getByText('DigiKey Electronics').waitFor(); | ||||
|   await page.getByRole('cell', { name: 'https://www.digikey.com/' }).waitFor(); | ||||
|   await page.getByRole('tab', { name: 'Supplied Parts' }).click(); | ||||
|   await page | ||||
|     .getByRole('cell', { name: 'RR05P100KDTR-ND', exact: true }) | ||||
|     .waitFor(); | ||||
|   await page.getByRole('tab', { name: 'Purchase Orders' }).click(); | ||||
|   await page.getByRole('cell', { name: 'Molex connectors' }).first().waitFor(); | ||||
|   await page.getByRole('tab', { name: 'Stock Items' }).click(); | ||||
|   await page | ||||
|     .getByRole('cell', { name: 'Blue plastic enclosure' }) | ||||
|     .first() | ||||
|     .waitFor(); | ||||
|   await page.getByRole('tab', { name: 'Contacts' }).click(); | ||||
|   await page.getByRole('cell', { name: 'jimmy.mcleod@digikey.com' }).waitFor(); | ||||
|   await page.getByRole('tab', { name: 'Addresses' }).click(); | ||||
|   await page.getByRole('cell', { name: 'Carla Tunnel' }).waitFor(); | ||||
|   await page.getByRole('tab', { name: 'Attachments' }).click(); | ||||
|   await page.getByRole('tab', { name: 'Notes' }).click(); | ||||
|  | ||||
|   // Let's edit the company details | ||||
|   await page.getByLabel('action-menu-company-actions').click(); | ||||
|   await page.getByLabel('action-menu-company-actions-edit').click(); | ||||
|  | ||||
|   await page.getByLabel('text-field-name').fill(''); | ||||
|   await page.getByLabel('text-field-website').fill('invalid-website'); | ||||
|   await page.getByRole('button', { name: 'Submit' }).click(); | ||||
|  | ||||
|   await page.getByText('This field may not be blank.').waitFor(); | ||||
|   await page.getByText('Enter a valid URL.').waitFor(); | ||||
|   await page.getByRole('button', { name: 'Cancel' }).click(); | ||||
| }); | ||||
| @@ -1,44 +1,7 @@ | ||||
| import { test } from './baseFixtures.js'; | ||||
| import { navigate } from './helpers.js'; | ||||
| import { globalSearch, navigate } from './helpers.js'; | ||||
| import { doQuickLogin } from './login.js'; | ||||
|  | ||||
| test('Company', async ({ page }) => { | ||||
|   await doQuickLogin(page); | ||||
|  | ||||
|   await navigate(page, 'company/1/details'); | ||||
|   await page.getByLabel('Details').getByText('DigiKey Electronics').waitFor(); | ||||
|   await page.getByRole('cell', { name: 'https://www.digikey.com/' }).waitFor(); | ||||
|   await page.getByRole('tab', { name: 'Supplied Parts' }).click(); | ||||
|   await page | ||||
|     .getByRole('cell', { name: 'RR05P100KDTR-ND', exact: true }) | ||||
|     .waitFor(); | ||||
|   await page.getByRole('tab', { name: 'Purchase Orders' }).click(); | ||||
|   await page.getByRole('cell', { name: 'Molex connectors' }).first().waitFor(); | ||||
|   await page.getByRole('tab', { name: 'Stock Items' }).click(); | ||||
|   await page | ||||
|     .getByRole('cell', { name: 'Blue plastic enclosure' }) | ||||
|     .first() | ||||
|     .waitFor(); | ||||
|   await page.getByRole('tab', { name: 'Contacts' }).click(); | ||||
|   await page.getByRole('cell', { name: 'jimmy.mcleod@digikey.com' }).waitFor(); | ||||
|   await page.getByRole('tab', { name: 'Addresses' }).click(); | ||||
|   await page.getByRole('cell', { name: 'Carla Tunnel' }).waitFor(); | ||||
|   await page.getByRole('tab', { name: 'Attachments' }).click(); | ||||
|   await page.getByRole('tab', { name: 'Notes' }).click(); | ||||
|  | ||||
|   // Let's edit the company details | ||||
|   await page.getByLabel('action-menu-company-actions').click(); | ||||
|   await page.getByLabel('action-menu-company-actions-edit').click(); | ||||
|  | ||||
|   await page.getByLabel('text-field-name').fill(''); | ||||
|   await page.getByLabel('text-field-website').fill('invalid-website'); | ||||
|   await page.getByRole('button', { name: 'Submit' }).click(); | ||||
|  | ||||
|   await page.getByText('This field may not be blank.').waitFor(); | ||||
|   await page.getByText('Enter a valid URL.').waitFor(); | ||||
|   await page.getByRole('button', { name: 'Cancel' }).click(); | ||||
| }); | ||||
|  | ||||
| /** | ||||
|  * Test for integration of django admin button | ||||
|  */ | ||||
| @@ -53,3 +16,39 @@ test('Admin Button', async ({ page }) => { | ||||
|   await page.getByRole('heading', { name: 'Change Company' }).waitFor(); | ||||
|   await page.getByRole('link', { name: 'View on site' }).waitFor(); | ||||
| }); | ||||
|  | ||||
| // Tests for the global search functionality | ||||
| test('Search', async ({ page }) => { | ||||
|   await doQuickLogin(page, 'steven', 'wizardstaff'); | ||||
|  | ||||
|   await globalSearch(page, 'another customer'); | ||||
|  | ||||
|   // Check for expected results | ||||
|   await page.locator('a').filter({ hasText: 'Customer B' }).first().waitFor(); | ||||
|   await page.locator('a').filter({ hasText: 'Customer C' }).first().waitFor(); | ||||
|   await page.locator('a').filter({ hasText: 'Customer D' }).first().waitFor(); | ||||
|   await page.locator('a').filter({ hasText: 'Customer E' }).first().waitFor(); | ||||
|  | ||||
|   // Click through to the "Customer" results | ||||
|   await page.getByRole('button', { name: 'view-all-results-customer' }).click(); | ||||
|  | ||||
|   await page.waitForURL('**/sales/index/customers**'); | ||||
|   await page.getByText('Custom table filters are active').waitFor(); | ||||
|  | ||||
|   await globalSearch(page, '0402 res'); | ||||
|  | ||||
|   await page | ||||
|     .locator('span') | ||||
|     .filter({ hasText: 'Parts - 16 results' }) | ||||
|     .first() | ||||
|     .waitFor(); | ||||
|   await page | ||||
|     .locator('span') | ||||
|     .filter({ hasText: 'Supplier Parts - 138 results' }) | ||||
|     .first() | ||||
|     .waitFor(); | ||||
|  | ||||
|   await page.getByLabel('view-all-results-manufacturerpart').click(); | ||||
|   await page.waitForURL('**/purchasing/index/manufacturer-parts**'); | ||||
|   await page.getByRole('cell', { name: 'RT0402BRD07100KL' }).waitFor(); | ||||
| }); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user