fix: improve E2E test assertions and remove silent skips

- Replace silent test.skip() with explicit conditional skips
- Add actual persistence assertion after page reload
- Use data-testid selector for new chat button test
This commit is contained in:
dayuan.jiang
2026-01-04 23:05:31 +09:00
parent d517268dbe
commit 948cc4666d
3 changed files with 34 additions and 17 deletions

View File

@@ -68,9 +68,12 @@ test.describe("Copy/Paste Functionality", () => {
'[data-testid="copy-button"], button[aria-label*="Copy"], button:has(svg.lucide-copy), button:has(svg.lucide-clipboard)',
)
// Skip test if copy button doesn't exist
// Copy button feature may not exist in all versions - skip if not available
const buttonCount = await copyButton.count()
test.skip(buttonCount === 0, "Copy button not available")
if (buttonCount === 0) {
test.skip()
return
}
await copyButton.first().click()
// Should show copied confirmation (toast or button state change)
@@ -98,11 +101,14 @@ test.describe("Copy/Paste Functionality", () => {
await xmlToggle.first().click()
}
// Skip test if XML input feature doesn't exist
// XML input feature may not exist in all versions - skip if not available
const xmlInputCount = await xmlInput.count()
const isXmlVisible =
xmlInputCount > 0 && (await xmlInput.first().isVisible())
test.skip(!isXmlVisible, "XML input feature not available")
if (!isXmlVisible) {
test.skip()
return
}
const testXml = `<mxCell id="pasted" value="Pasted Node" style="rounded=1;fillColor=#d5e8d4;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="120" height="60" as="geometry"/>

View File

@@ -73,8 +73,13 @@ test.describe("File Upload", () => {
const removeButton = page.locator(
'[data-testid="remove-file-button"], button[aria-label*="Remove"], button:has(svg.lucide-x)',
)
// Remove button feature may not exist in all versions - skip if not available
const removeButtonCount = await removeButton.count()
test.skip(removeButtonCount === 0, "Remove file button not available")
if (removeButtonCount === 0) {
test.skip()
return
}
await removeButton.first().click()
// Verify button is gone or file preview is removed

View File

@@ -34,15 +34,10 @@ test.describe("History and Session Restore", () => {
})
// Find and click new chat button
const newChatButton = page.locator(
'[data-testid="new-chat-button"], button[aria-label*="New"], button:has(svg.lucide-plus), button:has-text("New Chat")',
)
const newChatButton = page.locator('[data-testid="new-chat-button"]')
await expect(newChatButton).toBeVisible({ timeout: 5000 })
// Skip test if new chat button doesn't exist
const buttonCount = await newChatButton.count()
test.skip(buttonCount === 0, "New chat button not available")
await newChatButton.first().click()
await newChatButton.click()
// Conversation should be cleared
await expect(
@@ -61,9 +56,12 @@ test.describe("History and Session Restore", () => {
'button[aria-label*="History"]:not([disabled]), button:has(svg.lucide-history):not([disabled]), button:has(svg.lucide-menu):not([disabled]), button:has(svg.lucide-sidebar):not([disabled]), button:has(svg.lucide-panel-left):not([disabled])',
)
// Skip test if history button doesn't exist
// History feature may not exist in all versions - skip if not available
const buttonCount = await historyButton.count()
test.skip(buttonCount === 0, "History button not available")
if (buttonCount === 0) {
test.skip()
return
}
await historyButton.first().click()
// Wait for sidebar/panel to appear or verify page still works
@@ -111,6 +109,11 @@ test.describe("History and Session Restore", () => {
await expect(
page.locator('textarea[aria-label="Chat input"]'),
).toBeVisible({ timeout: 10000 })
// Verify the message persisted after reload
await expect(
page.locator('text="This message should persist."'),
).toBeVisible({ timeout: 10000 })
})
test("diagram state persists after reload", async ({ page }) => {
@@ -243,9 +246,12 @@ test.describe("History and Session Restore", () => {
'button[aria-label*="Model"], [data-testid="model-selector"], button:has-text("Claude")',
)
// Skip test if model selector doesn't exist
// Model selector feature may not exist in all versions - skip if not available
const selectorCount = await modelSelector.count()
test.skip(selectorCount === 0, "Model selector not available")
if (selectorCount === 0) {
test.skip()
return
}
const initialModel = await modelSelector.first().textContent()