Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(angular): update component correctly when remote uses inlineTemplate #12256

Merged
merged 1 commit into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions packages/angular/src/generators/remote/remote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,30 @@ describe('MF Remote App Generator', () => {
expect(projects.has('remote1-e2e')).toBeFalsy();
});

it('should generate a correct app component when inline template is used', async () => {
// ARRANGE
const tree = createTreeWithEmptyWorkspace();

// ACT
await remote(tree, {
name: 'test',
inlineTemplate: true,
});

// ASSERT
expect(tree.read('apps/test/src/app/app.component.ts', 'utf-8'))
.toMatchInlineSnapshot(`
"import { Component } from '@angular/core';

@Component({
selector: 'proj-root',
template: '<router-outlet></router-outlet>'

})
export class AppComponent {}"
`);
});

it('should update the index.html to use the remote entry component selector for root when standalone', async () => {
// ARRANGE
const tree = createTreeWithEmptyWorkspace();
Expand Down
5 changes: 4 additions & 1 deletion packages/angular/src/generators/remote/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,11 @@ function removeDeadCode(tree: Tree, options: Schema) {
);
if (!options.standalone) {
const component =
tree.read(pathToAppComponent, 'utf-8').split('templateUrl')[0] +
tree
.read(pathToAppComponent, 'utf-8')
.split(options.inlineTemplate ? 'template' : 'templateUrl')[0] +
`template: '<router-outlet></router-outlet>'

})
export class AppComponent {}`;

Expand Down