Skip to content

Commit

Permalink
[Spaces] Manage Space: features picker is shown only when solution is…
Browse files Browse the repository at this point in the history
… set to "classic"
  • Loading branch information
tsullivan committed Aug 27, 2024
1 parent 3f4c279 commit ae18346
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,51 @@ describe('ManageSpacePage', () => {
expect(wrapper.find(EnabledFeatures)).toHaveLength(0);
});

it('hides feature visibility controls when solution view is not "classic"', async () => {
const spacesManager = spacesManagerMock.create();

const wrapper = mountWithIntl(
<ManageSpacePage
spacesManager={spacesManager}
getFeatures={featuresStart.getFeatures}
notifications={notificationServiceMock.createStartContract()}
history={history}
capabilities={{
navLinks: {},
management: {},
catalogue: {},
spaces: { manage: true },
}}
eventTracker={eventTracker}
allowFeatureVisibility
allowSolutionVisibility
/>
);

await waitFor(async () => {
await Promise.resolve();

wrapper.update();

// default for create space: expect visible features table to exist
expect(wrapper.find(EnabledFeatures)).toHaveLength(1);
});

await waitFor(() => {
// switch to observability view
updateSpace(wrapper, false, 'oblt');
// expect visible features table to not exist
expect(wrapper.find(EnabledFeatures)).toHaveLength(0);
});

await waitFor(() => {
// switch to classic
updateSpace(wrapper, false, 'classic');
// expect visible features table to exist again
expect(wrapper.find(EnabledFeatures)).toHaveLength(1);
});
});

it('allows a space to be updated', async () => {
const spaceToUpdate = {
id: 'existing-space',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,13 @@ export class ManageSpacePage extends Component<Props, State> {
};

private onSolutionViewChange = (space: Partial<Space>) => {
let showVisibleFeaturesPicker = false;
if (space.solution === 'classic' || space.solution == null) {
showVisibleFeaturesPicker = true;
if (this.props.allowFeatureVisibility) {
let showVisibleFeaturesPicker = false;
if (space.solution === 'classic' || space.solution == null) {
showVisibleFeaturesPicker = true;
}
this.setState((state) => ({ ...state, showVisibleFeaturesPicker }));
}
this.setState((state) => ({ ...state, showVisibleFeaturesPicker }));
this.onSpaceChange(space);
};

Expand Down

0 comments on commit ae18346

Please sign in to comment.