Skip to content

Commit

Permalink
Fix UI bug for TaskRuns in read-only mode
Browse files Browse the repository at this point in the history
Batch actions should not be enabled in read-only mode. A bug introduced
during recent refactoring meant that the read-only flag wasn't being read
correctly in this case causing the checkboxes to appear on the TaskRuns
table. This gave the impression that TaskRuns could be deleted, however
the action is still blocked in environments where RBAC is enforced as
the Dashboard ServiceAccount does not have permissions to delete these
resources when deployed in read-only mode.

Update the test to prevent a similar regression in future, as well as
updating the equivalent test for PipelineRuns in the same manner.
  • Loading branch information
AlanGreene committed Jul 14, 2021
1 parent c7640dc commit 4ae04a3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/containers/PipelineRuns/PipelineRuns.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,12 @@ describe('PipelineRuns container', () => {
url: '/pipelineruns'
};

const { getByText, queryAllByText, queryAllByTitle } = renderWithRouter(
const {
getByText,
queryAllByLabelText,
queryAllByText,
queryAllByTitle
} = renderWithRouter(
<Provider store={mockTestStore}>
<Route
path="/pipelineruns"
Expand All @@ -399,6 +404,7 @@ describe('PipelineRuns container', () => {
await waitFor(() => getByText('pipelineRunWithTwoLabels'));
expect(queryAllByText('Create')[0]).toBeFalsy();
expect(queryAllByTitle(/actions/i)[0]).toBeFalsy();
expect(queryAllByLabelText('Select row').length).toBe(0);
});

it('handles rerun event in PipelineRuns page', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/containers/TaskRuns/TaskRuns.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ function TaskRuns(props) {
}
];

const batchActionButtons = props.isReadOnly
const batchActionButtons = isReadOnly
? []
: [
{
Expand Down
7 changes: 6 additions & 1 deletion src/containers/TaskRuns/TaskRuns.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,11 @@ describe('TaskRuns container', () => {
url: urls.taskRuns.all()
};

const { getByText, queryAllByTitle } = renderWithRouter(
const {
getByText,
queryAllByLabelText,
queryAllByTitle
} = renderWithRouter(
<Provider store={store.getStore()}>
<Route
path={urls.taskRuns.all()}
Expand All @@ -391,6 +395,7 @@ describe('TaskRuns container', () => {

await waitFor(() => getByText('taskRunWithTwoLabels'));
expect(queryAllByTitle(/actions/i)[0]).toBeFalsy();
expect(queryAllByLabelText('Select row').length).toBe(0);
});

it('handles rerun event in TaskRuns page', async () => {
Expand Down

0 comments on commit 4ae04a3

Please sign in to comment.