Skip to content

Commit

Permalink
task/WP-288: Implement Queue Filter (#883)
Browse files Browse the repository at this point in the history
* task/WP-288-QueueFilter

---------

Co-authored-by: Taylor Grafft <[email protected]>
Co-authored-by: Taylor Grafft <[email protected]>
Co-authored-by: Chandra Y <[email protected]>
  • Loading branch information
4 people authored Oct 24, 2023
1 parent e427c97 commit fa8c979
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 5 deletions.
20 changes: 15 additions & 5 deletions client/src/components/Applications/AppForm/AppForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -692,11 +692,21 @@ export const AppSchemaForm = ({ app }) => {
)
.map((q) => q.name)
.sort()
.map((queueName) => (
<option key={queueName} value={queueName}>
{queueName}
</option>
))
.map((queueName) =>
app.definition.notes.queueFilter ? (
app.definition.notes.queueFilter.includes(
queueName
) && (
<option key={queueName} value={queueName}>
{queueName}
</option>
)
) : (
<option key={queueName} value={queueName}>
{queueName}
</option>
)
)
.sort()}
</FormField>
)}
Expand Down
55 changes: 55 additions & 0 deletions client/src/components/Applications/AppForm/AppForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,58 @@ describe('AppDetail', () => {
).toBeDefined();
});
});

const mockAppWithQueueFilter = {
...helloWorldAppFixture,
definition: {
...helloWorldAppFixture.definition,
notes: {
...helloWorldAppFixture.definition.notes,
queueFilter: ['rtx', 'small'],
},
},
};

const mockAppWithoutQueueFilter = {
...helloWorldAppFixture,
definition: {
...helloWorldAppFixture.definition,
notes: {
...helloWorldAppFixture.definition.notes,
queueFilter: null,
},
},
};

describe('AppSchemaForm queueFilter tests', () => {
it('renders only the queues specified in the queueFilter', () => {
const { container } = renderAppSchemaFormComponent(
mockStore(initialMockState),
mockAppWithQueueFilter
);

const targetDropdown = container.querySelector(
'select[name="execSystemLogicalQueue"]'
);
const options = Array.from(targetDropdown.querySelectorAll('option'));
expect(options).toHaveLength(2);
expect(options[0].textContent).toBe('rtx');
expect(options[1].textContent).toBe('small');
});

it('renders all queues when no queueFilter is present', () => {
const { container } = renderAppSchemaFormComponent(
mockStore(initialMockState),
mockAppWithoutQueueFilter
);

const targetDropdown = container.querySelector(
'select[name="execSystemLogicalQueue"]'
);
const options = Array.from(targetDropdown.querySelectorAll('option'));
expect(options).toHaveLength(3);
expect(options[0].textContent).toBe('development');
expect(options[1].textContent).toBe('rtx');
expect(options[2].textContent).toBe('small');
});
});

0 comments on commit fa8c979

Please sign in to comment.