mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-30 03:00:41 -04:00
In this PR, I’ve added library page tests. ### Changes I’ve added 9 tests: 8 for normal flows and 1 for checking edge cases. Test names are something like: - Library navigation is accessible from the navbar. - The library page loads successfully. - Agents are visible, and cards work correctly. - Pagination works correctly. - Sorting works correctly. - Searching works correctly. - Pagination while searching works correctly. - Uploading an agent works correctly. - Edge case: Search edge cases and error handling behave correctly. Other than that, I’ve added a new utility that uses the build page to help us create users at the start, which we could use to test the library page. - All tests are passing locally <img width="514" height="465" alt="Screenshot 2025-07-12 at 11 13 41 AM" src="https://github.com/user-attachments/assets/7a46c437-7db5-458b-b99a-4fa0d479866f" /> ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] All library tests are working locally and on CI perfectly.
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import { FullConfig } from "@playwright/test";
|
|
import { createTestUsers, saveUserPool, loadUserPool } from "./utils/auth";
|
|
|
|
async function globalSetup(config: FullConfig) {
|
|
console.log("🚀 Starting global test setup...");
|
|
|
|
try {
|
|
const existingUserPool = await loadUserPool();
|
|
|
|
if (existingUserPool && existingUserPool.users.length > 0) {
|
|
console.log(
|
|
`♻️ Found existing user pool with ${existingUserPool.users.length} users`,
|
|
);
|
|
console.log("✅ Using existing user pool");
|
|
return;
|
|
}
|
|
|
|
// Create test users using signup page
|
|
const numberOfUsers = (config.workers || 1) + 8; // workers + buffer
|
|
console.log(`👥 Creating ${numberOfUsers} test users via signup...`);
|
|
console.log("⏳ Note: This may take a few minutes in CI environments");
|
|
|
|
const users = await createTestUsers(numberOfUsers);
|
|
|
|
if (users.length === 0) {
|
|
throw new Error("Failed to create any test users");
|
|
}
|
|
|
|
// Require at least a minimum number of users for tests to work
|
|
const minUsers = Math.max(config.workers || 1, 2);
|
|
if (users.length < minUsers) {
|
|
throw new Error(
|
|
`Only created ${users.length} users but need at least ${minUsers} for tests to run properly`,
|
|
);
|
|
}
|
|
|
|
// Save user pool
|
|
await saveUserPool(users);
|
|
|
|
console.log("✅ Global setup completed successfully!");
|
|
console.log(`📊 Created ${users.length} test users via signup page`);
|
|
} catch (error) {
|
|
console.error("❌ Global setup failed:", error);
|
|
console.error("💡 This is likely due to:");
|
|
console.error(" 1. Backend services not fully ready");
|
|
console.error(" 2. Network timeouts in CI environment");
|
|
console.error(" 3. Database or authentication issues");
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
export default globalSetup;
|