import type { Page, Locator } from '@playwright/test'; export class HostDashboard { readonly page: Page; readonly statsSection: Locator; readonly lockEventButton: Locator; readonly unlockEventButton: Locator; readonly releaseGalleryButton: Locator; readonly userSearchInput: Locator; constructor(page: Page) { this.page = page; this.statsSection = page.locator('[data-testid="host-stats"]'); this.lockEventButton = page .getByRole('button', { name: /uploads sperren|event sperren|sperren/i }) .first(); this.unlockEventButton = page .getByRole('button', { name: /uploads freigeben|entsperren/i }) .first(); this.releaseGalleryButton = page.getByRole('button', { name: /galerie freigeben/i }); this.userSearchInput = page.getByPlaceholder(/suche|search/i).first(); } async goto() { await this.page.goto('/host'); } userRow(displayName: string): Locator { return this.page .locator('tr,li,div', { hasText: displayName }) .filter({ has: this.page.getByRole('button') }) .first(); } async banUser(displayName: string) { // A ban always hides — the confirm dialog is a plain confirm, no "hide uploads" checkbox // (removed from the UI; the endpoint takes no body). const row = this.userRow(displayName); await row .getByRole('button', { name: /sperren/i }) .first() .click(); await this.page .getByRole('button', { name: /bestätigen|sperren/i }) .last() .click(); } }