Browse Source

added redirect fix to `chrome-test.js`

telamonian 5 years ago
parent
commit
4351ea3cd8
4 changed files with 26 additions and 38 deletions
  1. 1 1
      examples/chrome-example-test.js
  2. 1 1
      examples/example_check.py
  3. 21 36
      examples/test_examples.py
  4. 3 0
      jupyterlab/chrome-test.js

+ 1 - 1
examples/chrome-example-test.js

@@ -48,7 +48,7 @@ async function main() {
   await page.goto(URL);
   console.info('Waiting for page to load...');
 
-  // Wait for the local file to redirect on noteboox >= 6.0. Refs:
+  // Wait for the local file to redirect on notebook >= 6.0. Refs:
   // https://jupyter-notebook.readthedocs.io/en/stable/changelog.html?highlight=redirect
   // https://stackoverflow.com/q/46948489/425458
   await page.waitForNavigation();

+ 1 - 1
examples/example_check.py

@@ -4,7 +4,7 @@
 This file is mean to be called with a path to an example directory as
 its argument.  We import the application entry point for the example
 and add instrument them with a puppeteer test that makes sure
-there are no console errors or uncaught errors prior to a sentinal
+there are no console errors or uncaught errors prior to a sentinel
 string being printed.
 
 e.g. python example_check.py ./app

+ 21 - 36
examples/test_examples.py

@@ -8,12 +8,9 @@ there are no console errors or uncaught errors prior to a sentinel
 string being printed.
 """
 import glob
-import os
 import os.path as osp
 import subprocess
 import sys
-from traitlets import Unicode
-from traitlets.config.application import Application
 
 here = osp.abspath(osp.dirname(__file__))
 
@@ -24,45 +21,33 @@ def header(path):
     print('Starting %s test' % test_name)
     print('*' * 40)
 
-aliases = {'path': 'RunTestExamples.path'}
 
-class RunTestExamples(Application):
-    aliases = aliases
+def main():
+    paths = [i for i in glob.glob('%s/*' % here) if osp.isdir(i)]
 
-    path = Unicode(None, allow_none=True, config=True,
-                   help='Path to example dir')
+    services_dir = osp.abspath(osp.join(here, '../packages/services/examples'))
+    paths += [i for i in glob.glob('%s/*' % services_dir)]
 
-    def start(self):
-        if self.path is None:
-            self.path = here
-            paths = [i for i in glob.glob('%s/*' % self.path) if osp.isdir(i)]
+    count = 0
+    for path in sorted(paths):
+        if osp.basename(path) == 'node':
+            header(path)
+            runner = osp.join(path, 'main.py')
+            subprocess.check_call([sys.executable, runner])
+            count += 1
+            continue
 
-            services_dir = osp.abspath(osp.join(self.path, '../packages/services/examples'))
-            paths += [i for i in glob.glob('%s/*' % services_dir)]
-        else:
-            paths = [dirpath for (dirpath, _, filenames) in os.walk(self.path) if 'main.py' in filenames]
+        if not osp.exists(osp.join(path, 'main.py')):
+            continue
 
-        count = 0
-        for path in sorted(paths):
-            if osp.basename(path) == 'node':
-                header(path)
-                runner = osp.join(path, 'main.py')
-                subprocess.check_call([sys.executable, runner])
-                count += 1
-                continue
+        count += 1
+        header(path)
+        runner = osp.join(here, 'example_check.py')
+        subprocess.check_call([sys.executable, runner, path])
 
-            if not osp.exists(osp.join(path, 'main.py')):
-                continue
+    print('\n\n%s tests complete!' % count)
 
-            count += 1
-            header(path)
-            runner = osp.join(here, 'example_check.py')
-            subprocess.check_call([sys.executable, runner, path])
-
-        print('\n\n%s tests complete!' % count)
-
-        # start subapps, if any
-        super().start()
 
 if __name__ == "__main__":
-    RunTestExamples.launch_instance()
+    main()
+

+ 3 - 0
jupyterlab/chrome-test.js

@@ -13,6 +13,9 @@ async function main() {
   await page.goto(URL);
   console.info('Waiting for page to load...');
 
+  // Wait for the local file to redirect on notebook >= 6.0
+  await page.waitForNavigation();
+
   const html = await page.content();
   if (inspect(html).indexOf('jupyter-config-data') === -1) {
     console.error('Error loading JupyterLab page:');