Files
upstream-frappe-crm/e2e/pages/deals.page.ts
upstream-mirror db69de1c11
Some checks failed
Frontend / Unit Tests & Coverage (push) Has been skipped
Regenerate POT file (translatable strings) / Regenerate POT file (develop) (push) Failing after 1m13s
Regenerate POT file (translatable strings) / Regenerate POT file (main-hotfix) (push) Failing after 6s
Server / Tests (frappe ${{ matrix.frappe-branch }}) (push) Has been skipped
Server / Resolve frappe matrix (push) Failing after 1s
Frontend / Lint (push) Failing after 1s
Frontend / Production Build (push) Failing after 1s
Server / Coverage Wrap Up (push) Has been skipped
Frontend / Coverage Wrap Up (push) Has been skipped
snapshot of https://github.com/frappe/crm.git (develop, 2026-09-18; blobs > 131072B omitted)
2026-09-18 01:36:01 +05:00

50 lines
1.5 KiB
TypeScript

import { Page, expect } from '@playwright/test'
/**
* Deals list view (/crm/deals) and the "Create Deal" modal.
*/
export class DealsPage {
constructor(private page: Page) {}
async goto() {
await this.page.goto('/crm/deals')
await this.page.waitForLoadState('networkidle')
}
async openCreateModal() {
await this.page.getByRole('button', { name: 'Create', exact: true }).click()
await expect(
this.page.getByRole('heading', { name: 'Create Deal' }),
).toBeVisible()
}
/**
* Submit the deal. "Primary email" identifies it later. Value and closure
* date are only mandatory when a site customizes them (Property Setter), so
* they are filled conditionally to stay portable across sites.
*/
async createDeal(email: string) {
const dialog = this.page.getByRole('dialog')
await dialog.getByPlaceholder('Primary email', { exact: true }).fill(email)
await this.fillIfPresent(dialog, 'Expected Deal Value', '1000')
await this.fillIfPresent(dialog, 'Expected Closure Date', '2026-12-31', true)
await dialog.getByRole('button', { name: 'Create', exact: true }).click()
await expect(
this.page.getByRole('heading', { name: 'Create Deal' }),
).toBeHidden()
}
private async fillIfPresent(
scope: ReturnType<Page['getByRole']>,
placeholder: string,
value: string,
isDate = false,
) {
const field = scope.getByPlaceholder(placeholder, { exact: true })
if (!(await field.count())) return
await field.fill(value)
if (isDate) await field.press('Enter')
}
}