Linting fixes (#9348)

* linting fixes

* lint fixes

* linting and spellcheck fixes

* code fixes
This commit is contained in:
Denys Vuika 2024-02-16 11:04:49 -05:00 committed by GitHub
parent 9b0104fcf5
commit 4c75a6748c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 100 additions and 114 deletions

View File

@ -141,7 +141,9 @@
"Whitespaces",
"xdescribe",
"xsrf",
"BPMECM"
"BPMECM",
"berseria",
"zestiria"
],
"dictionaries": [
"html",

View File

@ -133,6 +133,7 @@ describe('ContentService', () => {
describe('Node Icons', () => {
let node: Node;
beforeEach(() => {
node = {
isFolder: true,
isFile: false,
@ -150,6 +151,7 @@ describe('ContentService', () => {
id: 'test node 1',
aspectNames: ['']
} as Node;
});
it('should resolve folder icon', () => {
expect(contentService.getNodeIcon(node)).toContain('assets/images/ft_ic_folder.svg');

View File

@ -16,21 +16,14 @@
*/
import { LayoutOrientedConfigService } from './layout-oriented-config.service';
import {
LayoutOrientedConfig,
Property,
OrganisedPropertyGroup,
PropertyGroupContainer
} from '../../interfaces/content-metadata.interfaces';
import { LayoutOrientedConfig, Property, OrganisedPropertyGroup, PropertyGroupContainer } from '../../interfaces/content-metadata.interfaces';
describe('LayoutOrientedConfigService', () => {
let configService: LayoutOrientedConfigService;
const createConfigService = (configObj: LayoutOrientedConfig) => new LayoutOrientedConfigService(configObj);
describe('isGroupAllowed', () => {
const testCases = [
{
config: [],
@ -48,11 +41,15 @@ describe('LayoutOrientedConfigService', () => {
groupNameToQuery: 'berseria'
},
{
config: [{
title: 'Deamons', items: [
{ aspect: 'zestiria', properties: '*' }, { aspect: 'berseria', properties: '*' }
config: [
{
title: 'Deamons',
items: [
{ aspect: 'zestiria', properties: '*' },
{ aspect: 'berseria', properties: '*' }
]
}],
}
],
expectation: true,
groupNameToQuery: 'berseria'
},
@ -73,9 +70,7 @@ describe('LayoutOrientedConfigService', () => {
groupNameToQuery: 'phantasia'
},
{
config: [
{ title: 'Deamons', includeAll: true, items: [{ aspect: 'zestiria', properties: '*' }] }
],
config: [{ title: 'Deamons', includeAll: true, items: [{ aspect: 'zestiria', properties: '*' }] }],
expectation: true,
groupNameToQuery: 'phantasia'
}
@ -93,7 +88,6 @@ describe('LayoutOrientedConfigService', () => {
});
describe('reorganiseByConfig', () => {
interface TestCase {
name: string;
config: LayoutOrientedConfig;
@ -123,94 +117,81 @@ describe('LayoutOrientedConfigService', () => {
name: 'First property of a group in one item',
config: [
{
title: 'First group', items: [
{ aspect: 'berseria', properties: ['property1'] }
]
title: 'First group',
items: [{ aspect: 'berseria', properties: ['property1'] }]
}
],
expectations: [
{ title: 'First group', properties: [property1] }
]
expectations: [{ title: 'First group', properties: [property1] }]
},
{
name: 'Second property of a group in one item',
config: [
{
title: 'First group', items: [
{ aspect: 'berseria', properties: ['property2'] }
]
title: 'First group',
items: [{ aspect: 'berseria', properties: ['property2'] }]
}
],
expectations: [
{ title: 'First group', properties: [property2] }
]
expectations: [{ title: 'First group', properties: [property2] }]
},
{
name: 'Properties with editable flag',
config: [
{
title: 'Editable property', items: [
title: 'Editable property',
items: [
{ aspect: 'otherTales', properties: ['property5'], editable: true },
{ aspect: 'otherTales', properties: ['property6'], editable: false }
]
}
],
expectations: [
{ title: 'Editable property', properties: [property5, property6] }
]
expectations: [{ title: 'Editable property', properties: [property5, property6] }]
},
{
name: 'More properties from one group in one item',
config: [
{
title: 'First group', items: [
{ aspect: 'berseria', properties: ['property2', 'property1'] }
]
title: 'First group',
items: [{ aspect: 'berseria', properties: ['property2', 'property1'] }]
}
],
expectations: [
{ title: 'First group', properties: [property2, property1] }
]
expectations: [{ title: 'First group', properties: [property2, property1] }]
},
{
name: 'First property of the second group in one item',
config: [
{
title: 'First group', items: [
{ aspect: 'zestiria', properties: ['property4'] }
]
title: 'First group',
items: [{ aspect: 'zestiria', properties: ['property4'] }]
}
],
expectations: [
{ title: 'First group', properties: [property4] }
]
expectations: [{ title: 'First group', properties: [property4] }]
},
{
name: 'One-one properties from multiple groups in one item',
config: [
{
title: 'First group', items: [
title: 'First group',
items: [
{ aspect: 'zestiria', properties: ['property4'] },
{ aspect: 'berseria', properties: ['property1'] }
]
}
],
expectations: [
{ title: 'First group', properties: [property4, property1] }
]
expectations: [{ title: 'First group', properties: [property4, property1] }]
},
{
name: 'Multiple properties mixed from multiple groups in multiple items',
config: [
{
title: 'First group', items: [
title: 'First group',
items: [
{ aspect: 'zestiria', properties: ['property4'] },
{ type: 'berseria', properties: ['property1'] }
]
},
{
title: 'Second group', items: [
title: 'Second group',
items: [
{ aspect: 'zestiria', properties: ['property3'] },
{ type: 'berseria', properties: ['property2', 'property1'] },
{ aspect: 'zestiria', properties: ['property4'] }
@ -226,15 +207,15 @@ describe('LayoutOrientedConfigService', () => {
name: 'Multiple properties mixed from multiple groups in multiple items with "*"',
config: [
{
title: 'First group', items: [
title: 'First group',
items: [
{ aspect: 'zestiria', properties: '*' },
{ type: 'berseria', properties: ['property1'] }
]
},
{
title: 'Second group', items: [
{ type: 'berseria', properties: ['property2', 'property1'] }
]
title: 'Second group',
items: [{ type: 'berseria', properties: ['property2', 'property1'] }]
}
],
expectations: [
@ -246,22 +227,22 @@ describe('LayoutOrientedConfigService', () => {
name: 'Not existing property',
config: [
{
title: 'First group', items: [
title: 'First group',
items: [
{ aspect: 'zestiria', properties: '*' },
{ type: 'berseria', properties: ['not-existing-property'] },
{ type: 'berseria', properties: ['property2'] }
]
}
],
expectations: [
{ title: 'First group', properties: [property3, property4, property2] }
]
expectations: [{ title: 'First group', properties: [property3, property4, property2] }]
},
{
name: 'Not existing group',
config: [
{
title: 'First group', items: [
title: 'First group',
items: [
{ aspect: 'zestiria', properties: '*' },
{ type: 'not-existing-group', properties: '*' },
{ type: 'berseria', properties: ['property2'] },
@ -269,9 +250,7 @@ describe('LayoutOrientedConfigService', () => {
]
}
],
expectations: [
{ title: 'First group', properties: [property3, property4, property2] }
]
expectations: [{ title: 'First group', properties: [property3, property4, property2] }]
},
{
name: 'Custom Title',
@ -297,7 +276,6 @@ describe('LayoutOrientedConfigService', () => {
}
]
}
];
testCases.forEach((testCase) => {
@ -308,7 +286,7 @@ describe('LayoutOrientedConfigService', () => {
expect(organisedPropertyGroups.length).toBe(testCase.expectations.length, 'Group count should match');
testCase.expectations.forEach((expectation, i) => {
expect(organisedPropertyGroups[i].title).toBe(expectation.title, 'Group\'s title should match');
expect(organisedPropertyGroups[i].title).toBe(expectation.title, 'Group title should match');
expect(organisedPropertyGroups[i].properties.length).toBe(
expectation.properties.length,
`Property count for "${organisedPropertyGroups[i].title}" group should match.`
@ -322,23 +300,27 @@ describe('LayoutOrientedConfigService', () => {
});
it('should include all exclusions passed to filterExcludedPreset', () => {
let properties: OrganisedPropertyGroup[] = [{
const properties: OrganisedPropertyGroup[] = [
{
name: 'propGroup',
title: 'propGroup',
properties: [ { name: 'property1', title: 'Custom title', editable: true } as Property,
properties: [
{ name: 'property1', title: 'Custom title', editable: true } as Property,
{ name: 'property2', title: 'Custom title', editable: true } as Property,
{ name: 'property3', title: 'Custom title', editable: true } as Property,
{ name: 'property4', title: 'Custom title', editable: true } as Property,
]}];
{ name: 'property4', title: 'Custom title', editable: true } as Property
]
}
];
configService = createConfigService([
{ title: 'Property group', items: [ { aspect: 'berseria', properties: ['property1', 'property2', 'property3', 'property4'] } ] },
{ title: 'Exclude group 1', items: [ { exclude: ['property1'], properties: [] } ] },
{ title: 'Exclude group 2', items: [ { exclude: ['property2'], properties: [] } ] },
{ title: 'Exclude group 3', items: [ { exclude: ['property3'], properties: [] } ] },
{ title: 'Property group', items: [{ aspect: 'berseria', properties: ['property1', 'property2', 'property3', 'property4'] }] },
{ title: 'Exclude group 1', items: [{ exclude: ['property1'], properties: [] }] },
{ title: 'Exclude group 2', items: [{ exclude: ['property2'], properties: [] }] },
{ title: 'Exclude group 3', items: [{ exclude: ['property3'], properties: [] }] }
]);
let result = configService.filterExcludedPreset(properties);
const result = configService.filterExcludedPreset(properties);
expect(result.length).toBe(1);
});

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { DownloadBodyCreate, DownloadEntry, Node } from '@alfresco/js-api';
import { DownloadBodyCreate, DownloadEntry, DownloadsApi, Node } from '@alfresco/js-api';
import { from, Observable, of, ReplaySubject, Subject } from 'rxjs';
import { catchError } from 'rxjs/internal/operators/catchError';
import { zipNode, downloadEntry } from './download-zip-data.mock';
@ -40,7 +40,7 @@ class AlfrescoApiMock {
}
export class ContentApiMock {
getContentUrl = (_: string, _1?: boolean, _2?: string): string => zipNode.entry.contentUrl;
getContentUrl = (): string => zipNode.entry.contentUrl;
}
class CoreMock {
@ -49,19 +49,19 @@ class CoreMock {
}
export class NodesApiMock {
getNode = (_: string, _2?: any): any => of(zipNode.entry);
getNode = (): any => of(zipNode.entry);
}
class DownloadsApiMock {
createDownload = (_: DownloadBodyCreate, _2?: any): Promise<DownloadEntry> => Promise.resolve(downloadEntry);
class DownloadsApiMock extends DownloadsApi {
createDownload = (): Promise<DownloadEntry> => Promise.resolve(downloadEntry);
getDownload = (_: string, _2?: any): Promise<DownloadEntry> => Promise.resolve(downloadEntry);
cancelDownload(_: string) {}
getDownload = (): Promise<DownloadEntry> => Promise.resolve(downloadEntry);
cancelDownload = () => Promise.resolve(true);
}
export class DownloadZipMockService {
private _downloadsApi: DownloadsApiMock;
get downloadsApi(): DownloadsApiMock {
private _downloadsApi: DownloadsApi;
get downloadsApi(): DownloadsApi {
this._downloadsApi = this._downloadsApi ?? new DownloadsApiMock();
return this._downloadsApi;
}

View File

@ -199,7 +199,7 @@ export class LibraryDialogComponent implements OnInit, OnDestroy {
}
private handleError(error: any): any {
let errorMessage = 'CORE.MESSAGES.ERRORS.GENERIC';
const errorMessage = 'CORE.MESSAGES.ERRORS.GENERIC';
try {
const {

View File

@ -912,15 +912,15 @@ describe('DocumentList', () => {
documentList.dataTable.columnsWidthChanged.emit(newColumnWidth as DataColumn[]);
expect(documentList.onColumnsWidthChange).toHaveBeenCalledWith(newColumnWidth);
expect(documentList.columnsWidthChanged.emit).toHaveBeenCalledWith({'tag': 65, 'name': 77});
expect(documentList.columnsWidthChanged.emit).toHaveBeenCalledWith({tag: 65, name: 77});
});
it('should emit new columns visibility', () => {
const newColumnsVisisbility = [{key: 'key', type: 'text', id: 'tag', isHidden: true}, {key: 'key1', type: 'text', id: 'name'}];
const newColumnsVisibility = [{key: 'key', type: 'text', id: 'tag', isHidden: true}, {key: 'key1', type: 'text', id: 'name'}];
spyOn(documentList.columnsVisibilityChanged, 'emit');
documentList.onColumnsVisibilityChange(newColumnsVisisbility as DataColumn[]);
documentList.onColumnsVisibilityChange(newColumnsVisibility as DataColumn[]);
expect(documentList.columnsVisibilityChanged.emit).toHaveBeenCalledWith({'tag': false});
expect(documentList.columnsVisibilityChanged.emit).toHaveBeenCalledWith({tag: false});
});
it('should perform folder navigation on single click', () => {

View File

@ -62,7 +62,7 @@ export const mockSearchFilterWithDisplayedLabelsByField: SearchCategory = {
field: 'test',
placeholder: 'test placeholder',
displayedLabelsByField: {
'test': 'test-tab-label'
test: 'test-tab-label'
}
}
}

View File

@ -24,7 +24,7 @@ import { SearchWidgetSettings } from '../search/models/search-widget-settings.in
export class TabLabelsPipe implements PipeTransform {
transform(field: string, settings?: SearchWidgetSettings): string {
return settings && settings.displayedLabelsByField && settings.displayedLabelsByField[field] ? settings.displayedLabelsByField[field] : field;
return settings?.displayedLabelsByField?.[field] ? settings.displayedLabelsByField[field] : field;
}
}

View File

@ -179,6 +179,6 @@ export class SearchDateRangeTabbedComponent implements SearchWidget, OnInit {
}
private getDisplayLabelForField(fieldForDisplayLabel: string): string {
return this.settings && this.settings.displayedLabelsByField && this.settings.displayedLabelsByField[fieldForDisplayLabel] ? this.settings.displayedLabelsByField[fieldForDisplayLabel] : fieldForDisplayLabel;
return this.settings?.displayedLabelsByField?.[fieldForDisplayLabel] ? this.settings.displayedLabelsByField[fieldForDisplayLabel] : fieldForDisplayLabel;
}
}