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

Linting fixes #9348

Merged
merged 4 commits into from
Feb 16, 2024
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
4 changes: 3 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@
"Whitespaces",
"xdescribe",
"xsrf",
"BPMECM"
"BPMECM",
"berseria",
"zestiria"
],
"dictionaries": [
"html",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,23 +133,25 @@ describe('ContentService', () => {
describe('Node Icons', () => {
let node: Node;

node = {
isFolder: true,
isFile: false,
createdByUser: { id: 'admin', displayName: 'Administrator' },
modifiedAt: new Date('2017-05-24T15:08:55.640Z'),
nodeType: 'cm:content',
content: {
mimeType: 'application/rtf',
mimeTypeName: 'Rich Text Format',
sizeInBytes: 14530
},
createdAt: new Date('2017-05-24T15:08:55.640Z'),
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
name: 'b_txt_file.rtf',
id: 'test node 1',
aspectNames: ['']
} as Node;
beforeEach(() => {
node = {
isFolder: true,
isFile: false,
createdByUser: { id: 'admin', displayName: 'Administrator' },
modifiedAt: new Date('2017-05-24T15:08:55.640Z'),
nodeType: 'cm:content',
content: {
mimeType: 'application/rtf',
mimeTypeName: 'Rich Text Format',
sizeInBytes: 14530
},
createdAt: new Date('2017-05-24T15:08:55.640Z'),
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
name: 'b_txt_file.rtf',
id: 'test node 1',
aspectNames: ['']
} as Node;
});

it('should resolve folder icon', () => {
expect(contentService.getNodeIcon(node)).toContain('assets/images/ft_ic_folder.svg');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand All @@ -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'
},
Expand All @@ -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'
}
Expand All @@ -93,7 +88,6 @@ describe('LayoutOrientedConfigService', () => {
});

describe('reorganiseByConfig', () => {

interface TestCase {
name: string;
config: LayoutOrientedConfig;
Expand Down Expand Up @@ -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'] }
Expand All @@ -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: [
Expand All @@ -246,32 +227,30 @@ 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'] },
{ type: 'not-existing-group', properties: 'not-existing-property' }
]
}
],
expectations: [
{ title: 'First group', properties: [property3, property4, property2] }
]
expectations: [{ title: 'First group', properties: [property3, property4, property2] }]
},
{
name: 'Custom Title',
Expand All @@ -297,7 +276,6 @@ describe('LayoutOrientedConfigService', () => {
}
]
}

];

testCases.forEach((testCase) => {
Expand All @@ -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.`
Expand All @@ -322,23 +300,27 @@ describe('LayoutOrientedConfigService', () => {
});

it('should include all exclusions passed to filterExcludedPreset', () => {
let properties: OrganisedPropertyGroup[] = [{
name: 'propGroup',
title: 'propGroup',
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,
]}];
const properties: OrganisedPropertyGroup[] = [
{
name: 'propGroup',
title: 'propGroup',
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
]
}
];

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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
Expand All @@ -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;
}
Expand Down
Loading
Loading