Skip to content

Commit 9128d7c

Browse files
cypress: minimal testcase with decryption #17
1 parent d4fed8d commit 9128d7c

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

frontend/submission/components/forms/FinalControlStep.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import {Box, Divider, Paper, Typography} from '@mui/material'
33
import {blue, green, grey} from '@mui/material/colors'
44
import React, {useState} from 'react'
55
import {useTranslation} from 'react-i18next'
6-
import {resources} from '../../i18n'
7-
import {useTokenStore, useSubmittedStore} from '../../state'
6+
87
import {useIs_TranslatorQuery} from '../../api/generates'
8+
import {resources} from '../../i18n'
9+
import {useSubmittedStore,useTokenStore} from '../../state'
910
import FormTranslationHelper from './FormTranslationHelper'
1011
import SubmitFormButton from './SubmitFormButton'
1112

frontend/submission/components/forms/LocalizedJsonForms.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import {Divider} from '@mui/material'
1111
import React, {useCallback, useEffect, useMemo, useState} from 'react'
1212
import {useTranslation} from 'react-i18next'
1313

14+
import {useIs_TranslatorQuery} from '../../api/generates'
1415
import {formNamespace} from '../../i18n'
1516
import {jsonSchema2TranslationJsonSchema} from '../../schema/utils'
1617
import {LocalizedFormTranslation} from '../../schema/utils/types'
1718
import {useTokenStore, useTranslationState} from '../../state'
18-
import {useIs_TranslatorQuery} from '../../api/generates'
1919
import MaterialListWithDetailRenderer from '../renderer/MaterialListWithDetailRenderer'
2020
import UploadRenderer from '../renderer/UploadRenderer'
2121
import FormTranslationHelper from './FormTranslationHelper'

frontend/submission/components/forms/SubmitFormButton.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const SubmitFormButton = ({}: SubmitFormButtonProps) => {
4141
variant='contained'
4242
disabled={isLoading}
4343
onClick={() => {mutate()}}
44+
title='submit'
4445
>{
4546
submitted ? t('submitted') : t('submit')
4647
}</Button>
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
1-
describe('Minimal test before testing details', () => {
2-
it('Click through wizard and submit the form', () => {
1+
describe('Minimal test, to check the setup before testing details', () => {
2+
it('Click through wizard and fill some of the forms', () => {
33
cy.visit('/?token=demoToken')
44
cy.log('In case of a dev build it might take some time to jit compile…')
5-
cy.log('The next test might fail, when the id is taken by another property with the same name')
6-
// TODO can we change the property name to something namespaced by the form?
5+
cy.log('The next test might fail, when the id is taken by another property with the same name. This sometimes happens with the combination of jsonforms and next dev builds.')
6+
/** TODO We need proper test selectors from jsonforms inputs.
7+
* - selectors should be stable in next dev builds
8+
* - selectors should be uniq when properties are reused at different places or we always need select the parent component (form) first
9+
**/
710
cy.get('input[id="#/properties/firstName-input"]', {timeout: 30000})
811
.type('Max')
912

10-
cy.log('Visit wizards last form step before submission')
11-
cy.visit('/?token=demoToken&step=3')
1213
cy.get('button[title="proceed to next step"]').click()
14+
cy.get('textarea[id="#/properties/risksCV-input"]')
15+
.type('risks…')
16+
})
1317

18+
it('Submit the formData', () => {
19+
// TODO we need selectors for navigating to a wizard step (without reloading the page)
20+
cy.get('button[title="proceed to next step"]').click()
21+
cy.get('button[title="proceed to next step"]').click()
22+
cy.get('button[title="proceed to next step"]').click()
1423
cy.get('main').contains('Almost done')
15-
// TODO we need proper selectors for the submit buttons
24+
25+
cy.get('button[title="submit"]').first().click()
26+
cy.get('main').contains('Successfully submitted')
27+
})
28+
29+
it('Decrypt formData', () => {
30+
cy.log('We expect, the test key is imported (gpg --import backend/data/keys/test.sec.gpg)') // TODO we should use a separate keyring
31+
cy.exec('(cd ../../backend/data/upload/demoToken/; gpg --decrypt --passphrase "test" "$(ls -t formData* | head -n1)")')
32+
.then($result => {
33+
const formData = JSON.parse($result.stdout)
34+
cy.log(formData)
35+
})
1636
})
1737
})

0 commit comments

Comments
 (0)