Skip to content
Snippets Groups Projects
Commit d7f73293 authored by piotr.kupczyk@id.ethz.ch's avatar piotr.kupczyk@id.ethz.ch
Browse files

NG_UI : types : SSDM-10193 - add tests for internal property types/assignments...

NG_UI : types : SSDM-10193 - add tests for internal property types/assignments and system internal property types/assignments
parent ca04ac1c
No related branches found
No related tags found
No related merge requests found
...@@ -53,6 +53,7 @@ describe('TypeFormComponent', () => { ...@@ -53,6 +53,7 @@ describe('TypeFormComponent', () => {
test('validate type', testValidateType) test('validate type', testValidateType)
test('validate property', testValidateProperty) test('validate property', testValidateProperty)
test('validate type and property', testValidateTypeAndProperty) test('validate type and property', testValidateTypeAndProperty)
test('internal', testInternal)
}) })
async function testLoadNew() { async function testLoadNew() {
...@@ -1498,6 +1499,139 @@ async function testValidateTypeAndProperty() { ...@@ -1498,6 +1499,139 @@ async function testValidateTypeAndProperty() {
}) })
} }
async function testInternal() {
await doTestInternal(true, fixture.SYSTEM_USER_DTO, fixture.SYSTEM_USER_DTO)
await doTestInternal(false, fixture.SYSTEM_USER_DTO, fixture.SYSTEM_USER_DTO)
await doTestInternal(true, fixture.SYSTEM_USER_DTO, fixture.TEST_USER_DTO)
await doTestInternal(false, fixture.SYSTEM_USER_DTO, fixture.TEST_USER_DTO)
await doTestInternal(true, fixture.TEST_USER_DTO, fixture.TEST_USER_DTO)
await doTestInternal(false, fixture.TEST_USER_DTO, fixture.TEST_USER_DTO)
await doTestInternal(true, fixture.TEST_USER_DTO, fixture.SYSTEM_USER_DTO)
await doTestInternal(false, fixture.TEST_USER_DTO, fixture.SYSTEM_USER_DTO)
}
async function doTestInternal(
propertyTypeInternal,
propertyTypeRegistrator,
propertyAssignmentRegistrator
) {
const isSystemInternalPropertyType =
propertyTypeInternal &&
propertyTypeRegistrator.userId === fixture.SYSTEM_USER_DTO.userId
const isSystemInternalPropertyAssignment =
propertyTypeInternal &&
propertyAssignmentRegistrator.userId === fixture.SYSTEM_USER_DTO.userId
const propertyType = new openbis.PropertyType()
propertyType.setCode('TEST_PROPERTY')
propertyType.setManagedInternally(propertyTypeInternal)
propertyType.setRegistrator(propertyTypeRegistrator)
propertyType.setDataType(openbis.DataType.VARCHAR)
const propertyAssignment = new openbis.PropertyAssignment()
propertyAssignment.setPropertyType(propertyType)
propertyAssignment.setPlugin(fixture.TEST_PLUGIN_DTO)
propertyAssignment.setRegistrator(propertyAssignmentRegistrator)
const type = new openbis.SampleType()
type.setCode('TEST_TYPE')
type.setPropertyAssignments([propertyAssignment])
facade.loadType.mockReturnValue(Promise.resolve(type))
facade.loadDynamicPlugins.mockReturnValue(
Promise.resolve([propertyAssignment.plugin])
)
const form = await common.mount({
id: type.getCode(),
type: objectTypes.OBJECT_TYPE
})
form.getButtons().getEdit().click()
await form.update()
form.expectJSON({
parameters: {
type: {
title: 'Type',
code: {
value: type.getCode(),
enabled: false
},
description: {
value: type.getDescription(),
enabled: true
}
}
}
})
form.getPreview().getSections()[0].getProperties()[0].click()
await form.update()
form.expectJSON({
parameters: {
property: {
title: 'Property',
code: {
value: propertyType.getCode(),
enabled: false
},
dataType: {
value: propertyType.getDataType(),
enabled: !isSystemInternalPropertyType
},
label: {
value: propertyType.getLabel(),
enabled: !isSystemInternalPropertyType
},
description: {
value: propertyType.getDescription(),
enabled: !isSystemInternalPropertyType
},
plugin: {
value: propertyAssignment.plugin.getName(),
enabled: !isSystemInternalPropertyAssignment
},
mandatory: {
value: propertyAssignment.isMandatory(),
enabled: !isSystemInternalPropertyAssignment
},
visible: {
value: propertyAssignment.isShowInEditView(),
enabled: !isSystemInternalPropertyAssignment
}
}
},
buttons: {
remove: {
enabled: !isSystemInternalPropertyAssignment
}
}
})
form.getPreview().getSections()[0].click()
await form.update()
form.expectJSON({
parameters: {
section: {
title: 'Section',
name: {
value: propertyAssignment.getSection(),
enabled: true
}
}
},
buttons: {
remove: {
enabled: !isSystemInternalPropertyAssignment
}
}
})
}
async function mountNew() { async function mountNew() {
return await common.mount({ return await common.mount({
type: objectTypes.NEW_OBJECT_TYPE type: objectTypes.NEW_OBJECT_TYPE
......
import AutocompleterField from '@src/js/components/common/form/AutocompleterField.jsx' import AutocompleterField from '@src/js/components/common/form/AutocompleterField.jsx'
import SelectField from '@src/js/components/common/form/SelectField.jsx' import SelectField from '@src/js/components/common/form/SelectField.jsx'
import TextField from '@src/js/components/common/form/TextField.jsx' import TextField from '@src/js/components/common/form/TextField.jsx'
import CheckboxField from '@src/js/components/common/form/CheckboxField.jsx'
import Message from '@src/js/components/common/form/Message.jsx' import Message from '@src/js/components/common/form/Message.jsx'
import TextFieldWrapper from '@srcTest/js/components/common/form/wrapper/TextFieldWrapper.js' import TextFieldWrapper from '@srcTest/js/components/common/form/wrapper/TextFieldWrapper.js'
import SelectFieldWrapper from '@srcTest/js/components/common/form/wrapper/SelectFieldWrapper.js' import SelectFieldWrapper from '@srcTest/js/components/common/form/wrapper/SelectFieldWrapper.js'
import CheckboxFieldWrapper from '@srcTest/js/components/common/form/wrapper/CheckboxFieldWrapper.js'
import AutocompleterFieldWrapper from '@srcTest/js/components/common/form/wrapper/AutocompleterFieldWrapper.js' import AutocompleterFieldWrapper from '@srcTest/js/components/common/form/wrapper/AutocompleterFieldWrapper.js'
import MessageWrapper from '@srcTest/js/components/common/form/wrapper/MessageWrapper.js' import MessageWrapper from '@srcTest/js/components/common/form/wrapper/MessageWrapper.js'
import TypeFormParametersCommonWrapper from './TypeFormParametersCommonWrapper.js' import TypeFormParametersCommonWrapper from './TypeFormParametersCommonWrapper.js'
...@@ -91,6 +93,18 @@ export default class TypeFormParametersPropertyWrapper extends TypeFormParameter ...@@ -91,6 +93,18 @@ export default class TypeFormParametersPropertyWrapper extends TypeFormParameter
) )
} }
getMandatory() {
return new CheckboxFieldWrapper(
this.findComponent(CheckboxField).filter({ name: 'mandatory' })
)
}
getVisible() {
return new CheckboxFieldWrapper(
this.findComponent(CheckboxField).filter({ name: 'showInEditView' })
)
}
toJSON() { toJSON() {
return { return {
...super.toJSON(), ...super.toJSON(),
...@@ -104,7 +118,9 @@ export default class TypeFormParametersPropertyWrapper extends TypeFormParameter ...@@ -104,7 +118,9 @@ export default class TypeFormParametersPropertyWrapper extends TypeFormParameter
vocabulary: this.getVocabulary().toJSON(), vocabulary: this.getVocabulary().toJSON(),
materialType: this.getMaterialType().toJSON(), materialType: this.getMaterialType().toJSON(),
schema: this.getSchema().toJSON(), schema: this.getSchema().toJSON(),
transformation: this.getTransformation().toJSON() transformation: this.getTransformation().toJSON(),
mandatory: this.getMandatory().toJSON(),
visible: this.getVisible().toJSON()
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment