tbonelee commented on code in PR #5100:
URL: https://github.com/apache/zeppelin/pull/5100#discussion_r2416158561
##########
zeppelin-web-angular/e2e/utils.ts:
##########
@@ -214,3 +215,23 @@ export async function waitForZeppelinReady(page: Page):
Promise<void> {
throw error instanceof Error ? error : new Error(`Zeppelin loading failed:
${String(error)}`);
}
}
+
+export async function createNotebookIfListEmpty(page: Page): Promise<void> {
Review Comment:
If my understanding is right, this function overlaps with the canonical
test-note helper, so we can drop it. (The other helper always creates a fresh
note; this one only does so conditionally.)
##########
zeppelin-web-angular/e2e/models/published-paragraph-page.util.ts:
##########
@@ -0,0 +1,243 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { expect, Page } from '@playwright/test';
+import { NotebookUtil } from './notebook.util';
+import { PublishedParagraphPage } from './published-paragraph-page';
+
+export class PublishedParagraphTestUtil {
+ private page: Page;
+ private publishedParagraphPage: PublishedParagraphPage;
+ private notebookUtil: NotebookUtil;
+
+ constructor(page: Page) {
+ this.page = page;
+ this.publishedParagraphPage = new PublishedParagraphPage(page);
+ this.notebookUtil = new NotebookUtil(page);
+ }
+
+ async testConfirmationModalForNoResultParagraph({
+ noteId,
+ paragraphId
+ }: {
+ noteId: string;
+ paragraphId: string;
+ }): Promise<void> {
+ await this.publishedParagraphPage.navigateToNotebook(noteId);
+
+ const paragraphElement =
this.page.locator('zeppelin-notebook-paragraph').first();
+
+ const settingsButton = paragraphElement.locator('a[nz-dropdown]');
+ await settingsButton.click();
+
+ const clearOutputButton = this.page.locator('li.list-item:has-text("Clear
output")');
+ await clearOutputButton.click();
+ await
expect(paragraphElement.locator('zeppelin-notebook-paragraph-result')).toBeHidden();
+
+ await this.publishedParagraphPage.navigateToPublishedParagraph(noteId,
paragraphId);
+
+ const modal = this.publishedParagraphPage.confirmationModal;
+ await expect(modal).toBeVisible();
+ await expect(this.publishedParagraphPage.modalTitle).toHaveText(
+ 'There is no result. Would you like to run this paragraph?'
+ );
+
+ await this.publishedParagraphPage.runButton.click();
+ await expect(modal).toBeHidden();
+ }
+
+ async verifyNonExistentParagraphError(validNoteId: string,
invalidParagraphId: string): Promise<void> {
+ await
this.publishedParagraphPage.navigateToPublishedParagraph(validNoteId,
invalidParagraphId);
+
+ const modal = this.page.locator('.ant-modal', { hasText: 'Paragraph Not
Found' }).last();
+ await expect(modal).toBeVisible({ timeout: 10000 });
+
+ await expect(modal).toContainText('Paragraph Not Found');
+
+ const content = await this.publishedParagraphPage.getErrorModalContent();
+ expect(content).toContain(invalidParagraphId);
+ expect(content).toContain('does not exist in notebook');
+ expect(content).toContain('redirected to the home page');
+
+ await this.publishedParagraphPage.clickErrorModalOk();
+
+ await expect(this.publishedParagraphPage.errorModal).toBeHidden();
+
+ expect(await this.publishedParagraphPage.isOnHomePage()).toBe(true);
+ }
+
+ async verifyClickLinkThisParagraphBehavior(noteId: string, paragraphId:
string): Promise<void> {
+ // 1. Navigate to the normal notebook view
+ await this.page.goto(`/#/notebook/${noteId}`);
+ await this.page.waitForLoadState('networkidle');
+
+ // 2. Find the correct paragraph result element and go up to the parent
paragraph container
+ const paragraphElement =
this.page.locator(`zeppelin-notebook-paragraph[data-testid="${paragraphId}"]`);
+ await expect(paragraphElement).toBeVisible();
+
+ // 3. Click the settings button to open the dropdown
+ const settingsButton = paragraphElement.locator('a[nz-dropdown]');
+ await settingsButton.click();
+
+ // 4. Click "Link this paragraph" in the dropdown menu
+ const linkParagraphButton = this.page.locator('li.list-item:has-text("Link
this paragraph")');
+ await expect(linkParagraphButton).toBeVisible();
+
+ // 5. Handle the new page/tab that opens
+ const [newPage] = await Promise.all([this.page.waitForEvent('popup'),
linkParagraphButton.click()]);
+ await newPage.waitForLoadState();
+
+ // 6. Verify the new page URL shows published paragraph (not redirected)
+ await expect(newPage).toHaveURL(new
RegExp(`/notebook/${noteId}/paragraph/${paragraphId}`), { timeout: 10000 });
+
+ const codeEditor =
newPage.locator('zeppelin-notebook-paragraph-code-editor');
+ await expect(codeEditor).toBeHidden();
+
+ const controlPanel =
newPage.locator('zeppelin-notebook-paragraph-control');
+ await expect(controlPanel).toBeHidden();
+ }
+
+ async openFirstNotebook(): Promise<{ noteId: string; paragraphId: string }> {
Review Comment:
We could remove this unused method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]