@@ -6,24 +6,34 @@ test.describe('Supplier Tests', () => {
66 await loginAsTestUser ( page ) ;
77 await page . waitForLoadState ( 'networkidle' ) ;
88
9+ console . log ( 'Waiting for network idle...' ) ;
10+
911 // Clean up any existing suppliers
1012 await page . click ( 'a:has-text("Suppliers")' ) ;
1113 await page . waitForLoadState ( 'networkidle' ) ;
1214
15+ console . log ( 'Waiting for Suppliers...' ) ;
16+
1317 // Wait for React Suspense to resolve and suppliers to load
1418 await page . waitForSelector ( 'h1:has-text("Suppliers")' , { timeout : 5000 } ) ;
1519
16- // Wait for either suppliers to load or empty state to appear
20+ /*
21+ console.log('Waiting for GraphQL response...');
22+
23+ // Wait for the GraphQL suppliers query to complete
1724 try {
18- await page . waitForFunction ( ( ) => {
19- const deleteLinks = Array . from ( document . querySelectorAll ( 'a' ) ) . filter ( a => a . textContent ?. includes ( 'delete' ) ) ;
20- const hasSuppliers = deleteLinks . length > 0 ;
21- const hasEmptyState = document . textContent ?. includes ( 'No suppliers found. Create one to get started!' ) ;
22- return hasSuppliers || hasEmptyState ;
23- } , { timeout : 5000 } ) ;
25+ await page.waitForResponse(response =>
26+ response.url(). includes('/api/graphql') &&
27+ response.request().postData()?.includes('SupplierListQuery'),
28+ { timeout: 5000 }
29+ ) ;
30+ console.log('GraphQL suppliers query completed' );
2431 } catch (e) {
25- console . log ( 'Timeout waiting for suppliers to load or empty state to appear ' ) ;
32+ console.log('Timeout waiting for GraphQL suppliers query ');
2633 }
34+ */
35+
36+ console . log ( 'bar' ) ;
2737
2838 // Debug: Check what's actually on the page
2939 const pageContent = await page . locator ( 'body' ) . innerHTML ( ) ;
@@ -111,23 +121,12 @@ test.describe('Supplier Tests', () => {
111121 // Initially disabled
112122 await expect ( page . locator ( 'button:has-text("Create Supplier")' ) ) . toBeDisabled ( ) ;
113123
114- // Fill required fields
124+ // Fill only name (should still be disabled - missing email)
115125 await page . fill ( 'input[placeholder="Supplier name"]' , 'Test Supplier' ) ;
116- await page . fill ( 'input[placeholder="contact@supplier.com"]' , 'test@supplier.com' ) ;
117-
118- // Should still be disabled (missing other required fields)
119126 await expect ( page . locator ( 'button:has-text("Create Supplier")' ) ) . toBeDisabled ( ) ;
120127
121- // Fill remaining required fields
122- await page . fill ( 'input[placeholder="Contact person name"]' , 'John Doe' ) ;
123- await page . fill ( 'input[placeholder="Street address"]' , '123 Main St' ) ;
124- await page . fill ( 'input[placeholder="City"]' , 'Test City' ) ;
125- await page . fill ( 'input[placeholder="(555) 123-4567"]' , '555-123-4567' ) ;
126- await page . fill ( 'input[placeholder="State"]' , 'CA' ) ;
127- await page . fill ( 'input[placeholder="12345"]' , '12345' ) ;
128- await page . fill ( 'input[placeholder="Country"]' , 'USA' ) ;
129-
130- // Now should be enabled
128+ // Fill email (should now be enabled - only name and email are validated)
129+ await page . fill ( 'input[placeholder="contact@supplier.com"]' , 'test@supplier.com' ) ;
131130 await expect ( page . locator ( 'button:has-text("Create Supplier")' ) ) . toBeEnabled ( ) ;
132131 } ) ;
133132
@@ -330,21 +329,4 @@ test.describe('Supplier Tests', () => {
330329 await expect ( page . locator ( 'text=Page 1 of 1' ) ) . toBeVisible ( ) ;
331330 } ) ;
332331
333- test ( 'should navigate properly to and from suppliers page' , async ( { page } ) => {
334- // Start at home page
335- await page . click ( 'a:has-text("Home")' ) ;
336- await expect ( page . locator ( 'h1:has-text("Welcome to create-rust-app!")' ) ) . toBeVisible ( ) ;
337-
338- // Navigate to suppliers
339- await page . click ( 'a:has-text("Suppliers")' ) ;
340- await expect ( page . locator ( 'h1:has-text("Suppliers")' ) ) . toBeVisible ( ) ;
341-
342- // Navigate to todos
343- await page . click ( 'a:has-text("Todos (REST)")' ) ;
344- await expect ( page . locator ( 'h1:has-text("Todos")' ) ) . toBeVisible ( ) ;
345-
346- // Navigate back to suppliers
347- await page . click ( 'a:has-text("Suppliers")' ) ;
348- await expect ( page . locator ( 'h1:has-text("Suppliers")' ) ) . toBeVisible ( ) ;
349- } ) ;
350332} ) ;
0 commit comments