|
| 1 | +/** |
| 2 | + * Copyright since 2026 Mifos Initiative |
| 3 | + * |
| 4 | + * This Source Code Form is subject to the terms of the Mozilla Public |
| 5 | + * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 | + * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 7 | + */ |
| 8 | + |
| 9 | +/** |
| 10 | + * Layer 2 — Typed selector contracts (Angular). |
| 11 | + * |
| 12 | + * This is the ONLY file that differs between Angular and React. |
| 13 | + * All page objects consume these typed maps. Specs never reference |
| 14 | + * selectors directly — they call page object methods only. |
| 15 | + * |
| 16 | + * React counterpart lives in |
| 17 | + * `mifos-x-web-app-react/playwright/config/selectors.ts` |
| 18 | + * and uses data-testid / name selectors instead of formcontrolname / |
| 19 | + * Angular Material class names. |
| 20 | + * |
| 21 | + * Interface signatures here MUST match the React file so a port across |
| 22 | + * frameworks is a configuration swap, not a code rewrite (proposal §8). |
| 23 | + */ |
| 24 | + |
| 25 | +// --------------------------------------------------------------------------- |
| 26 | +// Login |
| 27 | +// --------------------------------------------------------------------------- |
| 28 | + |
| 29 | +export interface LoginSelectors { |
| 30 | + usernameInput: string; |
| 31 | + passwordInput: string; |
| 32 | + loginButton: string; |
| 33 | + errorMessage: string; |
| 34 | + progressBar: string; |
| 35 | + loginForm: string; |
| 36 | +} |
| 37 | + |
| 38 | +export const LOGIN_SELECTORS: LoginSelectors = { |
| 39 | + usernameInput: 'input[formcontrolname="username"]', |
| 40 | + passwordInput: 'input[formcontrolname="password"]', |
| 41 | + loginButton: 'button:has-text("Login")', |
| 42 | + errorMessage: 'mat-error', |
| 43 | + progressBar: 'mat-progress-bar', |
| 44 | + loginForm: '#login-form' |
| 45 | +}; |
| 46 | + |
| 47 | +// --------------------------------------------------------------------------- |
| 48 | +// Dashboard / shell |
| 49 | +// --------------------------------------------------------------------------- |
| 50 | + |
| 51 | +export interface DashboardSelectors { |
| 52 | + toolbar: string; |
| 53 | +} |
| 54 | + |
| 55 | +export const DASHBOARD_SELECTORS: DashboardSelectors = { |
| 56 | + toolbar: 'mat-toolbar' |
| 57 | +}; |
| 58 | + |
| 59 | +// --------------------------------------------------------------------------- |
| 60 | +// Client — create form |
| 61 | +// --------------------------------------------------------------------------- |
| 62 | + |
| 63 | +export interface CreateClientSelectors { |
| 64 | + officeDropdown: string; |
| 65 | + firstnameInput: string; |
| 66 | + lastnameInput: string; |
| 67 | + submitButton: string; |
| 68 | + validationError: string; |
| 69 | +} |
| 70 | + |
| 71 | +export const CREATE_CLIENT_SELECTORS: CreateClientSelectors = { |
| 72 | + officeDropdown: 'mat-select[formcontrolname="officeId"]', |
| 73 | + firstnameInput: 'input[formcontrolname="firstname"]', |
| 74 | + lastnameInput: 'input[formcontrolname="lastname"]', |
| 75 | + submitButton: 'button[type="submit"]', |
| 76 | + validationError: 'mat-error' |
| 77 | +}; |
| 78 | + |
| 79 | +// --------------------------------------------------------------------------- |
| 80 | +// Client — view / actions |
| 81 | +// --------------------------------------------------------------------------- |
| 82 | + |
| 83 | +export interface ClientViewSelectors { |
| 84 | + actionsButton: string; |
| 85 | + actionsSubmenuTrigger: string; |
| 86 | + successSnackbar: string; |
| 87 | + personalDataTab: string; |
| 88 | + closedDateRow: string; |
| 89 | + closedDateValue: string; |
| 90 | + overlayBackdrop: string; |
| 91 | +} |
| 92 | + |
| 93 | +export const CLIENT_VIEW_SELECTORS: ClientViewSelectors = { |
| 94 | + actionsButton: 'button[aria-label="Client actions"], button:has-text("Client actions")', |
| 95 | + actionsSubmenuTrigger: 'Actions', |
| 96 | + successSnackbar: '.mat-mdc-snack-bar-container', |
| 97 | + personalDataTab: 'Personal Data', |
| 98 | + closedDateRow: '.data-item', |
| 99 | + closedDateValue: '.value', |
| 100 | + overlayBackdrop: '.cdk-overlay-backdrop' |
| 101 | +}; |
| 102 | + |
| 103 | +// --------------------------------------------------------------------------- |
| 104 | +// Close client action form |
| 105 | +// --------------------------------------------------------------------------- |
| 106 | + |
| 107 | +export interface CloseClientSelectors { |
| 108 | + closureDateInput: string; |
| 109 | + closureReasonSelect: string; |
| 110 | + confirmButton: string; |
| 111 | + cancelButton: string; |
| 112 | +} |
| 113 | + |
| 114 | +export const CLOSE_CLIENT_SELECTORS: CloseClientSelectors = { |
| 115 | + closureDateInput: 'input[formcontrolname="closureDate"]', |
| 116 | + closureReasonSelect: 'mat-select[formcontrolname="closureReasonId"]', |
| 117 | + confirmButton: 'Confirm', |
| 118 | + cancelButton: 'Cancel' |
| 119 | +}; |
0 commit comments