Skip to content

Commit

Permalink
feat: hidden-graph
Browse files Browse the repository at this point in the history
fix unit-tests
  • Loading branch information
mchlrch committed Mar 13, 2024
1 parent 7d9e9e5 commit b380cca
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions apis/core/test/domain/cube-projects/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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'])

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 })
Expand All @@ -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 })
Expand All @@ -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'])

Expand All @@ -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'])
Expand All @@ -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'])

Expand All @@ -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'))
Expand Down
1 change: 1 addition & 0 deletions apis/core/test/domain/cube-projects/import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/'))
Expand Down
19 changes: 19 additions & 0 deletions apis/core/test/domain/cube-projects/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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'])
Expand Down

0 comments on commit b380cca

Please sign in to comment.