import { Locator, Page } from '@playwright/test'; /** * The Customers tab. * * Rows are found by email rather than position: the table is shared with every * other run's accounts and is paginated, so an index means a different customer * depending on what else exists. */ export class AdminCustomers { readonly confirmDialog: Locator; constructor(private readonly page: Page) { this.confirmDialog = page.getByRole('dialog'); } row(email: string): Locator { return this.page.getByRole('row').filter({ hasText: email }); } /** The status chip in a customer's row — ACTIVE or DISABLED. */ status(email: string, status: string): Locator { return this.row(email).getByText(status); } disableButton(email: string): Locator { return this.row(email).getByRole('button', { name: 'Disable' }); } /** The count of items this customer is holding, which opens the list. */ reservedCountButton(email: string): Locator { return this.row(email).getByRole('button', { name: /item/ }); } get reservedItemsDialog(): Locator { return this.page.getByRole('dialog', { name: /Items reserved by/ }); } reEnableButton(email: string): Locator { return this.row(email).getByRole('button', { name: 'Re-enable' }); } /** Disabling asks for confirmation, so the button appears twice. */ async disable(email: string): Promise { await this.disableButton(email).click(); await this.confirmDialog.getByRole('button', { name: 'Disable' }).click(); } async reEnable(email: string): Promise { await this.reEnableButton(email).click(); await this.confirmDialog.getByRole('button', { name: 'Re-enable' }).click(); } }