Skip to content

Commit

Permalink
test: fix local tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KrupaPammi committed May 17, 2024
1 parent 0c42b8c commit 74fe36c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
31 changes: 18 additions & 13 deletions playwright-local/tests/submit/validFormSubmission.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,24 @@ test('Valid giftaid submission', async ({ page }) => {

await page.goto('/', { timeout: 30000 });
await page.waitForLoadState('domcontentloaded');

// Ensure the transaction ID input is visible
await expect(page.locator('input#field-input--transactionId')).toBeVisible();

// Populate all input fields with valid data
await commands.populateUpdateFormFields(page);

// Select 'Yes' for GiftAid declaration
await page.locator('#giftAidClaimChoice>div:nth-child(2)>label').click();

// Submit the form and validate the thank you message
await page.locator('button[type=submit]').click();
await expect(page.locator('div > h1')).toContainText('Thank you, test!');

// Click the Giftaid checkbox
await page.click('#field-label--giftaid');

// Populate all the form fields with valid inputs
await commands.populateFormFields(page);

// Select marketing preferences as required
await commands.selectMarketingPrefs(page);

// Submit the form and wait for the navigation to ensure the submission goes through
await Promise.all([
page.waitForNavigation(), // This ensures that the navigation happens before the check
page.click('button[type=submit]')
]);

// Check for the thank you message to confirm successful submission
await expect(page.locator('div > h1')).toHaveText('Thank you, test!');

await page.close();
});
7 changes: 5 additions & 2 deletions playwright-local/tests/update/formValidation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
const { test, expect } = require('@playwright/test');
const { Commands } = require('../utils/commands');
const { v4: uuidv4 } = require('uuid');
const transactionId = uuidv4();
const Chance = require('chance');
const chance = new Chance();

test.describe('Giftaid update form validation', () => {
let transactionId;

test.beforeEach(async ({ page }) => {
transactionId = uuidv4(); // Ensure unique transaction ID for each test

await page.goto('/update', { timeout: 30000 });

await page.waitForLoadState('domcontentloaded');
});

Expand Down

0 comments on commit 74fe36c

Please sign in to comment.