Improved count of items in e2e tests (#15986)

refs TryGhost/Team#2371
- We need to wait selectors before count them
https://github.com/microsoft/playwright/issues/14278

These changes needed to make the results of tests more stable on the CI
This commit is contained in:
Elena Baidakova 2022-12-12 16:51:31 +04:00 committed by GitHub
parent 8d2418578d
commit 7ef157b17f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,8 +23,10 @@ test.describe('Admin', () => {
await page.locator('button span:has-text("Save")').click();
await page.waitForSelector('button span:has-text("Saved")');
await page.locator('.gh-nav a[href="#/members/"]').click();
const count = await page.locator('tbody > tr').count();
expect(count).toBe(1);
// check number of members
await expect(page.locator('[data-test-list="members-list-item"]')).toHaveCount(1);
const member = page.locator('tbody > tr > a > div > div > h3').nth(0);
await expect(member).toHaveText(name);
const memberEmail = page.locator('tbody > tr > a > div > div > p').nth(0);
@ -49,8 +51,10 @@ test.describe('Admin', () => {
await page.locator('button span:has-text("Save")').click();
await page.waitForSelector('button span:has-text("Saved")');
await page.locator('.gh-nav a[href="#/members/"]').click();
const count = await page.locator('tbody > tr').count();
expect(count).toBe(1);
// check number of members
await expect(page.locator('[data-test-list="members-list-item"]')).toHaveCount(1);
const member = page.locator('tbody > tr > a > div > div > h3').nth(0);
await expect(member).toHaveText(name);
const memberEmail = page.locator('tbody > tr > a > div > div > p').nth(0);