|
5 | 5 | * environment with those deps installed (via rattler, not the prewarmed pool). |
6 | 6 | * |
7 | 7 | * Fixture: 3-conda-inline.ipynb (has markupsafe dependency via conda) |
| 8 | + * |
| 9 | + * Updated to use setCellSource + explicit button clicks for compatibility |
| 10 | + * with tauri-plugin-webdriver (synthetic keyboard events don't work). |
8 | 11 | */ |
9 | 12 |
|
10 | 13 | import { browser } from "@wdio/globals"; |
11 | 14 | import { |
12 | 15 | approveTrustDialog, |
13 | | - executeFirstCell, |
14 | | - typeSlowly, |
| 16 | + setCellSource, |
15 | 17 | waitForCellOutput, |
16 | 18 | waitForKernelReady, |
| 19 | + waitForNotebookSynced, |
17 | 20 | } from "../helpers.js"; |
18 | 21 |
|
19 | 22 | describe("Conda Inline Dependencies", () => { |
20 | 23 | it("should auto-launch kernel (may need trust approval)", async () => { |
21 | | - // Wait for kernel or trust dialog (120s for first startup + conda env creation) |
22 | | - await waitForKernelReady(180000); |
| 24 | + console.log("[conda-inline] Waiting for kernel ready (up to 300s)..."); |
| 25 | + // Wait for kernel or trust dialog (300s for first startup + conda env creation) |
| 26 | + await waitForKernelReady(300000); |
| 27 | + console.log("[conda-inline] Kernel is ready"); |
| 28 | + }); |
| 29 | + |
| 30 | + it("should show conda badge in toolbar", async () => { |
| 31 | + const depsToggle = await $('[data-testid="deps-toggle"]'); |
| 32 | + await depsToggle.waitForExist({ timeout: 10000 }); |
| 33 | + |
| 34 | + // env-manager syncs from RuntimeStateDoc after kernel launch — poll for it |
| 35 | + await browser.waitUntil( |
| 36 | + async () => { |
| 37 | + const mgr = await depsToggle.getAttribute("data-env-manager"); |
| 38 | + return mgr === "conda"; |
| 39 | + }, |
| 40 | + { |
| 41 | + timeout: 30000, |
| 42 | + interval: 500, |
| 43 | + timeoutMsg: "Expected conda badge never appeared", |
| 44 | + }, |
| 45 | + ); |
| 46 | + |
| 47 | + expect(await depsToggle.getAttribute("data-env-manager")).toBe("conda"); |
| 48 | + expect(await depsToggle.getAttribute("data-runtime")).toBe("python"); |
| 49 | + console.log("[conda-inline] Conda badge verified in toolbar"); |
23 | 50 | }); |
24 | 51 |
|
25 | 52 | it("should have inline deps available after trust", async () => { |
26 | | - // Execute the first cell (prints sys.executable) |
27 | | - const cell = await executeFirstCell(); |
| 53 | + console.log("[conda-inline] Waiting for notebook to sync..."); |
| 54 | + await waitForNotebookSynced(); |
| 55 | + |
| 56 | + // Find the first code cell |
| 57 | + const codeCell = await $('[data-cell-type="code"]'); |
| 58 | + await codeCell.waitForExist({ timeout: 10000 }); |
| 59 | + console.log("[conda-inline] Found first code cell"); |
| 60 | + |
| 61 | + // Set the cell source via CodeMirror dispatch (bypasses keyboard events) |
| 62 | + await setCellSource(codeCell, "import sys; print(sys.executable)"); |
| 63 | + console.log("[conda-inline] Set cell source via setCellSource"); |
| 64 | + |
| 65 | + // Click the execute button |
| 66 | + const executeButton = await codeCell.$('[data-testid="execute-button"]'); |
| 67 | + await executeButton.waitForClickable({ timeout: 5000 }); |
| 68 | + await executeButton.click(); |
| 69 | + console.log("[conda-inline] Clicked execute button"); |
28 | 70 |
|
29 | 71 | // May need to approve trust dialog for inline deps |
30 | 72 | const approved = await approveTrustDialog(15000); |
31 | 73 | if (approved) { |
| 74 | + console.log( |
| 75 | + "[conda-inline] Trust dialog approved, waiting for kernel restart...", |
| 76 | + ); |
32 | 77 | // If trust dialog appeared, wait for kernel to restart with deps |
33 | | - await waitForKernelReady(180000); |
34 | | - // Re-execute after kernel restart |
35 | | - await browser.keys(["Shift", "Enter"]); |
| 78 | + await waitForKernelReady(300000); |
| 79 | + console.log("[conda-inline] Kernel restarted after trust approval"); |
| 80 | + |
| 81 | + // Re-execute after kernel restart by clicking the button again |
| 82 | + const reExecuteButton = await codeCell.$( |
| 83 | + '[data-testid="execute-button"]', |
| 84 | + ); |
| 85 | + await reExecuteButton.waitForClickable({ timeout: 5000 }); |
| 86 | + await reExecuteButton.click(); |
| 87 | + console.log("[conda-inline] Re-executed cell after kernel restart"); |
36 | 88 | } |
37 | 89 |
|
38 | 90 | // Wait for output |
39 | | - const output = await waitForCellOutput(cell, 120000); |
| 91 | + const output = await waitForCellOutput(codeCell, 120000); |
| 92 | + console.log(`[conda-inline] Cell output: ${output}`); |
40 | 93 |
|
41 | 94 | // Should be a cached conda inline env (conda-inline-* path) |
42 | 95 | expect(output).toContain("conda-inline-"); |
43 | 96 | }); |
44 | 97 |
|
45 | 98 | it("should be able to import inline dependency", async () => { |
46 | | - // Find a cell and type import test |
| 99 | + // Find the cells — use a second cell if available, otherwise the first |
47 | 100 | const cells = await $$('[data-cell-type="code"]'); |
48 | 101 | const cell = cells.length > 1 ? cells[1] : cells[0]; |
| 102 | + console.log( |
| 103 | + `[conda-inline] Using cell index ${cells.length > 1 ? 1 : 0} for import test`, |
| 104 | + ); |
49 | 105 |
|
50 | | - const editor = await cell.$('.cm-content[contenteditable="true"]'); |
51 | | - await editor.click(); |
52 | | - await browser.pause(200); |
| 106 | + // Set the cell source directly via CodeMirror dispatch |
| 107 | + await setCellSource( |
| 108 | + cell, |
| 109 | + "import markupsafe; print(markupsafe.__version__)", |
| 110 | + ); |
| 111 | + console.log("[conda-inline] Set import test source via setCellSource"); |
53 | 112 |
|
54 | | - // Select all and type import |
55 | | - const modKey = process.platform === "darwin" ? "Meta" : "Control"; |
56 | | - await browser.keys([modKey, "a"]); |
57 | | - await browser.pause(100); |
58 | | - |
59 | | - await typeSlowly("import markupsafe; print(markupsafe.__version__)"); |
60 | | - await browser.keys(["Shift", "Enter"]); |
| 113 | + // Click the execute button |
| 114 | + const executeButton = await cell.$('[data-testid="execute-button"]'); |
| 115 | + await executeButton.waitForClickable({ timeout: 5000 }); |
| 116 | + await executeButton.click(); |
| 117 | + console.log("[conda-inline] Clicked execute button for import test"); |
61 | 118 |
|
62 | 119 | // Wait for version output |
63 | 120 | const output = await waitForCellOutput(cell, 30000); |
| 121 | + console.log(`[conda-inline] Import test output: ${output}`); |
| 122 | + |
64 | 123 | // Should show a version number (e.g., "1.26.4") |
65 | 124 | expect(output).toMatch(/^\d+\.\d+/); |
66 | 125 | }); |
|
0 commit comments