From 6cfd6435ace2b84877c44404fb97966721cd1936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20L=C3=B6tzsch?= Date: Sun, 3 Apr 2022 17:30:57 +0200 Subject: [PATCH] cypress: minimal testcase with decryption #17 --- .../components/forms/FinalControlStep.tsx | 5 ++-- .../components/forms/LocalizedJsonForms.tsx | 2 +- .../components/forms/SubmitFormButton.tsx | 1 + .../integration/1-core/minimal.spec.js | 23 ++++++++++++++----- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/frontend/submission/components/forms/FinalControlStep.tsx b/frontend/submission/components/forms/FinalControlStep.tsx index 0ae7ec7..f069cb4 100644 --- a/frontend/submission/components/forms/FinalControlStep.tsx +++ b/frontend/submission/components/forms/FinalControlStep.tsx @@ -3,9 +3,10 @@ import {Box, Divider, Paper, Typography} from '@mui/material' import {blue, green, grey} from '@mui/material/colors' import React, {useState} from 'react' import {useTranslation} from 'react-i18next' -import {resources} from '../../i18n' -import {useTokenStore, useSubmittedStore} from '../../state' + import {useIs_TranslatorQuery} from '../../api/generates' +import {resources} from '../../i18n' +import {useSubmittedStore,useTokenStore} from '../../state' import FormTranslationHelper from './FormTranslationHelper' import SubmitFormButton from './SubmitFormButton' diff --git a/frontend/submission/components/forms/LocalizedJsonForms.tsx b/frontend/submission/components/forms/LocalizedJsonForms.tsx index a49f810..dec020b 100644 --- a/frontend/submission/components/forms/LocalizedJsonForms.tsx +++ b/frontend/submission/components/forms/LocalizedJsonForms.tsx @@ -11,11 +11,11 @@ import {Divider} from '@mui/material' import React, {useCallback, useEffect, useMemo, useState} from 'react' import {useTranslation} from 'react-i18next' +import {useIs_TranslatorQuery} from '../../api/generates' import {formNamespace} from '../../i18n' import {jsonSchema2TranslationJsonSchema} from '../../schema/utils' import {LocalizedFormTranslation} from '../../schema/utils/types' import {useTokenStore, useTranslationState} from '../../state' -import {useIs_TranslatorQuery} from '../../api/generates' import MaterialListWithDetailRenderer from '../renderer/MaterialListWithDetailRenderer' import UploadRenderer from '../renderer/UploadRenderer' import FormTranslationHelper from './FormTranslationHelper' diff --git a/frontend/submission/components/forms/SubmitFormButton.tsx b/frontend/submission/components/forms/SubmitFormButton.tsx index 5560287..5ad9d2b 100644 --- a/frontend/submission/components/forms/SubmitFormButton.tsx +++ b/frontend/submission/components/forms/SubmitFormButton.tsx @@ -41,6 +41,7 @@ const SubmitFormButton = ({}: SubmitFormButtonProps) => { variant='contained' disabled={isLoading} onClick={() => {mutate()}} + title='submit' >{ submitted ? t('submitted') : t('submit') } diff --git a/frontend/submission/cypress/integration/1-core/minimal.spec.js b/frontend/submission/cypress/integration/1-core/minimal.spec.js index 6cb99df..3150463 100644 --- a/frontend/submission/cypress/integration/1-core/minimal.spec.js +++ b/frontend/submission/cypress/integration/1-core/minimal.spec.js @@ -1,17 +1,28 @@ -describe('Minimal test before testing details', () => { - it('Click through wizard and submit the form', () => { +describe('Minimal test, to check the setup before testing details', () => { + it('Click through wizard + submit the form + decrypt formData', () => { cy.visit('/?token=demoToken') cy.log('In case of a dev build it might take some time to jit compileā€¦') - cy.log('The next test might fail, when the id is taken by another property with the same name') - // TODO can we change the property name to something namespaced by the form? + 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.') + /** TODO We need proper test selectors from jsonforms inputs. + * - selectors should be stable in next dev builds + * - selectors should be uniq when properties are reused at different places or we always need select the parent component (form) first + **/ cy.get('input[id="#/properties/firstName-input"]', {timeout: 30000}) .type('Max') cy.log('Visit wizards last form step before submission') cy.visit('/?token=demoToken&step=3') cy.get('button[title="proceed to next step"]').click() - cy.get('main').contains('Almost done') - // TODO we need proper selectors for the submit buttons + + cy.get('button[title="submit"]').first().click() + cy.get('main').contains('Successfully submitted') + + cy.log('We expect, the test key is imported (gpg --import backend/data/keys/test.sec.gpg)') // TODO we should use a separate keyring + cy.exec('(cd ../../backend/data/upload/demoToken/; gpg --decrypt --passphrase "test" "$(ls -t formData* | head -n1)")') + .then($result => { + const formData = JSON.parse($result.stdout) + cy.log(formData) + }) }) })