Skip to content

Commit

Permalink
Add refresh button to rollup page (#132)
Browse files Browse the repository at this point in the history
Signed-off-by: Annie Lee <[email protected]>
  • Loading branch information
annie3431 authored Nov 17, 2021
1 parent 8099d0c commit fed8b29
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
10 changes: 10 additions & 0 deletions public/pages/Rollups/containers/Rollups/Rollups.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,14 @@ describe("<Rollups /> spec", () => {
expect(coreServicesMock.notifications.toasts.addSuccess).toHaveBeenCalledTimes(1);
expect(coreServicesMock.notifications.toasts.addSuccess).toHaveBeenCalledWith(`${testRollup._id} is disabled`);
});

it("calls getRollups when clicking refresh button", async () => {
browserServicesMock.rollupService.getRollups = jest.fn();

const { getByTestId } = renderRollupsWithRouter();

userEvent.click(getByTestId("refreshButton"));

expect(browserServicesMock.rollupService.getRollups).toHaveBeenCalledTimes(1);
});
});
5 changes: 5 additions & 0 deletions public/pages/Rollups/containers/Rollups/Rollups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,11 @@ export default class Rollups extends Component<RollupsProps, RollupsState> {
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFlexGroup alignItems="center" gutterSize="s">
<EuiFlexItem grow={false}>
<EuiButton iconType="refresh" onClick={this.getRollups} data-test-subj="refreshButton">
Refresh
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton disabled={!selectedItems.length} onClick={this.onDisable} data-test-subj="disableButton">
Disable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ exports[`<Rollups /> spec renders the component 1`] = `
<div
class="euiFlexGroup euiFlexGroup--gutterSmall euiFlexGroup--alignItemsCenter euiFlexGroup--directionRow euiFlexGroup--responsive"
>
<div
class="euiFlexItem euiFlexItem--flexGrowZero"
>
<button
class="euiButton euiButton--primary"
data-test-subj="refreshButton"
type="button"
>
<span
class="euiButtonContent euiButton__content"
>
EuiIconMock
<span
class="euiButton__text"
>
Refresh
</span>
</span>
</button>
</div>
<div
class="euiFlexItem euiFlexItem--flexGrowZero"
>
Expand Down
10 changes: 10 additions & 0 deletions public/pages/Transforms/containers/Transforms/Transforms.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,14 @@ describe("<Transforms /> spec", () => {
expect(coreServicesMock.notifications.toasts.addSuccess).toHaveBeenCalledTimes(1);
expect(coreServicesMock.notifications.toasts.addSuccess).toHaveBeenCalledWith(`\"${testTransform2._id}\" is disabled`);
});

it("calls getTransforms when clicking refresh button", async () => {
browserServicesMock.transformService.getTransforms = jest.fn();

const { getByTestId } = renderTransformsWithRouter();

userEvent.click(getByTestId("refreshButton"));

expect(browserServicesMock.transformService.getTransforms).toHaveBeenCalledTimes(1);
});
});

0 comments on commit fed8b29

Please sign in to comment.