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

pre angular 15 cleanup #8961

Merged
merged 8 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 2 additions & 6 deletions lib/cli/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"overrides": [
{
"files": ["*.ts"],
"extends": [
"plugin:@nrwl/nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
],
"extends": ["plugin:@nrwl/nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
"rules": {
"prefer-arrow/prefer-arrow-functions": "off",
"@typescript-eslint/no-var-requires": "off",
Expand Down Expand Up @@ -41,8 +38,7 @@
{
"files": ["*.html"],
"extends": ["plugin:@nrwl/nx/angular-template"],
"rules": {
}
"rules": {}
}
]
}
20 changes: 4 additions & 16 deletions lib/content-services/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"overrides": [
{
"files": ["*.ts"],
"extends": [
"plugin:@nrwl/nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
],
"extends": ["plugin:@nrwl/nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
"rules": {
"jsdoc/newline-after-description": "warn",
"@typescript-eslint/naming-convention": "warn",
Expand All @@ -27,24 +24,15 @@
"error",
{
"type": "element",
"prefix": [
"adf",
"app"
],
"prefix": ["adf", "app"],
"style": "kebab-case"
}
],
"@angular-eslint/directive-selector": [
"error",
{
"type": [
"element",
"attribute"
],
"prefix": [
"adf",
"app"
],
"type": ["element", "attribute"],
"prefix": ["adf", "app"],
"style": "kebab-case"
}
],
Expand Down
16 changes: 5 additions & 11 deletions lib/content-services/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
const rootMain = require('../../../.storybook/main');

module.exports = {
...rootMain,
core: { ...rootMain.core, builder: 'webpack5' },
stories: [
...rootMain.stories,
'../**/*.stories.@(js|jsx|ts|tsx)'
],
staticDirs: [
...rootMain.staticDirs,
{ from: __dirname + '/../src/lib/i18n', to: 'assets/adf-content-services/i18n' }
],
addons: [...rootMain.addons ]
...rootMain,
core: { ...rootMain.core, builder: 'webpack5' },
stories: [...rootMain.stories, '../**/*.stories.@(js|jsx|ts|tsx)'],
staticDirs: [...rootMain.staticDirs, { from: __dirname + '/../src/lib/i18n', to: 'assets/adf-content-services/i18n' }],
addons: ['@storybook/addon-essentials', ...rootMain.addons]
};
Original file line number Diff line number Diff line change
Expand Up @@ -504,12 +504,16 @@ describe('CategoriesManagementComponent', () => {
describe('Errors', () => {
it('should display validation error when searching for empty category', fakeAsync(() => {
typeCategory(' ');
component.categoryNameControl.markAsTouched();
fixture.detectChanges();

expect(getFirstError()).toBe('CATEGORIES_MANAGEMENT.ERRORS.EMPTY_CATEGORY');
}));

it('should show error for required', fakeAsync(() => {
typeCategory('');
component.categoryNameControl.markAsTouched();
fixture.detectChanges();

expect(getFirstError()).toBe('CATEGORIES_MANAGEMENT.ERRORS.REQUIRED');
}));
Expand All @@ -534,6 +538,7 @@ describe('CategoriesManagementComponent', () => {
it('should show error for required when not typed anything and blur input', fakeAsync(() => {
typeCategory('');
getCategoryControlInput().blur();
component.categoryNameControl.markAsTouched();
fixture.detectChanges();

expect(getFirstError()).toBe('CATEGORIES_MANAGEMENT.ERRORS.REQUIRED');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
displayCategories = false;

private _assignedTags: string[] = [];
private assignedTagsEntries: TagEntry[];
private assignedTagsEntries: TagEntry[] = [];
private _editable = false;
private _tagsCreatorMode = TagsCreatorMode.CREATE_AND_ASSIGN;
private _tags: string[] = [];
Expand Down Expand Up @@ -318,7 +318,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
this._saving = false;
return of(null);
}))
.subscribe((result) => {
.subscribe((result: any) => {
if (result) {
this.updateUndefinedNodeProperties(result.updatedNode);
if (this.hasContentTypeChanged(this.changedProperties)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('PropertyDescriptorLoaderService', () => {
expect(data['exif:exif']).toBe(exifResponse);
expect(data['cm:content']).toBe(contentResponse);
},
complete: done
complete: () => done()
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ describe('ContentNodeSelectorComponent', () => {
const adfUploadButton = fixture.debugElement.query(By.css('adf-upload-button'));

expect(adfUploadButton).not.toBeNull();
expect(adfUploadButton.nativeElement.innerText).toEqual('file_uploadFORM.FIELD.UPLOAD');
expect(adfUploadButton.nativeElement.textContent).toEqual('file_uploadFORM.FIELD.UPLOAD');
});

it('should be able to disable UploadButton if showingSearch set to true', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
[style.display]="isExpiryDateToggleChecked ? 'block' : 'none'"
data-automation-id="adf-slide-toggle-checked"
class="adf-share-link__date-time-container">
<mat-form-field class="adf-full-width adf-float-label" floatLabel='never'>
<mat-form-field class="adf-full-width adf-float-label">
<mat-label>{{ 'SHARE.EXPIRATION-PLACEHOLDER' | translate }}</mat-label>
<mat-datepicker-toggle
[disabled]="time.disabled"
Expand Down Expand Up @@ -74,7 +74,6 @@
</div>
<mat-form-field
class="adf-full-width adf-float-label"
floatLabel='never'
[ngClass]="isLinkWithExpiryDate? 'adf-share-link__border-color' : ''">
<input
#sharedLinkInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@
import { Component, Inject, OnInit, ViewEncapsulation, ViewChild, OnDestroy } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
import { MatSlideToggleChange } from '@angular/material/slide-toggle';
import {
UntypedFormGroup,
UntypedFormControl,
AbstractControl,
Validators,
ValidationErrors
} from '@angular/forms';
import { AbstractControl, FormControl, FormGroup, Validators } from '@angular/forms';
import { Subject } from 'rxjs';
import { ContentService } from '../common/services/content.service';
import { SharedLinksApiService } from './services/shared-links-api.service';
Expand All @@ -44,9 +38,8 @@ type DatePickerType = 'date' | 'time' | 'month' | 'datetime';
encapsulation: ViewEncapsulation.None
})
export class ShareDialogComponent implements OnInit, OnDestroy {
private minDateValidator = (control: AbstractControl): ValidationErrors | null => {
return isBefore(endOfDay(new Date(control.value)), this.minDate) ? {invalidDate: true} : null;
};
private minDateValidator = (control: AbstractControl): any =>
isBefore(endOfDay(new Date(control.value)), this.minDate) ? { invalidDate: true } : null;

minDate = add(new Date(), { days: 1 });
sharedId: string;
Expand All @@ -55,9 +48,9 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
isFileShared = false;
isDisabled = false;
isLinkWithExpiryDate = false;
form: UntypedFormGroup = new UntypedFormGroup({
sharedUrl: new UntypedFormControl(''),
time: new UntypedFormControl({value: '', disabled: true}, [Validators.required, this.minDateValidator])
form: FormGroup = new FormGroup({
sharedUrl: new FormControl(''),
time: new FormControl({ value: '', disabled: true }, [Validators.required, this.minDateValidator])
});
type: DatePickerType = 'date';
maxDebounceTime = 500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe('Confirm Dialog Component', () => {
By.css('[data-automation-id="adf-confirm-dialog-confirm-all"]')
);
expect(thirdOptionElement).not.toBeNull();
expect(thirdOptionElement.nativeElement.innerText).toBe('YES ALL');
expect(thirdOptionElement.nativeElement.innerText.toUpperCase()).toBe('YES ALL');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ describe('DocumentList', () => {
documentList.executeContentAction(node, action);

expect(action.execute).not.toHaveBeenCalled();
deleteObservable.next();
deleteObservable.next(undefined);
expect(action.execute).toHaveBeenCalledWith(node);
});

Expand Down
2 changes: 1 addition & 1 deletion lib/content-services/src/lib/material.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { MatCardModule } from '@angular/material/card';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatChipsModule } from '@angular/material/chips';
import { MatOptionModule, MatRippleModule } from '@angular/material/core';
import { MatRippleModule, MatOptionModule } from '@angular/material/core';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatDialogModule } from '@angular/material/dialog';
import { MatExpansionModule } from '@angular/material/expansion';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('AddPermissionDialog', () => {
it('should show the INJECTED title', () => {
const titleElement = fixture.debugElement.query(By.css('#add-permission-dialog-title'));
expect(titleElement).not.toBeNull();
expect(titleElement.nativeElement.innerText).toBe('dead or alive you are coming with me');
expect(titleElement.nativeElement.innerText.trim()).toBe('dead or alive you are coming with me');
});

it('should close the dialog when close button is clicked', () => {
Expand Down Expand Up @@ -128,7 +128,7 @@ describe('AddPermissionDialog', () => {
await fixture.whenStable();

const selectBox = fixture.debugElement.query(By.css(('[id="adf-select-role-permission"] .mat-select-trigger')));
selectBox.triggerEventHandler('click', null);
selectBox.nativeElement.dispatchEvent(new Event('click'));
fixture.detectChanges();

const options = fixture.debugElement.queryAll(By.css('mat-option'));
Expand Down Expand Up @@ -171,7 +171,7 @@ describe('AddPermissionDialog', () => {
await fixture.whenStable();

const selectBox = fixture.debugElement.query(By.css(('[id="adf-bulk-select-role-permission"] .mat-select-trigger')));
selectBox.triggerEventHandler('click', null);
selectBox.nativeElement.dispatchEvent(new Event('click'));

fixture.detectChanges();
await fixture.whenStable();
Expand Down Expand Up @@ -213,7 +213,7 @@ describe('AddPermissionDialog', () => {
await fixture.whenStable();

const selectBox = fixture.debugElement.query(By.css(('[id="adf-select-role-permission"] .mat-select-trigger')));
selectBox.triggerEventHandler('click', null);
selectBox.nativeElement.dispatchEvent(new Event('click'));

fixture.detectChanges();
await fixture.whenStable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<mat-list-option id="adf-add-permission-group-everyone"
class="adf-list-option-item"
#eveyone
disableRipple
[disableRipple]="true"
[value]="EVERYONE">
<adf-user-icon-column [node]="EVERYONE" id="add-group-icon" [selected]="eveyone.selected"></adf-user-icon-column>
<p class="adf-result-name">
Expand All @@ -50,7 +50,7 @@
</mat-list-option>

<mat-list-option *ngFor="let item of data?.list?.entries; let idx = index"
disableRipple
[disableRipple]="true"
[value]="item"
class="adf-list-option-item"
id="result_option_{{idx}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { By } from '@angular/platform-browser';
import { of } from 'rxjs';
import { fakeAuthorityListResult, fakeNameListResult } from '../../../mock/add-permission.component.mock';
import { ContentTestingModule } from '../../../testing/content.testing.module';
import { SearchService } from '../../../search/services/search.service';
import { SearchService } from '../../../search/services/search.service';
import { DebugElement } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import { MatIconTestingModule } from '@angular/material/icon/testing';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class PermissionListService {

toggleInherited(change: MatSlideToggleChange) {
if (this.contentService.hasAllowableOperations(this.node, AllowableOperationsEnum.UPDATEPERMISSIONS)) {
let updateLocalPermission$ = of(null);
let updateLocalPermission$: Observable<Node> = of(null);
const nodeBody = {
permissions: {
isInheritanceEnabled: !this.node.permissions.isInheritanceEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class PopOverDirective implements OnInit, OnDestroy, AfterViewInit {
ngOnDestroy(): void {
this.element.nativeElement.removeEventListener('keydown', this.preventDefaultForEnter);
this.detachOverlay();
this.destroy$.next();
this.destroy$.next(undefined);
this.destroy$.complete();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ export class SearchFacetFiltersService implements OnDestroy {
}

ngOnDestroy(): void {
this.onDestroy$.next();
this.onDestroy$.next(undefined);
this.onDestroy$.complete();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,17 @@ describe('TagService', () => {
});

describe('createTags', () => {
it('should call createTags on tagsApi', () => {
it('should call createTags on tagsApi', (done) => {
spyOn(service.tagsApi, 'createTags').and.returnValue(Promise.resolve([]));
const tag1 = new TagBody();
tag1.tag = 'Some tag 1';
const tag2 = new TagBody();
tag2.tag = 'Some tag 2';
const tags = [tag1, tag2];
service.createTags(tags);

expect(service.tagsApi.createTags).toHaveBeenCalledWith(tags);
done();
});

it('should emit refresh when tags creation is success', fakeAsync(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,25 +381,31 @@ describe('TagsCreatorComponent', () => {

it('should show error for only spaces', fakeAsync(() => {
typeTag(' ');
component.tagNameControl.markAsTouched();
fixture.detectChanges();
const error = getFirstError();
expect(error).toBe('TAG.TAGS_CREATOR.ERRORS.EMPTY_TAG');
}));

it('should show error for only spaces if tags are changed', fakeAsync(() => {
typeTag(' ');
component.tagNameControl.markAsTouched();
component.tags = ['new tag 1', 'new tag 2'];
fixture.detectChanges();
expect(getFirstError()).toBe('TAG.TAGS_CREATOR.ERRORS.EMPTY_TAG');
}));

it('should show error for required', fakeAsync(() => {
typeTag('');
component.tagNameControl.markAsTouched();
fixture.detectChanges();
const error = getFirstError();
expect(error).toBe('TAG.TAGS_CREATOR.ERRORS.REQUIRED');
}));

it('should not show error for required if tags are changed', fakeAsync(() => {
typeTag('');
component.tagNameControl.markAsTouched();
component.tags = ['new tag 1', 'new tag 2'];
fixture.detectChanges();
expect(getFirstError()).toBeUndefined();
Expand Down Expand Up @@ -443,10 +449,7 @@ describe('TagsCreatorComponent', () => {

it('should error for required when not typed anything and blur input', fakeAsync(() => {
component.tagNameControlVisible = true;
fixture.detectChanges();
tick(100);

getNameInput().blur();
component.tagNameControl.markAsTouched();
fixture.detectChanges();

const error = getFirstError();
Expand Down Expand Up @@ -600,6 +603,8 @@ describe('TagsCreatorComponent', () => {
);

typeTag('Tag');
component.tagNameControl.markAsTouched();
fixture.detectChanges();

const tagElements = getExistingTags();
expect(tagElements).toEqual([tag1, tag2]);
Expand Down Expand Up @@ -782,6 +787,8 @@ describe('TagsCreatorComponent', () => {

it('should be displayed when existing tags are loading', fakeAsync(() => {
typeTag('tag', 0);
component.tagNameControl.markAsTouched();
fixture.detectChanges();

const spinner = getSpinner();
expect(spinner).toBeTruthy();
Expand Down
Loading