Settings Helpers#
Helper functions for testing Settings pages (Assessment Test, Cashout, Demographic, Reminders, etc.).
Source: src/tests/HelperFiles/components/settings-helpers.ts
clickQuestionItem#
Clicks on a question item in a question list (Assessment Test, Cashout, Demographic).
verifyAddQuestionDialogFields#
Verifies the Add Question dialog fields are visible.
closeDialogWithoutSaving#
Closes a dialog without saving (Cancel/Close/Back button or backdrop click).
- closeDialogWithoutSaving(page)#
Close a dialog without saving (Cancel/Close/Back button or backdrop click).
- Arguments:
page (Page) – Playwright page
- Returns:
Promise –
Example:
await closeDialogWithoutSaving(page);
verifyDialogFields#
Verifies multiple dialog fields are visible. Throws an error if any fields are missing (unless throwOnMissing is false).
- verifyDialogFields(page, fields, throwOnMissing)#
Verify multiple dialog fields are visible. Throws an error if any fields are missing (unless throwOnMissing is false).
- Arguments:
- Returns:
Promise –
Examples:
```typescript await verifyDialogFields(page, ['Question', 'Answer', 'Submit']); ```
Example:
await verifyDialogFields(page, ['Question', 'Answer', 'Submit']);
verifyDialogOpened#
Verifies a dialog has opened by checking for possible headings or fallback indicators. Throws an error if dialog is not found.
- verifyDialogOpened(page, config)#
Verify a dialog has opened by checking for possible headings or fallback indicators. Throws an error if dialog is not found.
- Arguments:
page (Page) – Playwright page
config – Configuration with possible headings and fallback indicator
- Returns:
Promise –
Examples:
```typescript await verifyDialogOpened(page, { headings: ['Add System Demographic', 'Add Demographic'], fallbackIndicator: 'This question depends on the' }); ```
Example:
await verifyDialogOpened(page, {
headings: ['Add System Demographic', 'Add Demographic'],
fallbackIndicator: 'This question depends on the'
});
verifyDialogFieldVisible#
Verifies a field is visible in a dialog using multiple strategies (mat-card-title, then generic text).
- verifyDialogFieldVisible(page, fieldName)#
Verify a field is visible in a dialog using multiple strategies. Tries card title, then generic text.
- Arguments:
- Returns:
Promise –
Examples:
```typescript await verifyDialogFieldVisible(page, 'Question'); ```
Example:
await verifyDialogFieldVisible(page, 'Question');
testToggleSwitch#
Tests a toggle switch by clicking it, optionally verifying a result, then restoring. NON-DESTRUCTIVE - restores the switch to its original state.
- testToggleSwitch(page, switchName, options)#
Test a toggle switch by clicking it, optionally verifying a result, then restoring. NON-DESTRUCTIVE - restores the switch to its original state.
- Arguments:
- Returns:
Promise – true if switch was found and tested
Examples:
```typescript // Simple toggle test await testToggleSwitch(page, 'Yes or No answer'); // With verification that element appears await testToggleSwitch(page, 'Yes or No answer', { verifyAfterToggle: { role: 'row', name: 'Answer' } }); ```
Example:
// Simple toggle test
await testToggleSwitch(page, 'Yes or No answer');
// With verification that element appears after toggle
await testToggleSwitch(page, 'Yes or No answer', {
verifyAfterToggle: { role: 'row', name: 'Answer' }
});
verifyListItemsVisible#
Verifies that at least some items from a list are visible on the page. Useful for checking known questions or items exist.
- verifyListItemsVisible(page, items, options)#
Verify that at least some items from a list are visible on the page. Useful for checking known questions or items exist.
- Arguments:
page (Page) – Playwright page
items – Array of partial text strings to look for
options – Configuration options
- Returns:
Promise – Number of items found
Examples:
```typescript const found = await verifyListItemsVisible(page, settingsAssessmentTestConfig.knownQuestions); ```
Example:
const found = await verifyListItemsVisible(page, settingsAssessmentTestConfig.knownQuestions);
expect(found).toBeGreaterThan(0);
verifyColumnHeadersVisible#
Verifies column headers are visible in a table/dialog.
- verifyColumnHeadersVisible(page, headers)#
Verify column headers are visible in a table/dialog.
- Arguments:
page (Page) – Playwright page
headers – Array of header names to verify
- Returns:
Promise –
Examples:
```typescript await verifyColumnHeadersVisible(page, settingsAssessmentTestConfig.columnHeaders); ```
Example:
await verifyColumnHeadersVisible(page, settingsAssessmentTestConfig.columnHeaders);
await verifyColumnHeadersVisible(page, ['Correct', 'Answer', 'Action']);
expandMaterialPanel#
Expands an Angular Material expansion panel by name. Handles both mat-expansion-panel and accordion patterns. Returns the panel locator for scoped queries.
- expandMaterialPanel(page, panelName)#
Expands an Angular Material expansion panel by name. Handles both mat-expansion-panel and accordion patterns.
- Arguments:
- Returns:
Promise – The panel locator for chaining
Examples:
```typescript const panel = await expandMaterialPanel(page, 'Onboarding - Pending Upload'); ```
Example:
const panel = await expandMaterialPanel(page, 'Onboarding - Pending Upload');
// Use panel for scoped queries
await verifyAndToggleSwitches(page, switches, { context: panel });
collapseMaterialPanel#
Collapses an Angular Material expansion panel by name. Idempotent - safe to call if panel already collapsed.
- collapseMaterialPanel(page, panelName)#
Collapses an Angular Material expansion panel by name.
- Arguments:
- Returns:
Promise –
Examples:
```typescript await collapseMaterialPanel(page, 'Onboarding - Pending Upload'); ```
Example:
await expandMaterialPanel(page, 'Onboarding - Pending Upload');
// ... test panel content ...
await collapseMaterialPanel(page, 'Onboarding - Pending Upload');
verifyAndToggleSwitches#
Verifies and toggles switches within a panel or page context. NON-DESTRUCTIVE: Each switch is toggled ON then immediately toggled OFF to restore state.
- verifyAndToggleSwitches(page, switchNames, options)#
Verifies and toggles switches within a panel or page context. NON-DESTRUCTIVE: Each switch is toggled ON then immediately toggled OFF to restore state.
- Arguments:
page (Page) – Playwright page
switchNames – Array of switch names to test
options – Configuration options
- Returns:
Promise – Number of switches successfully toggled
Examples:
```typescript // Within entire page await verifyAndToggleSwitches(page, ['Visible', 'Hidden']); // Within a specific panel const panel = await expandMaterialPanel(page, 'Onboarding'); await verifyAndToggleSwitches(page, ['Document A', 'Document B'], { context: panel }); ```
Example:
// Within entire page
await verifyAndToggleSwitches(page, ['Visible', 'Hidden']);
// Within a specific panel (scoped)
const panel = await expandMaterialPanel(page, 'Onboarding');
await verifyAndToggleSwitches(page, settingsRemindersConfig.documents.onboardingUpload, { context: panel });
expandEmailTemplateSection#
Expands an email template section (accordion) by name. Returns true if section was found and expanded.
- expandEmailTemplateSection(page, sectionName)#
Expands an email template section (accordion) by name and returns the section locator.
- Arguments:
- Returns:
Promise – true if section was expanded
Examples:
```typescript await expandEmailTemplateSection(page, 'Account'); ```
Example:
const expanded = await expandEmailTemplateSection(page, 'Account');
if (expanded) {
const found = await verifyEmailTemplatesInSection(page, emailTemplates.Account);
}
verifyEmailTemplatesInSection#
Verifies templates are visible within an expanded email template section. Returns count of templates found.
- verifyEmailTemplatesInSection(page, templates)#
Verifies templates are visible within an expanded email template section.
- Arguments:
page (Page) – Playwright page
templates – Array of template names to verify
- Returns:
Promise – Number of templates found
Examples:
```typescript await expandEmailTemplateSection(page, 'Account'); const found = await verifyEmailTemplatesInSection(page, emailTemplates.Account); ```
Example:
await expandEmailTemplateSection(page, 'Account');
const found = await verifyEmailTemplatesInSection(page, emailTemplates.Account);
expect(found).toBeGreaterThan(0);
verifyNotificationToggles#
Verifies notification toggles are present on the page. Read-only verification - does NOT modify any toggle states.
- verifyNotificationToggles(page, notifications)#
Verifies notification toggles are present and optionally checks their states. Does NOT modify any toggle states.
- Arguments:
page (Page) – Playwright page
notifications – Array of notification names to verify
- Returns:
Promise – Object with found count and list of found notifications
Examples:
```typescript const { found, notifications } = await verifyNotificationToggles(page, notificationSettings.notifications); ```
Example:
const result = await verifyNotificationToggles(page, notificationSettings.notifications);
expect(result.found).toBeGreaterThan(0);
console.log(`Found notifications: ${result.foundItems.join(', ')}`);
clickItemByNameOrText#
Clicks an item by trying button role first, then exact text match. Common pattern for clicking templates, menu items, etc.
- clickItemByNameOrText(page, itemName, options)#
Clicks an item by trying button role first, then exact text match. Common pattern for clicking templates, menu items, etc.
- Arguments:
- Returns:
Promise – true if item was clicked
Examples:
```typescript await clickItemByNameOrText(page, 'Name Change Request Approved'); ```
Example:
await clickItemByNameOrText(page, 'Name Change Request Approved');
await clickItemByNameOrText(page, emailTemplates.Account[0]);
verifyEmailEditorElements#
Verifies email template editor elements are visible (Subject field, Helper Tags, textarea).
- verifyEmailEditorElements(page, config)#
Verifies email template editor elements are visible. Checks for Subject field, Helper Tags, and textarea.
- Arguments:
page (Page) – Playwright page
config – Editor field names from settingsEmailTemplatesConfig.editorFields
- Returns:
Promise – Number of editor elements found
Examples:
```typescript const found = await verifyEmailEditorElements(page, settingsEmailTemplatesConfig.editorFields); ```
Example:
const found = await verifyEmailEditorElements(page, settingsEmailTemplatesConfig.editorFields);
expect(found).toBeGreaterThan(0);