E2e assistant tests (#3869)

* adding llm override logic

* update

* general cleanup

* fix various tests

* rm

* update

* update

* better comments

* k

* k

* update to pass tests

* clarify content

* improve timeout
This commit is contained in:
pablonyx
2025-02-01 12:05:53 -08:00
committed by GitHub
parent a82cac5361
commit 3c34ddcc4f
23 changed files with 405 additions and 76 deletions

View File

@ -35,3 +35,40 @@ export async function loginAs(page: Page, userType: "admin" | "user") {
}
}
}
// Function to generate a random email and password
const generateRandomCredentials = () => {
const randomString = Math.random().toString(36).substring(2, 10);
const specialChars = "!@#$%^&*()_+{}[]|:;<>,.?~";
const randomSpecialChar =
specialChars[Math.floor(Math.random() * specialChars.length)];
const randomUpperCase = String.fromCharCode(
65 + Math.floor(Math.random() * 26)
);
const randomNumber = Math.floor(Math.random() * 10);
return {
email: `test_${randomString}@example.com`,
password: `P@ssw0rd_${randomUpperCase}${randomSpecialChar}${randomNumber}${randomString}`,
};
};
// Function to sign up a new random user
export async function loginAsRandomUser(page: Page) {
const { email, password } = generateRandomCredentials();
await page.goto("http://localhost:3000/auth/signup");
await page.fill("#email", email);
await page.fill("#password", password);
// Click the signup button
await page.click('button[type="submit"]');
try {
await page.waitForURL("http://localhost:3000/chat");
} catch (error) {
console.log(`Timeout occurred. Current URL: ${page.url()}`);
throw new Error("Failed to sign up and redirect to chat page");
}
return { email, password };
}