platform/qms-tests/sanity/tests/model/select-workspace-page.ts
2024-07-13 22:23:11 +07:00

26 lines
906 B
TypeScript

import { expect, type Locator, type Page } from '@playwright/test'
export class SelectWorkspacePage {
readonly page: Page
readonly buttonWorkspace: Locator
readonly buttonCreateWorkspace: Locator
readonly inputWorkspaceName: Locator
constructor (page: Page) {
this.page = page
this.buttonWorkspace = page.locator('div[class*="workspace"]')
this.buttonCreateWorkspace = page.locator('button > span', { hasText: 'Create workspace' })
this.inputWorkspaceName = page.locator('div.form input')
}
async selectWorkspace (workspace: string): Promise<void> {
await this.buttonWorkspace.filter({ hasText: workspace }).click()
}
async createWorkspace (workspaceName: string): Promise<void> {
await this.buttonCreateWorkspace.waitFor({ state: 'visible' })
await expect(this.inputWorkspaceName).toBeVisible()
await this.inputWorkspaceName.fill(workspaceName)
}
}