Skip to content

Commit

Permalink
Improve tests: wait for the plugin list to load,
Browse files Browse the repository at this point in the history
and ensure recordTiming does not get disabled
when mocking settings with defaults
  • Loading branch information
krassowski committed May 16, 2024
1 parent 179bd9a commit 35bcaca
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 19 deletions.
13 changes: 9 additions & 4 deletions ui-tests/tests/cell_operations.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { expect, galata, test } from '@jupyterlab/galata';
import { openNotebook, cleanup, watchTimeIncrease } from './utils';
import { expect, test } from '@jupyterlab/galata';
import {
DEFAULT_SETTINGS,
openNotebook,
cleanup,
watchTimeIncrease,
} from './utils';

const NOTEBOOK_ID = '@jupyterlab/notebook-extension:tracker';

test.describe('Cell operations', () => {
test.use({
mockSettings: {
...galata.DEFAULT_SETTINGS,
...DEFAULT_SETTINGS,
[NOTEBOOK_ID]: {
...galata.DEFAULT_SETTINGS[NOTEBOOK_ID],
...DEFAULT_SETTINGS[NOTEBOOK_ID],
windowingMode: 'defer',
},
},
Expand Down
1 change: 1 addition & 0 deletions ui-tests/tests/settings_editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test.describe('Settings Editor', () => {
'.jp-PluginList .jp-PluginList-entry >> text="Execute Time"'
);

await plugin.waitFor();
expect(plugin).toHaveCount(1);
});
});
14 changes: 10 additions & 4 deletions ui-tests/tests/timing_outcomes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { expect, galata, test } from '@jupyterlab/galata';
import { openNotebook, cleanup, acceptDialog, maskedScreenshot } from './utils';
import { expect, test } from '@jupyterlab/galata';
import {
DEFAULT_SETTINGS,
openNotebook,
cleanup,
acceptDialog,
maskedScreenshot,
} from './utils';

const SETTINGS_ID = 'jupyterlab-execute-time:settings';

Expand All @@ -9,9 +15,9 @@ test.describe('Timing outcomes', () => {
// Disable flashing highlight for screenshot consistency
test.use({
mockSettings: {
...galata.DEFAULT_SETTINGS,
...DEFAULT_SETTINGS,
[SETTINGS_ID]: {
...galata.DEFAULT_SETTINGS[SETTINGS_ID],
...DEFAULT_SETTINGS[SETTINGS_ID],
highlight: false,
},
},
Expand Down
13 changes: 9 additions & 4 deletions ui-tests/tests/timing_outputs_outcomes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { expect, galata, test } from '@jupyterlab/galata';
import { openNotebook, cleanup, maskedScreenshot } from './utils';
import { expect, test } from '@jupyterlab/galata';
import {
DEFAULT_SETTINGS,
openNotebook,
cleanup,
maskedScreenshot,
} from './utils';

const SETTINGS_ID = 'jupyterlab-execute-time:settings';

Expand All @@ -9,9 +14,9 @@ test.describe('Timing outcomes with ', () => {
// Disable flashing highlight for screenshot consistency
test.use({
mockSettings: {
...galata.DEFAULT_SETTINGS,
...DEFAULT_SETTINGS,
[SETTINGS_ID]: {
...galata.DEFAULT_SETTINGS[SETTINGS_ID],
...DEFAULT_SETTINGS[SETTINGS_ID],
highlight: false,
showOutputsPerSecond: true,
},
Expand Down
11 changes: 11 additions & 0 deletions ui-tests/tests/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { galata } from '@jupyterlab/galata';
import { Page, ElementHandle, Locator } from 'playwright';
import * as path from 'path';

const NOTEBOOK_ID = '@jupyterlab/notebook-extension:tracker';

export const DEFAULT_SETTINGS = {
...galata.DEFAULT_SETTINGS,
[NOTEBOOK_ID]: {
...galata.DEFAULT_SETTINGS[NOTEBOOK_ID],
recordTiming: true,
},
};

/**
* Upload and open given notebook.
*/
Expand Down
14 changes: 7 additions & 7 deletions ui-tests/tests/windowed_notebook.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { expect, galata, test } from '@jupyterlab/galata';
import { openNotebook, acceptDialog, cleanup } from './utils';
import { expect, test } from '@jupyterlab/galata';
import { DEFAULT_SETTINGS, openNotebook, acceptDialog, cleanup } from './utils';

const SETTINGS_ID = 'jupyterlab-execute-time:settings';
const NOTEBOOK_ID = '@jupyterlab/notebook-extension:tracker';

test.describe('Windowed notebook', () => {
test.use({
mockSettings: {
...galata.DEFAULT_SETTINGS,
...DEFAULT_SETTINGS,
[NOTEBOOK_ID]: {
...galata.DEFAULT_SETTINGS[NOTEBOOK_ID],
...DEFAULT_SETTINGS[NOTEBOOK_ID],
windowingMode: 'full',
},
},
Expand Down Expand Up @@ -40,13 +40,13 @@ test.describe('Windowed notebook/hover', () => {
// because in this mode execution does not move the notebook window.
test.use({
mockSettings: {
...galata.DEFAULT_SETTINGS,
...DEFAULT_SETTINGS,
[NOTEBOOK_ID]: {
...galata.DEFAULT_SETTINGS[NOTEBOOK_ID],
...DEFAULT_SETTINGS[NOTEBOOK_ID],
windowingMode: 'full',
},
[SETTINGS_ID]: {
...galata.DEFAULT_SETTINGS[SETTINGS_ID],
...DEFAULT_SETTINGS[SETTINGS_ID],
positioning: 'hover',
},
},
Expand Down

0 comments on commit 35bcaca

Please sign in to comment.