Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions cypress/integration/generic_templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,18 +338,26 @@ 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]'
).click();

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]'
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -63,7 +64,9 @@ export function GenericTemplateContainer(props: {

return (
<QuestionaryContext.Provider value={{ state, dispatch }}>
<Questionary title={state.genericTemplate.title || props.title} />
<Questionary
title={truncateString(state.genericTemplate.title || props.title, 30)}
/>
</QuestionaryContext.Provider>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function QuestionaryComponentGenericTemplateBasis(props: BasicComponentProps) {
},
}}
required
multiline
fullWidth
component={TextFieldNoSubmit}
data-cy="title-input"
Expand Down