File size: 2,904 Bytes
1dbc34b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | import { Page, Locator } from '@playwright/test';
import { waitForElement, waitForElementHidden } from '../core/waiting';
/**
* Check if the agent output modal is visible
*/
export async function isAgentOutputModalVisible(page: Page): Promise<boolean> {
const modal = page.locator('[data-testid="agent-output-modal"]');
return await modal.isVisible();
}
/**
* Wait for the agent output modal to be visible
*/
export async function waitForAgentOutputModal(
page: Page,
options?: { timeout?: number }
): Promise<Locator> {
return await waitForElement(page, 'agent-output-modal', options);
}
/**
* Wait for the agent output modal to be hidden
*/
export async function waitForAgentOutputModalHidden(
page: Page,
options?: { timeout?: number }
): Promise<void> {
await waitForElementHidden(page, 'agent-output-modal', options);
}
/**
* Get the modal title/description text to verify which feature's output is being shown
*/
export async function getAgentOutputModalDescription(page: Page): Promise<string | null> {
const modal = page.locator('[data-testid="agent-output-modal"]');
const description = modal.locator('[id="radix-\\:r.+\\:-description"]').first();
return await description.textContent().catch(() => null);
}
/**
* Check the dialog description content in the agent output modal
*/
export async function getOutputModalDescription(page: Page): Promise<string | null> {
const modalDescription = page.locator(
'[data-testid="agent-output-modal"] [data-slot="dialog-description"]'
);
return await modalDescription.textContent().catch(() => null);
}
/**
* Get the agent output modal description element
*/
export async function getAgentOutputModalDescriptionElement(page: Page): Promise<Locator> {
return page.locator('[data-testid="agent-output-description"]');
}
/**
* Check if the agent output modal description is scrollable
*/
export async function isAgentOutputDescriptionScrollable(page: Page): Promise<boolean> {
const description = page.locator('[data-testid="agent-output-description"]');
const scrollInfo = await description.evaluate((el) => {
return {
scrollHeight: el.scrollHeight,
clientHeight: el.clientHeight,
isScrollable: el.scrollHeight > el.clientHeight,
};
});
return scrollInfo.isScrollable;
}
/**
* Get scroll dimensions of the agent output modal description
*/
export async function getAgentOutputDescriptionScrollDimensions(page: Page): Promise<{
scrollHeight: number;
clientHeight: number;
maxHeight: string;
overflowY: string;
}> {
const description = page.locator('[data-testid="agent-output-description"]');
return await description.evaluate((el) => {
const style = window.getComputedStyle(el);
return {
scrollHeight: el.scrollHeight,
clientHeight: el.clientHeight,
maxHeight: style.maxHeight,
overflowY: style.overflowY,
};
});
}
|