def test_003_generate_component_in_existing_modules(self):
        result = NG.exec_command(command='g m module-test2', cwd=self.app_path)
        assert 'CREATE app/module-test2/module-test2.module.ts' in result.output

        result = NG.exec_command(command='g c module-test2/component-name', cwd=self.app_path)
        assert 'CREATE app/module-test2/component-name/component-name.component.html' in result.output
        assert 'CREATE app/module-test2/component-name/component-name.component.ts' in result.output
        assert 'CREATE app/module-test2/component-name/component-name.component.css' in result.output
        assert 'UPDATE app/module-test2/module-test2.module.ts' in result.output
    def workflow(app_name, device, platform, shared):
        # Create an app
        app_path = TnsPaths.get_app_path(app_name=app_name)
        Folder.clean(app_path)
        NG.new(collection=NS_SCHEMATICS, project=app_name, shared=shared)
        TnsAssert.created(app_name=app_name, app_data=None)

        # Run app initially
        text = 'TAP'
        if shared:
            text = 'Welcome to'
        result = Tns.run(app_name=app_name, platform=platform, emulator=True, hmr=True)
        strings = TnsLogs.run_messages(app_name=app_name, platform=platform, bundle=True, hmr=True, app_type=AppType.NG)
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=300)
        device.wait_for_text(text=text)

        # Generate module and component
        NG.exec_command(command='g m module-test', cwd=app_path)
        NG.exec_command(command='g c module-test/component-test', cwd=app_path)

        # Update app.modules.ts
        app_module_name = 'app.module.ts'
        app_module_path = os.path.join(app_path, 'app', app_module_name)
        if shared:
            app_module_name = 'app.module.tns.ts'
            app_module_path = os.path.join(app_path, 'src', 'app', app_module_name)
        old_string = "import { HomeComponent } from './home/home.component';"
        new_string = "import { ComponentTestComponent } from './module-test/component-test/component-test.component';"
        File.replace(path=app_module_path, old_string=old_string, new_string=new_string)
        File.replace(path=app_module_path, old_string='HomeComponent,', new_string='ComponentTestComponent,')

        # Update app-routing.module.ts
        app_routing_module_name = 'app-routing.module.ts'
        app_routing_module_path = os.path.join(app_path, 'app', app_routing_module_name)
        if shared:
            app_routing_module_name = 'app.routes.ts'
            app_routing_module_path = os.path.join(app_path, 'src', 'app', app_routing_module_name)
        old_string = "import { HomeComponent } from './home/home.component';"
        new_string = "import { ComponentTestComponent } from './module-test/component-test/component-test.component';"
        File.replace(path=app_routing_module_path, old_string=old_string, new_string=new_string)
        File.replace(path=app_routing_module_path, old_string='HomeComponent', new_string='ComponentTestComponent')

        # Verify app is updated
        logs = [app_module_name.replace('.tns', ''), app_routing_module_name.replace('.tns', ''),
                'Successfully synced application']
        TnsLogs.wait_for_log(log_file=result.log_file, string_list=logs, timeout=120)
        device.wait_for_text(text='component-test works!')
Example #3
0
 def test_004_generate_master_detail(self):
     result = NG.exec_command(
         command='g master-detail --master=dogs --detail=dog',
         cwd=self.app_path)
     assert 'CREATE src/app/dogs/dog-detail/dog-detail.component.html' in result.output
     assert 'CREATE src/app/dogs/dog-detail/dog-detail.component.tns.html' in result.output
     assert 'CREATE src/app/dogs/dogs/dogs.component.html' in result.output
     assert 'CREATE src/app/dogs/dogs/dogs.component.tns.html' in result.output
     assert 'data.service.ts' in result.output
     assert 'dogs.module.ts' in result.output
Example #4
0
 def test_001_generate_component(self):
     result = NG.exec_command(command='g c component-test',
                              cwd=self.app_path)
     assert 'CREATE src/app/component-test/component-test.component.html' in result.output
     assert 'CREATE src/app/component-test/component-test.component.ts' in result.output
     assert 'CREATE src/app/component-test/component-test.component.css' in result.output
     assert 'CREATE src/app/component-test/component-test.component.tns.css' in result.output
     assert 'CREATE src/app/component-test/component-test.component.tns.html' in result.output
     assert 'UPDATE src/app/app.module.ts' in result.output
     assert 'UPDATE src/app/app.module.tns.ts' in result.output
Example #5
0
 def ng_serve(self, prod=False):
     NG.serve(project=self.app_name, prod=prod)
     self.chrome.open(DEFAULT_WEB_URL)
     if "Angular CLI: 8.3" in NG.exec_command(command="version").output:
         element = self.chrome.driver.find_element(
             By.XPATH, '//*[contains(text(), "TestApp app is running!")]')
     else:
         element = self.chrome.driver.find_element(
             By.XPATH, '//*[contains(text(), "Welcome")]')
     assert element.is_displayed(), 'Failed to serve default NG project.'
     Log.info('Default NG web project loaded!')
     NG.kill()
 def test_300_help_ng_new(self):
     output = NG.exec_command('new --collection={0} --help'.format(NS_SCHEMATICS)).output
     assert '--sample' in output
     assert 'Specifies whether a sample master detail should be generated' in output
     assert '--shared' in output
     assert 'Specifies whether to generate a shared project or a {N} only' in output
     assert '--source-dir (-sd)' in output
     assert 'The path of the source directory' in output
     assert '--style' in output
     assert 'The file extension to be used for style files. Supported are css and scss' in output
     assert '--theme' in output
     assert 'Specifies whether the {N} theme for styling should be included' in output
     assert '--webpack' in output
     assert 'Specifies whether the new application has webpack set up' in output
 def test_002_generate_module(self):
     result = NG.exec_command(command='g m module-test', cwd=self.app_path)
     assert 'CREATE app/module-test/module-test.module.ts' in result.output