Skip to content

Commit

Permalink
fix: clear cookies before login
Browse files Browse the repository at this point in the history
  • Loading branch information
innerdvations committed Apr 28, 2024
1 parent cf2e764 commit afc823e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/constants.js
Expand Up @@ -46,7 +46,7 @@ const ADMIN_PASSWORD = 'Testing123!';
const TITLE_LOGIN = 'Strapi Admin';
const TITLE_HOME = 'Homepage | Strapi';

const URL_ROOT = '/';
const URL_ROOT = '/admin';

module.exports = {
ADMIN_EMAIL_ADDRESS,
Expand Down
6 changes: 5 additions & 1 deletion tests/e2e/utils/login.ts
Expand Up @@ -2,13 +2,17 @@ import type { Page } from '@playwright/test';
import { ADMIN_EMAIL_ADDRESS, ADMIN_PASSWORD, TITLE_HOME, URL_ROOT } from '../constants';

/**
* Log in to an e2e test app
* Clear cookoies, refresh, and log in to an e2e test app, landing on the admin home page
* it is often flaky, resulting in an infinite spinning loader, so it will attempt several retries before failing
*/
// TODO: solve why this is so flaky
export const login = async ({ page, rememberMe = false }: { page: Page; rememberMe?: boolean }) => {
const maxRetries = 5;
for (let i = 0; i < maxRetries; i++) {
// sometimes it gets stuck on the login screen with an invalid session and can't log in
await page.context().clearCookies();
await page.reload({ waitUntil: 'networkidle' });

// go to the root page which should be the logged in
await page.goto(URL_ROOT, { waitUntil: 'networkidle' });

Expand Down

0 comments on commit afc823e

Please sign in to comment.