mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 08:13:37 +00:00
refactor: extract sanitizeForTestId to shared utility
Address PR review comments by: - Creating shared sanitizeForTestId utility in apps/ui/src/lib/utils.ts - Updating ProjectSwitcherItem to use the shared utility - Adding matching helper to test utils for E2E tests - Updating all E2E tests to use the sanitization helper This ensures the component and tests use identical sanitization logic, making tests robust against project names with special characters.
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
authenticateForTests,
|
||||
handleLoginScreenIfPresent,
|
||||
waitForNetworkIdle,
|
||||
sanitizeForTestId,
|
||||
} from '../utils';
|
||||
|
||||
const TEST_TEMP_DIR = createTempDirPath('project-creation-test');
|
||||
@@ -79,7 +80,8 @@ test.describe('Project Creation', () => {
|
||||
// Wait for project to be set as current and visible on the page
|
||||
// The project name appears in the project switcher button
|
||||
// Use ends-with selector since data-testid format is: project-switcher-{id}-{sanitizedName}
|
||||
await expect(page.locator(`[data-testid$="-${projectName}"]`)).toBeVisible({
|
||||
const sanitizedProjectName = sanitizeForTestId(projectName);
|
||||
await expect(page.locator(`[data-testid$="-${sanitizedProjectName}"]`)).toBeVisible({
|
||||
timeout: 15000,
|
||||
});
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
authenticateForTests,
|
||||
handleLoginScreenIfPresent,
|
||||
waitForNetworkIdle,
|
||||
sanitizeForTestId,
|
||||
} from '../utils';
|
||||
|
||||
// Create unique temp dir for this test run
|
||||
@@ -159,7 +160,8 @@ test.describe('Open Project', () => {
|
||||
// The project name appears in the project switcher button
|
||||
// Use ends-with selector since data-testid format is: project-switcher-{id}-{sanitizedName}
|
||||
if (targetProjectName) {
|
||||
await expect(page.locator(`[data-testid$="-${targetProjectName}"]`)).toBeVisible({
|
||||
const sanitizedName = sanitizeForTestId(targetProjectName);
|
||||
await expect(page.locator(`[data-testid$="-${sanitizedName}"]`)).toBeVisible({
|
||||
timeout: 15000,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user