fix(playwright): enhance bot page token reset logic to handle button visibility (#22125)

- Added checks for the visibility of the revoke button and the authentication mechanism before performing actions.
- Improved flow to ensure appropriate button clicks based on the current UI state.
This commit is contained in:
Shailesh Parmar 2025-07-03 17:19:01 +05:30 committed by GitHub
parent 076d093891
commit 49c2a4d925
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -229,17 +229,26 @@ export const resetTokenFromBotPage = async (page: Page, botName: string) => {
await page.waitForLoadState('networkidle');
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
await expect(page.getByTestId('revoke-button')).toBeVisible();
const isRevokeButtonVisible = await page
.getByTestId('revoke-button')
.isVisible();
const isAuthMechanismVisible = await page
.getByTestId('auth-mechanism')
.isVisible();
await page.getByTestId('revoke-button').click();
if (isRevokeButtonVisible) {
await page.getByTestId('revoke-button').click();
await expect(page.getByTestId('save-button')).toBeVisible();
await expect(page.getByTestId('save-button')).toBeVisible();
await page.getByTestId('save-button').click();
await page.getByTestId('save-button').click();
} else if (isAuthMechanismVisible) {
await page.getByTestId('auth-mechanism').click();
}
await expect(page.getByTestId('token-expiry').locator('div')).toBeVisible();
await page.getByText('hr').click();
await page.getByTestId('token-expiry').click();
await page.getByText('Unlimited').click();
await expect(page.getByTestId('save-edit')).toBeVisible();