Files
bruno/tests/utils/page/preferences.ts
2026-07-08 21:46:11 +05:30

35 lines
1.3 KiB
TypeScript

import { test, Page } from '../../../playwright';
/**
* Locators for the Preferences dialog: the status-bar trigger that opens it
* and the top-level tabs inside it (General, Themes, AI, ...).
*/
export const buildPreferencesLocators = (page: Page) => ({
/** Status-bar button that opens the Preferences dialog */
statusBarTrigger: () => page.getByRole('button', { name: 'Open Preferences' }),
/** A top-level tab inside the Preferences dialog (exact name match) */
tab: (name: string) => page.getByRole('tab', { name, exact: true })
});
/**
* Open the Preferences dialog via the status bar. Waits for the app to finish
* loading first so the status bar is interactive.
*/
export const openPreferences = async (page: Page) => {
await test.step('Open Preferences', async () => {
const preferences = buildPreferencesLocators(page);
await page.locator('[data-app-state="loaded"]').waitFor();
await preferences.statusBarTrigger().click();
});
};
/**
* Switch to a top-level tab inside the (already open) Preferences dialog.
*/
export const selectPreferencesTab = async (page: Page, name: string) => {
await test.step(`Select Preferences tab "${name}"`, async () => {
const preferences = buildPreferencesLocators(page);
await preferences.tab(name).click();
});
};