Skip to content

Commit

Permalink
chore(isct-13): start add tests attributes to modal
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyKIron committed Oct 5, 2023
1 parent 500dfbd commit 516462b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="modal" #modalHolder>
<div class="modal" [attr.data-testid]="testIdsService.getTestAttribute.bind(this) | generic:testId:modalTestIdModifiers.MODAL" #modalHolder>
<div class="modal-body" [class.has-footer]="configuration?.hasFooter" [class.has-header]="configuration?.headerText" [style.width]="configuration?.width" [style.height]="configuration?.height" #modalBody>

<fusion-modal-header [headerText]="configuration?.headerText" [infoText]="configuration?.headerInfoText" (close)="onClose(true, 'close')"></fusion-modal-header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import {IconModule} from '@ironsource/fusion-ui/components/icon/v1';
import {ModalFooterComponent} from './components/modal-footer/modal-footer.component';
import {ModalContentComponent} from './components/modal-content/modal-content.component';
import {ModalHeaderComponent} from './components/modal-header/modal-header.component';
import {GenericPipe} from "@ironsource/fusion-ui/pipes/generic";

describe('ModalComponent', () => {
let component: ModalComponent;
let fixture: ComponentFixture<ModalComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ButtonModule, IconModule],
imports: [ButtonModule, IconModule, GenericPipe],
declarations: [ModalComponent, ModalFooterComponent, ModalContentComponent, ModalHeaderComponent]
}).compileComponents();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default {
}
},
args: {
configuration: DEFAULT_CONFIGURATION
configuration: DEFAULT_CONFIGURATION,
testId: 'modal-test-id'
}
} as Meta<ModalComponent>;

Expand All @@ -53,7 +54,7 @@ hr{
margin: 20px 0;
}
</style>
<fusion-modal [configuration]="configuration" [submitPending]="submitPending">
<fusion-modal [configuration]="configuration" [submitPending]="submitPending" [testId]="testId">
<div class="content-example">Content item placeholder. To be replaced with component</div>
<hr/>
<div class="content-example">Content item placeholder. To be replaced with component</div>
Expand Down
11 changes: 10 additions & 1 deletion projects/fusion-ui/components/modal/v3/modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
EventEmitter,
forwardRef,
Inject,
Injector,
Input,
OnDestroy,
OnInit,
Expand All @@ -22,6 +23,8 @@ import {ModalConfiguration} from './modal.entities';
import {getDefaultCssUnit} from './modal-utils';
import {takeUntil} from 'rxjs/operators';
import {isNullOrUndefined} from '@ironsource/fusion-ui/utils';
import {ModalTestIdModifiers} from '@ironsource/fusion-ui/entities';
import {TestIdsService} from '@ironsource/fusion-ui/services/test-ids';

@Component({
selector: 'fusion-modal',
Expand Down Expand Up @@ -56,6 +59,8 @@ export class ModalComponent implements OnDestroy, OnInit {
return this._configuration.getValue();
}

@Input() testId: string;

@Output() open = new EventEmitter();
@Output() close = new EventEmitter();

Expand All @@ -64,6 +69,9 @@ export class ModalComponent implements OnDestroy, OnInit {
/** @internal */
@ViewChild('modalHolder', {static: true}) modalHolder: ElementRef;

modalTestIdModifiers: typeof ModalTestIdModifiers = ModalTestIdModifiers;
testIdsService: TestIdsService = this.injector.get(TestIdsService);

private uid: string;
private _configuration = new BehaviorSubject<ModalConfiguration>(null);
private isClosed$ = new BehaviorSubject<boolean>(false);
Expand All @@ -76,7 +84,8 @@ export class ModalComponent implements OnDestroy, OnInit {
private elRef: ElementRef,
private windowRef: WindowService,
private logService: LogService,
private renderer: Renderer2
private renderer: Renderer2,
private injector: Injector
) {
this.uid = this.uidService.getUniqueId().toString();
}
Expand Down
3 changes: 2 additions & 1 deletion projects/fusion-ui/components/modal/v3/modal.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import {LoaderModule} from '@ironsource/fusion-ui/components/loader/v2';
import {ButtonModule} from '@ironsource/fusion-ui/components/button/v3';
import {IconModule} from '@ironsource/fusion-ui/components/icon/v1';
import {TooltipModule} from '@ironsource/fusion-ui/components/tooltip/v3';
import {GenericPipe} from '@ironsource/fusion-ui/pipes/generic';

@NgModule({
declarations: [ModalComponent, ModalFooterComponent, ModalContentComponent, ModalHeaderComponent],
exports: [ModalComponent, ModalFooterComponent, ModalContentComponent, ModalHeaderComponent],
imports: [CommonModule, LoaderModule, ButtonModule, IconModule, TooltipModule]
imports: [CommonModule, LoaderModule, ButtonModule, IconModule, TooltipModule, GenericPipe]
})
export class ModalModule {}

0 comments on commit 516462b

Please sign in to comment.