Back to Repositories

Validating User Profile Management in AutoGPT

This test suite validates user profile functionality in AutoGPT’s frontend, covering profile information display, navigation, and credential provider features. It ensures proper user authentication and profile data handling.

Test Coverage Overview

The test suite provides comprehensive coverage of profile-related functionality:

  • Profile information display verification
  • Navigation accessibility testing
  • User credential provider validation
  • Authentication state persistence
  • URL routing verification

Implementation Analysis

The tests utilize Playwright’s test framework with TypeScript, implementing page object pattern through ProfilePage class. The suite employs async/await patterns for handling asynchronous operations and includes workarounds for known system issues (#8788) through strategic page reloads.

Technical Details

Key technical components include:

  • Playwright Test Runner
  • TypeScript for type safety
  • Page Object Model implementation
  • Custom fixtures for authentication
  • URL pattern matching with RegExp
  • Test data isolation through testUser fixture

Best Practices Demonstrated

The test suite exemplifies several testing best practices:

  • Isolated test setup with beforeEach hooks
  • Modular page object pattern
  • Explicit wait strategies
  • Clear test case organization
  • Proper assertion patterns
  • Handling of async operations

significant-gravitas/autogpt

autogpt_platform/frontend/src/tests/profile.spec.ts

            
// profile.spec.ts
import { test } from "./fixtures";
import { ProfilePage } from "./pages/profile.page";

test.describe("Profile", () => {
  let profilePage: ProfilePage;

  test.beforeEach(async ({ page, loginPage, testUser }) => {
    profilePage = new ProfilePage(page);

    // Start each test with login using worker auth
    await page.goto("/login");
    await loginPage.login(testUser.email, testUser.password);
    await test.expect(page).toHaveURL("/");
  });

  test("user can view their profile information", async ({
    page,
    testUser,
  }) => {
    await profilePage.navbar.clickProfileLink();
    // workaround for #8788
    // sleep for 10 seconds to allow page to load due to bug in our system
    await page.waitForTimeout(10000);
    await page.reload();
    await page.reload();
    await test.expect(profilePage.isLoaded()).resolves.toBeTruthy();
    await test.expect(page).toHaveURL(new RegExp("/profile"));

    // Verify email matches test worker's email
    const displayedEmail = await profilePage.getDisplayedEmail();
    test.expect(displayedEmail).toBe(testUser.email);
  });

  test("profile navigation is accessible from navbar", async ({ page }) => {
    await profilePage.navbar.clickProfileLink();
    await test.expect(page).toHaveURL(new RegExp("/profile"));
    // workaround for #8788
    await page.reload();
    await page.reload();
    await test.expect(profilePage.isLoaded()).resolves.toBeTruthy();
  });

  test("profile displays user Credential providers", async ({ page }) => {
    await profilePage.navbar.clickProfileLink();

    // await test
    //   .expect(page.getByTestId("profile-section-personal"))
    //   .toBeVisible();
    // await test
    //   .expect(page.getByTestId("profile-section-settings"))
    //   .toBeVisible();
    // await test
    //   .expect(page.getByTestId("profile-section-security"))
    //   .toBeVisible();
  });
});