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

AAE-29971 Buttons for dynamic component #10539

Merged
merged 2 commits into from
Jan 15, 2025
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
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
<div #container></div>
<mat-card>
<mat-card-content>
dutta-arnab1 marked this conversation as resolved.
Show resolved Hide resolved
<div #container></div>
</mat-card-content>
<mat-card-actions align="end">
<ng-content select="[buttons]"></ng-content>
</mat-card-actions>
</mat-card>
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
*/

import { ComponentFixture, TestBed } from '@angular/core/testing';

import { TaskScreenCloudComponent } from './screen-cloud.component';
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ScreenRenderingService } from '../../../services/public-api';
import { Component } from '@angular/core';
import { By } from '@angular/platform-browser';
import { ScreenRenderingService } from '../../../services/public-api';
import { TaskScreenCloudComponent } from './screen-cloud.component';

@Component({
selector: 'adf-cloud-test-component',
Expand All @@ -31,15 +30,27 @@ import { By } from '@angular/platform-browser';
})
class TestComponent {}

@Component({
selector: 'adf-cloud-test-actions-component',
template: `<adf-cloud-task-screen [taskId]="'1'" [appName]="'app-name-test'" [screenId]="'test'">
<div buttons class="adf-cloud-test-buttons">
<button>Test</button>
</div>
</adf-cloud-task-screen> `,
imports: [CommonModule, TaskScreenCloudComponent],
standalone: true
})
class TestWrapperComponent {}

describe('TaskScreenCloudComponent', () => {
let fixture: ComponentFixture<TaskScreenCloudComponent>;
let fixture: ComponentFixture<TestWrapperComponent>;
let screenRenderingService: ScreenRenderingService;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [TaskScreenCloudComponent, TestComponent]
imports: [TaskScreenCloudComponent, TestComponent, TestWrapperComponent]
});
fixture = TestBed.createComponent(TaskScreenCloudComponent);
fixture = TestBed.createComponent(TestWrapperComponent);
screenRenderingService = TestBed.inject(ScreenRenderingService);
screenRenderingService.register({ ['test']: () => TestComponent });
fixture.componentRef.setInput('screenId', 'test');
Expand All @@ -50,4 +61,9 @@ describe('TaskScreenCloudComponent', () => {
const dynamicComponent = fixture.debugElement.query(By.css('.adf-cloud-test-container'));
expect(dynamicComponent).toBeTruthy();
});

it('should project content into component', async () => {
const projectedContent = fixture.debugElement.query(By.css('.adf-cloud-test-buttons'));
expect(projectedContent).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
import { CommonModule } from '@angular/common';
import { Component, ComponentRef, inject, Input, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
import { ScreenRenderingService } from '../../../services/public-api';
import { MatCardModule } from '@angular/material/card';

@Component({
selector: 'adf-cloud-task-screen',
standalone: true,
imports: [CommonModule],
template: '<div #container></div>'
imports: [CommonModule, MatCardModule],
templateUrl: './screen-cloud.component.html'
})
export class TaskScreenCloudComponent implements OnInit {
/** Task id to fetch corresponding form and values. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@

<ng-container *ngSwitchCase="taskTypeEnum.Screen">
<adf-cloud-task-screen
[taskId]="taskId"
[appName]="appName"
[screenId]="screenId"
/>
[taskId]="taskId"
>
<ng-template [ngTemplateOutlet]="taskFormCloudButtons" buttons>
</ng-template>
</adf-cloud-task-screen>
</ng-container>

<ng-container *ngSwitchCase="taskTypeEnum.None">
Expand Down
Loading