| | import { test, expect } from '@playwright/test' |
| | import { dropdownSelect, pageAction, userSessionFile } from './lib' |
| | import Chance from 'chance' |
| | const c = new Chance() |
| |
|
| | test.describe.configure({ mode: 'parallel' }) |
| | test.use({ storageState: userSessionFile }) |
| |
|
| | |
| | test('EMAIL contact method', async ({ page, browser, request }) => { |
| | const name = 'pw-email ' + c.name() |
| | const email = 'pw-email-' + c.email() |
| |
|
| | await page.goto('./profile') |
| |
|
| | await pageAction(page, 'Create Contact Method', 'Create Method') |
| |
|
| | await page.fill('input[name=name]', name) |
| |
|
| | |
| | await dropdownSelect(page, 'Destination Type', 'Voice Call') |
| |
|
| | await expect( |
| | page.locator('span', { hasText: 'test-disclaimer-text' }), |
| | ).toBeVisible() |
| |
|
| | await dropdownSelect(page, 'Destination Type', 'Email') |
| | await page.fill('input[name=email_address]', email) |
| | await page.click('[role=dialog] button[type=submit]') |
| |
|
| | const mail = await browser.newPage({ |
| | baseURL: 'http://localhost:6125', |
| | viewport: { width: 800, height: 600 }, |
| | }) |
| | await mail.goto('./') |
| | await mail.locator(`a:has-text("To: ${email}")`).click() |
| |
|
| | const code = await mail |
| | .frameLocator('#preview-html') |
| | .locator('.invite-code') |
| | .textContent() |
| | if (!code) { |
| | throw new Error('No code found') |
| | } |
| |
|
| | |
| | const url = mail.url() |
| | const id = url.match(/view\/(.+)/)?.[1] |
| |
|
| | |
| | const res = await request.get( |
| | `http://localhost:6125/api/v1/message/${id}/link-check`, |
| | ) |
| | await expect(res.ok()).toBeTruthy() |
| | const body = await res.json() |
| | body.Links.forEach( |
| | (l: { URL: string; StatusCode: number; Status: string }) => { |
| | expect(l, 'Link-Check: ' + l.URL).toHaveProperty('StatusCode', 200) |
| | }, |
| | ) |
| | expect(body).toHaveProperty('Errors', 0) |
| |
|
| | await mail.getByTitle('Delete message').click() |
| | await mail.close() |
| |
|
| | await page.fill('input[name=code]', code) |
| | await page.click('[role=dialog] button[type=submit]') |
| | await expect(page.locator('[role=dialog]')).toBeHidden() |
| |
|
| | |
| | const updatedName = 'updated name ' + c.name() |
| | await page.click(`li:has-text("${email}") [aria-label="Other Actions"]`) |
| | await page.getByRole('menuitem', { name: 'Edit' }).click() |
| | await page.fill('input[name=name]', updatedName) |
| | await page.click('input[name=enableStatusUpdates]') |
| | await page.click('[role=dialog] button[type=submit]') |
| | |
| | await page.mouse.move(0, 0) |
| | await expect(page.locator('[role=dialog]')).toBeHidden() |
| |
|
| | |
| | await page.click(`li:has-text("${email}") [aria-label="Other Actions"]`) |
| | await page.getByRole('menuitem', { name: 'Edit' }).click() |
| | await expect(page.locator('input[name=name]')).toHaveValue(updatedName) |
| | await expect(page.locator('input[name=enableStatusUpdates]')).toBeChecked() |
| | await page.click('[role=dialog] button[type=submit]') |
| |
|
| | await page.mouse.move(0, 0) |
| | await expect(page.locator('[role=dialog]')).toBeHidden() |
| |
|
| | |
| | await page.click( |
| | `li:has-text("Immediately notify me via Email at ${email}") button`, |
| | ) |
| |
|
| | |
| | await page.getByRole('button', { name: 'Confirm' }).click() |
| | await expect( |
| | page.locator('li', { |
| | hasText: `Immediately notify me via Email at ${email}`, |
| | }), |
| | ).toBeHidden() |
| |
|
| | |
| | await pageAction(page, 'Add Notification Rule', 'Add Rule') |
| | await dropdownSelect(page, 'Contact Method', updatedName) |
| | await page.fill('input[name=delayMinutes]', '5') |
| | await page.click('[role=dialog] button[type=submit]') |
| |
|
| | await page.mouse.move(0, 0) |
| | await expect(page.locator('[role=dialog]')).toBeHidden() |
| |
|
| | await expect( |
| | page.locator('li', { |
| | hasText: `After 5 minutes notify me via Email at ${email}`, |
| | }), |
| | ).toBeVisible() |
| |
|
| | await page.click(`li:has-text("${email}") [aria-label="Other Actions"]`) |
| | await page.getByRole('menuitem', { name: 'Delete' }).click() |
| | await page.getByRole('button', { name: 'Confirm' }).click() |
| |
|
| | await page.mouse.move(0, 0) |
| | await expect(page.locator('[role=dialog]')).toBeHidden() |
| | await page |
| | .locator('.MuiCard-root', { |
| | has: page.locator('div > div > h2', { hasText: 'Contact Methods' }), |
| | }) |
| | .locator('li', { hasText: email }) |
| | .isHidden() |
| | }) |
| |
|