minor fixes

This commit is contained in:
Yasa-Nataliya
2023-09-05 17:52:39 +05:30
committed by Anukriti Singh
parent ee4173ca2e
commit 3b6236b8a0
5 changed files with 60 additions and 10 deletions
-1
View File
@@ -48,7 +48,6 @@ export class MetadataViewPage {
applyAspect = element(by.cssContainingText(`button span.mat-button-wrapper`, 'Apply Aspect'));
saveMetadataButton = $(`[data-automation-id='save-metadata']`);
saveGeneralMetadataButton = $(`[data-automation-id='save-generalInfo-metadata']`);
resetGeneralMetadataButton = $(`[data-automation-id='reset-general-metadata']`);
resetMetadataButton = $(`[data-automation-id='reset-metadata']`);
private getMetadataGroupLocator = async (groupName: string): Promise<ElementFinder> => $(`mat-expansion-panel[data-automation-id="adf-metadata-group-${groupName}"]`);
@@ -9,7 +9,8 @@
(keyup.enter)="addCategory()"
aria-labelledby="adf-category-name-input-label"
placeholder="{{'CATEGORIES_MANAGEMENT.INPUT_PLACEHOLDER' | translate }}"
adf-auto-focus />
adf-auto-focus
/>
<mat-error [hidden]="!categoryNameControl.invalid">{{ categoryNameErrorMessageKey | translate }}</mat-error>
</mat-form-field>
</div>
@@ -17,7 +18,7 @@
<span
*ngFor="let category of categories"
[class.adf-categories-padded]="!isCRUDMode"
class="adf-assigned-categories">
class="adf-assigned-categories">
{{ category.name }}
<button
data-automation-id="categories-remove-category-button"
@@ -37,7 +38,7 @@
<div class="adf-existing-categories-panel" *ngIf="existingCategoriesPanelVisible">
<ng-container *ngIf="isCRUDMode && (!existingCategoriesLoading || existingCategories)">
<span class="adf-create-category-label"
(click)="addCategory()"
(click)="addCategory()"
[hidden]="categoryNameControl.invalid || typing">
{{ 'CATEGORIES_MANAGEMENT.GENERIC_CREATE' | translate : { name: categoryNameControl.value } }}
</span>
@@ -62,8 +63,8 @@
</mat-selection-list>
</ng-container>
<mat-spinner
*ngIf="existingCategoriesLoading"
[diameter]="50"
*ngIf="existingCategoriesLoading"
[diameter]="50"
[attr.aria-label]="'CATEGORIES_MANAGEMENT.LOADING' | translate">
</mat-spinner>
</div>
@@ -391,6 +391,16 @@ describe('CategoriesManagementComponent', () => {
expect(categoriesChangeSpy).toHaveBeenCalledOnceWith(component.categories);
}));
it('should clear and not hide input after category is created', fakeAsync(() => {
createCategory('test');
const categoryControl: HTMLDivElement = fixture.debugElement.query(By.css('.adf-category-name-field')).nativeElement;
expect(categoryControl.hidden).toBeFalse();
expect(getExistingCategoriesList()).toEqual([]);
expect(component.categoryNameControl.value).toBe('');
expect(component.categoryNameControl.untouched).toBeTrue();
}));
it('should be able to remove added category', fakeAsync(() => {
createCategory('test');
@@ -55,7 +55,8 @@
<ng-container *ngIf="displayTags">
<mat-expansion-panel
(opened)="handleTagPanelOpen()"
(closed)="handleTagPanelClose()" hideToggle
(closed)="handleTagPanelClose()"
hideToggle
[expanded]="tagsPanelState">
<mat-expansion-panel-header>
<div class="adf-metadata-properties-panel-content">
@@ -86,7 +87,8 @@
<button mat-icon-button
(click)="saveTagsChanges($event)"
color="primary"
data-automation-id="save-tags-metadata" [disabled]="!hasMetadataChanged">
data-automation-id="save-tags-metadata"
[disabled]="!hasMetadataChanged">
<mat-icon>check</mat-icon>
</button>
</div>
@@ -127,7 +129,8 @@
</div>
<div class="adf-metadata-categories-title">
<button *ngIf="!editableCategories"
mat-icon-button (click)="toggleCategoriesEdit($event)"
mat-icon-button
(click)="toggleCategoriesEdit($event)"
[attr.title]="'CORE.METADATA.ACTIONS.EDIT' | translate"
[attr.aria-label]="'CORE.METADATA.ACCESSIBILITY.EDIT' | translate"
data-automation-id="meta-data-card-toggle-categoeies-edit"
@@ -412,6 +412,44 @@ describe('ContentMetadataComponent', () => {
}));
});
describe('saveChanges', () => {
it('should save general info changes and toggle editable', () => {
const event = new Event('click');
spyOn(component, 'saveChanges');
component.editable = true;
component.saveGeneralInfoChanges(event);
expect(component.saveChanges).toHaveBeenCalledWith(event);
expect(component.editable).toBe(false);
});
it('should save tags changes and toggle editableTags', () => {
const event = new Event('click');
spyOn(component, 'saveChanges');
component.editableTags = true;
component.saveTagsChanges(event);
expect(component.saveChanges).toHaveBeenCalledWith(event);
expect(component.editableTags).toBe(false);
});
it('should save categories changes and toggle editableCategories', () => {
const event = new Event('click');
spyOn(component, 'saveChanges');
component.editableCategories = true;
component.saveCategoriesChanges(event);
expect(component.saveChanges).toHaveBeenCalledWith(event);
expect(component.editableTags).toBe(false);
});
it('should save group changes and toggle group.editable', () => {
const group = { editable: true };
const event = new Event('click');
spyOn(component, 'saveChanges');
component.saveGroupChanges(group, event);
expect(component.saveChanges).toHaveBeenCalledWith(event);
expect(group.editable).toBe(false);
});
})
describe('cancelChanges', () => {
it('should cancel group changes and set group editable to false', () => {
const group = { editable: true };
@@ -1225,7 +1263,6 @@ describe('ContentMetadataComponent', () => {
const tagName2 = 'New tag 3';
updateService.update(property, 'updated-value');
// tick(800);
fixture.detectChanges();
tagsCreator.tagsChange.emit([tagName1, tagName2]);