2024-09-02 13:20:23 +03:00
|
|
|
/* eslint-disable unicorn/prefer-dom-node-dataset */
|
2024-11-04 08:28:05 +03:00
|
|
|
import { expect, type Locator, type Page } from '@playwright/test';
|
2024-09-02 13:20:23 +03:00
|
|
|
|
|
|
|
export async function expandCollapsibleSection(page: Page, name: string) {
|
|
|
|
const divider = page.locator(`[data-collapsible]:has-text("${name}")`);
|
|
|
|
if ((await divider.getAttribute('data-collapsed')) === 'true') {
|
|
|
|
await divider.click();
|
|
|
|
}
|
|
|
|
await expect(divider).toHaveAttribute('data-collapsed', 'false');
|
|
|
|
const section = divider.locator(
|
|
|
|
'~ [data-testid="collapsible-section-content"]'
|
|
|
|
);
|
|
|
|
await expect(section).toBeVisible();
|
|
|
|
return section;
|
|
|
|
}
|
2024-10-22 06:01:04 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Click header "<" button
|
|
|
|
*/
|
|
|
|
export async function pageBack(page: Page) {
|
|
|
|
await page.getByTestId('page-header-back').tap();
|
|
|
|
}
|
2024-11-04 08:28:05 +03:00
|
|
|
|
|
|
|
export async function getAttrOfActiveElement(
|
|
|
|
page: Page,
|
|
|
|
attrName = 'data-testid'
|
|
|
|
) {
|
|
|
|
return await page.evaluate(name => {
|
|
|
|
const el = document.activeElement;
|
|
|
|
return el ? el.getAttribute(name) : '';
|
|
|
|
}, attrName);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open the context menu of an explorer node
|
|
|
|
* @returns Menu Locator
|
|
|
|
*/
|
|
|
|
export async function openExplorerNodeMenu(page: Page, node: Locator) {
|
|
|
|
await node.getByTestId('menu-trigger').tap();
|
|
|
|
const menu = page.getByRole('dialog');
|
|
|
|
await expect(menu).toBeVisible();
|
|
|
|
return menu;
|
|
|
|
}
|