mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Display symlinks in container listings.
Closes https://github.com/solid/community-server/issues/1015
This commit is contained in:
@@ -117,7 +117,14 @@ describe('A FileDataAccessor', (): void => {
|
||||
});
|
||||
|
||||
it('generates the metadata for a container.', async(): Promise<void> => {
|
||||
cache.data = { container: { resource: 'data', 'resource.meta': 'metadata', notAFile: 5, container2: {}}};
|
||||
cache.data = {
|
||||
container: {
|
||||
resource: 'data',
|
||||
'resource.meta': 'metadata',
|
||||
notAFile: 5,
|
||||
container2: {},
|
||||
},
|
||||
};
|
||||
metadata = await accessor.getMetadata({ path: `${base}container/` });
|
||||
expect(metadata.identifier.value).toBe(`${base}container/`);
|
||||
expect(metadata.getAll(RDF.type)).toEqualRdfTermArray(
|
||||
@@ -131,15 +138,50 @@ describe('A FileDataAccessor', (): void => {
|
||||
});
|
||||
|
||||
it('generates metadata for container child resources.', async(): Promise<void> => {
|
||||
cache.data = { container: { resource: 'data', 'resource.meta': 'metadata', notAFile: 5, container2: {}}};
|
||||
cache.data = {
|
||||
container: {
|
||||
resource: 'data',
|
||||
'resource.meta': 'metadata',
|
||||
symlink: Symbol(`${rootFilePath}/container/resource`),
|
||||
symlinkContainer: Symbol(`${rootFilePath}/container/container2`),
|
||||
symlinkInvalid: Symbol(`${rootFilePath}/invalid`),
|
||||
notAFile: 5,
|
||||
container2: {},
|
||||
},
|
||||
};
|
||||
|
||||
const children = [];
|
||||
for await (const child of accessor.getChildren({ path: `${base}container/` })) {
|
||||
children.push(child);
|
||||
}
|
||||
expect(children).toHaveLength(2);
|
||||
|
||||
// Identifiers
|
||||
expect(children).toHaveLength(4);
|
||||
expect(new Set(children.map((child): string => child.identifier.value))).toEqual(new Set([
|
||||
`${base}container/container2/`,
|
||||
`${base}container/resource`,
|
||||
`${base}container/symlink`,
|
||||
`${base}container/symlinkContainer/`,
|
||||
]));
|
||||
|
||||
// Containers
|
||||
for (const child of children.filter(({ identifier }): boolean => identifier.value.endsWith('/'))) {
|
||||
const types = child.getAll(RDF.type).map((term): string => term.value);
|
||||
expect(types).toContain(LDP.Resource);
|
||||
expect(types).toContain(LDP.Container);
|
||||
expect(types).toContain(LDP.BasicContainer);
|
||||
}
|
||||
|
||||
// Documents
|
||||
for (const child of children.filter(({ identifier }): boolean => !identifier.value.endsWith('/'))) {
|
||||
const types = child.getAll(RDF.type).map((term): string => term.value);
|
||||
expect(types).toContain(LDP.Resource);
|
||||
expect(types).not.toContain(LDP.Container);
|
||||
expect(types).not.toContain(LDP.BasicContainer);
|
||||
}
|
||||
|
||||
// All resources
|
||||
for (const child of children) {
|
||||
expect([ `${base}container/resource`, `${base}container/container2/` ]).toContain(child.identifier.value);
|
||||
expect(child.getAll(RDF.type)!.some((type): boolean => type.equals(LDP.terms.Resource))).toBe(true);
|
||||
expect(child.get(DC.modified)).toEqualRdfTerm(toLiteral(now.toISOString(), XSD.terms.dateTime));
|
||||
expect(child.get(POSIX.mtime)).toEqualRdfTerm(toLiteral(Math.floor(now.getTime() / 1000),
|
||||
XSD.terms.integer));
|
||||
|
||||
Reference in New Issue
Block a user