Skip to content

Commit

Permalink
Merge pull request #2965 from clari182/feature/playwright-confirmemail
Browse files Browse the repository at this point in the history
Feature/playwright confirmemail
  • Loading branch information
pdcp1 committed Aug 16, 2024
2 parents af28cc8 + 77195f6 commit 0a1e744
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 49 deletions.
49 changes: 0 additions & 49 deletions site/gatsby-site/cypress/e2e/integration/confirmemail.cy.js

This file was deleted.

43 changes: 43 additions & 0 deletions site/gatsby-site/playwright/e2e/integration/confirmemail.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { expect } from '@playwright/test';
import { test } from '../../utils';

const url = '/confirmemail';

test.describe('Confirm email', () => {

test('Should successfully load confirm email page', async ({ page }) => {
await page.goto(url);
});

test('Should display Invalid params message when token or tokenId are missing', async ({ page }) => {
await page.goto(`${url}?token=dummyToken`);
await expect(page.locator(':has-text("Invalid parameters")').first()).toBeVisible();
await expect(page.locator('[data-cy="confirm-login-btn"]')).toBeVisible();
await expect(page.locator('#content:has-text("An unknown error has occurred")')).toBeVisible();

await page.goto(`${url}?tokenId=dummyTokenId`);
await expect(page.locator(':has-text("Invalid parameters")').first()).toBeVisible();
await expect(page.locator('[data-cy="confirm-login-btn"]')).toBeVisible();
await expect(page.locator('#content:has-text("An unknown error has occurred")')).toBeVisible();
});

test('Should display an error message if the confirmation failed on Atlas', async ({ page }) => {
await page.goto(`${url}?token=invalidToken&tokenId=invalidTokenId`);
await expect(page.locator('[data-cy="toast"]:has-text("An unknown error has occurred")')).toBeVisible();
await expect(page.locator('[data-cy="confirm-login-btn"]')).toBeVisible();
await expect(page.locator('#content:has-text("An unknown error has occurred")')).toBeVisible();
});

test('Should display success message if the email is confirmed on Atlas', async ({ page }) => {
await page.route('**/confirm', route => route.fulfill({ status: 201 }));
await page.goto(`${url}?token=dummyToken&tokenId=dummyTokenId`);

await expect(page.locator('[data-cy="toast"]:has-text("Thank you for verifying your account.")')).toBeVisible();
await expect(page.locator('[data-cy="confirm-login-btn"]')).toBeVisible();
await expect(page.locator('#content:has-text("Thank you for verifying your account.")')).toBeVisible();

await page.locator('[data-cy="confirm-login-btn"]').click();
await expect(page).toHaveURL('/login/?redirectTo=/account/');
});

});

0 comments on commit 0a1e744

Please sign in to comment.