Skip to content

Commit 91042fb

Browse files
dididyjongyoul
authored andcommitted
fix broken tests
1 parent 968b503 commit 91042fb

3 files changed

Lines changed: 43 additions & 66 deletions

File tree

zeppelin-web-angular/e2e/models/base-page.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,11 @@ export class BasePage {
104104
await expect(locator).toBeVisible({ timeout });
105105
await expect(locator).toBeEnabled({ timeout: 5000 });
106106

107-
// Click first so Angular's form control is focused and its initial setValue cycle
108-
// has completed before we overwrite it. Then fill() atomically sets the value.
107+
// Click first so Angular's form control is focused.
108+
// Then wait for Angular's async setValue cycle (e.g. "Untitled Note 1") to settle
109+
// before overwriting — otherwise Angular can clobber our fill() value.
109110
await locator.click();
111+
await expect(locator).not.toHaveValue('', { timeout: 5000 });
110112
await locator.fill(value);
111113
await expect(locator).toHaveValue(value, { timeout: 10000 });
112114
}

zeppelin-web-angular/e2e/models/notebook-keyboard-page.ts

Lines changed: 37 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ export class NotebookKeyboardPage extends BasePage {
450450
const runningIndicator = paragraph.locator(
451451
'.paragraph-control .fa-spin, .running-indicator, .paragraph-status-running'
452452
);
453-
await this.waitForExecutionComplete(runningIndicator, paragraphIndex, timeout);
453+
await this.waitForExecutionComplete(runningIndicator, timeout);
454454

455455
// Step 3: Wait for result to be visible
456456
await this.waitForResultVisible(paragraphIndex, timeout);
@@ -565,81 +565,57 @@ export class NotebookKeyboardPage extends BasePage {
565565
}
566566

567567
private async waitForExecutionStart(paragraphIndex: number): Promise<void> {
568-
const started = await this.page
569-
.waitForFunction(
570-
// waitForFunction executes in browser context, not Node.js context.
571-
// Browser cannot access Node.js variables like PARAGRAPH_RESULT_SELECTOR.
572-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
573-
([index, selector]: any[]) => {
574-
const paragraphs = document.querySelectorAll('zeppelin-notebook-paragraph'); // JUSTIFIED: index-based paragraph lookup with sub-element checks not expressible via Playwright locator API
575-
const targetParagraph = paragraphs[index];
576-
if (!targetParagraph) {
577-
return false;
578-
}
568+
await this.page.waitForFunction(
569+
// waitForFunction executes in browser context, not Node.js context.
570+
// Browser cannot access Node.js variables like PARAGRAPH_RESULT_SELECTOR.
571+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
572+
([index, selector]: any[]) => {
573+
const paragraphs = document.querySelectorAll('zeppelin-notebook-paragraph'); // JUSTIFIED: index-based paragraph lookup with sub-element checks not expressible via Playwright locator API
574+
const targetParagraph = paragraphs[index];
575+
if (!targetParagraph) {
576+
return false;
577+
}
579578

580-
const hasRunning = targetParagraph.querySelector('.fa-spin, .running-indicator, .paragraph-status-running');
581-
const hasResult = targetParagraph.querySelector(selector);
582-
583-
return hasRunning || hasResult;
584-
},
585-
[paragraphIndex, PARAGRAPH_RESULT_SELECTOR],
586-
{ timeout: 8000 }
587-
)
588-
.catch(() => false); // JUSTIFIED: execution may not start within timeout; caller falls back to checking existing result
589-
590-
if (!started) {
591-
const paragraph = this.getParagraphByIndex(paragraphIndex);
592-
const existingResult = await paragraph.locator(PARAGRAPH_RESULT_SELECTOR).isVisible();
593-
if (!existingResult) {
594-
console.log(`Warning: Could not detect execution start for paragraph ${paragraphIndex}`);
595-
}
596-
}
579+
const hasRunning = targetParagraph.querySelector('.fa-spin, .running-indicator, .paragraph-status-running');
580+
const hasResult = targetParagraph.querySelector(selector);
581+
582+
return hasRunning || hasResult;
583+
},
584+
[paragraphIndex, PARAGRAPH_RESULT_SELECTOR],
585+
{ timeout: 30000 }
586+
);
597587
}
598588

599-
private async waitForExecutionComplete(
600-
runningIndicator: Locator,
601-
paragraphIndex: number,
602-
timeout: number
603-
): Promise<void> {
589+
private async waitForExecutionComplete(runningIndicator: Locator, timeout: number): Promise<void> {
604590
if (this.page.isClosed()) {
605591
return;
606592
}
607593

608-
await runningIndicator.waitFor({ state: 'detached', timeout: timeout / 2 }).catch(() => {}); // JUSTIFIED: UI stabilization — paragraph may have completed before indicator appeared
594+
await runningIndicator.waitFor({ state: 'detached', timeout });
609595
}
610596

611597
private async waitForResultVisible(paragraphIndex: number, timeout: number): Promise<void> {
612598
if (this.page.isClosed()) {
613599
return;
614600
}
615601

616-
const resultVisible = await this.page
617-
.waitForFunction(
618-
// waitForFunction executes in browser context, not Node.js context.
619-
// Browser cannot access Node.js variables like PARAGRAPH_RESULT_SELECTOR.
620-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
621-
([index, selector]: any[]) => {
622-
const paragraphs = document.querySelectorAll('zeppelin-notebook-paragraph'); // JUSTIFIED: index-based paragraph lookup with sub-element checks not expressible via Playwright locator API
623-
const targetParagraph = paragraphs[index];
624-
if (!targetParagraph) {
625-
return false;
626-
}
602+
await this.page.waitForFunction(
603+
// waitForFunction executes in browser context, not Node.js context.
604+
// Browser cannot access Node.js variables like PARAGRAPH_RESULT_SELECTOR.
605+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
606+
([index, selector]: any[]) => {
607+
const paragraphs = document.querySelectorAll('zeppelin-notebook-paragraph'); // JUSTIFIED: index-based paragraph lookup with sub-element checks not expressible via Playwright locator API
608+
const targetParagraph = paragraphs[index];
609+
if (!targetParagraph) {
610+
return false;
611+
}
627612

628-
const result = targetParagraph.querySelector(selector);
629-
return result && getComputedStyle(result).display !== 'none';
630-
},
631-
[paragraphIndex, PARAGRAPH_RESULT_SELECTOR],
632-
{ timeout: Math.min(timeout / 2, 15000) }
633-
)
634-
.catch(() => false); // JUSTIFIED: result may not appear within timeout; caller checks existence separately
635-
636-
if (!resultVisible) {
637-
const paragraph = this.getParagraphByIndex(paragraphIndex);
638-
const resultExists = await paragraph.locator(PARAGRAPH_RESULT_SELECTOR).isVisible();
639-
if (!resultExists) {
640-
console.log(`Warning: No result found for paragraph ${paragraphIndex} after execution`);
641-
}
642-
}
613+
const result = targetParagraph.querySelector(selector);
614+
return result && getComputedStyle(result).display !== 'none';
615+
},
616+
[paragraphIndex, PARAGRAPH_RESULT_SELECTOR],
617+
{ timeout }
618+
);
643619
}
644620

645621
private async focusEditorElement(paragraph: Locator, paragraphIndex: number): Promise<void> {

zeppelin-web-angular/e2e/tests/notebook/keyboard/notebook-keyboard-shortcuts.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,11 @@ test.describe.serial('Comprehensive Keyboard Shortcuts (ShortcutsMap)', () => {
8585
// When: User presses Shift+Enter
8686
await keyboardPage.pressRunParagraph();
8787

88-
// Then: Paragraph should execute (reach a terminal state — interpreter availability varies by env)
88+
// Then: Paragraph should execute (reach a terminal state)
8989
await keyboardPage.waitForParagraphExecution(0);
9090
// JUSTIFIED: single-paragraph test notebook; first() is deterministic
9191
const statusEl = keyboardPage.paragraphContainer.first().locator('.status');
92-
const statusText = (await statusEl.textContent({ timeout: 30000 }))?.trim();
93-
expect(statusText === 'FINISHED' || statusText === 'ERROR' || statusText === 'ABORT').toBe(true);
92+
await expect(statusEl).toHaveText(/FINISHED|ERROR|ABORT/, { timeout: 60000 });
9493
});
9594
});
9695

0 commit comments

Comments
 (0)