Parcourir la source

Backport PR #12311: Simplify galata import by proxying `expect` (#12431)

Co-authored-by: Eric Charles <eric@datalayer.io>
Frédéric Collonval il y a 3 ans
Parent
commit
7277d8c9a4

+ 1 - 2
galata/README.md

@@ -35,8 +35,7 @@ module.exports = require('@jupyterlab/galata/lib/playwright-config');
 Create `ui-tests/foo.spec.ts` to define your test.
 
 ```typescript
-import { test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, test } from '@jupyterlab/galata';
 
 test.describe('Notebook Tests', () => {
   test('Create New Notebook', async ({ page, tmpPath }) => {

+ 5 - 0
galata/src/index.ts

@@ -6,6 +6,11 @@
  * @module galata
  */
 
+/**
+ * Export expect from playwright to simplify the import in tests
+ */
+export { expect } from '@playwright/test';
+
 export * from './benchmarkReporter';
 export * from './galata';
 export * from './global';

+ 1 - 2
galata/test/galata/benchmarkReporter.spec.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, test } from '@jupyterlab/galata';
 import { TestResult } from '@playwright/test/reporter';
 import BenchmarkReporter, {
   benchmark,

+ 1 - 2
galata/test/galata/contents.spec.ts

@@ -4,8 +4,7 @@
 
 import * as path from 'path';
 
-import { test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, test } from '@jupyterlab/galata';
 
 test.describe('Contents API Tests', () => {
   test('Upload directory to server', async ({ page, tmpPath }) => {

+ 1 - 2
galata/test/galata/fixture.spec.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { expect } from '@playwright/test';
-import { JupyterLabPage, test } from '@jupyterlab/galata';
+import { expect, JupyterLabPage, test } from '@jupyterlab/galata';
 
 test.describe('page', () => {
   test('should return a JupyterLabPage', ({ page }) => {

+ 2 - 2
galata/test/galata/jupyterlabpage.spec.ts

@@ -1,8 +1,8 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { test } from '@jupyterlab/galata';
-import { expect, test as playwrightTest } from '@playwright/test';
+import { expect, test } from '@jupyterlab/galata';
+import { test as playwrightTest } from '@playwright/test';
 
 test.describe('appPath', () => {
   const APP_PATH = '/retro';

+ 1 - 2
galata/test/galata/notebook.spec.ts

@@ -4,8 +4,7 @@
 
 import * as path from 'path';
 
-import { test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, test } from '@jupyterlab/galata';
 
 test.describe('Notebook Tests', () => {
   test('Create New Notebook', async ({ page, tmpPath }) => {

+ 1 - 2
galata/test/galata/test.spec.ts

@@ -2,8 +2,7 @@
 // Copyright (c) Bloomberg Finance LP.
 // Distributed under the terms of the Modified BSD License.
 
-import { test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, test } from '@jupyterlab/galata';
 
 test('should display the launcher', async ({ page }) => {
   expect(await page.waitForSelector(page.launcherSelector)).toBeTruthy();

+ 1 - 2
galata/test/jupyterlab/completer.test.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, test } from '@jupyterlab/galata';
 
 const fileName = 'notebook.ipynb';
 const COMPLETER_SELECTOR = '.jp-Completer';

+ 1 - 2
galata/test/jupyterlab/contextmenu.test.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { galata, test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, galata, test } from '@jupyterlab/galata';
 
 import * as path from 'path';
 

+ 1 - 2
galata/test/jupyterlab/debugger.test.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, test } from '@jupyterlab/galata';
 
 test.describe('Debugger Tests', () => {
   test('Move Debugger to right', async ({ page }) => {

+ 1 - 2
galata/test/jupyterlab/general.test.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, test } from '@jupyterlab/galata';
 
 test.describe('General Tests', () => {
   test('Launch Screen', async ({ page }) => {

+ 1 - 2
galata/test/jupyterlab/menus.test.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, test } from '@jupyterlab/galata';
 
 const menuPaths = [
   'File',

+ 1 - 2
galata/test/jupyterlab/notebook-create.test.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { IJupyterLabPageFixture, test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, IJupyterLabPageFixture, test } from '@jupyterlab/galata';
 
 const fileName = 'notebook.ipynb';
 

+ 1 - 2
galata/test/jupyterlab/notebook-edit.test.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { IJupyterLabPageFixture, test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, IJupyterLabPageFixture, test } from '@jupyterlab/galata';
 
 const fileName = 'notebook.ipynb';
 

+ 1 - 2
galata/test/jupyterlab/notebook-markdown.test.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { IJupyterLabPageFixture, test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, IJupyterLabPageFixture, test } from '@jupyterlab/galata';
 import * as path from 'path';
 
 const fileName = 'markdown_notebook.ipynb';

+ 1 - 2
galata/test/jupyterlab/notebook-run.test.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { galata, test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, galata, test } from '@jupyterlab/galata';
 import * as path from 'path';
 
 const fileName = 'simple_notebook.ipynb';

+ 1 - 2
galata/test/jupyterlab/notebook-toolbar.test.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { IJupyterLabPageFixture, test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, IJupyterLabPageFixture, test } from '@jupyterlab/galata';
 
 const fileName = 'notebook.ipynb';
 

+ 1 - 2
galata/test/jupyterlab/sidebars.test.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { galata, test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, galata, test } from '@jupyterlab/galata';
 
 const sidebarIds: galata.SidebarTabId[] = [
   'filebrowser',

+ 1 - 2
galata/test/jupyterlab/terminal.test.ts

@@ -1,5 +1,4 @@
-import { test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, test } from '@jupyterlab/galata';
 
 const TERMINAL_SELECTOR = '.jp-Terminal';
 const TERMINAL_THEME_ATTRIBUTE = 'data-term-theme';

+ 1 - 2
galata/test/jupyterlab/texteditor.test.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, test } from '@jupyterlab/galata';
 
 const DEFAULT_NAME = 'untitled.txt';
 

+ 1 - 2
galata/test/jupyterlab/toc-running.test.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, test } from '@jupyterlab/galata';
 
 test.describe('ToC Running indicator', () => {
   test.beforeEach(async ({ page }) => {

+ 1 - 2
galata/test/jupyterlab/toc.test.ts

@@ -1,8 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { galata, test } from '@jupyterlab/galata';
-import { expect } from '@playwright/test';
+import { expect, galata, test } from '@jupyterlab/galata';
 import * as path from 'path';
 
 const fileName = 'toc_notebook.ipynb';

+ 2 - 2
galata/test/jupyterlab/workspace.test.ts

@@ -1,8 +1,8 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { galata, test } from '@jupyterlab/galata';
-import { expect, Page } from '@playwright/test';
+import { expect, galata, test } from '@jupyterlab/galata';
+import { Page } from '@playwright/test';
 import * as path from 'path';
 
 const nbFile = 'simple_notebook.ipynb';

+ 0 - 2
packages/apputils/test/commandpalette.spec.ts

@@ -1,8 +1,6 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-// import { expect } from 'chai';
-
 import { ModalCommandPalette } from '@jupyterlab/apputils';
 import { ITranslator, nullTranslator } from '@jupyterlab/translation';
 import { CommandPaletteSvg, paletteIcon } from '@jupyterlab/ui-components';

+ 0 - 2
packages/apputils/test/dialog.spec.tsx

@@ -2,8 +2,6 @@
 
 // Distributed under the terms of the Modified BSD License.
 
-// import { expect } from 'chai';
-
 import { Dialog, showDialog } from '@jupyterlab/apputils';
 import {
   acceptDialog,