Settings Helpers#

Helper functions for testing Settings pages (Assessment Test, Cashout, Demographic, Reminders, etc.).

Source: src/tests/HelperFiles/components/settings-helpers.ts

testVisibleHiddenSwitches#

Tests the Visible/Hidden filter switches common to Settings question pages. Toggles each switch and restores to original state (NON-DESTRUCTIVE).

testVisibleHiddenSwitches(page, config, filterText, hiddenInitial, visibleInitial)#

Test the Visible/Hidden filter switches on a settings page. Toggles each switch and restores to original state (NON-DESTRUCTIVE).

Arguments:
  • page (Page) – Playwright page

  • config (VisibleHiddenConfig) – Optional configuration

  • filterText (string) – Text to identify the filter section

  • hiddenInitial (boolean) – Expected initial state of Hidden switch

  • visibleInitial (boolean) – Expected initial state of Visible switch

Returns:

Promise – Object with switch states

Examples:

```typescript
await testVisibleHiddenSwitches(page);
// Or with config:
await testVisibleHiddenSwitches(page, { filterText: 'Filter' });
```

Example:

await testVisibleHiddenSwitches(page);

verifyVisibleHiddenInstructions#

Verifies the Visible/Hidden filter instruction text is present on a settings page.

verifyVisibleHiddenInstructions(page)#

Verify the Visible/Hidden filter instruction text is present.

Arguments:
  • page (Page) – Playwright page

Returns:

Promise – true if instruction text is found

clickQuestionItem#

Clicks on a question item in a question list (Assessment Test, Cashout, Demographic).

clickQuestionItem(page, questionText)#

Click on a question item in a question list (Assessment Test, Cashout, Demographic).

Arguments:
  • page (Page) – Playwright page

  • questionText (string) – Partial text of the question to click

Returns:

Promise – true if question was clicked

clickAddQuestionButton#

Opens the Add Question dialog by clicking the add button. Works for Assessment Test, Cashout, Demographic, and Renew Demographic pages. Uses multiple fallback strategies to find the add button.

clickAddQuestionButton(page, options)#

Open the Add Question dialog by clicking the add button. Works for Assessment Test, Cashout, Demographic, and Renew Demographic pages.

Uses multiple fallback strategies to find and click the add button: 1. mat-icon with “add” text (most reliable for Material Design) 2. Button role filtered by “add” text 3. Header text with add icon combined 4. Generic add/plus button patterns

Arguments:
  • page (Page) – Playwright page

  • options – Optional configuration

Returns:

Promise – true if dialog was opened successfully

Examples:

```typescript
// Basic usage - finds add button automatically
await clickAddQuestionButton(page);

// With header context
await clickAddQuestionButton(page, { headerText: 'Assessment Test Questions' });
```

Example:

// Basic usage
await clickAddQuestionButton(page);

// With header context
await clickAddQuestionButton(page, { headerText: 'Default System Cashout Questions' });

verifyAddQuestionDialogFields#

Verifies the Add Question dialog fields are visible.

verifyAddQuestionDialogFields(page, expectedFields)#

Verify the Add Question dialog fields are visible.

Arguments:
  • page (Page) – Playwright page

  • expectedFields – Array of field names to verify

Returns:

Promise

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:
  • page (Page) – Playwright page

  • fields – Array of field names/texts to verify

  • throwOnMissing (boolean) – If true (default), throws when fields are missing

Returns:

Promise

Examples:

```typescript
await verifyDialogFields(page, ['Question', 'Answer', 'Submit']);
```

Example:

await verifyDialogFields(page, ['Question', 'Answer', 'Submit']);

clickAddRowButton#

Clicks an add button within a specific section (e.g., for adding answer rows). Uses nth parameter to select the correct add button when multiple exist.

clickAddRowButton(page, options)#

Click an add button within a specific section (e.g., for adding answer rows). Uses nth parameter to select the correct add button when multiple exist.

Arguments:
  • page (Page) – Playwright page

  • options – Configuration options

Returns:

Promise – true if button was clicked

Examples:

```typescript
// Click the first add button
await clickAddRowButton(page);

// Click the second add button (for answer rows)
await clickAddRowButton(page, { nth: 1 });

// Click add button within a specific section
await clickAddRowButton(page, { sectionText: 'Pre-Select Answer Option' });
```

Example:

// Click the first add button
await clickAddRowButton(page);

// Click the second add button (for answer rows)
await clickAddRowButton(page, { nth: 1 });

// Click add button within a specific section
await clickAddRowButton(page, { sectionText: 'Pre-Select Answer Option' });

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:
  • page (Page) – Playwright page

  • fieldName (string) – Name of the field to verify

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:
  • page (Page) – Playwright page

  • switchName (string) – Name/label of the switch

  • options – Configuration options

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:
  • page (Page) – Playwright page

  • panelName (string) – Text content to identify the panel

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:
  • page (Page) – Playwright page

  • panelName (string) – Text content to identify the panel

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:
  • page (Page) – Playwright page

  • sectionName (string) – Name of the section (e.g., ‘Account’, ‘Billing’)

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:
  • page (Page) – Playwright page

  • itemName (string) – Name of the item to click

  • options – Configuration options

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);

verifyActionButtonsExist#

Verifies action buttons exist without clicking them. NON-DESTRUCTIVE.

verifyActionButtonsExist(page, buttonPatterns)#

Verifies action buttons exist without clicking them. NON-DESTRUCTIVE.

Arguments:
  • page (Page) – Playwright page

  • buttonPatterns – Array of regex patterns for button names

Returns:

Promise – Number of buttons found

Examples:

```typescript
const found = await verifyActionButtonsExist(page, [/save/i, /cancel|close/i]);
```

Example:

await verifyActionButtonsExist(page, [/save/i, /cancel|close/i]);