Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ repos:
name: "Run typos through pixi"
entry: pixi run check-typos
language: system
exclude: "^.*\\.png"
- id: pixi-mypy
name: "Run mypy through pixi"
entry: pixi run check-mypy
Expand Down
3 changes: 2 additions & 1 deletion src/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ abstract class InfoOnlyToolbar extends Widget {

const div = document.createElement("div");
div.className = "toolbar-group-cols-rows";
div.setAttribute("data-testid", "toolbar-group-cols-rows");
const labelCols = document.createElement("span");
const labelRows = document.createElement("span");

Expand Down Expand Up @@ -105,9 +106,9 @@ abstract class DropdownToolbar extends InfoOnlyToolbar {
select.appendChild(option);
}
selectDiv.appendChild(label);

const node = Styling.wrapSelect(select);
node.classList.add("toolbar-dropdown");
node.setAttribute("data-testid", "toolbar-dropdown");
selectDiv.appendChild(node);
return selectDiv;
}
Expand Down
66 changes: 64 additions & 2 deletions ui-tests/tests/arbalister.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
import { expect, test } from "@jupyterlab/galata";
import { expect, galata, type IJupyterLabPageFixture, test } from "@jupyterlab/galata";

import path from "node:path";

async function openFile(page: IJupyterLabPageFixture, filename: string) {
await page.goto();
const tmpPath = "arbalister-viewer-tests";
const target = `${tmpPath}/${filename}`;
await page.notebook.openByPath(target);
await page.notebook.activate(target);
await page.waitForTimeout(10000);
}

async function checkFile(page: IJupyterLabPageFixture, filename: string, snapshotFile: string) {
await openFile(page, filename);
expect(await page.screenshot()).toMatchSnapshot({
name: snapshotFile,
maxDiffPixelRatio: 0.02,
});
}

async function checkToolbar(page: IJupyterLabPageFixture) {
const text = page.getByTestId(`toolbar-group-cols-rows`);
await expect(text).toBeVisible();

const rows = page.locator(".toolbar-group-cols-rows .toolbar-label:not(.cols)");
await expect(rows).toHaveText("3 rows;");

const cols = page.locator(".toolbar-group-cols-rows .toolbar-label.cols");
await expect(cols).toHaveText("3 columns");
}

/**
* Don't load JupyterLab webpage before running the tests.
* This is required to ensure we capture all log messages.
*/
test.use({ autoGoto: false });
test.use({ autoGoto: false, tmpPath: "arbalister-viewer-tests" });

test("should emit an activation console message", async ({ page }) => {
const logs: string[] = [];
Expand All @@ -17,3 +47,35 @@ test("should emit an activation console message", async ({ page }) => {

expect(logs.filter((s) => s === "Launching JupyterLab extension arbalister")).toHaveLength(1);
});

test.describe
.serial("Arbalister Viewer", () => {
test.beforeAll(async ({ request, tmpPath }) => {
const contents = galata.newContentsHelper(request);
await contents.uploadFile(
path.resolve(__dirname, `./test-files/test.csv`),
`${tmpPath}/test.csv`,
);

await contents.uploadFile(
path.resolve(__dirname, `./test-files/test.parquet`),
`${tmpPath}/test.parquet`,
);
});

test.afterAll(async ({ request, tmpPath }) => {
const contents = galata.newContentsHelper(request);
await contents.deleteDirectory(tmpPath);
});

test("open csv file and change a delimiter", async ({ page }) => {
await checkFile(page, "test.csv", "arbalister_viewer_csv.png");
await page.notebook.close(true);
});

test("open parquet file", async ({ page }) => {
await checkFile(page, "test.parquet", "arbalister_viewer_parquet.png");
await checkToolbar(page);
await page.notebook.close(true);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions ui-tests/tests/test-files/test.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,flag,score
1,True,12.0
2,False,65.0
3,True,38.2
Binary file added ui-tests/tests/test-files/test.parquet
Binary file not shown.
Loading