Skip to content

Commit

Permalink
Upgrade newly added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed Aug 25, 2021
1 parent e5f8e22 commit f000590
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 107 deletions.
5 changes: 2 additions & 3 deletions galata/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jupyterlab/galata",
"version": "3.3.0-alpha.4",
"version": "4.3.0-alpha.4",
"description": "JupyterLab UI Testing Framework",
"homepage": "https://github.com/jupyterlab/galata",
"bugs": {
Expand Down Expand Up @@ -33,7 +33,6 @@
"build:galata": "tsc -b",
"build:inpage": "webpack --mode=production",
"clean": "rimraf lib tsconfig.tsbuildinfo",
"prepublishOnly": "npm run build",
"start": "jupyter lab --config ./jupyter_server_config.py",
"start:detached": "(yarn run start&)",
"test": "playwright test",
Expand All @@ -51,7 +50,7 @@
"@jupyterlab/services": "^6.3.0-alpha.4",
"@jupyterlab/settingregistry": "^3.3.0-alpha.4",
"@lumino/algorithm": "^1.3.3",
"@playwright/test": "1.14.0",
"@playwright/test": "1.14.1",
"fs-extra": "^9.0.1",
"http-server": "^13.0.0",
"json5": "^2.1.1",
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 18 additions & 66 deletions galata/test/jupyterlab/notebook-markdown.test.ts
Original file line number Diff line number Diff line change
@@ -1,83 +1,35 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { describe, galata, test } from '@jupyterlab/galata';
import { test } from '@jupyterlab/galata';
import { expect } from '@playwright/test';
import * as path from 'path';

const fileName = 'markdown_notebook.ipynb';

jest.setTimeout(60000);

describe('Notebook Markdown', () => {
beforeAll(async () => {
await galata.resetUI();
galata.context.capturePrefix = 'notebook-markdown';
});

afterAll(() => {
galata.context.capturePrefix = '';
});

test('Upload files to JupyterLab', async () => {
await galata.contents.moveFileToServer(
test.describe('Notebook Markdown', () => {
test.beforeEach(async ({ page, tmpPath }) => {
await page.contents.uploadFile(
path.resolve(__dirname, `./notebooks/${fileName}`),
`uploaded/${fileName}`
`${tmpPath}/${fileName}`
);
expect(
await galata.contents.fileExists(`uploaded/${fileName}`)
).toBeTruthy();
});

test('Refresh File Browser', async () => {
await expect(galata.filebrowser.refresh()).resolves.toBeUndefined();
});

test('Open directory uploaded', async () => {
await galata.filebrowser.openDirectory('uploaded');
expect(
await galata.filebrowser.isFileListedInBrowser(fileName)
).toBeTruthy();
});
test('Highlight LaTeX syntax', async ({ page, tmpPath }) => {
await page.notebook.openByPath(`${tmpPath}/${fileName}`);
const imageName = 'highlight-latex.png';
await page.notebook.enterCellEditingMode(0);
const cell = await page.notebook.getCell(0);

test('Open Notebook', async () => {
await galata.notebook.open(fileName);
expect(await galata.notebook.isOpen(fileName)).toBeTruthy();
await galata.notebook.activate(fileName);
expect(await galata.notebook.isActive(fileName)).toBeTruthy();
expect(await cell.screenshot()).toMatchSnapshot(imageName);
});

test('Highlight LaTeX syntax', async () => {
const imageName = 'highlight-latex';
await galata.notebook.enterCellEditingMode(0);
const cell = await galata.notebook.getCell(0);
await galata.capture.screenshot(imageName, cell);
expect(await galata.capture.compareScreenshot(imageName)).toBe('same');
});
test('Do not highlight non-LaTeX syntax', async ({ page, tmpPath }) => {
await page.notebook.openByPath(`${tmpPath}/${fileName}`);

test('Do not highlight non-LaTeX syntax', async () => {
const imageName = 'do-not-highlight-not-latex';
await galata.notebook.enterCellEditingMode(1);
const cell = await galata.notebook.getCell(1);
await galata.capture.screenshot(imageName, cell);
expect(await galata.capture.compareScreenshot(imageName)).toBe('same');
});

test('Close Notebook', async () => {
await expect(galata.notebook.activate(fileName)).resolves.toEqual(true);
await expect(galata.notebook.close(true)).resolves.toEqual(true);
});

test('Open home directory', async () => {
await galata.sidebar.openTab('filebrowser');
await expect(galata.sidebar.isTabOpen('filebrowser')).resolves.toEqual(
true
);
await expect(galata.filebrowser.openHomeDirectory()).resolves.toEqual(true);
});

test('Delete uploaded directory', async () => {
await expect(galata.contents.deleteDirectory('uploaded')).resolves.toEqual(
true
);
const imageName = 'do-not-highlight-not-latex.png';
await page.notebook.enterCellEditingMode(1);
const cell = await page.notebook.getCell(1);
expect(await cell.screenshot()).toMatchSnapshot(imageName);
});
});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 18 additions & 34 deletions galata/test/jupyterlab/texteditor.test.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { describe, galata, test } from '@jupyterlab/galata';

jest.setTimeout(60000);
import { test } from '@jupyterlab/galata';
import { expect } from '@playwright/test';

const DEFAULT_NAME = 'untitled.txt';

describe('Text Editor Tests', () => {
beforeAll(async () => {
await galata.resetUI();
galata.context.capturePrefix = 'text-editor';
});
test.describe('Text Editor Tests', () => {
test('Open a text editor', async ({ page }) => {
const imageName = 'text-editor.png';
await page.menu.clickMenuItem('File>New>Text File');

afterAll(async () => {
galata.context.capturePrefix = '';
await page.waitForSelector(`[role="main"] >> text=${DEFAULT_NAME}`);

const tabHandle = await page.activity.getPanel(DEFAULT_NAME);
expect(await tabHandle.screenshot()).toMatchSnapshot(imageName);
});

test('Open a text editor', async () => {
const imageName = 'text-editor';
await galata.filebrowser.openHomeDirectory();
await galata.menu.clickMenuItem('File>New>Text File');
test('Changing a text editor settings', async ({ page }) => {
const imageName = 'text-editor-rulers.png';
await page.menu.clickMenuItem('File>New>Text File');

await galata.context.page.waitForSelector(
`[role="main"] >> text=${DEFAULT_NAME}`
);
await page.waitForSelector(`[role="main"] >> text=${DEFAULT_NAME}`);

const tabHandle = await galata.activity.getPanel(DEFAULT_NAME);
await galata.capture.screenshot(imageName, tabHandle);
expect(await galata.capture.compareScreenshot(imageName)).toBe('same');
});

test('Changing a text editor settings', async () => {
const imageName = 'text-editor-rulers';
await galata.menu.clickMenuItem('Settings>Advanced Settings Editor');
await page.menu.clickMenuItem('Settings>Advanced Settings Editor');

const page = galata.context.page;
await page.click('text=Text Editor');
await page.dblclick('pre[role="presentation"]:has-text("{}")');
await page.keyboard.type('{"editorConfig":{"rulers":[50, 75]}}');
Expand All @@ -45,15 +34,10 @@ describe('Text Editor Tests', () => {
/.*api\/settings\/@jupyterlab\/fileeditor-extension:plugin/
);

await galata.activity.activateTab(DEFAULT_NAME);
await page.activity.activateTab(DEFAULT_NAME);

const tabHandle = await galata.activity.getPanel(DEFAULT_NAME);
await galata.capture.screenshot(imageName, tabHandle);
expect(await galata.capture.compareScreenshot(imageName)).toBe('same');
});
const tabHandle = await page.activity.getPanel(DEFAULT_NAME);

test('Remove created file', async () => {
await galata.filebrowser.openHomeDirectory();
expect(await galata.contents.deleteFile(DEFAULT_NAME)).toEqual(true);
expect(await tabHandle.screenshot()).toMatchSnapshot(imageName);
});
});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2642,10 +2642,10 @@
resolved "https://registry.yarnpkg.com/@phosphor/coreutils/-/coreutils-1.3.1.tgz#441e34f42340f7faa742a88b2a181947a88d7226"
integrity sha512-9OHCn8LYRcPU/sbHm5v7viCA16Uev3gbdkwqoQqlV+EiauDHl70jmeL7XVDXdigl66Dz0LI11C99XOxp+s3zOA==

"@playwright/test@1.14.0":
version "1.14.0"
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.14.0.tgz#8df90c554c3d10895bab1b3e921e417fdb61f416"
integrity sha512-8jCS6fmzGZTW7e/Tri0tfxhl5bYpsQSDmCA7TtU6F4WV3CgxnOh44KOynol623p5ftVQ08Jdodu/x4WJ1dNqrg==
"@playwright/test@1.14.1":
version "1.14.1"
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.14.1.tgz#b2c6b76b8bf5958da307c80895847844b7fd172c"
integrity sha512-yL/808TEvUmsXxKMPf/Hf6Tajx666QFr8g+hCUZbRy2cbmQOPt7xhwGvXb1cpwMwIlJ4gBx/AiOpnnppsuLgTA==
dependencies:
"@babel/code-frame" "^7.14.5"
"@babel/core" "^7.14.8"
Expand Down

0 comments on commit f000590

Please sign in to comment.