diff --git a/src/__tests__/integration/app.test.js b/src/__tests__/integration/app.test.js index 15cfd1c9..c1966089 100644 --- a/src/__tests__/integration/app.test.js +++ b/src/__tests__/integration/app.test.js @@ -1,4 +1,4 @@ -import { integrationTest } from './index'; +import { integrationTest, toggleSettingsCheckbox } from './index'; import Loading from '../../components/layouts/pages/loading/Loading'; const { REACT_APP_VERSION } = process.env; @@ -24,4 +24,17 @@ describe('App', () => { } ) ); + + it( + 'Turn settings on and off', + integrationTest((store, component) => { + expect(component.find('.MuiStepLabel-root')).toHaveLength(3); + + toggleSettingsCheckbox(component, true); + expect(component.find('.MuiStepLabel-root')).toHaveLength(4); + + toggleSettingsCheckbox(component, false); + expect(component.find('.MuiStepLabel-root')).toHaveLength(3); + }) + ); }); diff --git a/src/__tests__/integration/index.js b/src/__tests__/integration/index.js index 642b55c1..4a8a377c 100644 --- a/src/__tests__/integration/index.js +++ b/src/__tests__/integration/index.js @@ -7,6 +7,7 @@ import fs from 'mz/fs'; import App from '../../components/App'; import configureStore from '../../store/rootStore'; +import Checkbox from '@material-ui/core/Checkbox'; import { getInfo as getFileServiceInfo, uploadFile, getFileContent } from '../../services/fileService'; import { getInfo as getJobServiceInfo, createJob, updateJob, executeJob, getJob } from '../../services/jobService'; import { getList as getProfilesList } from '../../services/profiles'; @@ -262,3 +263,13 @@ export const skipLoadingPage = async (store, component) => { export const isFileStored = state => state.pdfFiles.length; export const stepFinished = key => state => getProgress(state).steps.find(({ stepKey }) => stepKey === key)?.completed; + +export const toggleSettingsCheckbox = (component, checked) => { + expect(component.find(Checkbox)).toHaveLength(1); + component + .find(Checkbox) + .props() + .onChange({ target: { checked } }); + component.update(); + expect(component.find(Checkbox).props().checked).toBe(checked); +}; diff --git a/src/__tests__/integration/settings.test.js b/src/__tests__/integration/settings.test.js index 0c8b46c9..0eb812a2 100644 --- a/src/__tests__/integration/settings.test.js +++ b/src/__tests__/integration/settings.test.js @@ -1,4 +1,11 @@ -import { DEFAULT_STARTUP_RESPONSES, TEST_FILE, integrationTest, storeFile, moveNext } from './index'; +import { + DEFAULT_STARTUP_RESPONSES, + TEST_FILE, + integrationTest, + storeFile, + moveNext, + toggleSettingsCheckbox, +} from './index'; import MaterialSelect from '@material-ui/core/Select'; import Settings from '../../components/layouts/pages/settings/Settings'; @@ -20,6 +27,7 @@ describe('Settings', () => { integrationTest( async (store, component) => { await storeFile(component, store); + toggleSettingsCheckbox(component, true); moveNext(component); expect(component.find(Settings)).toHaveLength(1); @@ -39,6 +47,7 @@ describe('Settings', () => { 'Profiles list loaded', integrationTest(async (store, component) => { await storeFile(component, store); + toggleSettingsCheckbox(component, true); moveNext(component); expect(component.find(Settings)).toHaveLength(1); @@ -57,6 +66,7 @@ describe('Settings', () => { integrationTest( async (store, component) => { await storeFile(component, store); + toggleSettingsCheckbox(component, true); moveNext(component); expect(component.find(Settings)).toHaveLength(1); expect(getProfileSelectError(component).text()).toBe( @@ -76,6 +86,7 @@ describe('Settings', () => { 'Profile changed', integrationTest(async (store, component) => { await storeFile(component, store, TEST_FILE); + toggleSettingsCheckbox(component, true); moveNext(component); expect(getProfileValue(store)).toEqual(PROFILE_VALUES[0]); diff --git a/src/__tests__/integration/upload.test.js b/src/__tests__/integration/upload.test.js index 378b3145..b8c541a0 100644 --- a/src/__tests__/integration/upload.test.js +++ b/src/__tests__/integration/upload.test.js @@ -1,4 +1,12 @@ -import { TEST_FILE, integrationTest, getNextStepButton, storeFile, moveBack, moveNext } from './index'; +import { + TEST_FILE, + integrationTest, + getNextStepButton, + storeFile, + moveBack, + moveNext, + toggleSettingsCheckbox, +} from './index'; const EMPTY_DROPZONE_TEXT = 'Drop a PDF file, or click to select a file'; const FAILED_FILE = { @@ -58,6 +66,7 @@ describe('Upload', () => { 'File still attached after going back from next step', integrationTest(async (store, component) => { await storeFile(component, store); + toggleSettingsCheckbox(component, true); moveNext(component); moveBack(component); diff --git a/src/__tests__/integration/validation.test.js b/src/__tests__/integration/validation.test.js index da87d12e..3c218c3c 100644 --- a/src/__tests__/integration/validation.test.js +++ b/src/__tests__/integration/validation.test.js @@ -21,9 +21,6 @@ describe('Validation', () => { integrationTest(async (store, component) => { await storeFile(component, store); - // Move to settings - moveNext(component); - // Click validate button moveNext(component); expect(createJob).toHaveBeenCalledTimes(1);