Skip to content

Commit 3dcb84d

Browse files
committed
add react relate test scenario
1 parent cd54756 commit 3dcb84d

File tree

2 files changed

+71
-3
lines changed

2 files changed

+71
-3
lines changed

zeppelin-web-angular/e2e/tests/notebook/published/published-paragraph.spec.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@ test.describe('Published Paragraph', () => {
9999
timeout: 10000
100100
});
101101
});
102+
103+
test('should enter published paragraph in React mode via URL with react=true', async ({ page }) => {
104+
await test.step('Given I navigate to React mode URL', async () => {
105+
const reactModeUrl = `/#/notebook/${testNotebook.noteId}/paragraph/${testNotebook.paragraphId}?react=true`;
106+
await page.goto(reactModeUrl);
107+
await waitForZeppelinReady(page);
108+
109+
// URL 이동 완료까지 명시적으로 대기
110+
await page.waitForURL(`**/${testNotebook.noteId}/paragraph/${testNotebook.paragraphId}*`, {
111+
timeout: 15000
112+
});
113+
});
114+
115+
await test.step('Then React mode should be active', async () => {
116+
const currentUrl = page.url();
117+
expect(currentUrl).toContain('react=true');
118+
});
119+
});
102120
});
103121

104122
test('should show confirmation modal and allow running the paragraph', async ({ page }) => {
@@ -138,4 +156,53 @@ test.describe('Published Paragraph', () => {
138156
await runButton.click();
139157
await expect(modal).toBeHidden();
140158
});
159+
160+
test('should show confirmation modal in React mode and allow running the paragraph', async ({ page }) => {
161+
const { noteId, paragraphId } = testNotebook;
162+
163+
await test.step('Given I clear paragraph output in normal notebook view', async () => {
164+
await publishedParagraphPage.navigateToNotebook(noteId);
165+
166+
const paragraphElement = page.locator('zeppelin-notebook-paragraph').first();
167+
const paragraphResult = paragraphElement.locator('zeppelin-notebook-paragraph-result');
168+
169+
// Only clear output if result exists
170+
if (await paragraphResult.isVisible()) {
171+
const settingsButton = paragraphElement.locator('a[nz-dropdown]');
172+
await settingsButton.click();
173+
174+
const clearOutputButton = page.locator('li.list-item:has-text("Clear output")');
175+
await clearOutputButton.click();
176+
await expect(paragraphResult).toBeHidden();
177+
}
178+
});
179+
180+
await test.step('When I navigate to React mode published paragraph URL', async () => {
181+
const reactModeUrl = `/#/notebook/${noteId}/paragraph/${paragraphId}?react=true`;
182+
await page.goto(reactModeUrl);
183+
await waitForZeppelinReady(page);
184+
185+
// Wait for React mode to load
186+
await page.waitForTimeout(2000);
187+
});
188+
189+
await test.step('Then confirmation modal should appear in React mode', async () => {
190+
const modal = publishedParagraphPage.confirmationModal;
191+
await expect(modal).toBeVisible({ timeout: 30000 });
192+
193+
// Check for the enhanced modal content
194+
await expect(publishedParagraphPage.modalTitle).toHaveText('Run Paragraph?');
195+
196+
// Verify that the modal shows code preview
197+
const modalContent = publishedParagraphPage.confirmationModal.locator('.ant-modal-confirm-content');
198+
await expect(modalContent).toContainText('This paragraph contains the following code:');
199+
await expect(modalContent).toContainText('Would you like to execute this code?');
200+
201+
// Click the Run button in the modal (OK button in confirmation modal)
202+
const runButton = modal.locator('.ant-modal-confirm-btns .ant-btn-primary');
203+
await expect(runButton).toBeVisible();
204+
await runButton.click();
205+
await expect(modal).toBeHidden();
206+
});
207+
});
141208
});

zeppelin-web-angular/src/app/pages/workspace/published/paragraph/paragraph.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,17 @@ export class PublishedParagraphComponent extends ParagraphBase implements Publis
9494
if (!isNil(note)) {
9595
this.paragraph = note.paragraphs.find(p => p.id === this.paragraphId);
9696
if (this.paragraph) {
97+
if (!this.paragraph.results) {
98+
this.showRunConfirmationModal();
99+
}
97100
if (this.useReact) {
98101
this.setResults(this.paragraph);
99102
this.isLoading = false;
100103
this.cdr.markForCheck();
101104
this.loadReactWidget();
102105
return;
103106
}
104-
if (!this.paragraph.results) {
105-
this.showRunConfirmationModal();
106-
}
107+
107108
this.setResults(this.paragraph);
108109
this.originalText = this.paragraph.text;
109110
this.initializeDefault(this.paragraph.config, this.paragraph.settings);

0 commit comments

Comments
 (0)