Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign the SCA table from agent's dashboard #4512

Merged
merged 23 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6d8e71c
SCA table: Latest scans
chantal-kelm Sep 14, 2022
bf727a0
redirect and states
chantal-kelm Sep 21, 2022
7fba6a2
params url
chantal-kelm Sep 21, 2022
6bb26a4
the tables are working properly
chantal-kelm Sep 21, 2022
f9fa2fd
styles
chantal-kelm Sep 21, 2022
6574890
inventory test
chantal-kelm Sep 22, 2022
71f129d
styles euiFlexGroup
chantal-kelm Sep 22, 2022
9e03a69
SCA test, back button and parameter renaming
chantal-kelm Sep 23, 2022
ba53ea9
load for tables
chantal-kelm Sep 25, 2022
0089174
Added new policies table for reuse in agent welcome and sca
Machi3mfl Oct 17, 2022
e458ca6
Fixed table redirection on row clicked
Machi3mfl Oct 18, 2022
253912d
Solved review comments
Machi3mfl Oct 18, 2022
db0bdb0
Merge branch '4.4-7.10' into 4238-Redesign-the-agents-dashboard
Machi3mfl Oct 19, 2022
65a3d96
Fixed policy row redirect, renaming and remove it unused code
Machi3mfl Oct 19, 2022
d27f9f8
Updated CHANGELOG
Machi3mfl Oct 19, 2022
8bd7d74
Added pagination
Machi3mfl Oct 20, 2022
15e1e48
Merge branch '4.4-7.10' into 4238-Redesign-the-agents-dashboard
Machi3mfl Oct 20, 2022
59b6c63
Updated snapshots to fix unit tests
Machi3mfl Oct 20, 2022
f3b0873
Merge branch '4.4-7.10' into 4238-Redesign-the-agents-dashboard
Machi3mfl Oct 20, 2022
5b712e9
Updated CHANGELOG
Machi3mfl Oct 20, 2022
49f714f
Fixed lastest scan navigation
Machi3mfl Oct 20, 2022
3eb8834
Merge branch '4.4-7.10' into 4238-Redesign-the-agents-dashboard
Machi3mfl Oct 20, 2022
4e4896c
Merge branch '4.4-7.10' into 4238-Redesign-the-agents-dashboard
Machi3mfl Oct 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions public/components/agents/sca/__snapshots__/inventory.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`SCA Inventory Test should render correctly 1`] = `
<DocumentFragment>
<div>
<div
style="margin: 16px;"
>
<div
class="euiSpacer euiSpacer--m"
/>
<div
class="euiProgress euiProgress--indeterminate euiProgress--xs euiProgress--primary"
/>
</div>
</div>
<div
class="euiPage"
/>
</DocumentFragment>
`;

exports[`SCA Inventory Test should render correctly 2`] = `
<DocumentFragment>
<div />
<div
class="euiPage"
>
<div
class="euiCallOut euiCallOut--primary"
>
<div
class="euiCallOutHeader"
>
<svg
aria-hidden="true"
class="euiIcon euiIcon--medium euiCallOutHeader__icon"
focusable="false"
height="16"
role="img"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M7.5 11.508L7.468 8H6.25V7h2.401l.03 3.508H9.8v1H7.5zm-.25-6.202a.83.83 0 01.207-.577c.137-.153.334-.229.59-.229.256 0 .454.076.594.23.14.152.209.345.209.576 0 .228-.07.417-.21.568-.14.15-.337.226-.593.226-.256 0-.453-.075-.59-.226a.81.81 0 01-.207-.568zM8 13A5 5 0 108 3a5 5 0 000 10zm0 1A6 6 0 118 2a6 6 0 010 12z"
fill-rule="evenodd"
/>
</svg>
<span
class="euiCallOutHeader__title"
>
No scans available
</span>
</div>
<div
class="euiText euiText--small"
>
<button
class="euiButton euiButton--primary"
type="button"
>
<span
class="euiButtonContent euiButton__content"
>
<span
class="euiButton__text"
>
Refresh
</span>
</span>
</button>
</div>
</div>
</div>
</DocumentFragment>
`;

exports[`SCA Inventory Test should render correctly 3`] = `<DocumentFragment />`;
81 changes: 81 additions & 0 deletions public/components/agents/sca/inventory.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { fireEvent, render, waitFor } from '@testing-library/react';
import '@testing-library/jest-dom';
// import {jest} from '@jest/globals'
import React from 'react';
import { Inventory } from './inventory'
import * as _ from 'lodash'
import { createGetterSetter } from '../../../utils/create-getter-setter';
import { ErrorOrchestratorService } from '../../../react-services/error-orchestrator/error-orchestrator.service';
import configureMockStore from 'redux-mock-store';
import { Provider } from 'react-redux';
import { WzRequest } from '../../../react-services/wz-request';



const mockedGetErrorOrchestrator = {
handleError: jest.fn(),
};

jest.mock('../../../react-services/common-services', () => {
return {
getErrorOrchestrator: () => mockedGetErrorOrchestrator,
};
});

jest.mock('../../../react-services/wz-request')

describe('SCA Inventory Test', () => {
// mocked getErrorOrchestrator
// const mockGet = jest.fn();
// const mockSet = jest.fn();
// jest.mock('../../../react-services/error-orchestrator/error-orchestrator.service');
// jest.mock('../../../utils/create-getter-setter');
it('should render correctly', () => {
const mockStore = configureMockStore();
const store = mockStore({policy_id:'cis_bu'});
const apiReqMock = jest.fn().mockReturnValue({
data: {
data: { affected_items: ['hola'] },
},
})
WzRequest.apiReq = apiReqMock
const onClickRow = jest.fn()
const props= {
agent: {
agentPlatform:"linux",
configSum:"ab73af41699f13fdd81903b5f23d8d00",
dateAdd: "2022-09-01T15:40:06+00:00",
group: ['default'],
group_config_status: "synced",
id: "001",
ip: "172.18.0.5",
lastKeepAlive: "2022-09-21T23:47:35+00:00",
manager: "wazuh_manager_filebeat_sources_cmake-4.4-7.10.2",
mergedSum: "4a8724b20dee0124ff9656783c490c4e",
name: "wazuh_agent_ubuntu_sources_cmake-4.4",
node_name: "manager-node",
os: {arch: 'x86_64', codename: 'Bionic Beaver', major: '18', minor: '04', name: 'Ubuntu'},
registerIP: "any",
status: "active",
version: "Wazuh v4.4.0",
},
onClickRow,
withoutDashboard: true
}
// try {

const { asFragment, debug } = render(<Provider store={store}><Inventory {...props} /></Provider>);
debug()

// await waitFor(() => expect(asFragment()).toMatchSnapshot());
expect(apiReqMock).toHaveBeenCalledTimes(1)
// await waitFor(() => expect(createGetterSetter).toHaveBeenCalledTimes(1))
// await waitFor(() => expect(ErrorOrchestratorService).toHaveBeenCalledTimes(1))
// } catch(error) {
// console.log(error)
// }
// expect(asFragment()).toMatchSnapshot();
// const { debug } = render(<Inventory {...props} />);

})
});
Loading