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

feat(element-templates): open custom groups #621

Merged
merged 1 commit into from
Mar 29, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ function addCustomGroup(groups, props) {
id,
label,
component: Group,
entries: []
entries: [],
shouldOpen: true
};

properties.forEach((property, index) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ function addCustomGroup(groups, props) {
id,
label,
component: Group,
entries: []
entries: [],
shouldOpen: true
};

properties.forEach((property, index) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from 'min-dash';

import {
classes as domClasses,
query as domQuery,
queryAll as domQueryAll
} from 'min-dom';
Expand Down Expand Up @@ -1043,6 +1044,27 @@ describe('provider/cloud-element-templates - CustomProperties', function() {
});


it('should open custom groups', async function() {

// given
await expectSelected('ServiceTask_1');

// when
var customGroups = [
getGroupById('ElementTemplates__CustomProperties-headers', container),
getGroupById('ElementTemplates__CustomProperties-payload', container),
getGroupById('ElementTemplates__CustomProperties-mapping', container),
getGroupById('ElementTemplates__CustomProperties', container)
];

// then
customGroups.forEach(function(group) {
expectGroupOpen(group, true);
});

});


it('should display in defined properties order', async function() {

// given
Expand Down Expand Up @@ -1091,6 +1113,22 @@ describe('provider/cloud-element-templates - CustomProperties', function() {
});


it('should open default group', async function() {

// given
await expectSelected('ServiceTask_noGroups');

// when
var tempalteGroup = getGroupById('ElementTemplates__Template', container);
var customPropertiesGroup = getGroupById('ElementTemplates__CustomProperties', container);


// then
expectGroupOpen(tempalteGroup, false);
expectGroupOpen(customPropertiesGroup, true);
});


it('should not create default group', async function() {

// given
Expand Down Expand Up @@ -1265,6 +1303,13 @@ function expectError(entry, message) {
expect(error).to.equal(message);
}

function expectGroupOpen(group, open) {

const entries = domQuery('.bio-properties-panel-group-entries', group);

expect(domClasses(entries).contains('open')).to.eql(open);
}

function expectValid(entry) {
expectError(entry, null);
}
Expand All @@ -1285,6 +1330,15 @@ function getGroup(entry) {
return parent && withoutPrefix(parent.dataset.groupId);
}

function getGroupById(id, container) {
const group = domQuery(
`[data-group-id=group-${id}]`,
container
);

return group;
}

function withoutPrefix(groupId) {
return groupId.slice(6);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from 'min-dash';

import {
classes as domClasses,
query as domQuery,
queryAll as domQueryAll
} from 'min-dom';
Expand Down Expand Up @@ -1762,6 +1763,27 @@ describe('provider/element-templates - CustomProperties', function() {
});


it('should open defined groups', async function() {

// given
await expectSelected('ServiceTask_1');

// when
var customGroups = [
getGroupById('ElementTemplates__CustomProperties-one', container),
getGroupById('ElementTemplates__CustomProperties-two', container),
getGroupById('ElementTemplates__CustomProperties-three', container),
getGroupById('ElementTemplates__CustomProperties', container)
];

// then
customGroups.forEach(function(group) {
expectGroupOpen(group, true);
});

});


it('should display in defined properties order', async function() {

// given
Expand Down Expand Up @@ -1810,6 +1832,22 @@ describe('provider/element-templates - CustomProperties', function() {
});


it('should open default group', async function() {

// given
await expectSelected('ServiceTask_noGroups');

// when
var tempalteGroup = getGroupById('ElementTemplates__Template', container);
var customPropertiesGroup = getGroupById('ElementTemplates__CustomProperties', container);


// then
expectGroupOpen(tempalteGroup, false);
expectGroupOpen(customPropertiesGroup, true);
});


it('should not create default group', async function() {

// given
Expand Down Expand Up @@ -1896,6 +1934,13 @@ function expectValid(entry) {
expectError(entry, null);
}

function expectGroupOpen(group, open) {

const entries = domQuery('.bio-properties-panel-group-entries', group);

expect(domClasses(entries).contains('open')).to.eql(open);
}

function findEntry(id, container) {
return domQuery(`[data-entry-id='${ id }']`, container);
}
Expand All @@ -1912,6 +1957,15 @@ function findTextarea(container) {
return domQuery('textarea', container);
}

function getGroupById(id, container) {
const group = domQuery(
`[data-group-id=group-${id}]`,
container
);

return group;
}

function getGroupIds(container) {
if (!container) {
throw new Error('container is missing');
Expand Down