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-10292] Fix opening two dialogs for card view array items #7770

Merged
merged 2 commits into from
Aug 16, 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div [attr.data-automation-id]="'card-array-label-' + property.key" class="adf-property-label">{{ property.label | translate }}</div>
<div class="adf-property-value adf-card-view-array-item-container" (click)="clicked()">
<div class="adf-property-value adf-card-view-array-item-container">
<ng-container *ngIf="(property.displayValue | async) as items; else elseEmptyValueBlock">
<mat-chip-list *ngIf="items.length > 0; else elseEmptyValueBlock" data-automation-id="card-arrayitem-chip-list-container">
<ng-container *ngIf="displayCount() > 0; else withOutDisplayCount" >
Expand Down Expand Up @@ -46,6 +46,7 @@
<span class="adf-card-array-item-default" data-automation-id="card-arrayitem-default">{{ property?.default | translate }}</span>
</ng-template>
<button mat-icon-button *ngIf="showClickableIcon()"
(click)="clicked()"
class="adf-array-item-action"
[attr.aria-label]="'CORE.METADATA.ACTIONS.EDIT' | translate"
[attr.title]="'CORE.METADATA.ACTIONS.EDIT' | translate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,11 @@
max-height: 300px;
overflow-y: auto;
}

.mat-chip {
cursor: pointer;
}
}

&-property-value {
.mat-chip-list {
width: 100%;
padding-top: 6px;
cursor: pointer;
}

.mat-chip {
cursor: pointer;
}
}

Expand All @@ -50,5 +40,9 @@
display: flex;
place-content: center space-between;
align-items: center;

.mat-chip:hover {
cursor: pointer;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ import { CardViewArrayItemComponent } from './card-view-arrayitem.component';
import { CardViewArrayItemModel, CardViewArrayItem } from '../../models/card-view-arrayitem.model';
import { By } from '@angular/platform-browser';
import { TranslateModule } from '@ngx-translate/core';
import { CardViewUpdateService } from 'core/public-api';

describe('CardViewArrayItemComponent', () => {
let component: CardViewArrayItemComponent;
let fixture: ComponentFixture<CardViewArrayItemComponent>;
let service: CardViewUpdateService;
let serviceSpy: jasmine.Spy;

const mockData = [
{ icon: 'person', value: 'Zlatan' },
Expand Down Expand Up @@ -55,10 +58,44 @@ describe('CardViewArrayItemComponent', () => {

beforeEach(() => {
fixture = TestBed.createComponent(CardViewArrayItemComponent);
service = TestBed.inject(CardViewUpdateService);
component = fixture.componentInstance;
component.property = new CardViewArrayItemModel(mockDefaultProps);
});

describe('Click event', () => {
beforeEach(() => {
serviceSpy = spyOn(service, 'clicked');
component.property = new CardViewArrayItemModel({
...mockDefaultProps,
clickable: true
});

fixture.detectChanges();
});

it('should call service on chip click', () => {
const chip: HTMLElement = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-Zlatan"]');
chip.dispatchEvent(new Event('click'));

expect(serviceSpy).toHaveBeenCalled();
});

it('should call service on edit icon click', () => {
const editIcon: HTMLElement = fixture.nativeElement.querySelector('[data-automation-id="card-array-item-clickable-icon-array"]');
editIcon.dispatchEvent(new Event('click'));

expect(serviceSpy).toHaveBeenCalled();
});

it('should NOT call service on chip list container click', () => {
const chiplistContainer: HTMLElement = fixture.nativeElement.querySelector('[data-automation-id="card-arrayitem-chip-list-container"]');
chiplistContainer.dispatchEvent(new Event('click'));

expect(serviceSpy).not.toHaveBeenCalled();
});
});

describe('Rendering', () => {
it('should render the label', () => {
fixture.detectChanges();
Expand Down