From 41fd73ec4d22b9a3624bf861189f92296bdc56da Mon Sep 17 00:00:00 2001 From: ayusht2810 Date: Mon, 12 Feb 2024 16:50:43 +0530 Subject: [PATCH] Added snapshot testing --- webapp/package-lock.json | 27 +++++++----- webapp/package.json | 4 +- ...confluence_instance_selector.test.jsx.snap | 42 +++++++++++++++++++ .../confluence_instance_selector.test.jsx | 29 +++++++++++++ .../confluence_space_selector.test.jsx.snap | 42 +++++++++++++++++++ .../confluence_space_selector.test.jsx | 31 ++++++++++++++ ...create_confluence_page_modal.test.jsx.snap | 40 ++++++++++++++++++ .../create_confluence_page_modal.test.jsx | 32 ++++++++++++++ 8 files changed, 234 insertions(+), 13 deletions(-) create mode 100644 webapp/src/components/confluence_instance_selector/__snapshots__/confluence_instance_selector.test.jsx.snap create mode 100644 webapp/src/components/confluence_instance_selector/confluence_instance_selector.test.jsx create mode 100644 webapp/src/components/confluence_space_selector/__snapshots__/confluence_space_selector.test.jsx.snap create mode 100644 webapp/src/components/confluence_space_selector/confluence_space_selector.test.jsx create mode 100644 webapp/src/components/create_confluence_page_modal/__snapshots__/create_confluence_page_modal.test.jsx.snap create mode 100644 webapp/src/components/create_confluence_page_modal/create_confluence_page_modal.test.jsx diff --git a/webapp/package-lock.json b/webapp/package-lock.json index fbece76..27abfa3 100644 --- a/webapp/package-lock.json +++ b/webapp/package-lock.json @@ -3060,14 +3060,6 @@ "csstype": "^2.2.0" } }, - "@types/react-bootstrap": { - "version": "0.32.25", - "resolved": "https://registry.npmjs.org/@types/react-bootstrap/-/react-bootstrap-0.32.25.tgz", - "integrity": "sha512-VTa6viz5L+uPblEiF2pZz/n425cC49hrjLTsiLySxf7fw+UkchkjpskrsOHRvC6cCgCAG9futRWvOOjD1IBQqQ==", - "requires": { - "@types/react": "*" - } - }, "@types/react-dom": { "version": "16.9.8", "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-16.9.8.tgz", @@ -9285,9 +9277,9 @@ } }, "fsevents": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", - "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, "optional": true }, @@ -11169,6 +11161,11 @@ "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", "dev": true }, + "lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==" + }, "lodash.sortby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", @@ -13999,6 +13996,14 @@ "symbol-observable": "^1.0.2" } }, + "redux-mock-store": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/redux-mock-store/-/redux-mock-store-1.5.4.tgz", + "integrity": "sha512-xmcA0O/tjCLXhh9Fuiq6pMrJCwFRaouA8436zcikdIpYWWCjU76CRk+i2bHx8EeiSiMGnB85/lZdU3wIJVXHTA==", + "requires": { + "lodash.isplainobject": "^4.0.6" + } + }, "redux-offline": { "version": "git+https://github.com/enahum/redux-offline.git#885024de96b6ec73650c340c8928066585c413df", "from": "git+https://github.com/enahum/redux-offline.git#885024de96b6ec73650c340c8928066585c413df", diff --git a/webapp/package.json b/webapp/package.json index e04e0b4..b1514a9 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -72,9 +72,9 @@ "react-redux": "7.2.0", "react-select": "3.1.0", "redux": "4.0.5", + "redux-mock-store": "1.5.4", "superagent": "5.3.1", - "typescript": "3.9.6", - "@types/react-bootstrap": "0.32.25" + "typescript": "3.9.6" }, "jest": { "snapshotSerializers": [ diff --git a/webapp/src/components/confluence_instance_selector/__snapshots__/confluence_instance_selector.test.jsx.snap b/webapp/src/components/confluence_instance_selector/__snapshots__/confluence_instance_selector.test.jsx.snap new file mode 100644 index 0000000..fe6357d --- /dev/null +++ b/webapp/src/components/confluence_instance_selector/__snapshots__/confluence_instance_selector.test.jsx.snap @@ -0,0 +1,42 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`components/ConfluenceInstanceSelector confluence instance selector snapshot test 1`] = ` + + + , + +`; diff --git a/webapp/src/components/confluence_instance_selector/confluence_instance_selector.test.jsx b/webapp/src/components/confluence_instance_selector/confluence_instance_selector.test.jsx new file mode 100644 index 0000000..bf76d14 --- /dev/null +++ b/webapp/src/components/confluence_instance_selector/confluence_instance_selector.test.jsx @@ -0,0 +1,29 @@ +import React from 'react'; + +import {shallow} from 'enzyme'; +import ConfluenceInstanceSelector from './confluence_instance_selector'; +import configureStore from 'redux-mock-store' + +import { Provider } from 'react-redux'; + +describe('components/ConfluenceInstanceSelector', () => { + const initialState = {} + const baseProps = { + theme: {}, + selectedInstanceID:'test-spaceKey', + onInstanceChange:jest.fn() + }; + const mockStore = configureStore() + test('confluence instance selector snapshot test', async () => { + const props = { + ...baseProps, + }; + const store = mockStore(initialState) + const wrapper = shallow( + + < ConfluenceInstanceSelector {...props}/>, + + ); + expect(wrapper).toMatchSnapshot(); + }); +}); diff --git a/webapp/src/components/confluence_space_selector/__snapshots__/confluence_space_selector.test.jsx.snap b/webapp/src/components/confluence_space_selector/__snapshots__/confluence_space_selector.test.jsx.snap new file mode 100644 index 0000000..6ce8863 --- /dev/null +++ b/webapp/src/components/confluence_space_selector/__snapshots__/confluence_space_selector.test.jsx.snap @@ -0,0 +1,42 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`components/ConfluenceSpaceSelector confluence space selector snapshot test 1`] = ` + + + , + +`; diff --git a/webapp/src/components/confluence_space_selector/confluence_space_selector.test.jsx b/webapp/src/components/confluence_space_selector/confluence_space_selector.test.jsx new file mode 100644 index 0000000..93ded2b --- /dev/null +++ b/webapp/src/components/confluence_space_selector/confluence_space_selector.test.jsx @@ -0,0 +1,31 @@ +/*eslint max-nested-callbacks: ["error", 3]*/ + +import React from 'react'; + +import {shallow} from 'enzyme'; +import ConfluenceSpaceSelector from './confluence_space_selector'; +import configureStore from 'redux-mock-store' + +import { Provider } from 'react-redux'; + +describe('components/ConfluenceSpaceSelector', () => { + const initialState = {} + const baseProps = { + theme: {}, + selectedSpaceKey:'test-spaceKey', + onSpaceKeyChange:jest.fn() + }; + const mockStore = configureStore() + test('confluence space selector snapshot test', async () => { + const props = { + ...baseProps, + }; + const store = mockStore(initialState) + const wrapper = shallow( + + < ConfluenceSpaceSelector {...props}/>, + + ); + expect(wrapper).toMatchSnapshot(); + }); +}); \ No newline at end of file diff --git a/webapp/src/components/create_confluence_page_modal/__snapshots__/create_confluence_page_modal.test.jsx.snap b/webapp/src/components/create_confluence_page_modal/__snapshots__/create_confluence_page_modal.test.jsx.snap new file mode 100644 index 0000000..4d08791 --- /dev/null +++ b/webapp/src/components/create_confluence_page_modal/__snapshots__/create_confluence_page_modal.test.jsx.snap @@ -0,0 +1,40 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`components/CreateCofluencePageModal confluence create page modal snapshot test 1`] = ` + + + , + +`; diff --git a/webapp/src/components/create_confluence_page_modal/create_confluence_page_modal.test.jsx b/webapp/src/components/create_confluence_page_modal/create_confluence_page_modal.test.jsx new file mode 100644 index 0000000..e482bb0 --- /dev/null +++ b/webapp/src/components/create_confluence_page_modal/create_confluence_page_modal.test.jsx @@ -0,0 +1,32 @@ +/*eslint max-nested-callbacks: ["error", 3]*/ + +import React from 'react'; + +import {shallow} from 'enzyme'; +import CreateConfluencePage from './create_confluence_page_modal'; + +import configureStore from 'redux-mock-store' + +import { Provider } from 'react-redux'; + +describe('components/CreateCofluencePageModal', () => { + const initialState = { + message : 'test-message' + } + const baseProps = { + theme: {}, + }; + const mockStore = configureStore() + test('confluence create page modal snapshot test', async () => { + const props = { + ...baseProps, + }; + const store = mockStore(initialState) + const wrapper = shallow( + + < CreateConfluencePage {...props}/>, + + ); + expect(wrapper).toMatchSnapshot(); + }); +});