From 4c0822520ff7df45426cd4680ce053fe1babad79 Mon Sep 17 00:00:00 2001 From: Vanessa Oduguwa Date: Thu, 8 Sep 2022 17:05:10 +0100 Subject: [PATCH 1/3] refactor: make title input multiline, truncate longer titles and fix/add tests Part of UserOfficeProject/user-office-project-issue-tracker#239 --- cypress/integration/generic_templates.ts | 21 +++++++++++++------ .../GenericTemplateContainer.tsx | 5 ++++- ...estionaryComponentGenericTemplateBasis.tsx | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/cypress/integration/generic_templates.ts b/cypress/integration/generic_templates.ts index 17506496e..76b91b770 100644 --- a/cypress/integration/generic_templates.ts +++ b/cypress/integration/generic_templates.ts @@ -314,7 +314,7 @@ context('GenericTemplates tests', () => { cy.contains(genericTemplateQuestions[1]).should('exist'); }); - it('Should be able to create proposal with genericTemplate', () => { + it.only('Should be able to create proposal with genericTemplate', () => { cy.updateCall({ id: initialDBData.call.id, ...updatedCall, @@ -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 longTitle = faker.lorem.paragraph(5); + + cy.get('[data-cy=title-input] textarea') + .first() .clear() - .type(genericTemplateTitle) - .should('have.value', genericTemplateTitle); + .type(longTitle) + .should('have.value', longTitle) + .blur(); + + cy.get( + '[data-cy=genericTemplate-declaration-modal] [data-cy=questionary-title]' + ).contains(longTitle.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" From f017b9a46a4b7147d8c1e282918a6245e2cf07d8 Mon Sep 17 00:00:00 2001 From: Vanessa Oduguwa Date: Mon, 12 Sep 2022 10:34:53 +0100 Subject: [PATCH 2/3] test: Remove 'only' from GenericTemplate test Part of UserOfficeProject/user-office-project-issue-tracker#239 --- cypress/integration/generic_templates.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/integration/generic_templates.ts b/cypress/integration/generic_templates.ts index 76b91b770..7dafb1226 100644 --- a/cypress/integration/generic_templates.ts +++ b/cypress/integration/generic_templates.ts @@ -314,7 +314,7 @@ context('GenericTemplates tests', () => { cy.contains(genericTemplateQuestions[1]).should('exist'); }); - it.only('Should be able to create proposal with genericTemplate', () => { + it('Should be able to create proposal with genericTemplate', () => { cy.updateCall({ id: initialDBData.call.id, ...updatedCall, From 3c852c13dec5b6d8960aecfc1f847d107f5cc536 Mon Sep 17 00:00:00 2001 From: Vanessa Oduguwa Date: Tue, 13 Sep 2022 15:39:55 +0100 Subject: [PATCH 3/3] refactor: change variable name Part of UserOfficeProject/user-office-project-issue-tracker#239 --- cypress/integration/generic_templates.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cypress/integration/generic_templates.ts b/cypress/integration/generic_templates.ts index 7dafb1226..95cfc7e0f 100644 --- a/cypress/integration/generic_templates.ts +++ b/cypress/integration/generic_templates.ts @@ -346,18 +346,18 @@ context('GenericTemplates tests', () => { cy.contains('This is a required field'); - const longTitle = faker.lorem.paragraph(5); + const longText = faker.lorem.paragraph(5); cy.get('[data-cy=title-input] textarea') .first() .clear() - .type(longTitle) - .should('have.value', longTitle) + .type(longText) + .should('have.value', longText) .blur(); cy.get( '[data-cy=genericTemplate-declaration-modal] [data-cy=questionary-title]' - ).contains(longTitle.substring(0, 30) + '...'); + ).contains(longText.substring(0, 30) + '...'); cy.get( '[data-cy=genericTemplate-declaration-modal] [data-cy=save-and-continue-button]'