Skip to content
Snippets Groups Projects

Update ATK-PW-1050 for Drupal 7.

1 file
+ 13
49
Compare changes
  • Side-by-side
  • Inline
@@ -10,14 +10,6 @@
import * as atkCommands from '../support/atk_commands';
import * as atkUtilities from '../support/atk_utilities';
// Set up Playwright.
const { test, expect } = require('@playwright/test');
import playwrightConfig from '../../playwright.config';
const baseUrl = playwrightConfig.use.baseURL;
// Import ATK Configuration.
import atkConfig from '../../playwright.atk.config';
@@ -27,7 +19,10 @@ import userEtherealAccount from '../data/etherealUser.json';
// Standard accounts that use user accounts created
// by QA Accounts. QA Accounts are created when the QA
// Accounts module is enabled.
import qaUserAccounts from '../data/qaUsers.json';
import qaUsers from '../data/qaUsers.json';
// Set up Playwright.
const { test, expect } = require('@playwright/test');
test.describe('Contact Us tests.', () => {
//
@@ -37,52 +32,21 @@ test.describe('Contact Us tests.', () => {
const uniqueToken = atkUtilities.createRandomString(6);
const testId = '(ATK-PW-1050)';
const subjectLine = `${testId} ${uniqueToken}`;
let textContent = '';
// Add permission
atkCommands.addRolePerm('anonymous user', 'access site-wide contact form');
// Begin registration.
await page.goto(baseUrl + atkConfig.contactUsUrl);
await page.goto(atkConfig.contactUsUrl);
await page.getByLabel('Your name').fill(userEtherealAccount.userName);
await page.getByLabel('Your email').fill(userEtherealAccount.userEmail);
await page.getByLabel('Your name').fill(uniqueToken);
await page.getByLabel('Your e-mail').fill(`${uniqueToken}@example.com`);
await page.getByLabel('Subject').fill(subjectLine);
await page.getByLabel('Message').fill(testId);
await page.getByRole('button', { name: 'Send message' }).click();
await atkCommands.expectMessage(page, 'Your message has been sent.');
// The status box needs a moment to appear.
await page.waitForSelector('[aria-label="Status message"]');
// Should see the thank-you message.
textContent = await page.content();
expect(textContent).toContain('Your message has been sent.');
// Now check for the entry in the database.
await atkCommands.logOutViaUi(page, context);
await atkCommands.logInViaForm(page, context, qaUserAccounts.admin);
await page.goto(`${baseUrl}admin/structure/webform/manage/contact/results/submissions`);
// Check for presence of random string.
// Part A passes: the submission appears.
textContent = await page.content();
expect(textContent).toContain(uniqueToken);
// Check for registration email at Ethereal.
const etherealUrl = 'https://ethereal.email';
await page.goto(`${etherealUrl}/login`);
await page.getByPlaceholder('Enter email').fill(userEtherealAccount.userEmail);
await page.getByPlaceholder('Password').fill(userEtherealAccount.userPassword);
await page.getByRole('button', { name: 'Log in' }).click();
textContent = await page.textContent('body');
expect(textContent).toContain(`Logged in as ${userEtherealAccount.userEmail}`);
await page.goto(`${etherealUrl}/messages`);
textContent = await page.textContent('body');
expect(textContent).toContain(`Messages for ${userEtherealAccount.userEmail}`);
// Look for "ATK-CY-1050) uniqueToken" generated above.
await expect(page.getByRole('row', { subject: subjectLine })).toBeVisible;
// Check for Contact Us email at Ethereal.
await atkCommands.checkEmail(page, null, subjectLine);
});
});
Loading