Sfoglia il codice sorgente

More work on browser tests.

Brian E. Granger 4 anni fa
parent
commit
2e8501392c
2 ha cambiato i file con 44 aggiunte e 3 eliminazioni
  1. 1 0
      jupyterlab/browser_check.py
  2. 43 3
      jupyterlab/chrome-test.js

+ 1 - 0
jupyterlab/browser_check.py

@@ -175,6 +175,7 @@ class BrowserApp(LabApp):
         self.settings.setdefault('page_config_data', dict())
         self.settings['page_config_data']['browserTest'] = True
         self.settings['page_config_data']['buildAvailable'] = False
+        web_app.settings['page_config_data']['exposeAppInBrowser'] = True
         super().initialize_settings()
 
     def initialize_handlers(self):

+ 43 - 3
jupyterlab/chrome-test.js

@@ -6,7 +6,10 @@ async function main() {
   /* eslint-disable no-console */
   console.info('Starting Chrome Headless');
 
-  const browser = await puppeteer.launch({ args: ['--no-sandbox'] });
+  const browser = await puppeteer.launch({
+    headless: true,
+    args: ['--no-sandbox']
+  });
   const page = await browser.newPage();
 
   console.info('Navigating to page:', URL);
@@ -38,13 +41,50 @@ async function main() {
     console.error(`Parsed an error from text content: ${error.message}`, error);
   }
 
-  await page.evaluate(async () => {
+  function delay(duration) {
+    return function() {
+      return new Promise(function(resolve, reject) {
+        setTimeout(function() {
+          resolve();
+        }, duration);
+      });
+    };
+  }
+
+  const w1Id = await page.evaluate(async () => {
     const jlab = window.jupyterlab;
     const w1 = await jlab.commands.execute('fileeditor:create-new');
     const w2 = await jlab.commands.execute('fileeditor:create-new');
-    await jlab.shell.activateById(w1.id);
+    await new Promise((resolve, reject) => {
+      setTimeout(() => {
+        resolve();
+      }, 1000);
+    });
+    w1.content._ensureFocus();
+    await new Promise((resolve, reject) => {
+      setTimeout(() => {
+        resolve();
+      }, 1000);
+    });
+    // jlab.shell.activateById(w1.id);
+    // w2.activate();
+    // jlab._pluginMap['@jupyterlab/docmanager-extension:plugin'].service.mode;
+    return w1.id;
   });
 
+  // foundId = await page.evaluate(async (w1Id) => {
+  //   const jlab = window.jupyterlab;
+  //   jlab.shell.activateById(w1Id);
+  //   return jlab.shell.currentWidget.id;
+  // }, w1Id);
+
+  // const sel = "#" + w1Id + " .CodeMirror";
+  // console.log(sel);
+  // // await page.focus(sel);
+
+  // console.log(foundId);
+
+  await page.waitFor(2000);
   console.log(page.url());
 
   await browser.close();