瀏覽代碼

Examples tests working again

Eric Charles 5 年之前
父節點
當前提交
c880fec8fa

+ 6 - 13
examples/example_check.py

@@ -47,23 +47,17 @@ def main():
         JS console errors, JS errors, and Python logged errors.
         """
         extension_name = 'example'
-        extension_url = '/example'
+        default_url = '/example'
         open_browser = Bool(False)
         base_url = '/foo/'
         ip = '127.0.0.1'
 
-        def _jupyter_server_extension_paths():
-            return [
-                {
-                    'module': 'example',
-                    'app': App
-                }
-            ]
-
-        mod._jupyter_server_extension_paths = _jupyter_server_extension_paths
+        def initialize_handlers(self):
+            run_test(self.serverapp, run_browser)
+            super().initialize_handlers()
 
     App.__name__ = osp.basename(example_dir).capitalize() + 'Test'
-    
+
     def _jupyter_server_extension_paths():
         return [
             {
@@ -72,9 +66,8 @@ def main():
             }
         ]
     sys.modules['example']._jupyter_server_extension_paths = _jupyter_server_extension_paths
-    ExampleServerApp.jpserver_extensions = Dict({'example': True})
-    ExampleServerApp.launch_instance()
 
+    App.launch_instance()
 
 def run_browser(url):
     """Run the browser test and return an exit code.

+ 1 - 1
examples/notebook/main.py

@@ -49,7 +49,7 @@ class ExampleHandler(
             # Use camelCase here, since that's what the lab components expect
             'baseUrl': self.base_url,
             'token': self.settings['token'],
-            'notebookPath': os.path.join(HERE, 'test.ipynb'),
+            'notebookPath': 'test.ipynb',
             'fullStaticUrl': ujoin(self.base_url, 'static', self.extension_name),
             'frontendUrl': ujoin(self.base_url, 'example/'),
             # FIXME: Don't use a CDN here

+ 2 - 2
examples/terminal/main.py

@@ -64,8 +64,8 @@ class ExampleHandler(
 
 class ExampleApp(LabServerApp):
 
-    default_url = Unicode('/example')
-    extension_name = 'main'
+    extension_url = '/example'
+    extension_name = __name__
     app_name = 'JupyterLab Example Terminal'
     app_settings_dir = os.path.join(HERE, 'build', 'application_settings')
     app_url = '/example_app'

+ 1 - 1
packages/services/examples/browser-require/index.html

@@ -38,6 +38,6 @@
         }
     });
     </script>
-    <script src="{{base_url | e}}static/example/index.js"></script>
+    <script src="{{page_config['fullStaticUrl'] | e}}/index.js" main="index"></script>
   </body>
 </html>

+ 2 - 2
packages/services/examples/browser-require/main.py

@@ -35,7 +35,7 @@ class ExampleHandler(
             # Use camelCase here, since that's what the lab components expect
             'baseUrl': self.base_url,
             'token': self.settings['token'],
-            'fullStaticUrl': ujoin(self.base_url, 'static', 'main'), 
+            'fullStaticUrl': ujoin(self.base_url, 'static', self.extension_name),
             'frontendUrl': ujoin(self.base_url, 'example/'),
         }
         return self.write(
@@ -50,7 +50,7 @@ class ExampleHandler(
 
 class ExampleApp(LabServerApp):
 
-    extension_url = '/lab'
+    extension_url = '/example'
     extension_name = 'main'
     app_name = 'JupyterLab Example Service'
     app_url = '/example_app'

+ 1 - 1
packages/services/examples/browser/index.html

@@ -11,7 +11,7 @@
       {{ page_config_full | tojson }}
     </script>
   
-    <script src="{{base_url | e}}static/example/bundle.js"></script>
+    <script src="{{page_config['fullStaticUrl'] | e}}/bundle.js" main="index"></script>
     <pre id='output'></pre>
   </body>
 </html>

+ 6 - 6
packages/services/examples/browser/main.py

@@ -39,8 +39,8 @@ class ExampleHandler(
             "appVersion": version,
             'baseUrl': self.base_url,
             'token': self.settings['token'],
-            'fullStaticUrl': ujoin(self.base_url, 'static', 'main'), 
-            'frontendUrl': ujoin(self.base_url, 'example/'),
+            'fullStaticUrl': ujoin(self.base_url, 'static', self.extension_name),
+            'frontendUrl': ujoin(self.base_url, 'example/')
         }
         return self.write(
             self.render_template(
@@ -54,15 +54,15 @@ class ExampleHandler(
 
 class ExampleApp(LabServerApp):
 
-    extension_url = '/lab'
+    extension_url = '/example'
     extension_name = 'main'
     app_name = 'JupyterLab Example Service'
+    app_settings_dir = os.path.join(HERE, 'build', 'application_settings')
     app_url = '/example_app'
-    static_dir = os.path.join(HERE, 'build')
-    templates_dir = os.path.join(HERE, 'templates')
     app_version = version
-    app_settings_dir = os.path.join(HERE, 'build', 'application_settings')
     schemas_dir = os.path.join(HERE, 'build', 'schemas')
+    static_dir = os.path.join(HERE, 'build')
+    templates_dir = os.path.join(HERE, 'templates')
     themes_dir = os.path.join(HERE, 'build', 'themes')
     user_settings_dir = os.path.join(HERE, 'build', 'user_settings')
     workspaces_dir = os.path.join(HERE, 'build', 'workspaces')

+ 1 - 1
packages/services/examples/browser/templates/index.html

@@ -11,7 +11,7 @@
       {{ page_config_full | tojson }}
     </script>
   
-    <script src="{{base_url | e}}static/example/bundle.js"></script>
+    <script src="{{page_config['fullStaticUrl'] | e}}/bundle.js" main="index"></script>
     <pre id='output'></pre>
   </body>
 </html>

+ 1 - 1
packages/services/examples/typescript-browser-with-output/index.html

@@ -11,7 +11,7 @@
       {{ page_config_full | tojson }}
     </script>
 
-    <script src="{{base_url | e}}static/example/bundle.js"></script>
+    <script src="{{page_config['fullStaticUrl'] | e}}/bundle.js" main="index"></script>
     <span id='outputarea'></span>
   </body>
 </html>

+ 3 - 3
packages/services/examples/typescript-browser-with-output/main.py

@@ -39,8 +39,8 @@ class ExampleHandler(
             "appVersion": version,
             'baseUrl': self.base_url,
             'token': self.settings['token'],
-            'fullStaticUrl': ujoin(self.base_url, 'static', 'example'), 
-            'frontendUrl': ujoin(self.base_url, 'example/'),
+            'fullStaticUrl': ujoin(self.base_url, 'static', self.extension_name),
+            'frontendUrl': ujoin(self.base_url, 'main/'),
         }
         return self.write(
             self.render_template(
@@ -54,7 +54,7 @@ class ExampleHandler(
 
 class ExampleApp(LabServerApp):
 
-    extension_url = '/lab'
+    extension_url = '/example'
     extension_name = 'main'
     app_name = 'JupyterLab Example Service'
     app_url = '/example_app'