mirror of
https://github.com/ansible/awx.git
synced 2026-01-22 06:58:06 -03:30
Merge pull request #8624 from nixocio/ui_issue_8620
Hide instance group for Inventory Details if the data is not available Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
7faf9c6267
@ -80,19 +80,21 @@ function InventoryDetail({ inventory, i18n }) {
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
<Detail
|
||||
fullWidth
|
||||
label={i18n._(t`Instance Groups`)}
|
||||
value={
|
||||
<ChipGroup numChips={5} totalChips={instanceGroups.length}>
|
||||
{instanceGroups.map(ig => (
|
||||
<Chip key={ig.id} isReadOnly>
|
||||
{ig.name}
|
||||
</Chip>
|
||||
))}
|
||||
</ChipGroup>
|
||||
}
|
||||
/>
|
||||
{instanceGroups && instanceGroups.length > 0 && (
|
||||
<Detail
|
||||
fullWidth
|
||||
label={i18n._(t`Instance Groups`)}
|
||||
value={
|
||||
<ChipGroup numChips={5} totalChips={instanceGroups.length}>
|
||||
{instanceGroups.map(ig => (
|
||||
<Chip key={ig.id} isReadOnly>
|
||||
{ig.name}
|
||||
</Chip>
|
||||
))}
|
||||
</ChipGroup>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<VariablesDetail
|
||||
label={i18n._(t`Variables`)}
|
||||
value={inventory.variables}
|
||||
|
||||
@ -63,11 +63,6 @@ const associatedInstanceGroups = [
|
||||
name: 'Foo',
|
||||
},
|
||||
];
|
||||
InventoriesAPI.readInstanceGroups.mockResolvedValue({
|
||||
data: {
|
||||
results: associatedInstanceGroups,
|
||||
},
|
||||
});
|
||||
|
||||
function expectDetailToMatch(wrapper, label, value) {
|
||||
const detail = wrapper.find(`Detail[label="${label}"]`);
|
||||
@ -77,6 +72,12 @@ function expectDetailToMatch(wrapper, label, value) {
|
||||
|
||||
describe('<InventoryDetail />', () => {
|
||||
test('should render details', async () => {
|
||||
InventoriesAPI.readInstanceGroups.mockResolvedValue({
|
||||
data: {
|
||||
results: associatedInstanceGroups,
|
||||
},
|
||||
});
|
||||
|
||||
let wrapper;
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(
|
||||
@ -105,6 +106,12 @@ describe('<InventoryDetail />', () => {
|
||||
});
|
||||
|
||||
test('should load instance groups', async () => {
|
||||
InventoriesAPI.readInstanceGroups.mockResolvedValue({
|
||||
data: {
|
||||
results: associatedInstanceGroups,
|
||||
},
|
||||
});
|
||||
|
||||
let wrapper;
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(
|
||||
@ -119,4 +126,24 @@ describe('<InventoryDetail />', () => {
|
||||
expect(chip.prop('isReadOnly')).toEqual(true);
|
||||
expect(chip.prop('children')).toEqual('Foo');
|
||||
});
|
||||
|
||||
test('should not load instance groups', async () => {
|
||||
InventoriesAPI.readInstanceGroups.mockResolvedValue({
|
||||
data: {
|
||||
results: [],
|
||||
},
|
||||
});
|
||||
|
||||
let wrapper;
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(
|
||||
<InventoryDetail inventory={mockInventory} />
|
||||
);
|
||||
});
|
||||
wrapper.update();
|
||||
expect(InventoriesAPI.readInstanceGroups).toHaveBeenCalledWith(
|
||||
mockInventory.id
|
||||
);
|
||||
expect(wrapper.find(`Detail[label="Instance Groups"]`)).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user