fix(test): flaky login spec (#23359)

* fix(test): flaky login spec

* fix ingestion bot spec
This commit is contained in:
Chirag Madlani 2025-09-12 18:08:34 +05:30 committed by GitHub
parent b97185b0a2
commit d5ca346270
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 1 deletions

View File

@ -10,7 +10,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { expect, Page, test as base } from '@playwright/test';
import { test as base, expect, Page } from '@playwright/test';
import { SidebarItem } from '../../constant/sidebar';
import { Domain } from '../../support/domain/Domain';
import { AdminClass } from '../../support/user/AdminClass';
@ -109,6 +109,9 @@ test.describe('Ingestion Bot ', () => {
await redirectToHomePage(page);
await sidebarClick(page, SidebarItem.DOMAIN);
await page.waitForLoadState('networkidle');
await page.waitForSelector('[data-testid="loader"]', {
state: 'detached',
});
await selectDomain(page, domain1.data);
await addAssetsToDomain(page, domain1, domainAsset1);
@ -116,6 +119,9 @@ test.describe('Ingestion Bot ', () => {
await redirectToHomePage(page);
await sidebarClick(page, SidebarItem.DOMAIN);
await page.waitForLoadState('networkidle');
await page.waitForSelector('[data-testid="loader"]', {
state: 'detached',
});
await selectDomain(page, domain2.data);
await addAssetsToDomain(page, domain2, domainAsset2);
});
@ -159,6 +165,9 @@ test.describe('Ingestion Bot ', () => {
await redirectToHomePage(page);
await sidebarClick(page, SidebarItem.DOMAIN);
await page.waitForLoadState('networkidle');
await page.waitForSelector('[data-testid="loader"]', {
state: 'detached',
});
await selectDomain(page, domain1.data);
await addServicesToDomain(page, domain1.data, [
domainAsset1[0].get().service,
@ -168,6 +177,9 @@ test.describe('Ingestion Bot ', () => {
await redirectToHomePage(page);
await sidebarClick(page, SidebarItem.DOMAIN);
await page.waitForLoadState('networkidle');
await page.waitForSelector('[data-testid="loader"]', {
state: 'detached',
});
await selectDomain(page, domain2.data);
await addServicesToDomain(page, domain2.data, [
domainAsset2[0].get().service,

View File

@ -61,6 +61,7 @@ test.describe('Login flow should work properly', () => {
test('Signup and Login with signed up credentials', async ({ page }) => {
await page.goto('/');
await page.waitForLoadState('networkidle');
await expect(page).toHaveURL(`/signin`);
@ -85,15 +86,21 @@ test.describe('Login flow should work properly', () => {
await expect(page.locator('#password')).toHaveAttribute('type', 'password');
await page.locator('#confirmPassword').fill(CREDENTIALS.password);
const createUserResponse = page.waitForResponse(`/api/v1/users/signup`);
// Click on create account button
await page.getByRole('button', { name: 'Create Account' }).click();
await createUserResponse;
await expect(page).toHaveURL(`/signin`);
// Login with the created user
await page.fill('#email', CREDENTIALS.email);
await page.fill('#password', CREDENTIALS.password);
const loginResponse = page.waitForResponse(`/api/v1/users/login`);
await page.locator('[data-testid="login"]').click();
await loginResponse;
await page.waitForLoadState('networkidle');
await expect(page).toHaveURL(`/my-data`);
@ -107,10 +114,13 @@ test.describe('Login flow should work properly', () => {
test('Signin using invalid credentials', async ({ page }) => {
await page.goto(`/signin`);
await page.waitForLoadState('networkidle');
// Login with invalid email
await page.fill('#email', invalidEmail);
await page.fill('#password', CREDENTIALS.password);
const loginResponse = page.waitForResponse(`/api/v1/users/login`);
await page.locator('[data-testid="login"]').click();
await loginResponse;
await expect(page.locator('[data-testid="alert-bar"]')).toHaveText(
LOGIN_ERROR_MESSAGE
@ -119,7 +129,9 @@ test.describe('Login flow should work properly', () => {
// Login with invalid password
await page.fill('#email', CREDENTIALS.email);
await page.fill('#password', invalidPassword);
const loginResponse2 = page.waitForResponse(`/api/v1/users/login`);
await page.locator('[data-testid="login"]').click();
await loginResponse2;
await expect(page.locator('[data-testid="alert-bar"]')).toHaveText(
LOGIN_ERROR_MESSAGE