Skip to content

Commit

Permalink
[New] Support rendering test with startingQuestionId query parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
blcham committed Oct 4, 2020
1 parent 7eee20d commit 8d628d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"html-webpack-plugin": "^4.3.0",
"jest": "^26.0.1",
"prettier": "^2.0.5",
"query-string": "^6.13.5",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"style-loader": "^1.2.1",
Expand Down
18 changes: 17 additions & 1 deletion test/rendering/TestApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,25 @@ import SForms from '../../src/components/SForms';

import '../../src/styles/s-forms.css';
import 'react-datepicker/dist/react-datepicker.css';
import queryString from 'query-string'

const form1 = require('./form1.json'); // form with wizard steps
const form2 = require('./form2.json'); // form without wizard steps (proudly assembled in Semantic Form Web Editor)

const getP = (queryParameterName, defaultValue) => {
return {
[queryParameterName]: getQueryParameter(queryParameterName, defaultValue)
}
}

const getQueryParameter = (parameterName, defaultValue) => {
const value = queryString.parse(window.location.search)[parameterName];
if (value) {
return value;
}
return defaultValue;
}

class TestApp extends React.Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -41,9 +56,10 @@ class TestApp extends React.Component {
},
modalView: false,
modalProps,
horizontalWizardNav: true,
horizontalWizardNav: false,
wizardStepButtons: true,
enableForwardSkip: true,
...getP('startingQuestionId', "layout-options-65"),
startingStep: 1
};

Expand Down

0 comments on commit 8d628d6

Please sign in to comment.