diff --git a/cypress/integration/generic_templates.ts b/cypress/integration/generic_templates.ts index 17506496e..95cfc7e0f 100644 --- a/cypress/integration/generic_templates.ts +++ b/cypress/integration/generic_templates.ts @@ -338,7 +338,7 @@ context('GenericTemplates tests', () => { cy.contains(genericTemplateQuestions[0]); - cy.get('[data-cy=title-input] input').clear(); + cy.get('[data-cy=title-input] textarea').first().clear(); cy.get( '[data-cy=genericTemplate-declaration-modal] [data-cy=save-and-continue-button]' @@ -346,10 +346,18 @@ context('GenericTemplates tests', () => { cy.contains('This is a required field'); - cy.get('[data-cy=title-input] input') + const longText = faker.lorem.paragraph(5); + + cy.get('[data-cy=title-input] textarea') + .first() .clear() - .type(genericTemplateTitle) - .should('have.value', genericTemplateTitle); + .type(longText) + .should('have.value', longText) + .blur(); + + cy.get( + '[data-cy=genericTemplate-declaration-modal] [data-cy=questionary-title]' + ).contains(longText.substring(0, 30) + '...'); cy.get( '[data-cy=genericTemplate-declaration-modal] [data-cy=save-and-continue-button]' @@ -474,7 +482,8 @@ context('GenericTemplates tests', () => { cy.contains(addButtonLabel[0]).click(); - cy.get('[data-cy=title-input] input') + cy.get('[data-cy=title-input] textarea') + .first() .clear() .type(genericTemplateTitle) .should('have.value', genericTemplateTitle) diff --git a/src/components/questionary/questionaryComponents/GenericTemplate/GenericTemplateContainer.tsx b/src/components/questionary/questionaryComponents/GenericTemplate/GenericTemplateContainer.tsx index e50b2a20c..8c6653043 100644 --- a/src/components/questionary/questionaryComponents/GenericTemplate/GenericTemplateContainer.tsx +++ b/src/components/questionary/questionaryComponents/GenericTemplate/GenericTemplateContainer.tsx @@ -15,6 +15,7 @@ import { QuestionarySubmissionModel, } from 'models/questionary/QuestionarySubmissionState'; import useEventHandlers from 'models/questionary/useEventHandlers'; +import { truncateString } from 'utils/truncateString'; export interface GenericTemplateContextType extends QuestionaryContextType { state: GenericTemplateSubmissionState | null; @@ -63,7 +64,9 @@ export function GenericTemplateContainer(props: { return ( - + ); } diff --git a/src/components/questionary/questionaryComponents/GenericTemplateBasis/QuestionaryComponentGenericTemplateBasis.tsx b/src/components/questionary/questionaryComponents/GenericTemplateBasis/QuestionaryComponentGenericTemplateBasis.tsx index 49c115400..40637b801 100644 --- a/src/components/questionary/questionaryComponents/GenericTemplateBasis/QuestionaryComponentGenericTemplateBasis.tsx +++ b/src/components/questionary/questionaryComponents/GenericTemplateBasis/QuestionaryComponentGenericTemplateBasis.tsx @@ -54,6 +54,7 @@ function QuestionaryComponentGenericTemplateBasis(props: BasicComponentProps) { }, }} required + multiline fullWidth component={TextFieldNoSubmit} data-cy="title-input"