chore(test): fix ingestion bot tests (#23439)

This commit is contained in:
Chirag Madlani 2025-09-18 14:59:57 +05:30 committed by GitHub
parent f8f57fc4af
commit 075b4ea6d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 15 deletions

View File

@ -13,9 +13,8 @@
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';
import { performAdminLogin } from '../../utils/admin';
import { getApiContext, redirectToHomePage } from '../../utils/common';
import { redirectToHomePage } from '../../utils/common';
import {
addAssetsToDomain,
addServicesToDomain,
@ -31,21 +30,16 @@ const test = base.extend<{
ingestionBotPage: Page;
}>({
page: async ({ browser }, use) => {
const adminUser = new AdminClass();
const adminPage = await browser.newPage();
await adminUser.login(adminPage);
await use(adminPage);
await adminPage.close();
const { afterAction, page } = await performAdminLogin(browser);
await use(page);
await afterAction();
},
ingestionBotPage: async ({ browser }, use) => {
const admin = new AdminClass();
const { apiContext, afterAction } = await performAdminLogin(browser);
const page = await browser.newPage();
// login with admin user
await admin.login(page);
await page.waitForURL('**/my-data');
const { apiContext } = await getApiContext(page);
await page.goto('/');
const bot = await apiContext
.get('/api/v1/bots/name/ingestion-bot')
@ -55,10 +49,15 @@ const test = base.extend<{
.then((response) => response.json());
await setToken(page, tokenData.config.JWTToken);
await redirectToHomePage(page);
await page.waitForLoadState('networkidle');
await page.waitForSelector('loader', { state: 'hidden' });
await expect(page.getByTestId('nav-user-name')).toHaveText('ingestion-bot');
// await afterAction();
await use(page);
await page.close();
await afterAction();
},
});

View File

@ -186,6 +186,10 @@ setup('authenticate all users', async ({ browser }) => {
.storageState({ path: ownerFile, indexedDB: true });
await afterAction();
if (newAdminPage) {
await newAdminPage.close();
}
} catch (error) {
// eslint-disable-next-line no-console
console.error('Error during authentication setup:', error);