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

fix(resource-instance-form): resource class name now updates correctly (DSP-1810) #531

Merged
merged 1 commit into from Sep 10, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -299,7 +299,7 @@ describe('ResourceInstanceFormComponent', () => {
usersEndpoint: jasmine.createSpyObj('usersEndpoint', ['getUserByUsername'])
},
v2: {
onto: jasmine.createSpyObj('onto', ['getOntologiesByProjectIri']),
onto: jasmine.createSpyObj('onto', ['getOntologiesByProjectIri', 'getOntology', 'getResourceClassDefinition']),
ontologyCache: jasmine.createSpyObj('ontologyCache', ['getOntology', 'getResourceClassDefinition']),
res: jasmine.createSpyObj('res', ['createResource'])
}
Expand Down Expand Up @@ -452,16 +452,11 @@ describe('ResourceInstanceFormComponent', () => {
it('should show the select resource class component', () => {
const dspConnSpy = TestBed.inject(DspApiConnectionToken);

(dspConnSpy.v2.ontologyCache as jasmine.SpyObj<OntologyCache>).getOntology.and.callFake(
(dspConnSpy.v2.onto as jasmine.SpyObj<OntologiesEndpointV2>).getOntology.and.callFake(
() => {

const anythingOnto = MockOntology.mockReadOntology('http://0.0.0.0:3333/ontology/0001/anything/v2');

const ontoMap: Map<string, ReadOntology> = new Map();

ontoMap.set('http://0.0.0.0:3333/ontology/0001/anything/v2', anythingOnto);

return of(ontoMap);
return of(anythingOnto);
}
);

Expand All @@ -484,16 +479,11 @@ describe('ResourceInstanceFormComponent', () => {

const dspConnSpy = TestBed.inject(DspApiConnectionToken);

(dspConnSpy.v2.ontologyCache as jasmine.SpyObj<OntologyCache>).getOntology.and.callFake(
(dspConnSpy.v2.onto as jasmine.SpyObj<OntologiesEndpointV2>).getOntology.and.callFake(
() => {

const anythingOnto = MockOntology.mockReadOntology('http://0.0.0.0:3333/ontology/0001/anything/v2');

const ontoMap: Map<string, ReadOntology> = new Map();

ontoMap.set('http://0.0.0.0:3333/ontology/0001/anything/v2', anythingOnto);

return of(ontoMap);
return of(anythingOnto);
}
);

Expand Down
Expand Up @@ -305,9 +305,9 @@ export class ResourceInstanceFormComponent implements OnInit, OnDestroy {

this.selectedOntology = ontologyIri;

this._dspApiConnection.v2.ontologyCache.getOntology(ontologyIri).subscribe(
(onto: Map<string, ReadOntology>) => {
this.resourceClasses = onto.get(ontologyIri).getClassDefinitionsByType(ResourceClassDefinition);
this._dspApiConnection.v2.onto.getOntology(ontologyIri).subscribe(
(onto: ReadOntology) => {
this.resourceClasses = onto.getClassDefinitionsByType(ResourceClassDefinition);

if (this.selectResourceClassComponent && this.resourceClasses.length === 1) {
// since the component already exists, the ngAfterInit method of the component will not be called so we must assign the value here manually
Expand Down