Skip to content

Commit 983fff7

Browse files
committed
Adds unit tests for back button
1 parent 2464de0 commit 983fff7

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.test.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,30 @@ describe('When on the Event Filters List Page', () => {
175175
});
176176
});
177177
});
178+
179+
describe('and the back button is present', () => {
180+
beforeEach(async () => {
181+
renderResult = render();
182+
act(() => {
183+
history.push('/event_filters', {
184+
onBackButtonNavigateTo: [{ appId: 'appId' }],
185+
backButtonLabel: 'back to fleet',
186+
backButtonUrl: '/fleet',
187+
});
188+
});
189+
});
190+
191+
it('back button is present', () => {
192+
const button = renderResult.queryByTestId('backToOrigin');
193+
expect(button).not.toBeNull();
194+
expect(button).toHaveAttribute('href', '/fleet');
195+
});
196+
197+
it('back button is not present', () => {
198+
act(() => {
199+
history.push('/event_filters');
200+
});
201+
expect(renderResult.queryByTestId('backToOrigin')).toBeNull();
202+
});
203+
});
178204
});

x-pack/plugins/security_solution/public/management/pages/trusted_apps/view/trusted_apps_page.test.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,4 +900,34 @@ describe('When on the Trusted Apps Page', () => {
900900
});
901901
});
902902
});
903+
904+
describe('and the back button is present', () => {
905+
let renderResult: ReturnType<AppContextTestRender['render']>;
906+
beforeEach(async () => {
907+
renderResult = render();
908+
await act(async () => {
909+
await waitForAction('trustedAppsListResourceStateChanged');
910+
});
911+
reactTestingLibrary.act(() => {
912+
history.push('/trusted_apps', {
913+
onBackButtonNavigateTo: [{ appId: 'appId' }],
914+
backButtonLabel: 'back to fleet',
915+
backButtonUrl: '/fleet',
916+
});
917+
});
918+
});
919+
920+
it('back button is present', () => {
921+
const button = renderResult.queryByTestId('backToOrigin');
922+
expect(button).not.toBeNull();
923+
expect(button).toHaveAttribute('href', '/fleet');
924+
});
925+
926+
it('back button is not present', () => {
927+
reactTestingLibrary.act(() => {
928+
history.push('/trusted_apps');
929+
});
930+
expect(renderResult.queryByTestId('backToOrigin')).toBeNull();
931+
});
932+
});
903933
});

0 commit comments

Comments
 (0)