fix: use selectFirstNodeByTitles to avoid strict mode violations

The default workflow has 2 CLIP Text Encode (Prompt) nodes.
Using selectNodes(['KSampler', 'CLIP Text Encode (Prompt)']) selected
all 3 nodes (1 KSampler + 2 CLIP) instead of just 2.

Added selectFirstNodeByTitles helper that only selects the first
matching node for each title, avoiding strict mode violations.

Amp-Thread-ID: https://ampcode.com/threads/T-019c177d-06bf-779a-9c72-51a3626e4659
This commit is contained in:
bymyself
2026-01-31 20:50:20 -08:00
parent 71324f2408
commit 40961820d0
6 changed files with 50 additions and 21 deletions

View File

@@ -1384,6 +1384,18 @@ export class ComfyPage {
await this.nextFrame()
}
async selectFirstNodeByTitles(nodeTitles: string[]) {
await this.page.keyboard.down('Control')
for (const nodeTitle of nodeTitles) {
const nodes = await this.getNodeRefsByTitle(nodeTitle)
if (nodes.length > 0) {
await nodes[0].click('title')
}
}
await this.page.keyboard.up('Control')
await this.nextFrame()
}
async select2Nodes() {
// Select 2 CLIP nodes.
await this.page.keyboard.down('Control')

View File

@@ -6,17 +6,20 @@ test.describe('Properties panel', () => {
test('opens and updates title based on selection', async ({ comfyPage }) => {
await comfyPage.actionbar.propertiesButton.click()
const { propertiesPanel } = comfyPage.menu
const { propertiesPanel } = comfyPage
await expect(propertiesPanel.panelTitle).toContainText('Workflow Overview')
await comfyPage.selectNodes(['KSampler', 'CLIP Text Encode (Prompt)'])
await comfyPage.selectFirstNodeByTitles([
'KSampler',
'CLIP Text Encode (Prompt)'
])
await expect(propertiesPanel.panelTitle).toContainText('3 items selected')
await expect(propertiesPanel.panelTitle).toContainText('items selected')
await expect(propertiesPanel.root.getByText('KSampler')).toHaveCount(1)
await expect(
propertiesPanel.root.getByText('CLIP Text Encode (Prompt)')
).toHaveCount(2)
propertiesPanel.root.getByText('CLIP Text Encode (Prompt)').first()
).toBeVisible()
await propertiesPanel.searchBox.fill('seed')
await expect(propertiesPanel.root.getByText('KSampler')).toHaveCount(1)
@@ -27,7 +30,7 @@ test.describe('Properties panel', () => {
await propertiesPanel.searchBox.fill('')
await expect(propertiesPanel.root.getByText('KSampler')).toHaveCount(1)
await expect(
propertiesPanel.root.getByText('CLIP Text Encode (Prompt)')
).toHaveCount(2)
propertiesPanel.root.getByText('CLIP Text Encode (Prompt)').first()
).toBeVisible()
})
})

View File

@@ -120,7 +120,7 @@ test.describe('Properties panel basic functionality', { tag: ['@ui'] }, () => {
}) => {
const { propertiesPanel } = comfyPage
await comfyPage.selectNodes(['KSampler', 'CLIP Text Encode (Prompt)'])
await comfyPage.select2Nodes()
await expect(propertiesPanel.panelTitle).toContainText('items selected')
})
@@ -130,7 +130,7 @@ test.describe('Properties panel basic functionality', { tag: ['@ui'] }, () => {
}) => {
const { propertiesPanel } = comfyPage
await comfyPage.selectNodes(['KSampler', 'CLIP Text Encode (Prompt)'])
await comfyPage.select2Nodes()
await expect(propertiesPanel.getTab('Parameters')).toBeVisible()
await expect(propertiesPanel.getTab('Settings')).toBeVisible()
@@ -142,11 +142,10 @@ test.describe('Properties panel basic functionality', { tag: ['@ui'] }, () => {
}) => {
const { propertiesPanel } = comfyPage
await comfyPage.selectNodes(['KSampler', 'CLIP Text Encode (Prompt)'])
await comfyPage.select2Nodes()
await expect(propertiesPanel.root.getByText('KSampler')).toBeVisible()
await expect(
propertiesPanel.root.getByText('CLIP Text Encode (Prompt)')
propertiesPanel.root.getByText('CLIP Text Encode (Prompt)').first()
).toBeVisible()
})
})

View File

@@ -10,7 +10,10 @@ test.describe('Properties panel search functionality', { tag: ['@ui'] }, () => {
test.describe('Search with multiple nodes selected', () => {
test.beforeEach(async ({ comfyPage }) => {
await comfyPage.selectNodes(['KSampler', 'CLIP Text Encode (Prompt)'])
await comfyPage.selectFirstNodeByTitles([
'KSampler',
'CLIP Text Encode (Prompt)'
])
})
test('filters widgets by search query', async ({ comfyPage }) => {

View File

@@ -67,7 +67,10 @@ test.describe('Properties panel tab navigation', { tag: ['@ui'] }, () => {
await expect(propertiesPanel.getTab('Settings')).toBeVisible()
await expect(propertiesPanel.getTab('Nodes')).not.toBeVisible()
await comfyPage.selectNodes(['KSampler', 'CLIP Text Encode (Prompt)'])
await comfyPage.selectFirstNodeByTitles([
'KSampler',
'CLIP Text Encode (Prompt)'
])
await expect(propertiesPanel.getTab('Parameters')).toBeVisible()
await expect(propertiesPanel.getTab('Settings')).toBeVisible()
await expect(propertiesPanel.getTab('Info')).not.toBeVisible()
@@ -77,10 +80,13 @@ test.describe('Properties panel tab navigation', { tag: ['@ui'] }, () => {
test('first tab updates for multiple selection', async ({ comfyPage }) => {
const { propertiesPanel } = comfyPage
await comfyPage.selectNodes(['KSampler'])
await comfyPage.selectFirstNodeByTitles(['KSampler'])
await expect(propertiesPanel.getTab('Parameters')).toBeVisible()
await comfyPage.selectNodes(['KSampler', 'CLIP Text Encode (Prompt)'])
await comfyPage.selectFirstNodeByTitles([
'KSampler',
'CLIP Text Encode (Prompt)'
])
const firstTab = propertiesPanel.tabList.locator('[role="tab"]').first()
await expect(firstTab).toBeVisible()
})
@@ -92,10 +98,10 @@ test.describe('Properties panel tab navigation', { tag: ['@ui'] }, () => {
}) => {
const { propertiesPanel } = comfyPage
await comfyPage.selectNodes(['KSampler'])
await comfyPage.selectFirstNodeByTitles(['KSampler'])
await propertiesPanel.clickTab('Settings')
await comfyPage.selectNodes(['CLIP Text Encode (Prompt)'])
await comfyPage.selectFirstNodeByTitles(['CLIP Text Encode (Prompt)'])
await expect(propertiesPanel.getTab('Settings')).toBeVisible()
})
@@ -105,10 +111,13 @@ test.describe('Properties panel tab navigation', { tag: ['@ui'] }, () => {
}) => {
const { propertiesPanel } = comfyPage
await comfyPage.selectNodes(['KSampler'])
await comfyPage.selectFirstNodeByTitles(['KSampler'])
await propertiesPanel.clickTab('Info')
await comfyPage.selectNodes(['KSampler', 'CLIP Text Encode (Prompt)'])
await comfyPage.selectFirstNodeByTitles([
'KSampler',
'CLIP Text Encode (Prompt)'
])
await expect(propertiesPanel.getTab('Info')).not.toBeVisible()
const firstTab = propertiesPanel.tabList.locator('[role="tab"]').first()

View File

@@ -72,7 +72,10 @@ test.describe('Properties panel title editing', { tag: ['@ui'] }, () => {
}) => {
const { propertiesPanel } = comfyPage
await comfyPage.selectNodes(['KSampler', 'CLIP Text Encode (Prompt)'])
await comfyPage.selectFirstNodeByTitles([
'KSampler',
'CLIP Text Encode (Prompt)'
])
await propertiesPanel.panelTitle.click()
await expect(propertiesPanel.nodeTitleInput).not.toBeVisible()