|
| 1 | +import { Locator, type Page } from '@playwright/test'; |
| 2 | +import { TemplateMgmtBasePageDynamic } from 'pages/template-mgmt-base-page-dynamic'; |
| 3 | + |
| 4 | +export class RoutingChooseTemplatesPage extends TemplateMgmtBasePageDynamic { |
| 5 | + static readonly pageUrlSegment = 'message-plans/choose-templates'; |
| 6 | + |
| 7 | + public readonly errorSummary: Locator; |
| 8 | + |
| 9 | + public readonly changeNameLink: Locator; |
| 10 | + |
| 11 | + public readonly routingConfigId: Locator; |
| 12 | + |
| 13 | + public readonly messagePlanStatus: Locator; |
| 14 | + |
| 15 | + public readonly channelBlocks: Locator; |
| 16 | + |
| 17 | + public readonly moveToProductionButton: Locator; |
| 18 | + |
| 19 | + public readonly saveAndCloseButton: Locator; |
| 20 | + |
| 21 | + constructor(page: Page) { |
| 22 | + super(page); |
| 23 | + this.errorSummary = page.locator('.nhsuk-error-summary'); |
| 24 | + this.changeNameLink = page.getByTestId('change-message-plan-name-link'); |
| 25 | + this.routingConfigId = page.locator( |
| 26 | + '[class*=create-edit-message-plan-routing-config-id]' |
| 27 | + ); |
| 28 | + this.messagePlanStatus = page.locator('strong.nhsuk-tag'); |
| 29 | + this.channelBlocks = page.locator('[data-testid^="message-plan-block-"]'); |
| 30 | + this.moveToProductionButton = page.getByTestId('move-to-production-cta'); |
| 31 | + this.saveAndCloseButton = page.getByTestId('save-and-close-cta'); |
| 32 | + } |
| 33 | + |
| 34 | + public messagePlanChannel(channel: string) { |
| 35 | + return { |
| 36 | + block: this.page.getByTestId(`message-plan-block-${channel}`), |
| 37 | + number: this.page |
| 38 | + .getByTestId(`message-plan-block-${channel}`) |
| 39 | + .locator('[class*=message-plan-block-number]'), |
| 40 | + heading: this.page |
| 41 | + .getByTestId(`message-plan-block-${channel}`) |
| 42 | + .getByRole('heading', { level: 3 }), |
| 43 | + templateName: this.page.getByTestId(`template-name-${channel}`), |
| 44 | + fallbackConditions: this.page.getByTestId( |
| 45 | + `message-plan-fallback-conditions-${channel}` |
| 46 | + ), |
| 47 | + changeTemplateLink: this.page.getByTestId( |
| 48 | + `change-template-link-${channel}` |
| 49 | + ), |
| 50 | + chooseTemplateLink: this.page.getByTestId( |
| 51 | + `choose-template-link-${channel}` |
| 52 | + ), |
| 53 | + removeTemplateLink: this.page.getByTestId( |
| 54 | + `remove-template-link-${channel}` |
| 55 | + ), |
| 56 | + async clickChooseTemplateLink() { |
| 57 | + await this.chooseTemplateLink.click(); |
| 58 | + }, |
| 59 | + async clickChangeTemplateLink() { |
| 60 | + await this.changeTemplateLink.click(); |
| 61 | + }, |
| 62 | + async clickRemoveTemplateLink() { |
| 63 | + await this.removeTemplateLink.click(); |
| 64 | + }, |
| 65 | + }; |
| 66 | + } |
| 67 | + |
| 68 | + public readonly nhsApp = this.messagePlanChannel('NHSAPP'); |
| 69 | + |
| 70 | + public readonly sms = this.messagePlanChannel('SMS'); |
| 71 | + |
| 72 | + public readonly email = this.messagePlanChannel('EMAIL'); |
| 73 | + |
| 74 | + public readonly letter = this.messagePlanChannel('LETTER'); |
| 75 | + |
| 76 | + async clickMoveToProduction() { |
| 77 | + await this.moveToProductionButton.click(); |
| 78 | + } |
| 79 | + |
| 80 | + async clickSaveAndClose() { |
| 81 | + await this.saveAndCloseButton.click(); |
| 82 | + } |
| 83 | +} |
0 commit comments