mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-31 20:51:26 +00:00
fix(test): flaky Policies.spec and Roles.spec (#21917)
* fix getElementWithPagination function * fix flakyness * fix test * remove error statements
This commit is contained in:
parent
16aa38da8f
commit
7d74efa501
@ -372,6 +372,10 @@ test.describe('Policy page should work properly', () => {
|
||||
|
||||
await page.reload();
|
||||
|
||||
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
|
||||
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
await getElementWithPagination(page, policyLocator);
|
||||
|
||||
await page.getByTestId('manage-button').click();
|
||||
|
@ -301,6 +301,8 @@ test('Delete role action from manage button options', async ({ page }) => {
|
||||
|
||||
await settingClick(page, GlobalSettingOptions.ROLES);
|
||||
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
await getElementWithPagination(page, roleLocator);
|
||||
|
||||
await page.getByTestId('manage-button').click();
|
||||
|
@ -33,29 +33,23 @@ export const removePolicyFromRole = async (
|
||||
export const getElementWithPagination = async (
|
||||
page: Page,
|
||||
locator: Locator,
|
||||
click = true
|
||||
click = true,
|
||||
maxPages = 15
|
||||
) => {
|
||||
let hasNext = true;
|
||||
|
||||
while (hasNext) {
|
||||
for (let currentPage = 0; currentPage < maxPages; currentPage++) {
|
||||
// Check if element is visible on current page
|
||||
if (await locator.isVisible()) {
|
||||
click && (await locator.click());
|
||||
if (click) {
|
||||
await locator.click();
|
||||
}
|
||||
|
||||
break;
|
||||
return;
|
||||
}
|
||||
const nextBtn = page.locator('[data-testid="next"]');
|
||||
await nextBtn.scrollIntoViewIfNeeded();
|
||||
|
||||
const nextBtn = page.locator('[data-testid="next"]');
|
||||
await nextBtn.waitFor({ state: 'visible' });
|
||||
|
||||
hasNext = !(await nextBtn.getAttribute('disabled'));
|
||||
|
||||
if (!hasNext) {
|
||||
throw new Error('Element not found and no more pages to paginate.');
|
||||
}
|
||||
|
||||
await nextBtn.click();
|
||||
|
||||
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user