Skip to content

Commit cd08560

Browse files
gigaraclaude
andcommitted
fix(e2e): replace clickNextDiagramPlus with explicit diagram link indices
The default automation template wraps the function body in a do/on fail Error Handler block. clickNextDiagramPlus (hover-last-link strategy) was always landing on the function-level link AFTER the Error Handler, placing Match, Log Error, Log Warn, and While outside the do block — making count invisible to those nodes and causing "undefined symbol 'count'". Replace all four clickNextDiagramPlus calls with targeted actions: - Match: clickHoverAddButtonByIndex(5) — link after If, inside do block - Log Error: click last empty-node-add-button — Match 1=> clause is last - Log Warn: clickHoverAddButtonByIndex(7) — inside Match after Log Error - While: clickHoverAddButtonByIndex(6) — after Match, inside do block Remove the now-unused clickNextDiagramPlus helper entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 40be7f3 commit cd08560

1 file changed

Lines changed: 14 additions & 38 deletions

File tree

packages/ballerina-extension/e2e-test/e2e-playwright-tests/automation/flow-nodes.spec.ts

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -101,40 +101,6 @@ async function clickLinkButtonText(webview: Frame, text: string) {
101101
});
102102
}
103103

104-
// Real Playwright click on diagram add buttons. empty-node-add-button elements are
105-
// always visible (inside branches or at diagram end). For hover-only link-add-buttons
106-
// we hover each diagram link and wait for React to re-render before clicking.
107-
async function clickNextDiagramPlus(webview: Frame) {
108-
await webview.locator('[data-testid="bi-diagram-canvas"]').waitFor({ state: 'visible', timeout: 30000 });
109-
// Give React time to attach event handlers after the previous saveForm
110-
await page.page.waitForTimeout(1000);
111-
112-
// First try: always-visible add buttons (e.g. inside empty If/Match branches).
113-
// Only use this path when exactly one is present — with multiple buttons (e.g. two Match
114-
// clauses both empty) .first() would pick the wrong branch.
115-
const emptyButtons = webview.locator('[data-testid^="empty-node-add-button"]');
116-
if (await emptyButtons.count() === 1) {
117-
await emptyButtons.first().click({ force: true });
118-
await webview.getByTestId('side-panel').waitFor({ state: 'visible', timeout: 30000 });
119-
return;
120-
}
121-
122-
// Second try: hover each diagram link from last to first to reveal hover-only add buttons
123-
const links = webview.locator('[data-testid^="diagram-link-"]');
124-
const linkCount = await links.count();
125-
for (let i = linkCount - 1; i >= 0; i--) {
126-
await links.nth(i).hover({ force: true });
127-
await page.page.waitForTimeout(500);
128-
const addButton = webview.locator('[data-testid^="link-add-button-"]').last();
129-
if (await addButton.isVisible({ timeout: 300 }).catch(() => false)) {
130-
await addButton.click({ force: true });
131-
await webview.getByTestId('side-panel').waitFor({ state: 'visible', timeout: 30000 });
132-
return;
133-
}
134-
}
135-
136-
throw new Error('No diagram add button was available');
137-
}
138104

139105
export default function createTests() {
140106
test.describe.serial('Automation Flow Nodes Tests', {}, async () => {
@@ -224,15 +190,21 @@ export default function createTests() {
224190
await saveForm(artifactWebView);
225191

226192
logStep('Add Match node');
227-
await clickNextDiagramPlus(artifactWebView);
193+
// link-5 = after If, inside the do block (same sequential numbering as links 1-4)
194+
await diagram.clickHoverAddButtonByIndex(5);
195+
await artifactWebView.getByTestId('side-panel').waitFor({ state: 'visible', timeout: 30000 });
228196
await selectNode(sidePanel, 'Match', 'Control');
229197
await form.switchToFormView(false, artifactWebView);
230198
await fillCodeMirror(artifactWebView, 'count', 0);
231199
await fillCodeMirror(artifactWebView, '1', 1);
232200
await saveForm(artifactWebView);
233201

234202
logStep('Add Log Error node');
235-
await clickNextDiagramPlus(artifactWebView);
203+
// Match 1=> clause is the last empty-node-add-button (below If branches in the diagram)
204+
await artifactWebView.locator('[data-testid="bi-diagram-canvas"]').waitFor({ state: 'visible', timeout: 30000 });
205+
await page.page.waitForTimeout(1000);
206+
await artifactWebView.locator('[data-testid^="empty-node-add-button"]').last().click({ force: true });
207+
await artifactWebView.getByTestId('side-panel').waitFor({ state: 'visible', timeout: 30000 });
236208
await selectNode(sidePanel, 'Log Error', 'Logging');
237209
await form.switchToFormView(false, artifactWebView);
238210
await form.fill({
@@ -247,7 +219,9 @@ export default function createTests() {
247219
await saveForm(artifactWebView);
248220

249221
logStep('Add Log Warn node');
250-
await clickNextDiagramPlus(artifactWebView);
222+
// link-7 = inside Match 1=> clause, after Log Error (link-6 = after Match inside do)
223+
await diagram.clickHoverAddButtonByIndex(7);
224+
await artifactWebView.getByTestId('side-panel').waitFor({ state: 'visible', timeout: 30000 });
251225
await selectNode(sidePanel, 'Log Warn', 'Logging');
252226
await form.switchToFormView(false, artifactWebView);
253227
await form.fill({
@@ -262,7 +236,9 @@ export default function createTests() {
262236
await saveForm(artifactWebView);
263237

264238
logStep('Add While node');
265-
await clickNextDiagramPlus(artifactWebView);
239+
// link-6 = after Match inside the do block
240+
await diagram.clickHoverAddButtonByIndex(6);
241+
await artifactWebView.getByTestId('side-panel').waitFor({ state: 'visible', timeout: 30000 });
266242
await selectNode(sidePanel, 'While', 'Control');
267243
await form.switchToFormView(false, artifactWebView);
268244
await fillFirstCodeMirror(artifactWebView, 'count < 3');

0 commit comments

Comments
 (0)