Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
drewdelano committed Oct 11, 2022
1 parent b7df9bd commit fcebe5e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/website/tests/accountPayment.e2e.spec.ts
Expand Up @@ -11,20 +11,30 @@ test.beforeEach(async ({ page }) => {

test.describe('/account/payment', () => {
test('redirects through login and back when not initially authenticated', async ({ page }, testInfo) => {
const accountPaymentPathname = '/account/payment';
const accountPaymentPathname = '/account/payment/?plan=lite';
// try to go to page that requires authn
await page.goto(accountPaymentPathname, { waitUntil: 'networkidle' });
// wait for redirect to a Log in page
await page.locator('text=Log in').waitFor();
const pageUrl = new URL(page.url());

console.log("initial validation");
console.log(`expected: ${accountPaymentPathname}`);
console.log(`actual: ${pageUrl.searchParams.get('redirect_uri')}`);

expect(pageUrl.pathname).toEqual('/login/');
expect(pageUrl.searchParams.get('redirect_uri')).toEqual(accountPaymentPathname);
// fill login
await LoginTester().login(page, {
email: MAGIC_SUCCESS_EMAIL,
});
// should be back at our initial target destination
expect(new URL(page.url()).pathname).toEqual(accountPaymentPathname + '/');

console.log("final validation");
console.log(`expected: ${accountPaymentPathname}`);
console.log(`actual: ${new URL(page.url()).pathname}`);

expect(new URL(page.url()).pathname).toEqual(accountPaymentPathname);
await page.screenshot({
fullPage: true,
path: await E2EScreenshotPath(testInfo, `accountPayment-noauth`),
Expand Down

0 comments on commit fcebe5e

Please sign in to comment.