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

Change when plugin fieldset is hidden in registration variables table #5113

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 @@ -45,6 +45,12 @@ const RegistrationVariables = ({onFieldChange}) => {
plugin.pluginVariables.length
);

// A plugin fieldset will not be included if there is only one registration backend configured,
// or if all configured backends are the same type
const hidePluginFieldset =
registrationBackends.length === 1 ||
new Set(registrationBackends.map(b => b.backend)).size === 1;

const headColumns = (
<>
<HeadColumn content="" />
Expand Down Expand Up @@ -85,7 +91,7 @@ const RegistrationVariables = ({onFieldChange}) => {
/>
);

if (registrationPluginsVariables.length === 1) return pluginVariables;
if (hidePluginFieldset) return pluginVariables;

return (
<Fieldset title={registrationPlugin.pluginVerboseName} key={index}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ export const WithObjectsAPIRegistrationBackends = {
const pdfUrl = canvas.getByRole('cell', {name: 'pdf_url'});
expect(pdfUrl).toBeVisible();

// With a single backend, the heading shouldn't display:
// With all backends of the same type, the heading shouldn't display
const objectsApiTitle = canvas.queryByRole('heading', {name: 'Objects API registration'});
expect(objectsApiTitle).toBeNull();
},
Expand Down Expand Up @@ -462,6 +462,23 @@ export const FilesMappingAndObjectAPIRegistration = {
{
pluginIdentifier: 'objects_api',
pluginVerboseName: 'Objects API registration',
pluginVariables: [
{
form: null,
formDefinition: null,
name: 'PDF Url',
key: 'pdf_url',
source: '',
prefillPlugin: '',
prefillAttribute: '',
prefillIdentifierRole: 'main',
dataType: 'string',
dataFormat: '',
isSensitiveData: false,
serviceFetchConfiguration: undefined,
initialValue: '',
},
],
},
],
},
Expand Down Expand Up @@ -652,6 +669,21 @@ export const WithObjectsAPIAndTestRegistrationBackends = {
],
},
},
play: async ({canvasElement}) => {
const canvas = within(canvasElement);

const registrationTab = canvas.getByRole('tab', {name: 'Registratie'});
await userEvent.click(registrationTab);

// With multiple backends configured, and two of them introduce registration variables,
// the plugin headings should be visible.
expect(canvas.getByRole('heading', {name: 'Objects API registration'})).toBeVisible();
expect(canvas.getByRole('heading', {name: 'Test plugin'})).toBeVisible();

// Navigate back to component tab for visual regression testing
const componentTab = canvas.getByRole('tab', {name: /Component/});
await componentTab.click(componentTab);
},
};

export const WithJSONDumpRegistrationBackend = {
Expand Down Expand Up @@ -1326,3 +1358,55 @@ export const AddressNLMappingSpecificTargetsDeriveAddress = {
expect(streetNameSelect).not.toBeDisabled();
},
};

export const TwoBackendsWhereOnlyOneIntroducesRegistrationVariables = {
args: {
registrationBackends: [
{
backend: 'objects_api',
key: 'objects_api_1',
name: 'Example Objects API reg.',
options: {},
},
{
backend: 'testPlugin',
key: 'test_backend',
name: 'Example test registration',
options: {},
},
],
registrationPluginsVariables: [
{
pluginIdentifier: 'objects_api',
pluginVerboseName: 'Objects API registration',
pluginVariables: [
{
form: null,
formDefinition: null,
name: 'PDF Url',
key: 'pdf_url',
source: '',
prefillPlugin: '',
prefillAttribute: '',
prefillIdentifierRole: 'main',
dataType: 'string',
dataFormat: '',
isSensitiveData: false,
serviceFetchConfiguration: undefined,
initialValue: '',
},
],
},
],
},
play: async ({canvasElement}) => {
const canvas = within(canvasElement);

const registrationTab = canvas.getByRole('tab', {name: 'Registratie'});
await userEvent.click(registrationTab);

// With multiple backends configured, but only one of them introduces registration variables,
// the plugin heading should be visible.
expect(canvas.getByRole('heading', {name: 'Objects API registration'})).toBeVisible();
},
};
Loading