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

feat(vue): add snapshot tests for rs-vue components #1854

Draft
wants to merge 34 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8fd9e22
feat(vue): configured component wrapper for snapshot testing
mohdashraf010897 Jan 17, 2022
3cae26a
feat(vue): configured MultiList component for snapshot testing
mohdashraf010897 Jan 17, 2022
8623935
refactor: the getComponent and hadcustomrenderer method to carefully …
mohdashraf010897 Jan 17, 2022
41f2c9c
feat(vue): wrote test cases for MultiList component
mohdashraf010897 Jan 17, 2022
2c7e9c8
feat(vue): configured vue for snapshot testing with jest and support …
mohdashraf010897 Jan 17, 2022
ccbe13d
fix(eslint): ignore snapshot files
mohdashraf010897 Jan 17, 2022
839f0dc
feat(vue): added packages for vue snapshot testing with jest
mohdashraf010897 Jan 17, 2022
6681083
feat(vue): added packages for vue snapshot testing with jest
mohdashraf010897 Jan 17, 2022
04d8e2c
feat(vue): added default value test casde for MultiList component
mohdashraf010897 Jan 17, 2022
56311ca
feat(vue): modified SingleList component to support snapshot testing
mohdashraf010897 Jan 17, 2022
986f9fa
feat(vue): added snapshot tests for SingleList component
mohdashraf010897 Jan 17, 2022
d2abf18
feat(vue): modified Multidropdown component for snapshot testing
mohdashraf010897 Jan 17, 2022
e62c764
feat(vue): added open prop to by-default open dropdown for snapshot t…
mohdashraf010897 Jan 17, 2022
05fe7cb
feat(vue): added snapshot test for MultidropdownList component
mohdashraf010897 Jan 17, 2022
e856e23
feat(vue): modified SingleDropdownList component for snapshot testing
mohdashraf010897 Jan 17, 2022
e388089
feat(vue): added snapshot test for SingledropdownList component
mohdashraf010897 Jan 17, 2022
921ff66
sync vue-playground package
mohdashraf010897 Jan 17, 2022
338a67b
feat(vue): modified RangeSlider component to support snapshot testing
mohdashraf010897 Jan 18, 2022
dc8eb1a
feat(vue): added sanpshot tests for RangeSlider component
mohdashraf010897 Jan 18, 2022
f3328b5
feat(vue): modified RangeInput component to support snapshot testing
mohdashraf010897 Jan 18, 2022
ceca4f1
feat(vue): added sanpshot tests for RangeInput component
mohdashraf010897 Jan 18, 2022
5506849
feat(vue): added snapshot tests for DynamicRangeSlider
mohdashraf010897 Jan 18, 2022
02581ae
fix(vue): bug with render slider
mohdashraf010897 Jan 18, 2022
1a59c26
fix(vue): fix range-slider snapshot post a minor bug fix
mohdashraf010897 Jan 18, 2022
47fa83a
feat(vue): added snapshot tests for ReactiveList component
mohdashraf010897 Jan 18, 2022
196b666
sync sub-module
mohdashraf010897 Jan 18, 2022
bba8c74
fix(vue): RangeInput component to pass value attribute directly to in…
mohdashraf010897 Jan 18, 2022
1c369f2
sync submodule
mohdashraf010897 Jan 27, 2022
2f9c06c
sync with next branch
mohdashraf010897 Feb 8, 2022
208931f
update snapshots after merging next branch
mohdashraf010897 Feb 8, 2022
c3c7722
Merge branch 'next' of github.com:appbaseio/reactivesearch into feat/…
bietkul Apr 6, 2022
e1e120e
chore: fix test cases
bietkul Apr 6, 2022
71234cd
chore: update gitignore
bietkul Apr 6, 2022
5ce7cc1
chore: ignore coverage
bietkul Apr 6, 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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ vue-playground
packages/vue
.expo/
packages/reactivecore/coverage/
__snapshots__
2 changes: 1 addition & 1 deletion packages/playground
Submodule playground updated 2 files
+2 −2 package.json
+0 −47 yarn.lock
1 change: 1 addition & 0 deletions packages/vue/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
node_modules
/dist
/coverage

# local env files
.env.local
Expand Down
1 change: 1 addition & 0 deletions packages/vue/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { presets: ['@babel/preset-env', '@vue/babel-preset-jsx'] };
17 changes: 17 additions & 0 deletions packages/vue/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
// preset: '@vue/cli-plugin-unit-jest',
// transform: {
// '^.+\\.(js|jsx)$': 'babel-jest',
// },
verbose: true,
collectCoverage: false,
testURL: 'http://localhost/',
testEnvironment: 'jest-environment-jsdom-fifteen',
// snapshotSerializers: ['./serialize.js'],
// snapshotSerializers: ['dfs'],
// snapshotSerializers: [
// '@emotion/jest/serializer' /* if needed other snapshotSerializers should go here */,
// ],
snapshotSerializers: ['jest-serializer-vue', '@emotion/jest/serializer'],
testMatch: ['**/*.test.[jt]s?(x)'],
};
8 changes: 7 additions & 1 deletion packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"start": "nps",
"pretest": "nps build",
"test": "nps test",
"clear-jest-cache": "jest --clearCache",
"precommit": "lint-staged",
"prepare": "npm start validate",
"version-upgrade": "nps upgrade-vue -c ../../package-scripts.js",
Expand Down Expand Up @@ -61,11 +62,16 @@
"@babel/plugin-syntax-jsx": "^7.2.0",
"@babel/preset-env": "^7.5.5",
"@babel/preset-stage-2": "^7.0.0",
"@emotion/jest": "^11.9.0",
"@vue/babel-preset-jsx": "^1.1.0",
"@vue/cli-plugin-unit-jest": "^4.5.15",
"@vue/test-utils": "^1.3.0",
"eslint": "^4.12.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-vue": "^4.7.1",
"eslint": "^4.12.0",
"jest-serializer-vue": "^2.0.2",
"jest-vue-emotion": "^1.0.0",
"nps": "^5.9.3",
"nps-utils": "^1.7.0",
"rollup": "^1.20.3",
Expand Down
11 changes: 10 additions & 1 deletion packages/vue/src/components/basic/ComponentWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
setQueryListener,
setComponentProps,
updateComponentProps,
mockDataForTesting,
} = Actions;

const { pushToAndClause, checkPropChange, checkSomePropChange } = helper;
Expand Down Expand Up @@ -48,6 +49,13 @@ const ComponentWrapper = (
this.componentProps = parsedProps;
this.componentId = this.componentProps.componentId;
this.react = this.componentProps.react;

if (this.componentProps.mockData) {
this.mockDataForTesting(
this.componentProps.componentId,
this.componentProps.mockData,
);
}
},
beforeMount() {
let components = [];
Expand Down Expand Up @@ -93,7 +101,7 @@ const ComponentWrapper = (
}
},
mounted() {
if (this.internalComponent) {
if (this.internalComponent && this.componentProps.mode !== 'test') {
// Watch component after rendering the component to avoid the un-necessary calls
this.setReact(this.componentProps);
}
Expand Down Expand Up @@ -163,6 +171,7 @@ const mapDispatchToProps = {
watchComponent,
setComponentProps,
updateComponentProps,
mockDataForTesting,
};
export default (component, options = {}) =>
connect(mapStateToProps, mapDispatchToProps)(ComponentWrapper(component, options));
31 changes: 16 additions & 15 deletions packages/vue/src/components/list/MultiDropdownList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const MultiDropdownList = {
nestedField: types.string,
index: VueTypes.string,
searchPlaceholder: VueTypes.string.def('Type here to search...'),
isOpen: VueTypes.bool.def(false),
},
created() {
if (!this.enableAppbase && this.$props.index) {
Expand All @@ -88,8 +89,8 @@ const MultiDropdownList = {
);
}
const props = this.$props;
this.modifiedOptions =
this.options && this.options[props.dataField]
this.modifiedOptions
= this.options && this.options[props.dataField]
? this.options[props.dataField].buckets
: [];
// Set custom and default queries in store
Expand Down Expand Up @@ -247,14 +248,15 @@ const MultiDropdownList = {
searchPlaceholder={this.$props.searchPlaceholder}
transformData={this.$props.transformData}
footer={
showLoadMore &&
!isLastBucket && (
showLoadMore
&& !isLastBucket && (
<div css={loadMoreContainer}>
<Button onClick={this.handleLoadMore}>{loadMoreLabel}</Button>
</div>
)
}
customLabelRenderer={renderLabelCalc}
open={this.$props.isOpen}
/>
</Container>
);
Expand Down Expand Up @@ -370,7 +372,6 @@ const MultiDropdownList = {
const customQueryOptions = getOptionsForCustomQuery(customQueryCalc);
this.setQueryOptions(props.componentId, customQueryOptions, false);
}

this.updateQuery({
componentId: props.componentId,
query,
Expand All @@ -386,9 +387,9 @@ const MultiDropdownList = {
const queryOptions = getQueryOptions(props);
return props.showLoadMore
? getCompositeAggsQuery({
query: queryOptions,
props,
after,
query: queryOptions,
props,
after,
})
: getAggsQuery(queryOptions, props);
},
Expand Down Expand Up @@ -531,9 +532,9 @@ MultiDropdownList.generateQueryOptions = (props, after) => {
const queryOptions = getQueryOptions(props);
return props.showLoadMore
? getCompositeAggsQuery({
query: queryOptions,
props,
after,
query: queryOptions,
props,
after,
})
: getAggsQuery(queryOptions, props);
};
Expand All @@ -547,9 +548,9 @@ const mapStateToProps = (state, props) => ({
rawData: state.rawData[props.componentId],
isLoading: state.isLoading[props.componentId],
selectedValue:
(state.selectedValues[props.componentId] &&
state.selectedValues[props.componentId].value) ||
null,
(state.selectedValues[props.componentId]
&& state.selectedValues[props.componentId].value)
|| null,
themePreset: state.config.themePreset,
error: state.error[props.componentId],
componentProps: state.props[props.componentId],
Expand All @@ -563,7 +564,7 @@ const mapDispatchtoProps = {
setDefaultQuery,
};

const ListConnected = ComponentWrapper(
export const ListConnected = ComponentWrapper(
connect(mapStateToProps, mapDispatchtoProps)(MultiDropdownList),
{
componentType: componentTypes.multiDropdownList,
Expand Down
Loading