mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-30 03:00:41 -04:00
## Changes 🏗️ <img width="800" height="687" alt="Screenshot 2025-08-12 at 15 52 41" src="https://github.com/user-attachments/assets/0d2d70b8-e727-428b-915e-d4c108ab7245" /> <img width="800" height="772" alt="Screenshot 2025-08-12 at 15 52 53" src="https://github.com/user-attachments/assets/b9790616-3754-455e-b8f6-58cd7f6b5a18" /> Update the Account Settings ( `profile/settings` ) form so that: - it uses the new Design System components - it is split into 2 forms ( update email & notifications ) - the change password inputs have been removed instead we link to the `/reset-password` page - uses a normal API route and client query to update the email This might fix as well an error we are seeing when updating email preferences on dev. My guess is it is failing because previously it was using a server action + supabase and it didn't have access to the cookies auth 🍪 ## 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] Navigate to `/profile/settings` - [x] Can update the email - [x] Can change notification preferences - [x] New E2E tests pass on the CI and make sense ### For configuration changes: None
145 lines
4.8 KiB
TypeScript
145 lines
4.8 KiB
TypeScript
import test, { expect } from "@playwright/test";
|
|
import { getTestUser } from "./utils/auth";
|
|
import { LoginPage } from "./pages/login.page";
|
|
import { hasAttribute, hasUrl, isHidden, isVisible } from "./utils/assertion";
|
|
import { getSelectors } from "./utils/selectors";
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
const testUser = await getTestUser();
|
|
const loginPage = new LoginPage(page);
|
|
|
|
// Login and navigate to settings
|
|
await page.goto("/login");
|
|
await loginPage.login(testUser.email, testUser.password);
|
|
await hasUrl(page, "/marketplace");
|
|
|
|
// Navigate to settings page
|
|
await page.goto("/profile/settings");
|
|
await hasUrl(page, "/profile/settings");
|
|
});
|
|
|
|
test("should display email form elements correctly", async ({ page }) => {
|
|
const { getField, getButton, getText, getLink } = getSelectors(page);
|
|
|
|
// Check email form elements are displayed
|
|
await isVisible(getText("Security & Access"));
|
|
await isVisible(getField("Email"));
|
|
await isVisible(getLink("Reset password"));
|
|
await isVisible(getButton("Update email"));
|
|
|
|
const updateEmailButton = getButton("Update email");
|
|
const resetPasswordButton = getLink("Reset password");
|
|
|
|
// Button should be disabled initially (no changes)
|
|
await expect(updateEmailButton).toBeDisabled();
|
|
|
|
// Test reset password navigation
|
|
await hasAttribute(resetPasswordButton, "href", "/reset-password");
|
|
});
|
|
|
|
test("should show validation error for empty email", async ({ page }) => {
|
|
const { getField, getButton } = getSelectors(page);
|
|
|
|
const emailField = getField("Email");
|
|
const updateEmailButton = getButton("Update email");
|
|
|
|
await emailField.fill("");
|
|
await updateEmailButton.click();
|
|
await isVisible(page.getByText("Email is required"));
|
|
});
|
|
|
|
test("should show validation error for invalid email", async ({ page }) => {
|
|
const { getField, getButton } = getSelectors(page);
|
|
|
|
const emailField = getField("Email");
|
|
const updateEmailButton = getButton("Update email");
|
|
|
|
await emailField.fill("invalid email");
|
|
await updateEmailButton.click();
|
|
await isVisible(page.getByText("Please enter a valid email address"));
|
|
});
|
|
|
|
test("should handle valid email", async ({ page }) => {
|
|
const { getField, getButton } = getSelectors(page);
|
|
|
|
const emailField = getField("Email");
|
|
const updateEmailButton = getButton("Update email");
|
|
|
|
// Test successful email update
|
|
const newEmail = `test+${Date.now()}@example.com`;
|
|
await emailField.fill(newEmail);
|
|
await expect(updateEmailButton).toBeEnabled();
|
|
await updateEmailButton.click();
|
|
await isHidden(page.getByText("Email is required"));
|
|
await isHidden(page.getByText("Please enter a valid email address"));
|
|
});
|
|
|
|
test("should handle complete notification form functionality and form interactions", async ({
|
|
page,
|
|
}) => {
|
|
const { getButton } = getSelectors(page);
|
|
|
|
// Check notification form elements are displayed
|
|
await isVisible(
|
|
page.getByRole("heading", { name: "Notifications", exact: true }),
|
|
);
|
|
|
|
await isVisible(getButton("Cancel"));
|
|
await isVisible(getButton("Save preferences"));
|
|
|
|
// Check all notification switches are present - get all switches on page
|
|
const switches = await page.getByRole("switch").all();
|
|
|
|
for (const switchElement of switches) {
|
|
await isVisible(switchElement);
|
|
}
|
|
|
|
const savePreferencesButton = getButton("Save preferences");
|
|
const cancelButton = getButton("Cancel");
|
|
|
|
// Button should be disabled initially (no changes)
|
|
await expect(savePreferencesButton).toBeDisabled();
|
|
|
|
// Test switch toggling functionality
|
|
for (const switchElement of switches) {
|
|
const initialState = await switchElement.isChecked();
|
|
await switchElement.click();
|
|
const newState = await switchElement.isChecked();
|
|
expect(newState).toBe(!initialState);
|
|
}
|
|
|
|
// Test button enabling when changes are made
|
|
if (switches.length > 0) {
|
|
await expect(savePreferencesButton).toBeEnabled();
|
|
}
|
|
|
|
// Test cancel functionality
|
|
await cancelButton.click();
|
|
// Wait for form state to update after cancel
|
|
await page.waitForTimeout(100);
|
|
await expect(savePreferencesButton).toBeDisabled();
|
|
|
|
// Test successful save with multiple switches
|
|
const testSwitches = switches.slice(0, Math.min(3, switches.length));
|
|
for (const switchElement of testSwitches) {
|
|
await switchElement.click();
|
|
}
|
|
await expect(savePreferencesButton).toBeEnabled();
|
|
await savePreferencesButton.click();
|
|
await isVisible(getButton("Saving..."));
|
|
await isVisible(
|
|
page.getByText("Successfully updated notification preferences"),
|
|
);
|
|
|
|
// Test persistence after page reload
|
|
if (testSwitches.length > 0) {
|
|
const finalState = await testSwitches[0].isChecked();
|
|
await page.reload();
|
|
await hasUrl(page, "/profile/settings");
|
|
const reloadedSwitches = await page.getByRole("switch").all();
|
|
if (reloadedSwitches.length > 0) {
|
|
expect(await reloadedSwitches[0].isChecked()).toBe(finalState);
|
|
}
|
|
}
|
|
});
|