Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add macos UI tests #403

Closed
wants to merge 15 commits into from
Closed
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
64 changes: 60 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ jobs:
jupyter labextension list 2>&1 | grep -ie "@jupyterlab/scheduler.*OK"
python -m jupyterlab.browser_check

integration-tests:
name: Integration tests
integration-tests-ubuntu:
name: Integration tests ubuntu
needs: build
runs-on: ubuntu-latest

Expand All @@ -111,7 +111,7 @@ jobs:
- name: Install the extension
run: |
set -eux
python -m pip install "jupyterlab~=4.0" jupyter_scheduler*.whl
python -m pip install "jupyterlab==4.0.3" jupyter_scheduler*.whl

- name: Install dependencies
working-directory: ui-tests
Expand All @@ -138,7 +138,63 @@ jobs:
if: always()
uses: actions/upload-artifact@v2
with:
name: jupyter_scheduler-playwright-tests
name: jupyter_scheduler-playwright-tests-ubuntu
path: |
ui-tests/test-results
ui-tests/playwright-report

integration-tests-macos:
name: Integration tests macOS
needs: build
runs-on: macos-latest

env:
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/pw-browsers

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Download extension package
uses: actions/download-artifact@v2
with:
name: extension-artifacts

- name: Install the extension
run: |
set -eux
python -m pip install "jupyterlab==4.0.3" jupyter_scheduler*.whl

- name: Install dependencies
working-directory: ui-tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: jlpm install

- name: Set up browser cache
uses: actions/cache@v2
with:
path: |
${{ github.workspace }}/pw-browsers
key: ${{ runner.os }}-${{ hashFiles('ui-tests/yarn.lock') }}

- name: Install browser
run: jlpm playwright install chromium
working-directory: ui-tests

- name: Execute integration tests
working-directory: ui-tests
run: |
jlpm playwright test

- name: Upload Playwright Test report
if: always()
uses: actions/upload-artifact@v2
with:
name: jupyter_scheduler-playwright-tests-macos
path: |
ui-tests/test-results
ui-tests/playwright-report
2 changes: 1 addition & 1 deletion .github/workflows/update-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
python_version: '3.11'

- name: Install dependencies
run: python -m pip install -U jupyterlab~=4.0
run: python -m pip install -U jupyterlab=4.0.3

- name: Install extension
run: |
Expand Down
56 changes: 51 additions & 5 deletions ui-tests/helpers/SchedulerHelper.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { expect, IJupyterLabPageFixture } from '@jupyterlab/galata';
import type { Locator, TestInfo } from '@playwright/test';

export enum SELECTORS {
enum SELECTORS {
// tbutton = toolbar button
CREATE_JOB_TBUTTON = 'button.jp-ToolbarButtonComponent[data-command="scheduling:create-from-notebook"][title="Create a notebook job"]',
LAUNCHER_CARD = 'div.jp-LauncherCard[title="Notebook Jobs"]',
LIST_VIEW_TIMES = 'td.MuiTableCell-body:has-text(" AM"), td.MuiTableCell-body:has-text(" PM")'
LIST_VIEW_TIMES = 'td.MuiTableCell-body:has-text(" AM"), td.MuiTableCell-body:has-text(" PM")',
NOTEBOOK_TOOLBAR = '.jp-NotebookPanel-toolbar[aria-label="notebook actions"]',
ENABLE_DEBUGGER_TBUTTON = '.jp-DebuggerBugButton',
KERNEL_NAME_TBUTTON = '.jp-KernelName',
EXECUTION_INDICATOR_TBUTTON = '.jp-Notebook-ExecutionIndicator'
}

type SnapshotOptions = {
Expand All @@ -23,6 +27,11 @@
* https://playwright.dev/docs/api/class-page#page-screenshot-option-mask.
*/
mask?: Locator[];
/**
* An acceptable amount of pixels that could be different. See
* https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1-option-max-diff-pixels
*/
maxDiffPixels?: number;
};

const DEFAULT_SNAPSHOT_OPTS: SnapshotOptions = {
Expand Down Expand Up @@ -50,16 +59,47 @@
) {}

/**
* JupyterLab launcher "Notebook Jobs" card selector
* JupyterLab launcher "Notebook Jobs" card locator
*/
get launcherCard() {
return this.page.locator(SELECTORS.LAUNCHER_CARD);
}

/**
* Locates notebook toolbar
*/
get notebookToolbar() {
return this.page.locator(SELECTORS.NOTEBOOK_TOOLBAR);
}

/**
* Locates "Create a notebook job" button in notebook toolbar
*/
get createJobTbutton() {
return this.page.locator(SELECTORS.CREATE_JOB_TBUTTON);
}

/**
* Locates "Enable debugger" icon in notebook toolbar
*/
get enableDebuggerTbutton() {
return this.page.locator(SELECTORS.ENABLE_DEBUGGER_TBUTTON);
}

/**
* Locates kernel name button in notebook toolbar
*/
get kernelNameTbutton() {
return this.page.locator(SELECTORS.KERNEL_NAME_TBUTTON);
}

/**
* Locates execution indicator icon in notebook toolbar
*/
get executionIndicatorTbutton() {
return this.page.locator(SELECTORS.EXECUTION_INDICATOR_TBUTTON);
}

/**
* Locates the previously created notebook's listing in the filebrowser.
*/
Expand All @@ -79,7 +119,7 @@
* Locates the column of timestamps in the list view. Used to mask this column
* during snapshot tests.
*/
get timestampLocator() {
get timestamp() {
return this.page.locator(SELECTORS.LIST_VIEW_TIMES);
}

Expand Down Expand Up @@ -178,7 +218,13 @@
const screenshotArgs = {
mask: opts.mask
};
expect(await target.screenshot(screenshotArgs)).toMatchSnapshot(filename);
const snapshotArgs = {
maxDiffPixels: opts.maxDiffPixels
};
expect(await target.screenshot(screenshotArgs)).toMatchSnapshot(

Check failure on line 224 in ui-tests/helpers/SchedulerHelper.ts

View workflow job for this annotation

GitHub Actions / Integration tests macOS

tests/jupyter_scheduler.spec.ts:29:7 › Jupyter Scheduler › shows card in launcher

1) tests/jupyter_scheduler.spec.ts:29:7 › Jupyter Scheduler › shows card in launcher ───────────── Error: A snapshot doesn't exist at /Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/tests/jupyter_scheduler.spec.ts-snapshots/launcher-darwin.png, writing actual. at helpers/SchedulerHelper.ts:224 222 | maxDiffPixels: opts.maxDiffPixels 223 | }; > 224 | expect(await target.screenshot(screenshotArgs)).toMatchSnapshot( | ^ 225 | filename, 226 | snapshotArgs 227 | ); at SchedulerHelper.assertSnapshot (/Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/helpers/SchedulerHelper.ts:224:53) at /Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/tests/jupyter_scheduler.spec.ts:31:5

Check failure on line 224 in ui-tests/helpers/SchedulerHelper.ts

View workflow job for this annotation

GitHub Actions / Integration tests macOS

tests/jupyter_scheduler.spec.ts:34:7 › Jupyter Scheduler › shows notebook toolbar button

2) tests/jupyter_scheduler.spec.ts:34:7 › Jupyter Scheduler › shows notebook toolbar button ────── Error: A snapshot doesn't exist at /Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/tests/jupyter_scheduler.spec.ts-snapshots/notebook-toolbar-darwin.png, writing actual. at helpers/SchedulerHelper.ts:224 222 | maxDiffPixels: opts.maxDiffPixels 223 | }; > 224 | expect(await target.screenshot(screenshotArgs)).toMatchSnapshot( | ^ 225 | filename, 226 | snapshotArgs 227 | ); at SchedulerHelper.assertSnapshot (/Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/helpers/SchedulerHelper.ts:224:53) at /Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/tests/jupyter_scheduler.spec.ts:37:5

Check failure on line 224 in ui-tests/helpers/SchedulerHelper.ts

View workflow job for this annotation

GitHub Actions / Integration tests macOS

tests/jupyter_scheduler.spec.ts:47:7 › Jupyter Scheduler › opens create job view from notebook toolbar

3) tests/jupyter_scheduler.spec.ts:47:7 › Jupyter Scheduler › opens create job view from notebook toolbar Error: Screenshot comparison failed: Expected an image 1024px by 768px, received 948px by 680px. 51156 pixels (ratio 0.07 of all image pixels) are different. Expected: /Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/test-results/tests-jupyter_scheduler-Jupyter-Scheduler-opens-create-job-view-from-notebook-toolbar/create-view-from-toolbar-expected.png Received: /Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/test-results/tests-jupyter_scheduler-Jupyter-Scheduler-opens-create-job-view-from-notebook-toolbar/create-view-from-toolbar-actual.png Diff: /Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/test-results/tests-jupyter_scheduler-Jupyter-Scheduler-opens-create-job-view-from-notebook-toolbar/create-view-from-toolbar-diff.png at helpers/SchedulerHelper.ts:224 222 | maxDiffPixels: opts.maxDiffPixels 223 | }; > 224 | expect(await target.screenshot(screenshotArgs)).toMatchSnapshot( | ^ 225 | filename, 226 | snapshotArgs 227 | ); at SchedulerHelper.assertSnapshot (/Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/helpers/SchedulerHelper.ts:224:53) at /Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/tests/jupyter_scheduler.spec.ts:52:5

Check failure on line 224 in ui-tests/helpers/SchedulerHelper.ts

View workflow job for this annotation

GitHub Actions / Integration tests macOS

tests/jupyter_scheduler.spec.ts:55:7 › Jupyter Scheduler › shows filebrowser menu item

4) tests/jupyter_scheduler.spec.ts:55:7 › Jupyter Scheduler › shows filebrowser menu item ──────── Error: A snapshot doesn't exist at /Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/tests/jupyter_scheduler.spec.ts-snapshots/filebrowser-menu-darwin.png, writing actual. at helpers/SchedulerHelper.ts:224 222 | maxDiffPixels: opts.maxDiffPixels 223 | }; > 224 | expect(await target.screenshot(screenshotArgs)).toMatchSnapshot( | ^ 225 | filename, 226 | snapshotArgs 227 | ); at SchedulerHelper.assertSnapshot (/Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/helpers/SchedulerHelper.ts:224:53) at /Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/tests/jupyter_scheduler.spec.ts:60:5

Check failure on line 224 in ui-tests/helpers/SchedulerHelper.ts

View workflow job for this annotation

GitHub Actions / Integration tests macOS

tests/jupyter_scheduler.spec.ts:66:7 › Jupyter Scheduler › opens create job view from filebrowser menu item

5) tests/jupyter_scheduler.spec.ts:66:7 › Jupyter Scheduler › opens create job view from filebrowser menu item Error: A snapshot doesn't exist at /Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/tests/jupyter_scheduler.spec.ts-snapshots/create-view-from-filebrowser-darwin.png, writing actual. at helpers/SchedulerHelper.ts:224 222 | maxDiffPixels: opts.maxDiffPixels 223 | }; > 224 | expect(await target.screenshot(screenshotArgs)).toMatchSnapshot( | ^ 225 | filename, 226 | snapshotArgs 227 | ); at SchedulerHelper.assertSnapshot (/Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/helpers/SchedulerHelper.ts:224:53) at /Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/tests/jupyter_scheduler.spec.ts:69:5

Check failure on line 224 in ui-tests/helpers/SchedulerHelper.ts

View workflow job for this annotation

GitHub Actions / Integration tests macOS

tests/jupyter_scheduler.spec.ts:72:7 › Jupyter Scheduler › shows newly created job in job list view

6) tests/jupyter_scheduler.spec.ts:72:7 › Jupyter Scheduler › shows newly created job in job list view Error: A snapshot doesn't exist at /Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/tests/jupyter_scheduler.spec.ts-snapshots/list-view-darwin.png, writing actual. at helpers/SchedulerHelper.ts:224 222 | maxDiffPixels: opts.maxDiffPixels 223 | }; > 224 | expect(await target.screenshot(screenshotArgs)).toMatchSnapshot( | ^ 225 | filename, 226 | snapshotArgs 227 | ); at SchedulerHelper.assertSnapshot (/Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/helpers/SchedulerHelper.ts:224:53) at /Users/runner/work/jupyter-scheduler/jupyter-scheduler/ui-tests/tests/jupyter_scheduler.spec.ts:76:5
filename,
snapshotArgs
);
}

protected async _waitForCreateJobLoaded() {
Expand Down
15 changes: 11 additions & 4 deletions ui-tests/tests/jupyter_scheduler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SchedulerHelper } from '../helpers/SchedulerHelper';

enum FILENAMES {
LAUNCHER = 'launcher.png',
NOTEBOOK = 'notebook-view.png',
NOTEBOOK_TOOLBAR = 'notebook-toolbar.png',
FILEBROWSER_MENU = 'filebrowser-menu.png',
// TODO: resolve this inconsistency in our frontend code. One entry point
// includes the file extension in the job name, the other does not.
Expand Down Expand Up @@ -34,7 +34,14 @@ test.describe('Jupyter Scheduler', () => {
test('shows notebook toolbar button', async () => {
await scheduler.createNotebook();
await expect(scheduler.createJobTbutton).toBeVisible();
await scheduler.assertSnapshot(FILENAMES.NOTEBOOK);
await scheduler.assertSnapshot(FILENAMES.NOTEBOOK_TOOLBAR, {
locator: scheduler.notebookToolbar,
mask: [
scheduler.enableDebuggerTbutton,
scheduler.kernelNameTbutton,
scheduler.executionIndicatorTbutton
]
});
});

test('opens create job view from notebook toolbar', async ({ page }) => {
Expand Down Expand Up @@ -66,9 +73,9 @@ test.describe('Jupyter Scheduler', () => {
await scheduler.createNotebook();
await scheduler.createJobFromFilebrowser();

const timeStamp = scheduler.timestampLocator;
await scheduler.assertSnapshot(FILENAMES.LIST_VIEW, {
mask: [timeStamp]
mask: [scheduler.timestamp],
maxDiffPixels: 420
});
});

Expand Down
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.
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.
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.
Loading
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading