From b380cca90109479218df7c7c333fb1438b183d08 Mon Sep 17 00:00:00 2001 From: Michael Rauch Date: Wed, 13 Mar 2024 15:40:51 +0100 Subject: [PATCH] feat: hidden-graph fix unit-tests --- .../test/domain/cube-projects/create.test.ts | 20 +++++++++++++++++++ .../test/domain/cube-projects/import.test.ts | 1 + .../test/domain/cube-projects/update.test.ts | 19 ++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/apis/core/test/domain/cube-projects/create.test.ts b/apis/core/test/domain/cube-projects/create.test.ts index c5962e2bc..47b70f08b 100644 --- a/apis/core/test/domain/cube-projects/create.test.ts +++ b/apis/core/test/domain/cube-projects/create.test.ts @@ -52,6 +52,7 @@ describe('domain/cube-projects/create', () => { .addOut(rdfs.label, 'Foo bar project') .addOut(dcterms.identifier, 'ubd/28') .addOut(schema.maintainer, organization.id) + .addOut(cc.isHiddenCube, true) .addOut(cc.projectSourceKind, cc['projectSourceKind/CSV']) // when @@ -73,6 +74,7 @@ describe('domain/cube-projects/create', () => { .addOut(rdfs.label, 'Foo bar project') .addOut(dcterms.identifier, 'ubd/28') .addOut(schema.maintainer, organization.id) + .addOut(cc.isHiddenCube, true) .addOut(cc.projectSourceKind, cc['projectSourceKind/CSV']) // when @@ -130,6 +132,7 @@ describe('domain/cube-projects/create', () => { .addOut(rdfs.label, 'Foo bar project') .addOut(dcterms.identifier, 'ubd/28') .addOut(schema.maintainer, organization.id) + .addOut(cc.isHiddenCube, true) .addOut(cc.projectSourceKind, cc['projectSourceKind/CSV']) // when @@ -155,6 +158,7 @@ describe('domain/cube-projects/create', () => { .addOut(rdfs.label, 'Foo bar project') .addOut(dcterms.identifier, 'ubd/28') .addOut(schema.maintainer, organization.id) + .addOut(cc.isHiddenCube, true) .addOut(cc.projectSourceKind, cc['projectSourceKind/CSV']) // when @@ -205,6 +209,7 @@ describe('domain/cube-projects/create', () => { .addOut(rdfs.label, 'Foo bar project') .addOut(dcterms.identifier, 'ubd/28') .addOut(schema.maintainer, organization.id) + .addOut(cc.isHiddenCube, true) .addOut(cc.projectSourceKind, cc['projectSourceKind/CSV']) // when @@ -222,6 +227,7 @@ describe('domain/cube-projects/create', () => { .addOut(rdfs.label, 'Foo bar project') .addOut(schema.maintainer, organization.id) .addOut(dcterms.identifier, 'ubd/28') + .addOut(cc.isHiddenCube, true) .addOut(cc.projectSourceKind, cc['projectSourceKind/CSV']) // when @@ -239,6 +245,7 @@ describe('domain/cube-projects/create', () => { .addOut(rdfs.label, 'Foo bar project') .addOut(schema.maintainer, organization.id) .addOut(dcterms.identifier, 'ubd/28') + .addOut(cc.isHiddenCube, true) .addOut(cc.projectSourceKind, cc['projectSourceKind/CSV']) // when @@ -255,6 +262,7 @@ describe('domain/cube-projects/create', () => { .addOut(rdfs.label, 'Foo bar project') .addOut(schema.maintainer, organization.id) .addOut(dcterms.identifier, 'ubd/28') + .addOut(cc.isHiddenCube, true) .addOut(cc.projectSourceKind, cc['projectSourceKind/CSV']) // when @@ -271,6 +279,7 @@ describe('domain/cube-projects/create', () => { .addOut(rdfs.label, 'Foo bar project') .addOut(schema.maintainer, organization.id) .addOut(dcterms.identifier, 'ubd/28') + .addOut(cc.isHiddenCube, true) .addOut(cc.projectSourceKind, cc['projectSourceKind/CSV']) // when @@ -287,6 +296,7 @@ describe('domain/cube-projects/create', () => { .addOut(rdfs.label, 'Foo bar project') .addOut(schema.maintainer, organization.id) .addOut(dcterms.identifier, 'ubd/28') + .addOut(cc.isHiddenCube, true) .addOut(cc.publishGraph, $rdf.namedNode('http://example.com/published-cube')) .addOut(cc.projectSourceKind, cc['projectSourceKind/CSV']) @@ -318,6 +328,7 @@ describe('domain/cube-projects/create', () => { .addOut(rdfs.label, 'Foo bar project') .addOut(cc.projectSourceKind, cc['projectSourceKind/CSV']) .addOut(dcterms.identifier, 'ubd/28') + .addOut(cc.isHiddenCube, true) .addOut(schema.maintainer, organization.id) // when @@ -350,6 +361,7 @@ describe('domain/cube-projects/create', () => { .addOut(rdfs.label, 'Foo bar project') .addOut(cc.projectSourceKind, cc['projectSourceKind/CSV']) .addOut(dcterms.identifier, 'ubd/28') + .addOut(cc.isHiddenCube, true) .addOut(schema.maintainer, organization.id) // when @@ -388,6 +400,7 @@ describe('domain/cube-projects/create', () => { .addOut(rdfs.label, 'Foo bar project') .addOut(cc.projectSourceKind, cc['projectSourceKind/CSV']) .addOut(dcterms.identifier, 'ubd/28') + .addOut(cc.isHiddenCube, true) .addOut(schema.maintainer, organization.id) // when @@ -435,6 +448,7 @@ describe('domain/cube-projects/create', () => { .addOut(rdfs.label, 'Foo bar project') .addOut(cc.projectSourceKind, cc['projectSourceKind/CSV']) .addOut(dcterms.identifier, 'ubd/28') + .addOut(cc.isHiddenCube, true) .addOut(schema.maintainer, organization.id) // when @@ -486,6 +500,7 @@ describe('domain/cube-projects/create', () => { .addOut(cc['CubeProject/sourceCube'], $rdf.namedNode('http://example.cube/')) .addOut(cc['CubeProject/sourceEndpoint'], $rdf.namedNode('http://example.endpoint/')) .addOut(schema.maintainer, organization.id) + .addOut(cc.isHiddenCube, true) // when const { project } = await createProject({ resource, store, projectsCollection, user }) @@ -503,6 +518,7 @@ describe('domain/cube-projects/create', () => { .addOut(cc['CubeProject/sourceCube'], $rdf.namedNode('http://example.cube/')) .addOut(cc['CubeProject/sourceEndpoint'], $rdf.namedNode('http://example.endpoint/')) .addOut(schema.maintainer, organization.id) + .addOut(cc.isHiddenCube, true) // when const { project } = await createProject({ resource, store, projectsCollection, user }) @@ -517,6 +533,7 @@ describe('domain/cube-projects/create', () => { .namedNode('') .addOut(rdfs.label, 'Import project') .addOut(schema.maintainer, organization.id) + .addOut(cc.isHiddenCube, true) .addOut(cc['CubeProject/sourceEndpoint'], $rdf.namedNode('http://example.endpoint/')) .addOut(cc.projectSourceKind, cc['projectSourceKind/ExistingCube']) @@ -533,6 +550,7 @@ describe('domain/cube-projects/create', () => { .namedNode('') .addOut(rdfs.label, 'Import project') .addOut(schema.maintainer, organization.id) + .addOut(cc.isHiddenCube, true) .addOut(cc['CubeProject/sourceCube'], $rdf.literal('http://example.cube/')) .addOut(cc['CubeProject/sourceEndpoint'], $rdf.namedNode('http://example.endpoint/')) .addOut(cc.projectSourceKind, cc['projectSourceKind/ExistingCube']) @@ -550,6 +568,7 @@ describe('domain/cube-projects/create', () => { .namedNode('') .addOut(rdfs.label, 'Import project') .addOut(schema.maintainer, organization.id) + .addOut(cc.isHiddenCube, true) .addOut(cc['CubeProject/sourceCube'], $rdf.namedNode('http://example.cube/')) .addOut(cc.projectSourceKind, cc['projectSourceKind/ExistingCube']) @@ -566,6 +585,7 @@ describe('domain/cube-projects/create', () => { .namedNode('') .addOut(rdfs.label, 'Import project') .addOut(schema.maintainer, organization.id) + .addOut(cc.isHiddenCube, true) .addOut(cc['CubeProject/sourceCube'], $rdf.namedNode('http://example.cube/')) .addOut(cc['CubeProject/sourceEndpoint'], $rdf.namedNode('http://example.endpoint/')) .addOut(cc.publishGraph, $rdf.namedNode('http://example.com/published-cube')) diff --git a/apis/core/test/domain/cube-projects/import.test.ts b/apis/core/test/domain/cube-projects/import.test.ts index d2ff8d806..2cbd894d2 100644 --- a/apis/core/test/domain/cube-projects/import.test.ts +++ b/apis/core/test/domain/cube-projects/import.test.ts @@ -32,6 +32,7 @@ describe('@cube-creator/core-api/lib/domain/cube-projects/import', () => { resource = blankNode() .addOut(rdfs.label, 'UBD Imported') .addOut(schema.maintainer, ex.Bafu) + .addOut(cc.isHiddenCube, true) const organization = namedNode(ex.Bafu) .addOut(rdf.type, schema.Organization) .addOut(cc.namespace, $rdf.namedNode('https://test.ld.admin.ch/org/')) diff --git a/apis/core/test/domain/cube-projects/update.test.ts b/apis/core/test/domain/cube-projects/update.test.ts index f4c5970ca..62a4da241 100644 --- a/apis/core/test/domain/cube-projects/update.test.ts +++ b/apis/core/test/domain/cube-projects/update.test.ts @@ -55,6 +55,7 @@ describe('domain/cube-projects/update', () => { .node(id) .addOut(rdfs.label, 'Created name') .addOut(schema.maintainer, bafu.id) + .addOut(cc.isHiddenCube, true) .addOut(dcterms.identifier, 'cube') .addOut(cc.projectSourceKind, cc['projectSourceKind/CSV']) } @@ -101,6 +102,23 @@ describe('domain/cube-projects/update', () => { expect(editedProject.pointer.out(rdfs.label).term?.value).to.eq('Edited name') }) + it('updates isHiddenCube', async () => { + // given + const resource = projectPointer(project.term) + resource + .deleteOut(cc.isHiddenCube) + .addOut(cc.isHiddenCube, false) + + // when + const editedProject = await updateProject({ + resource, + store, + }) + + // then + expect(editedProject.pointer.out(cc.isHiddenCube).term?.value).to.eq('false') + }) + describe('when maintainer changes', () => { let editedProject: Project @@ -360,6 +378,7 @@ describe('domain/cube-projects/update', () => { .node(id) .addOut(rdfs.label, 'Created name') .addOut(schema.maintainer, bafu.id) + .addOut(cc.isHiddenCube, true) .addOut(cc['CubeProject/sourceCube'], $rdf.namedNode('http://external.cube')) .addOut(cc['CubeProject/sourceEndpoint'], $rdf.namedNode('http://external.cube/query')) .addOut(cc.projectSourceKind, cc['projectSourceKind/ExistingCube'])