Add .prettierrc.json and refactor test files for improved formatting consistency:
- Introduced `.prettierrc.json` to enforce consistent code formatting across the project. - Updated unit and e2e test files to address formatting issues, improve readability, and ensure alignment with the new Prettier configuration.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Page, expect } from '@playwright/test';
|
||||
import { Page, expect } from "@playwright/test";
|
||||
import {
|
||||
userCredentials,
|
||||
subuserPhoneCredentials,
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
user2FACredentials,
|
||||
subuser2FACredentials,
|
||||
qrAuthToken,
|
||||
} from './testData';
|
||||
import { generateOTP } from './otp';
|
||||
} from "./testData";
|
||||
import { generateOTP } from "./otp";
|
||||
|
||||
// Auth timeout in milliseconds (15 seconds)
|
||||
const AUTH_TIMEOUT = 15000;
|
||||
@@ -30,7 +30,7 @@ export async function loginAsUser(
|
||||
credentials?: { customerNumber: string; password: string; twoFactorAuthentication?: boolean; otpSecret?: string }
|
||||
) {
|
||||
const creds = credentials || userCredentials;
|
||||
await page.goto('/login');
|
||||
await page.goto("/login");
|
||||
await page.fill('input[name="customer_number"]', creds.customerNumber);
|
||||
await page.fill('input[name="password"]', creds.password);
|
||||
await page.click('button[id="login-button"]');
|
||||
@@ -51,10 +51,16 @@ export async function loginAsUser(
|
||||
*/
|
||||
export async function loginAsSubuserByPhone(
|
||||
page: Page,
|
||||
credentials?: { phoneCountryCode: string; phone: string; password: string; twoFactorAuthentication?: boolean; otpSecret?: string }
|
||||
credentials?: {
|
||||
phoneCountryCode: string;
|
||||
phone: string;
|
||||
password: string;
|
||||
twoFactorAuthentication?: boolean;
|
||||
otpSecret?: string;
|
||||
}
|
||||
) {
|
||||
const creds = credentials || subuserPhoneCredentials;
|
||||
await page.goto('/login/driver');
|
||||
await page.goto("/login/driver");
|
||||
await page.fill('input[name="phone_country_code"]', creds.phoneCountryCode);
|
||||
await page.fill('input[name="phone"]', creds.phone);
|
||||
await page.fill('input[name="password"]', creds.password);
|
||||
@@ -79,7 +85,7 @@ export async function loginAsSubuserByUsername(
|
||||
credentials?: { username: string; password: string; twoFactorAuthentication?: boolean; otpSecret?: string }
|
||||
) {
|
||||
const creds = credentials || subuserUsernameCredentials;
|
||||
await page.goto('/login/driver');
|
||||
await page.goto("/login/driver");
|
||||
await page.click('button[id="subuser_login_method_username_button"]');
|
||||
await page.waitForSelector('input[name="username"]');
|
||||
await page.waitForSelector('input[name="password"]');
|
||||
@@ -101,12 +107,9 @@ export async function loginAsSubuserByUsername(
|
||||
* @param page - Playwright page object
|
||||
* @param credentials - Optional custom credentials (defaults to operatorCredentials)
|
||||
*/
|
||||
export async function loginAsOperator(
|
||||
page: Page,
|
||||
credentials?: { userId: string; password: string }
|
||||
) {
|
||||
export async function loginAsOperator(page: Page, credentials?: { userId: string; password: string }) {
|
||||
const creds = credentials || operatorCredentials;
|
||||
await page.goto('/admin/login');
|
||||
await page.goto("/admin/login");
|
||||
await page.fill('input[name="user_id"]', creds.userId);
|
||||
await page.fill('input[name="password"]', creds.password);
|
||||
await page.click('button[id="operator_login_button"]');
|
||||
@@ -119,7 +122,7 @@ export async function loginAsOperator(
|
||||
* @param page - Playwright page object
|
||||
*/
|
||||
export async function goToUserLogin(page: Page) {
|
||||
await page.goto('/login');
|
||||
await page.goto("/login");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +130,7 @@ export async function goToUserLogin(page: Page) {
|
||||
* @param page - Playwright page object
|
||||
*/
|
||||
export async function goToSubuserLogin(page: Page) {
|
||||
await page.goto('/login/driver');
|
||||
await page.goto("/login/driver");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +138,7 @@ export async function goToSubuserLogin(page: Page) {
|
||||
* @param page - Playwright page object
|
||||
*/
|
||||
export async function goToOperatorLogin(page: Page) {
|
||||
await page.goto('/admin/login');
|
||||
await page.goto("/admin/login");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,12 +146,9 @@ export async function goToOperatorLogin(page: Page) {
|
||||
* @param page - Playwright page object
|
||||
* @param credentials - Optional custom credentials (defaults to user2FACredentials)
|
||||
*/
|
||||
export async function loginAsUserWith2FA(
|
||||
page: Page,
|
||||
credentials?: { customerNumber: string; password: string }
|
||||
) {
|
||||
export async function loginAsUserWith2FA(page: Page, credentials?: { customerNumber: string; password: string }) {
|
||||
const creds = credentials || user2FACredentials;
|
||||
await page.goto('/login');
|
||||
await page.goto("/login");
|
||||
await page.fill('input[name="customer_number"]', creds.customerNumber);
|
||||
await page.fill('input[name="password"]', creds.password);
|
||||
await page.click('button[id="login-button"]');
|
||||
@@ -184,7 +184,7 @@ export async function loginAsSubuserWith2FA(
|
||||
credentials?: { phoneCountryCode: string; phone: string; password: string }
|
||||
) {
|
||||
const creds = credentials || subuser2FACredentials;
|
||||
await page.goto('/login/driver');
|
||||
await page.goto("/login/driver");
|
||||
await page.fill('input[name="phone_country_code"]', creds.phoneCountryCode);
|
||||
await page.fill('input[name="phone"]', creds.phone);
|
||||
await page.fill('input[name="password"]', creds.password);
|
||||
@@ -207,13 +207,10 @@ export async function isPasskeyButtonVisible(page: Page): Promise<boolean> {
|
||||
* @param page - Playwright page object
|
||||
* @param token - Optional QR auth token (defaults to qrAuthToken from testData)
|
||||
*/
|
||||
export async function loginWithQRCode(
|
||||
page: Page,
|
||||
token?: string
|
||||
) {
|
||||
export async function loginWithQRCode(page: Page, token?: string) {
|
||||
const authToken = token || qrAuthToken;
|
||||
if (!authToken) {
|
||||
throw new Error('QR auth token is not set. Set PLENO_QR_TOKEN environment variable or pass token directly.');
|
||||
throw new Error("QR auth token is not set. Set PLENO_QR_TOKEN environment variable or pass token directly.");
|
||||
}
|
||||
await page.goto(`/login/qr?token=${authToken}`);
|
||||
await expect(page).toHaveURL(USER_HOME_URL, { timeout: AUTH_TIMEOUT });
|
||||
@@ -225,7 +222,7 @@ export async function loginWithQRCode(
|
||||
* @param page - Playwright page object
|
||||
*/
|
||||
export async function goToQRCodeLogin(page: Page) {
|
||||
await page.goto('/login/qr');
|
||||
await page.goto("/login/qr");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,9 +231,6 @@ export async function goToQRCodeLogin(page: Page) {
|
||||
* @param page - Playwright page object
|
||||
* @param invalidToken - Invalid token to test with
|
||||
*/
|
||||
export async function attemptInvalidQRCodeLogin(
|
||||
page: Page,
|
||||
invalidToken: string = 'invalid-token'
|
||||
) {
|
||||
export async function attemptInvalidQRCodeLogin(page: Page, invalidToken: string = "invalid-token") {
|
||||
await page.goto(`/login/qr?token=${invalidToken}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user