test: Add wait for delete button in creation test
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Playwright Tests / test (pull_request) Successful in 2m24s
				
			
		
		
	
	
		
	
		
			All checks were successful
		
		
	
	Playwright Tests / test (pull_request) Successful in 2m24s
				
			This commit is contained in:
		
					parent
					
						
							
								e91dc49804
							
						
					
				
			
			
				commit
				
					
						d3b9362023
					
				
			
		
					 1 changed files with 14 additions and 5 deletions
				
			
		| 
						 | 
					@ -59,6 +59,7 @@ test.describe('mitarbeiter', () => {
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  test('CreationAndDeletion', async ({ page }) => {
 | 
					  test('CreationAndDeletion', async ({ page }) => {
 | 
				
			||||||
 | 
					    await page.getByLabel('First Name').fill('a');
 | 
				
			||||||
    await page.getByLabel('Last Name').fill('a');
 | 
					    await page.getByLabel('Last Name').fill('a');
 | 
				
			||||||
    await page.getByLabel('Street').fill('a');
 | 
					    await page.getByLabel('Street').fill('a');
 | 
				
			||||||
    await page.getByLabel('Postcode').fill('12345');
 | 
					    await page.getByLabel('Postcode').fill('12345');
 | 
				
			||||||
| 
						 | 
					@ -66,16 +67,24 @@ test.describe('mitarbeiter', () => {
 | 
				
			||||||
    await page.getByLabel('Phone Number').fill('1234');
 | 
					    await page.getByLabel('Phone Number').fill('1234');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    await page.getByText('Save').click();
 | 
					    await page.getByText('Save').click();
 | 
				
			||||||
 | 
					 | 
				
			||||||
    expect(page.url().includes('erstellen')).toBeFalsy();
 | 
					    expect(page.url().includes('erstellen')).toBeFalsy();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const deleteButton = page.getByText('Delete').nth(2);
 | 
					    // Wait for the "Delete" button to be attached to the DOM
 | 
				
			||||||
    await deleteButton.waitFor({ state: 'visible', timeout: 5000 }); // Add a timeout for safety
 | 
					    await page.locator('text=Delete').nth(2).waitFor({ state: 'attached', timeout: 10000 });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    await deleteButton.click();
 | 
					    // Wait for the third "Delete" button to be visible
 | 
				
			||||||
 | 
					    const deleteButtons = page.locator('text=Delete');
 | 
				
			||||||
 | 
					    const deleteButtonCount = await deleteButtons.count();
 | 
				
			||||||
 | 
					    if (deleteButtonCount > 2) {
 | 
				
			||||||
 | 
					      const deleteButton = deleteButtons.nth(2);
 | 
				
			||||||
 | 
					      await deleteButton.waitFor({ state: 'visible', timeout: 5000 });
 | 
				
			||||||
 | 
					      await deleteButton.click();
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      throw new Error('The expected "Delete" button was not found.');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const deletedEmployee = page.getByText('12345');
 | 
					    const deletedEmployee = page.getByText('12345');
 | 
				
			||||||
    await expect(deletedEmployee).toHaveCount(0, { timeout: 5000 });
 | 
					    await expect(deletedEmployee).toHaveCount(0, { timeout: 10000 });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue