diff --git a/apps/user-office-frontend-e2e/cypress/fixtures/template_export.json b/apps/user-office-frontend-e2e/cypress/fixtures/template_export.json index 9332ce3f15..459af07656 100644 --- a/apps/user-office-frontend-e2e/cypress/fixtures/template_export.json +++ b/apps/user-office-frontend-e2e/cypress/fixtures/template_export.json @@ -1 +1 @@ -{"metadata":{"version":"1.2.0","exportDate":"2023-02-27T08:40:16.667Z"},"data":{"template":{"templateId":1,"groupId":"PROPOSAL","name":"default template","description":"original template","isArchived":false},"templateSteps":[{"topic":{"id":1,"title":"New proposal","templateId":1,"sortOrder":0,"isEnabled":true},"fields":[{"question":{"categoryId":1,"id":"proposal_basis","naturalKey":"proposal_basis","dataType":"PROPOSAL_BASIS","question":"Proposal basic information","config":{"tooltip":"","required":false,"small_label":""}},"topicId":1,"sortOrder":0,"config":{"tooltip":"","required":false,"small_label":""},"dependencies":[],"dependenciesOperator":"AND"}]},{"topic":{"id":5,"title":"Topic title","templateId":1,"sortOrder":1,"isEnabled":true},"fields":[{"question":{"categoryId":1,"id":"sample_declaration_question","naturalKey":"sample_declaration_question","dataType":"SAMPLE_DECLARATION","question":"Add samples","config":{"addEntryButtonLabel":"Add","templateCategory":"SAMPLE_DECLARATION","templateId":4,"esiTemplateId":3,"small_label":"","required":false,"maxEntries":null,"minEntries":null}},"topicId":5,"sortOrder":0,"config":{"addEntryButtonLabel":"Add","templateCategory":"SAMPLE_DECLARATION","templateId":4,"esiTemplateId":3,"small_label":"","required":false,"maxEntries":null,"minEntries":null},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"number_question","naturalKey":"number_question","dataType":"NUMBER_INPUT","question":"Number question from seeds","config":{"small_label":"","required":false,"tooltip":"","units":[{"id":"meter","unit":"meter","symbol":"m","quantity":"length","siConversionFormula":"x"},{"id":"centimeter","unit":"centimeter","symbol":"cm","quantity":"length","siConversionFormula":"x / 100"}],"numberValueConstraint":null}},"topicId":5,"sortOrder":2,"config":{"small_label":"","required":false,"tooltip":"","units":[{"id":"meter","unit":"meter","symbol":"m","quantity":"length","siConversionFormula":"x"},{"id":"centimeter","unit":"centimeter","symbol":"cm","quantity":"length","siConversionFormula":"x / 100"}],"numberValueConstraint":null},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"boolean_question","naturalKey":"boolean_question","dataType":"BOOLEAN","question":"Boolean question from seeds","config":{"small_label":"","required":false,"tooltip":""}},"topicId":5,"sortOrder":3,"config":{"small_label":"","required":false,"tooltip":""},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"interval_question","naturalKey":"interval_question","dataType":"INTERVAL","question":"Interval question from seeds","config":{"small_label":"","required":false,"tooltip":"","units":[{"id":"meter","unit":"meter","symbol":"m","quantity":"length","siConversionFormula":"x"}]}},"topicId":5,"sortOrder":4,"config":{"small_label":"","required":false,"tooltip":"","units":[{"id":"meter","unit":"meter","symbol":"m","quantity":"length","siConversionFormula":"x"}]},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"date_question","naturalKey":"date_question","dataType":"DATE","question":"Date question from seeds","config":{"small_label":"","required":false,"tooltip":"","includeTime":false}},"topicId":5,"sortOrder":5,"config":{"small_label":"","required":false,"tooltip":"","includeTime":false},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"selection_from_options_question","naturalKey":"selection_from_options_question","dataType":"SELECTION_FROM_OPTIONS","question":"Selection from options question from seeds","config":{"small_label":"","required":false,"tooltip":"","variant":"dropdown","options":["One","Two","Three"],"isMultipleSelect":true}},"topicId":5,"sortOrder":6,"config":{"small_label":"","required":false,"tooltip":"","variant":"dropdown","options":["One","Two","Three"],"isMultipleSelect":true},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"dynamic_multiple_choice_question","naturalKey":"dynamic_multiple_choice_question","dataType":"DYNAMIC_MULTIPLE_CHOICE","question":"Dynamic multiple choice question from seeds","config":{"required":false,"small_label":"","tooltip":"","variant":"dropdown","url":"","options":["One","Two","Three"],"jsonPath":"","isMultipleSelect":true,"externalApiCall":true}},"topicId":5,"sortOrder":6,"config":{"required":false,"small_label":"","tooltip":"","variant":"dropdown","url":"","options":["One","Two","Three"],"jsonPath":"","isMultipleSelect":true,"externalApiCall":true},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"text_input_question","naturalKey":"text_input_question","dataType":"TEXT_INPUT","question":"Text input question from seeds","config":{"required":false,"small_label":"","tooltip":"","htmlQuestion":"","isHtmlQuestion":false,"min":null,"max":null,"multiline":false,"placeholder":"","isCounterHidden":false}},"topicId":5,"sortOrder":7,"config":{"required":false,"small_label":"","tooltip":"","htmlQuestion":"","isHtmlQuestion":false,"min":null,"max":null,"multiline":false,"placeholder":"","isCounterHidden":false},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"rich_text_input_question","naturalKey":"rich_text_input_question","dataType":"RICH_TEXT_INPUT","question":"Rich text input question from seeds","config":{"required":false,"small_label":"","tooltip":"","max":null}},"topicId":5,"sortOrder":8,"config":{"required":false,"small_label":"","tooltip":"","max":null},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"file_upload_question","naturalKey":"file_upload_question","dataType":"FILE_UPLOAD","question":"File upload question from seeds","config":{"small_label":"","required":false,"tooltip":"","file_type":[".pdf",".doc",".docx"],"pdf_page_limit":0,"max_files":0}},"topicId":5,"sortOrder":8,"config":{"small_label":"","required":false,"tooltip":"","file_type":[".pdf",".doc",".docx"],"pdf_page_limit":0,"max_files":0},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"embellishment_question","naturalKey":"embellishment_question","dataType":"EMBELLISHMENT","question":"Embellishment question from seeds","config":{"html":"","plain":"","omitFromPdf":false,"tooltip":"","required":false,"small_label":""}},"topicId":5,"sortOrder":9,"config":{"html":"","plain":"","omitFromPdf":false,"tooltip":"","required":false,"small_label":""},"dependencies":[],"dependenciesOperator":"AND"}]}],"questions":[{"categoryId":1,"id":"proposal_basis","naturalKey":"proposal_basis","dataType":"PROPOSAL_BASIS","question":"Proposal basic information","config":{"tooltip":"","required":false,"small_label":""}},{"categoryId":1,"id":"sample_declaration_question","naturalKey":"sample_declaration_question","dataType":"SAMPLE_DECLARATION","question":"Add samples","config":{"addEntryButtonLabel":"Add","templateCategory":"SAMPLE_DECLARATION","templateId":4,"esiTemplateId":3,"small_label":"","required":false,"maxEntries":null,"minEntries":null}},{"categoryId":1,"id":"number_question","naturalKey":"number_question","dataType":"NUMBER_INPUT","question":"Number question from seeds","config":{"small_label":"","required":false,"tooltip":"","units":[{"id":"meter","unit":"meter","symbol":"m","quantity":"length","siConversionFormula":"x"},{"id":"centimeter","unit":"centimeter","symbol":"cm","quantity":"length","siConversionFormula":"x / 100"}],"numberValueConstraint":null}},{"categoryId":1,"id":"boolean_question","naturalKey":"boolean_question","dataType":"BOOLEAN","question":"Boolean question from seeds","config":{"small_label":"","required":false,"tooltip":""}},{"categoryId":1,"id":"interval_question","naturalKey":"interval_question","dataType":"INTERVAL","question":"Interval question from seeds","config":{"small_label":"","required":false,"tooltip":"","units":[{"id":"meter","unit":"meter","symbol":"m","quantity":"length","siConversionFormula":"x"}]}},{"categoryId":1,"id":"date_question","naturalKey":"date_question","dataType":"DATE","question":"Date question from seeds","config":{"small_label":"","required":false,"tooltip":"","includeTime":false}},{"categoryId":1,"id":"selection_from_options_question","naturalKey":"selection_from_options_question","dataType":"SELECTION_FROM_OPTIONS","question":"Selection from options question from seeds","config":{"small_label":"","required":false,"tooltip":"","variant":"dropdown","options":["One","Two","Three"],"isMultipleSelect":true}},{"categoryId":1,"id":"dynamic_multiple_choice_question","naturalKey":"dynamic_multiple_choice_question","dataType":"DYNAMIC_MULTIPLE_CHOICE","question":"Dynamic multiple choice question from seeds","config":{"required":false,"small_label":"","tooltip":"","variant":"dropdown","url":"","options":["One","Two","Three"],"jsonPath":"","isMultipleSelect":true,"externalApiCall":true}},{"categoryId":1,"id":"text_input_question","naturalKey":"text_input_question","dataType":"TEXT_INPUT","question":"Text input question from seeds","config":{"required":false,"small_label":"","tooltip":"","htmlQuestion":"","isHtmlQuestion":false,"min":null,"max":null,"multiline":false,"placeholder":"","isCounterHidden":false}},{"categoryId":1,"id":"rich_text_input_question","naturalKey":"rich_text_input_question","dataType":"RICH_TEXT_INPUT","question":"Rich text input question from seeds","config":{"required":false,"small_label":"","tooltip":"","max":null}},{"categoryId":1,"id":"file_upload_question","naturalKey":"file_upload_question","dataType":"FILE_UPLOAD","question":"File upload question from seeds","config":{"small_label":"","required":false,"tooltip":"","file_type":[".pdf",".doc",".docx"],"pdf_page_limit":0,"max_files":0}},{"categoryId":1,"id":"embellishment_question","naturalKey":"embellishment_question","dataType":"EMBELLISHMENT","question":"Embellishment question from seeds","config":{"html":"","plain":"","omitFromPdf":false,"tooltip":"","required":false,"small_label":""}}],"subTemplates":[{"template":{"templateId":4,"groupId":"SAMPLE","name":"default sample template","description":"default sample template","isArchived":false},"templateSteps":[{"topic":{"id":4,"title":"New sample","templateId":4,"sortOrder":0,"isEnabled":true},"fields":[{"question":{"categoryId":2,"id":"sample_basis","naturalKey":"sample_basis","dataType":"SAMPLE_BASIS","question":"Sample basic information","config":{"titlePlaceholder":"Title","tooltip":"","required":false,"small_label":""}},"topicId":4,"sortOrder":0,"config":{"titlePlaceholder":"Title","tooltip":"","required":false,"small_label":""},"dependencies":[],"dependenciesOperator":"AND"}]}],"questions":[{"categoryId":2,"id":"sample_basis","naturalKey":"sample_basis","dataType":"SAMPLE_BASIS","question":"Sample basic information","config":{"titlePlaceholder":"Title","tooltip":"","required":false,"small_label":""}}],"subTemplates":[]}]}} \ No newline at end of file +{"metadata":{"version":"1.2.0","exportDate":"2023-02-27T08:40:16.667Z"},"data":{"template":{"templateId":1,"groupId":"PROPOSAL","name":"default template","description":"original template","isArchived":false},"templateSteps":[{"topic":{"id":1,"title":"New proposal","templateId":1,"sortOrder":0,"isEnabled":true},"fields":[{"question":{"categoryId":1,"id":"proposal_basis","naturalKey":"proposal_basis","dataType":"PROPOSAL_BASIS","question":"Proposal basic information","config":{"tooltip":"","required":false,"small_label":""}},"topicId":1,"sortOrder":0,"config":{"tooltip":"","required":false,"small_label":""},"dependencies":[],"dependenciesOperator":"AND"}]},{"topic":{"id":5,"title":"Topic title","templateId":1,"sortOrder":1,"isEnabled":true},"fields":[{"question":{"categoryId":1,"id":"sample_declaration_question","naturalKey":"sample_declaration_question","dataType":"SAMPLE_DECLARATION","question":"Add samples","config":{"addEntryButtonLabel":"Add","templateCategory":"SAMPLE_DECLARATION","templateId":4,"esiTemplateId":3,"small_label":"","required":false,"maxEntries":null,"minEntries":null}},"topicId":5,"sortOrder":0,"config":{"addEntryButtonLabel":"Add","templateCategory":"SAMPLE_DECLARATION","templateId":4,"esiTemplateId":3,"small_label":"","required":false,"maxEntries":null,"minEntries":null},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"number_question","naturalKey":"number_question","dataType":"NUMBER_INPUT","question":"Number question from seeds","config":{"small_label":"","required":false,"tooltip":"","units":[{"id":"meter","unit":"meter","symbol":"m","quantity":"length","siConversionFormula":"x"},{"id":"centimeter","unit":"centimeter","symbol":"cm","quantity":"length","siConversionFormula":"x / 100"}],"numberValueConstraint":null}},"topicId":5,"sortOrder":2,"config":{"small_label":"","required":false,"tooltip":"","units":[{"id":"meter","unit":"meter","symbol":"m","quantity":"length","siConversionFormula":"x"},{"id":"centimeter","unit":"centimeter","symbol":"cm","quantity":"length","siConversionFormula":"x / 100"}],"numberValueConstraint":null},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"boolean_question","naturalKey":"boolean_question","dataType":"BOOLEAN","question":"Boolean question from seeds","config":{"small_label":"","required":false,"tooltip":""}},"topicId":5,"sortOrder":3,"config":{"small_label":"","required":false,"tooltip":""},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"interval_question","naturalKey":"interval_question","dataType":"INTERVAL","question":"Interval question from seeds","config":{"small_label":"","required":false,"tooltip":"","units":[{"id":"meter","unit":"meter","symbol":"m","quantity":"length","siConversionFormula":"x"}]}},"topicId":5,"sortOrder":4,"config":{"small_label":"","required":false,"tooltip":"","units":[{"id":"meter","unit":"meter","symbol":"m","quantity":"length","siConversionFormula":"x"}]},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"date_question","naturalKey":"date_question","dataType":"DATE","question":"Date question from seeds","config":{"small_label":"","required":false,"tooltip":"","includeTime":false}},"topicId":5,"sortOrder":5,"config":{"small_label":"","required":false,"tooltip":"","includeTime":false},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"instrument_picker_question","naturalKey":"instrument_picker_question","dataType":"INSTRUMENT_PICKER","question":"Instrument Picker question from seeds","config":{"small_label":"","required":false,"tooltip":"","variant":"dropdown","instruments":[],"options":[1,2]}},"topicId":5,"sortOrder":6,"config":{"small_label":"","required":false,"tooltip":"","variant":"dropdown","instruments":[],"options":[1,2]},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"selection_from_options_question","naturalKey":"selection_from_options_question","dataType":"SELECTION_FROM_OPTIONS","question":"Selection from options question from seeds","config":{"small_label":"","required":false,"tooltip":"","variant":"dropdown","options":["One","Two","Three"],"isMultipleSelect":true}},"topicId":5,"sortOrder":6,"config":{"small_label":"","required":false,"tooltip":"","variant":"dropdown","options":["One","Two","Three"],"isMultipleSelect":true},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"dynamic_multiple_choice_question","naturalKey":"dynamic_multiple_choice_question","dataType":"DYNAMIC_MULTIPLE_CHOICE","question":"Dynamic multiple choice question from seeds","config":{"required":false,"small_label":"","tooltip":"","variant":"dropdown","url":"","options":["One","Two","Three"],"jsonPath":"","isMultipleSelect":true,"externalApiCall":true}},"topicId":5,"sortOrder":6,"config":{"required":false,"small_label":"","tooltip":"","variant":"dropdown","url":"","options":[],"jsonPath":"","isMultipleSelect":true,"externalApiCall":true},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"text_input_question","naturalKey":"text_input_question","dataType":"TEXT_INPUT","question":"Text input question from seeds","config":{"required":false,"small_label":"","tooltip":"","htmlQuestion":"","isHtmlQuestion":false,"min":null,"max":null,"multiline":false,"placeholder":"","isCounterHidden":false}},"topicId":5,"sortOrder":7,"config":{"required":false,"small_label":"","tooltip":"","htmlQuestion":"","isHtmlQuestion":false,"min":null,"max":null,"multiline":false,"placeholder":"","isCounterHidden":false},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"file_upload_question","naturalKey":"file_upload_question","dataType":"FILE_UPLOAD","question":"File upload question from seeds","config":{"small_label":"","required":false,"tooltip":"","file_type":[".pdf",".doc",".docx"],"pdf_page_limit":0,"max_files":0}},"topicId":5,"sortOrder":8,"config":{"small_label":"","required":false,"tooltip":"","file_type":[".pdf",".doc",".docx"],"pdf_page_limit":0,"max_files":0},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"rich_text_input_question","naturalKey":"rich_text_input_question","dataType":"RICH_TEXT_INPUT","question":"Rich text input question from seeds","config":{"required":false,"small_label":"","tooltip":"","max":null}},"topicId":5,"sortOrder":8,"config":{"required":false,"small_label":"","tooltip":"","max":null},"dependencies":[],"dependenciesOperator":"AND"},{"question":{"categoryId":1,"id":"embellishment_question","naturalKey":"embellishment_question","dataType":"EMBELLISHMENT","question":"Embellishment question from seeds","config":{"html":"","plain":"","omitFromPdf":false,"tooltip":"","required":false,"small_label":""}},"topicId":5,"sortOrder":9,"config":{"html":"","plain":"","omitFromPdf":false,"tooltip":"","required":false,"small_label":""},"dependencies":[],"dependenciesOperator":"AND"}]}],"questions":[{"categoryId":1,"id":"proposal_basis","naturalKey":"proposal_basis","dataType":"PROPOSAL_BASIS","question":"Proposal basic information","config":{"tooltip":"","required":false,"small_label":""}},{"categoryId":1,"id":"sample_declaration_question","naturalKey":"sample_declaration_question","dataType":"SAMPLE_DECLARATION","question":"Add samples","config":{"addEntryButtonLabel":"Add","templateCategory":"SAMPLE_DECLARATION","templateId":4,"esiTemplateId":3,"small_label":"","required":false,"maxEntries":null,"minEntries":null}},{"categoryId":1,"id":"number_question","naturalKey":"number_question","dataType":"NUMBER_INPUT","question":"Number question from seeds","config":{"small_label":"","required":false,"tooltip":"","units":[{"id":"meter","unit":"meter","symbol":"m","quantity":"length","siConversionFormula":"x"},{"id":"centimeter","unit":"centimeter","symbol":"cm","quantity":"length","siConversionFormula":"x / 100"}],"numberValueConstraint":null}},{"categoryId":1,"id":"boolean_question","naturalKey":"boolean_question","dataType":"BOOLEAN","question":"Boolean question from seeds","config":{"small_label":"","required":false,"tooltip":""}},{"categoryId":1,"id":"interval_question","naturalKey":"interval_question","dataType":"INTERVAL","question":"Interval question from seeds","config":{"small_label":"","required":false,"tooltip":"","units":[{"id":"meter","unit":"meter","symbol":"m","quantity":"length","siConversionFormula":"x"}]}},{"categoryId":1,"id":"date_question","naturalKey":"date_question","dataType":"DATE","question":"Date question from seeds","config":{"small_label":"","required":false,"tooltip":"","includeTime":false}},{"categoryId":1,"id":"instrument_picker_question","naturalKey":"instrument_picker_question","dataType":"INSTRUMENT_PICKER","question":"Instrument Picker question from seeds","config":{"small_label":"","required":false,"tooltip":"","variant":"dropdown","instruments":[],"options":[1,2]}},{"categoryId":1,"id":"selection_from_options_question","naturalKey":"selection_from_options_question","dataType":"SELECTION_FROM_OPTIONS","question":"Selection from options question from seeds","config":{"small_label":"","required":false,"tooltip":"","variant":"dropdown","options":["One","Two","Three"],"isMultipleSelect":true}},{"categoryId":1,"id":"dynamic_multiple_choice_question","naturalKey":"dynamic_multiple_choice_question","dataType":"DYNAMIC_MULTIPLE_CHOICE","question":"Dynamic multiple choice question from seeds","config":{"required":false,"small_label":"","tooltip":"","variant":"dropdown","url":"","options":["One","Two","Three"],"jsonPath":"","isMultipleSelect":true,"externalApiCall":true}},{"categoryId":1,"id":"text_input_question","naturalKey":"text_input_question","dataType":"TEXT_INPUT","question":"Text input question from seeds","config":{"required":false,"small_label":"","tooltip":"","htmlQuestion":"","isHtmlQuestion":false,"min":null,"max":null,"multiline":false,"placeholder":"","isCounterHidden":false}},{"categoryId":1,"id":"file_upload_question","naturalKey":"file_upload_question","dataType":"FILE_UPLOAD","question":"File upload question from seeds","config":{"small_label":"","required":false,"tooltip":"","file_type":[".pdf",".doc",".docx"],"pdf_page_limit":0,"max_files":0}},{"categoryId":1,"id":"rich_text_input_question","naturalKey":"rich_text_input_question","dataType":"RICH_TEXT_INPUT","question":"Rich text input question from seeds","config":{"required":false,"small_label":"","tooltip":"","max":null}},{"categoryId":1,"id":"embellishment_question","naturalKey":"embellishment_question","dataType":"EMBELLISHMENT","question":"Embellishment question from seeds","config":{"html":"","plain":"","omitFromPdf":false,"tooltip":"","required":false,"small_label":""}}],"subTemplates":[{"template":{"templateId":4,"groupId":"SAMPLE","name":"default sample template","description":"default sample template","isArchived":false},"templateSteps":[{"topic":{"id":4,"title":"New sample","templateId":4,"sortOrder":0,"isEnabled":true},"fields":[{"question":{"categoryId":2,"id":"sample_basis","naturalKey":"sample_basis","dataType":"SAMPLE_BASIS","question":"Sample basic information","config":{"titlePlaceholder":"Title","tooltip":"","required":false,"small_label":""}},"topicId":4,"sortOrder":0,"config":{"titlePlaceholder":"Title","tooltip":"","required":false,"small_label":""},"dependencies":[],"dependenciesOperator":"AND"}]}],"questions":[{"categoryId":2,"id":"sample_basis","naturalKey":"sample_basis","dataType":"SAMPLE_BASIS","question":"Sample basic information","config":{"titlePlaceholder":"Title","tooltip":"","required":false,"small_label":""}}],"subTemplates":[]}]}} \ No newline at end of file diff --git a/apps/user-office-frontend-e2e/cypress/integration/templates_advanced.ts b/apps/user-office-frontend-e2e/cypress/integration/templates_advanced.ts index 9ea1c81f2f..c42db317dc 100644 --- a/apps/user-office-frontend-e2e/cypress/integration/templates_advanced.ts +++ b/apps/user-office-frontend-e2e/cypress/integration/templates_advanced.ts @@ -437,414 +437,5 @@ context('Template tests', () => { cy.contains(proposal.title); cy.contains('submitted'); }); - - it('File Upload field could be set as required', () => { - const fileName = 'file_upload_test.png'; - - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Edit']") - .first() - .click(); - - cy.contains(fileQuestion).click(); - - cy.get('[role="presentation"]').contains('image/*').click(); - - cy.get('body').type('{esc}'); - - cy.contains('Is required').click(); - - cy.contains('Update').click(); - - cy.logout(); - - cy.login('user1'); - cy.visit('/'); - - cy.contains('New Proposal').click(); - cy.get('[data-cy=call-list]').find('li:first-child').click(); - - cy.get('[data-cy=title] input').type(faker.lorem.words(2)); - cy.get('[data-cy=abstract] textarea').first().type(faker.lorem.words(2)); - cy.contains('Save and continue').click(); - - cy.contains(fileQuestion); - cy.contains('Save and continue').click(); - cy.contains(fileQuestion) - .parent() - .contains('field must have at least 1 items'); - - cy.intercept({ - method: 'POST', - url: '/files/upload', - }).as('upload'); - - // NOTE: Force is needed because file input is not visible and has display: none - cy.contains(fileQuestion) - .parent() - .find('input[type="file"]') - .selectFile( - { - contents: `cypress/fixtures/${fileName}`, - fileName: fileName, - }, - { force: true } - ); - - // wait for the '/files/upload' request, and leave a 30 seconds delay before throwing an error - cy.wait('@upload', { requestTimeout: 30000 }); - - cy.contains(fileName); - - cy.contains(fileQuestion) - .parent() - .should('not.contain.text', 'field must have at least 1 items'); - - cy.logout(); - }); - - it('File Upload max files should be required', () => { - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Edit']") - .first() - .click(); - - cy.contains(fileQuestion).click(); - - cy.get('[role="presentation"]').contains('image/*').click(); - - cy.get('body').type('{esc}'); - - cy.get('[data-cy="max_files"] input').clear().type('-1'); - - cy.contains('Update').should('be.disabled'); - - cy.get('[data-cy="max_files"] input').clear(); - - cy.get('[data-cy="max_files"] input').should('be.focused'); - cy.get('[data-cy="max_files"] input:invalid').should('have.length', 1); - - cy.get('[data-cy="max_files"] input').clear().type('1'); - - cy.contains('Update').click(); - - cy.get('[data-cy="question-relation-dialogue"]').should('not.exist'); - - cy.logout(); - }); - - it('Officer can delete proposal questions', () => { - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Edit']") - .first() - .click(); - - cy.contains(textQuestion.title).click(); - cy.get("[data-cy='remove-from-template']").click(); - - cy.contains(booleanQuestion).click(); - cy.get("[data-cy='remove-from-template']").click(); - - cy.contains(dateQuestion.title).click(); - cy.get("[data-cy='remove-from-template']").click(); - - cy.contains(fileQuestion).click(); - cy.get("[data-cy='remove-from-template']").click(); - }); - - it('User officer can add multiple dependencies on a question', () => { - cy.createProposal({ callId: initialDBData.call.id }).then((result) => { - const createdProposal = result.createProposal; - if (createdProposal) { - cy.updateProposal({ - proposalPk: createdProposal.primaryKey, - title: proposal.title, - abstract: proposal.abstract, - proposerId: initialDBData.users.user1.id, - }); - } - }); - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Edit']") - .first() - .click(); - - cy.createTextQuestion(templateDependencies.questions.textQuestion.title); - - cy.contains(templateDependencies.questions.textQuestion.title).click(); - - cy.get('[data-cy="add-dependency-button"]').click(); - - cy.get('[id="dependency-id"]').click(); - - cy.get('[role="presentation"]') - .contains(multipleChoiceQuestion.title) - .click(); - - cy.get('[id="dependencyValue"]').click(); - - cy.contains(multipleChoiceQuestion.answers[1]).click(); - - cy.get('[data-cy="add-dependency-button"]').click(); - - cy.get('[id="dependency-id"]').last().click(); - - cy.get('[role="presentation"]').contains(booleanQuestion).click(); - - cy.get('[id="dependencyValue"]').last().click(); - - cy.contains('true').click(); - - cy.get('[data-cy="submit"]').click(); - - cy.logout(); - - cy.login('user1'); - cy.visit('/'); - - cy.contains(proposal.title) - .parent() - .find('[aria-label="Edit proposal"]') - .click(); - - cy.contains('save and continue', { matchCase: false }).click(); - cy.finishedLoading(); - - cy.get('main form').should( - 'not.contain.text', - templateDependencies.questions.textQuestion.title - ); - - cy.contains(multipleChoiceQuestion.title).parent().click(); - cy.contains(multipleChoiceQuestion.answers[1]).click(); - cy.get('body').type('{esc}'); - cy.get('main form').should( - 'not.contain.text', - templateDependencies.questions.textQuestion.title - ); - - cy.contains(booleanQuestion).click(); - - cy.get('main form').should( - 'contain.text', - templateDependencies.questions.textQuestion.title - ); - - cy.contains(multipleChoiceQuestion.title).parent().click(); - cy.get('[role="presentation"]') - .contains(multipleChoiceQuestion.answers[1]) - .click(); - cy.contains(multipleChoiceQuestion.answers[2]).click(); - cy.get('body').type('{esc}'); - - cy.get('main form').should( - 'not.contain.text', - templateDependencies.questions.textQuestion.title - ); - }); - - it('User officer can change dependency logic operator', () => { - cy.createProposal({ callId: initialDBData.call.id }).then((result) => { - const createdProposal = result.createProposal; - if (createdProposal) { - cy.updateProposal({ - proposalPk: createdProposal.primaryKey, - title: proposal.title, - abstract: proposal.abstract, - proposerId: initialDBData.users.user1.id, - }); - } - }); - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.get('[aria-label="Edit"]').last().click(); - - cy.contains(textQuestion.title).click(); - - cy.get('[data-cy="add-dependency-button"]').click(); - - cy.get('[id="dependency-id"]').last().click(); - - cy.get('[role="presentation"]') - .contains(multipleChoiceQuestion.title) - .click(); - - cy.get('[id="dependencyValue"]').last().click(); - - cy.contains(multipleChoiceQuestion.answers[1]).click(); - - cy.get('[data-cy="dependencies-operator"]').click(); - - cy.get('[data-value="OR"]').click(); - - cy.get('[data-cy="submit"]').click(); - - cy.logout(); - - cy.login('user1'); - cy.visit('/'); - - cy.contains(proposal.title) - .parent() - .find('[aria-label="Edit proposal"]') - .click(); - - cy.contains('save and continue', { matchCase: false }).click(); - cy.finishedLoading(); - - cy.get('main form').should('not.contain.text', textQuestion.title); - - cy.contains(multipleChoiceQuestion.title).parent().click(); - cy.contains(multipleChoiceQuestion.answers[1]).click(); - cy.get('body').type('{esc}'); - cy.contains(textQuestion.title); - - cy.contains(multipleChoiceQuestion.title).parent().click(); - cy.get('[role="presentation"]') - .contains(multipleChoiceQuestion.answers[1]) - .click(); - cy.contains(multipleChoiceQuestion.answers[2]).click(); - cy.get('body').type('{esc}'); - - cy.get('main form').should('not.contain.text', textQuestion.title); - - cy.contains(booleanQuestion).click(); - cy.contains(textQuestion.title); - }); - - it('Can delete dependee, which will remove the dependency on depender', () => { - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Edit']") - .first() - .click(); - - cy.contains(textQuestion.title) - .closest('[data-cy=question-container]') - .find('[data-cy=dependency-list]') - .should('exist'); - cy.contains(booleanQuestion).click(); - cy.get('[data-cy=remove-from-template]').click(); - cy.contains(textQuestion.title) - .closest('[data-cy=question-container]') - .find('[data-cy=dependency-list]') - .should('not.exist'); - }); - - it('User can add captions after uploading image/* file', () => { - const fileName = 'file_upload_test2.png'; // need to use another file due to bug in cypress, which do not allow the same fixture to be reused - cy.createProposal({ callId: initialDBData.call.id }).then((result) => { - const createdProposal = result.createProposal; - if (createdProposal) { - cy.updateProposal({ - proposalPk: createdProposal.primaryKey, - title: proposal.title, - abstract: proposal.abstract, - proposerId: initialDBData.users.user1.id, - }); - } - }); - - cy.login('user1'); - cy.visit('/'); - - cy.contains(proposal.title) - .parent() - .find('[aria-label="Edit proposal"]') - .click(); - cy.finishedLoading(); - - cy.contains('Save and continue').click(); - - cy.contains(fileQuestion); - - cy.intercept({ - method: 'POST', - url: '/files/upload', - }).as('upload'); - - // NOTE: Force is needed because file input is not visible and has display: none - cy.contains(fileQuestion) - .parent() - .find('input[type="file"]') - .selectFile( - { - contents: `cypress/fixtures/${fileName}`, - fileName: fileName, - }, - { force: true } - ); - - // wait for the '/files/upload' request, and leave a 30 seconds delay before throwing an error - cy.wait('@upload', { requestTimeout: 30000 }); - - cy.contains(fileName); - - cy.get('[aria-label="Add image caption"]').click(); - - cy.get('[data-cy="image-figure"] input').type('Fig_test'); - cy.get('[data-cy="image-caption"] input').type('Test caption'); - - cy.get('[data-cy="save-button"]').click(); - - cy.notification({ variant: 'success', text: 'Saved' }); - - cy.finishedLoading(); - - cy.get('.MuiStep-root').contains('Review').click(); - - cy.contains(proposal.abstract); - - cy.contains(fileName); - - cy.get('[data-cy="questionary-stepper"]') - .contains(initialDBData.template.topic.title) - .click(); - - cy.finishedLoading(); - cy.contains('Save and continue'); - - cy.contains(fileQuestion) - .parent() - .should('contain.text', fileName) - .find('[data-cy="image-caption"] input') - .should('have.value', 'Test caption'); - cy.contains(fileQuestion) - .parent() - .find('[data-cy="image-figure"] input') - .should('have.value', 'Fig_test'); - }); }); }); diff --git a/apps/user-office-frontend-e2e/cypress/integration/templates_basic.ts b/apps/user-office-frontend-e2e/cypress/integration/templates_basic.ts index 5229f79931..5909f30645 100644 --- a/apps/user-office-frontend-e2e/cypress/integration/templates_basic.ts +++ b/apps/user-office-frontend-e2e/cypress/integration/templates_basic.ts @@ -5,12 +5,9 @@ import { DataType, DependenciesLogicOperator, EvaluatorOperator, - FeatureId, TemplateCategoryId, } from '@user-office-software-libs/shared-types'; -import { DateTime } from 'luxon'; -import featureFlags from '../support/featureFlags'; import initialDBData from '../support/initialDBData'; context('Template tests', () => { @@ -359,981 +356,6 @@ context('Template tests', () => { }); describe('Proposal templates basic tests', () => { - it('User officer can delete active template', function () { - if (!featureFlags.getEnabledFeatures().get(FeatureId.SHIPPING)) { - this.skip(); - } - const newName = faker.lorem.words(3); - const newDescription = faker.lorem.words(5); - - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Shipment declaration templates'); - - cy.get('[data-cy=create-new-button]').click(); - - cy.get('[data-cy=name] input').type(newName); - cy.get('[data-cy=description]').type(newDescription); - - cy.get('[data-cy=submit]').click(); - - cy.visit('/'); - cy.navigateToTemplatesSubmenu('Shipment declaration templates'); - - cy.get('[data-cy=mark-as-active]').click(); - - cy.get('[data-cy=delete-template]').click(); - - cy.get('[data-cy=confirm-ok]').click(); - - cy.finishedLoading(); - - cy.contains(newName).should('not.exist'); - }); - - it('User officer can modify and preview proposal template', () => { - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Edit']") - .first() - .click(); - - /* Boolean */ - - cy.createBooleanQuestion(booleanQuestion); - - cy.contains(booleanQuestion) - .closest('[data-cy=question-container]') - .find("[data-cy='proposal-question-id']") - .invoke('html'); - - /* --- */ - - /* Interval */ - cy.createIntervalQuestion(intervalQuestion, { - units: ['celsius', 'kelvin'], - }); - - cy.contains(intervalQuestion) - .closest('[data-cy=question-container]') - .find("[data-cy='proposal-question-id']") - .invoke('html'); - - /* --- */ - - /* Number */ - - cy.createNumberInputQuestion(numberQuestion, { - units: ['celsius', 'kelvin'], - }); - - cy.contains(numberQuestion) - .closest('[data-cy=question-container]') - .find("[data-cy='proposal-question-id']") - .invoke('html'); - - /* --- */ - - /* Text input */ - cy.createTextQuestion(textQuestion.title, { - isRequired: true, - isMultipleLines: true, - maxCharacters: textQuestion.maxChars, - }); - - cy.contains(textQuestion.title) - .closest('[data-cy=question-container]') - .find("[data-cy='proposal-question-id']") - .invoke('html'); - - /* Update question */ - - cy.contains(textQuestion.title).click(); - - cy.get('[data-cy="natural-key"]').click(); - - cy.get("[data-cy='natural_key']").clear().type(textQuestion.newId); - - cy.contains('Save').click(); - - cy.contains(textQuestion.newId); - /* --- */ - - /* Check if template preview works */ - cy.get('[data-cy="preview-questionary-template"]').click(); - cy.get('[aria-labelledby="preview-questionary-template-modal"]').should( - 'exist' - ); - - cy.get('[data-cy="questionary-stepper"] button').last().click(); - - cy.get( - '[aria-labelledby="preview-questionary-template-modal"] form' - ).contains(booleanQuestion); - cy.get( - '[aria-labelledby="preview-questionary-template-modal"] form' - ).contains(intervalQuestion); - cy.get( - '[aria-labelledby="preview-questionary-template-modal"] form' - ).contains(numberQuestion); - cy.get( - '[aria-labelledby="preview-questionary-template-modal"] form' - ).contains(textQuestion.title); - - cy.closeModal(); - /* --- */ - - cy.contains(textQuestion.title).click(); - - // Updating dependencies - cy.get('[data-cy="add-dependency-button"]').click(); - cy.get('#dependency-id').click(); - cy.get('[data-cy=question-relation-dialogue]') - .get('#menu- > .MuiPaper-root > .MuiList-root > [tabindex="0"]') - .click(); // get boolean question - - cy.get('#dependencyValue').click(); - cy.get('[data-cy=question-relation-dialogue]') - .get("#menu- > .MuiPaper-root > .MuiList-root > [tabindex='0']") - .click(); // get true from dropdown - - cy.contains('Update').click(); - - // Check reordering - cy.contains(textQuestion.title) - .parent() - .dragElement([{ direction: 'up', length: 1 }]); // Move item to top, in case it isn't - - cy.contains(initialDBData.template.topic.title) - .closest('[data-rbd-draggable-context-id]') // new topic column - .find('[data-rbd-drag-handle-draggable-id]') // all questions - .first() // first question - .contains(textQuestion.title); - - cy.contains(textQuestion.title) - .parent() - .dragElement([{ direction: 'down', length: 1 }]); - - cy.contains(initialDBData.template.topic.title) - .closest('[data-rbd-draggable-context-id]') // new topic column - .find('[data-rbd-drag-handle-draggable-id]') // all questions - .first() // first question - .should('not.contain', textQuestion); - - /* Selection from options */ - cy.createMultipleChoiceQuestion(multipleChoiceQuestion.title, { - option1: multipleChoiceQuestion.answers[0], - option2: multipleChoiceQuestion.answers[1], - option3: multipleChoiceQuestion.answers[2], - isMultipleSelect: true, - }); - - cy.contains(multipleChoiceQuestion.title) - .closest('[data-cy=question-container]') - .find("[data-cy='proposal-question-id']") - .invoke('html'); - - cy.finishedLoading(); - - cy.contains(multipleChoiceQuestion.title).click(); - - cy.get('[data-cy=natural-key]').click(); - - cy.get('[index=0]').should( - 'not.contain', - multipleChoiceQuestion.answers[1] - ); - - cy.contains(multipleChoiceQuestion.answers[1]) - .parent() - .find('[aria-label=Up]') - .click(); - - cy.get('[index=0]').contains(multipleChoiceQuestion.answers[1]); - cy.get('[index=1]').contains(multipleChoiceQuestion.answers[0]); - - cy.contains(multipleChoiceQuestion.answers[1]) - .parent() - .find('[aria-label=Down]') - .click(); - - cy.contains(multipleChoiceQuestion.answers[0]) - .parent() - .find('[aria-label=Up]') - .find('[type=button]') - .should('be.disabled'); - - cy.contains(multipleChoiceQuestion.answers[0]) - .parent() - .find('[aria-label=Down]') - .click(); - - cy.contains(multipleChoiceQuestion.answers[0]) - .parent() - .find('[aria-label=Up]') - .click(); - - cy.contains(multipleChoiceQuestion.answers[2]) - .parent() - .find('[aria-label=Down]') - .find('[type=button]') - .should('be.disabled'); - - cy.contains(multipleChoiceQuestion.answers[2]) - .parent() - .find('[aria-label=Up]') - .click(); - - cy.contains(multipleChoiceQuestion.answers[2]) - .parent() - .find('[aria-label=Down]') - .click(); - - cy.contains(multipleChoiceQuestion.answers[0]) - .parent() - .find('[aria-label=Edit]') - .click() - .get('[aria-label=Answer]') - .type(multipleChoiceQuestion.answers[3]) - .get('[aria-label=Save]') - .click() - .get('[index=0]') - .should('contain', multipleChoiceQuestion.answers[3]); - - cy.contains(multipleChoiceQuestion.answers[1]) - .parent() - .find('[aria-label=Delete]') - .click() - .get('[aria-label=Save]') - .click() - .should('not.exist'); - - cy.contains('Save').click(); - - /* --- */ - - /* Dynamic multiple choice */ - cy.createDynamicMultipleChoiceQuestion( - dynamicMultipleChoiceQuestion.title, - { - url: dynamicMultipleChoiceQuestion.url, - isMultipleSelect: true, - } - ); - - cy.contains(dynamicMultipleChoiceQuestion.title) - .closest('[data-cy=question-container]') - .find("[data-cy='proposal-question-id']") - .invoke('html'); - - cy.contains(dynamicMultipleChoiceQuestion.title).click(); - cy.get('[data-cy=natural-key]').click(); - cy.contains('Save').click(); - /* --- */ - - /* Date */ - cy.createDateQuestion(dateQuestion.title, { - includeTime: false, - isRequired: true, - }); - - cy.contains(dateQuestion.title) - .closest('[data-cy=question-container]') - .find("[data-cy='proposal-question-id']") - .invoke('html'); - - cy.createDateQuestion(timeQuestion, { - includeTime: true, - isRequired: false, - }); - - cy.contains(timeQuestion) - .closest('[data-cy=question-container]') - .find("[data-cy='proposal-question-id']") - .invoke('html'); - - /* --- */ - - /* File */ - - cy.createFileUploadQuestion(fileQuestion, ['.pdf', 'image/*']); - - /* --- */ - - /* Rich Text Input */ - - cy.createRichTextInput(richTextInputQuestion.title, { - maxChars: richTextInputQuestion.maxChars, - }); - - cy.contains(richTextInputQuestion.title); - - cy.contains(richTextInputQuestion.title) - .closest('[data-cy=question-container]') - .find("[data-cy='proposal-question-id']") - .invoke('html'); - - /* --- */ - - /* --- Update templateQuestionRelation */ - cy.contains(dateQuestion.title).click(); - cy.get("[data-cy='tooltip'] input").clear().type(dateQuestion.tooltip); - - cy.contains('Update').click(); - - cy.reload(); - - cy.contains(dateQuestion.title).click(); - cy.get("[data-cy='tooltip'] input").should( - 'have.value', - dateQuestion.tooltip - ); - cy.get('body').type('{esc}'); - /* --- */ - - cy.contains(booleanQuestion); - cy.contains(textQuestion.title); - cy.contains(dateQuestion.title); - cy.contains(timeQuestion); - }); - - it('User officer can change template title and description', () => { - const newName = faker.lorem.words(3); - const newDescription = faker.lorem.words(5); - - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Edit']") - .first() - .click(); - - cy.get('[data-cy=edit-metadata]').click(); - cy.get('[data-cy=template-name] input').clear().type(newName); - cy.get('[data-cy=template-description] input') - .clear() - .type(newDescription); - - cy.get('[data-cy="save-metadata-btn"]').click(); - - cy.finishedLoading(); - - cy.contains(newName); - cy.contains(newDescription); - }); - - it('User officer can clone template', () => { - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Clone']") - .first() - .click(); - - cy.contains('Yes').click(); - - cy.contains(`Copy of ${initialDBData.template.name}`); - }); - - it('User officer can delete template', () => { - cy.cloneTemplate({ templateId: initialDBData.template.id }); - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.contains(`Copy of ${initialDBData.template.name}`) - .parent() - .find("[aria-label='Delete']") - .first() - .click(); - - cy.contains('Yes').click(); - - cy.contains(`Copy of ${initialDBData.template.name}`).should('not.exist'); - }); - - it('User officer archive and unarchive template', () => { - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Archive']") - .first() - .click(); - - cy.contains('Yes').click(); - - cy.notification({ variant: 'success', text: 'successfully' }); - - cy.contains(initialDBData.template.name).should('not.exist'); - - cy.contains('Archived').click(); - - cy.contains(initialDBData.template.name); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Unarchive']") - .first() - .click(); - - cy.contains('Yes').click(); - }); - - it('should render the Date field with default value and min max values when set', () => { - let dateFieldId: string; - const minDate = DateTime.fromJSDate(faker.date.past()).toFormat( - initialDBData.getFormats().dateFormat - ); - const earlierThanMinDate = DateTime.fromFormat( - minDate, - initialDBData.getFormats().dateFormat - ) - .minus({ day: 1 }) - .toFormat(initialDBData.getFormats().dateFormat); - const maxDate = DateTime.fromJSDate(faker.date.future()).toFormat( - initialDBData.getFormats().dateFormat - ); - const laterThanMaxDate = DateTime.fromFormat( - maxDate, - initialDBData.getFormats().dateFormat - ) - .plus({ day: 1 }) - .toFormat(initialDBData.getFormats().dateFormat); - const defaultDate = DateTime.now().toFormat( - initialDBData.getFormats().dateFormat - ); - - const tomorrowDate = DateTime.now() - .plus({ day: 1 }) - .toFormat(initialDBData.getFormats().dateFormat); - - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Edit']") - .first() - .click(); - - cy.get('[data-cy=show-more-button]').first().click(); - - cy.get('[data-cy=add-question-menu-item]').first().click(); - - cy.get('[data-cy=questionPicker] [data-cy=show-more-button]') - .first() - .click(); - - cy.contains('Add Date').click(); - - cy.get('[data-cy=question]').clear().type(dateQuestion.title); - - cy.get('[data-cy="minDate"] input').type(minDate); - cy.get('[data-cy="maxDate"] input').type(maxDate); - cy.get('[data-cy="defaultDate"] input').type(defaultDate); - - cy.contains('Save').click(); - - cy.contains(dateQuestion.title) - .closest('[data-cy=question-container]') - .find("[data-cy='proposal-question-id']") - .invoke('html') - .then((fieldId) => { - dateFieldId = fieldId; - }); - - cy.contains(dateQuestion.title) - .parent() - .dragElement([{ direction: 'left', length: 1 }]); - - cy.finishedLoading(); - - cy.contains(dateQuestion.title).click(); - - cy.get('[data-cy="minDate"] input').should('have.value', minDate); - cy.get('[data-cy="maxDate"] input').should('have.value', maxDate); - cy.get('[data-cy="defaultDate"] input').should('have.value', defaultDate); - - cy.get('[data-cy="minDate"] input').clear().type(minDate); - cy.get('[data-cy="maxDate"] input').clear().type(maxDate); - cy.get('[data-cy="defaultDate"] input').clear().type(defaultDate); - - cy.contains('Update').click(); - - cy.logout(); - - cy.login('user1'); - cy.visit('/'); - - cy.contains('New Proposal').click(); - cy.get('[data-cy=call-list]').find('li:first-child').click(); - - cy.contains(dateQuestion.title); - cy.get('body').then(() => { - cy.get(`[data-cy="${dateFieldId}.value"] input`).as('dateField'); - - cy.get('@dateField').should('have.value', defaultDate); - - cy.get('@dateField').clear().type(earlierThanMinDate); - cy.contains('Save and continue').click(); - cy.contains('Date must be no earlier than'); - - cy.get('@dateField').clear().type(laterThanMaxDate); - cy.contains('Save and continue').click(); - cy.contains('Date must be no latter than'); - - cy.get('@dateField').clear().type(tomorrowDate); - cy.contains('Save and continue').click(); - cy.contains('Date must be no').should('not.exist'); - }); - }); - - it('should be able to create new unit from the Unit field', () => { - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Edit']") - .first() - .click(); - - cy.get('[data-cy=show-more-button]').first().click(); - - cy.get('[data-cy=add-question-menu-item]').first().click(); - - cy.get('[data-cy=questionPicker] [data-cy=show-more-button]') - .first() - .click(); - - cy.contains('Add Number').click(); - - cy.get('[data-cy=units]') - .find('#config-units') - .type('test_cannot_be_found'); - cy.get('[data-cy=add-button]').click(); - cy.get('[data-cy="unit-id"]').clear().type(numberQuestion); - cy.get('[data-cy="unit-name"]').clear().type(numberQuestion); - cy.get('[data-cy="unit-quantity"]').click(); - cy.get('[role="presentation"] [role="option"]').first().click(); - cy.get('[data-cy="unit-symbol"]').clear().type(numberQuestion); - cy.get('[data-cy="unit-siConversionFormula"]').clear().type('x'); - cy.get('[data-cy=unit-modal] [data-cy=submit]').click(); - cy.get('[data-tag-index=0] > span').should( - 'include.text', - numberQuestion - ); - }); - - it('should render the Number field accepting only positive, negative numbers if set', () => { - const generateId = () => - `${faker.lorem.word()}_${faker.lorem.word()}_${faker.lorem.word()}`; - - const questions = [ - { - id: generateId(), - title: faker.lorem.words(3), - valueConstraint: 'Only positive numbers', - fieldName: 'numberField2', - badInput: '1{leftarrow}-', - goodInput: '1', - failureMessage: 'Value must be a negative number', - }, - { - id: generateId(), - title: faker.lorem.words(3), - valueConstraint: 'Only negative numbers', - fieldName: 'numberField3', - badInput: '1', - goodInput: '1{leftarrow}-', - failureMessage: 'Value must be a positive number', - }, - { - id: generateId(), - title: faker.lorem.words(3), - valueConstraint: 'Only negative integers', - fieldName: 'numberField4', - badInput: '1.1{leftarrow}{leftarrow}{leftarrow}-', - goodInput: '-1', - failureMessage: 'Value must be negative whole number', - }, - { - id: generateId(), - title: faker.lorem.words(3), - valueConstraint: 'Only positive integers', - fieldName: 'numberField5', - badInput: '1.1', - goodInput: '1', - failureMessage: 'Value must be positive whole number', - }, - ]; - - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Edit']") - .first() - .click(); - - /* Create questions */ - for (const question of questions) { - cy.createNumberInputQuestion(question.title, { - key: question.id, - units: ['kelvin'], - valueConstraint: question.valueConstraint, - firstTopic: true, - }); - } - - cy.logout(); - - cy.login('user1'); - cy.visit('/'); - - cy.contains('New Proposal').click(); - cy.get('[data-cy=call-list]').find('li:first-child').click(); - - /* Test questions exist */ - for (const question of questions) { - cy.contains(question.title); - } - - /* Test bad inputs */ - for (const question of questions) { - cy.get(`[data-natural-key="${question.id}"] input`).type( - question.badInput - ); - } - cy.contains('Save and continue').click(); - for (const question of questions) { - cy.contains(question.failureMessage); - } - - /* Test good inputs */ - for (const question of questions) { - cy.get(`[data-natural-key="${question.id}"] input`) - .clear() - .type(question.goodInput); - } - cy.contains('Save and continue').click(); - for (const question of questions) { - cy.contains(question.failureMessage).should('not.exist'); - } - }); - - it('User officer can add multiple choice question as a dependency', () => { - cy.createProposal({ callId: initialDBData.call.id }).then((result) => { - const createdProposal = result.createProposal; - if (createdProposal) { - cy.updateProposal({ - proposalPk: createdProposal.primaryKey, - title: proposal.title, - abstract: proposal.abstract, - proposerId: initialDBData.users.user1.id, - }); - } - }); - - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Edit']") - .first() - .click(); - - cy.createMultipleChoiceQuestion( - templateDependencies.questions.selectQuestion.title, - { - option1: templateDependencies.questions.selectQuestion.answer1, - option2: templateDependencies.questions.selectQuestion.answer2, - } - ); - - cy.createBooleanQuestion( - templateDependencies.questions.booleanQuestion.title - ); - - cy.contains(templateDependencies.questions.booleanQuestion.title).click(); - - cy.get('[data-cy="add-dependency-button"]').click(); - - cy.get('[id="dependency-id"]').click(); - - cy.get('[role="presentation"]') - .contains(templateDependencies.questions.selectQuestion.title) - .click(); - - cy.get('[id="dependencyValue"]').click(); - - cy.contains( - templateDependencies.questions.selectQuestion.answer1 - ).click(); - - cy.get('[data-cy="submit"]').click(); - - cy.logout(); - - cy.login('user1'); - cy.visit('/'); - - cy.contains(proposal.title) - .parent() - .find('[aria-label="Edit proposal"]') - .click(); - - cy.contains('save and continue', { matchCase: false }).click(); - cy.finishedLoading(); - - // Dependee is NOT visible - cy.get('main form').should( - 'not.contain.text', - templateDependencies.questions.booleanQuestion.title - ); - - cy.contains(templateDependencies.questions.selectQuestion.title) - .parent() - .click(); - cy.contains( - templateDependencies.questions.selectQuestion.answer1 - ).click(); - - // Dependee is visible - cy.get('main form').should( - 'contain.text', - templateDependencies.questions.booleanQuestion.title - ); - - cy.contains(templateDependencies.questions.selectQuestion.title) - .parent() - .click(); - cy.contains( - templateDependencies.questions.selectQuestion.answer2 - ).click(); - - // Dependee is NOT visible again - cy.get('main form').should( - 'not.contain.text', - templateDependencies.questions.booleanQuestion.title - ); - }); - - it('Should not let you create circular dependency chain', () => { - const field1 = 'boolean_1_' + Date.now(); - const field2 = 'boolean_2_' + Date.now(); - const field3 = 'boolean_3_' + Date.now(); - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Edit']") - .first() - .click(); - - cy.createBooleanQuestion(field1); - cy.createBooleanQuestion(field2); - cy.createBooleanQuestion(field3); - - function addDependency( - fieldName: string, - contains: string[], - select?: string - ) { - cy.contains(fieldName).click(); - cy.get('[data-cy="add-dependency-button"]').click(); - cy.get('[id="dependency-id"]').click(); - - contains.forEach((field) => { - cy.get('[role="listbox"]').contains(field); - }); - - if (contains.length === 0) { - cy.get('[role="listbox"]').children().should('have.length', 2); - } - - if (select) { - cy.get('[role="listbox"]').contains(select).click(); - - cy.get('[id="dependencyValue"]').click(); - cy.get('[role="listbox"]').contains('true').click(); - - cy.contains('Update').click(); - - cy.finishedLoading(); - } - } - - addDependency(field1, [field2, field3], field2); - addDependency(field2, [field3], field3); - addDependency(field3, []); - }); - - it('User officer should be able to search questions', function () { - createTopicWithQuestionsAndRelations(); - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - // Create an empty template so we can search all question from the question picker - - cy.get('[data-cy=create-new-button]').click(); - - cy.get('[data-cy="name"]').type(templateSearch.title); - - cy.get('[data-cy="description"]').type(templateSearch.description); - - cy.get('[data-cy="submit"]').click(); - - cy.get('[data-cy=show-more-button]').click(); - - // Search questions - cy.contains('Add question').click(); - - cy.get('[data-cy=search-button]').click(); - - // after entering textQuestion, dateQuestion should not be visible - cy.contains(dateQuestion.title); - cy.get('[data-cy=search-text] input').clear().type(textQuestion.title); - cy.contains(textQuestion.title).should('exist'); - cy.contains(dateQuestion.title).should('not.exist'); - - cy.get('[data-cy=search-text] input').clear(); - - // after entering dateQuestion, textQuestion should not be visible - cy.contains(textQuestion.title); - cy.get('[data-cy=search-text] input').clear().type(dateQuestion.title); - cy.contains(dateQuestion.title).should('exist'); - cy.contains(textQuestion.title).should('not.exist'); - - cy.get('[data-cy=search-text] input').clear(); - cy.get('[data-cy=question-list]') - .contains(booleanQuestion) - .should('exist'); // this command is here to wait for the list to be clean of the previous search - - // searching by categories - - // Boolean - cy.get('[data-cy=data-type]').click(); - cy.get('[role=listbox]').contains('Boolean').click(); - cy.get('[data-cy=question-list]') - .contains(booleanQuestion) - .should('exist'); - cy.get('[data-cy=question-list]') - .contains(textQuestion.title) - .should('not.exist'); - - // Date - cy.get('[data-cy=data-type]').click(); - cy.get('[role=listbox]').contains('Date').click(); - cy.get('[data-cy=question-list]') - .contains(dateQuestion.title) - .should('exist'); - cy.get('[data-cy=question-list]') - .contains(textQuestion.title) - .should('not.exist'); - - // All question types - cy.get('[data-cy=data-type]').click(); - cy.get('[role=listbox]').contains('All').click(); - cy.get('[data-cy=question-list]') - .contains(dateQuestion.title) - .should('exist'); - cy.get('[data-cy=question-list]') - .contains(textQuestion.title) - .should('exist'); - - // filter with no results - cy.get('[data-cy=search-text] input') - .clear() - .type('string match no results'); - cy.get('[data-cy=question-list] div').should('have.length', 0); - - // closing resets the filter - cy.get('[data-cy=search-button]').click(); - cy.get('[data-cy=question-list] div').should('have.length.above', 0); - }); - - it('User officer import template', () => { - const fileName = 'template_import.json'; - const resolvedQuestionTitle = 'General information'; - - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.get('[data-cy=import-template-button]').click(); - - // NOTE: Force is needed because file input is not visible and has display: none - cy.get('input[type="file"]').selectFile( - { - contents: `cypress/fixtures/${fileName}`, - fileName: fileName, - }, - { force: true } - ); - - cy.get("[data-cy='proposal_basis-accordion']") - .find('[data-cy=conflict-icon]') - .should('exist'); - - cy.get("[data-cy='proposal_basis-accordion']").click(); - - cy.get("[data-cy='proposal_basis-accordion']") - .find("[data-cy='new-item-checkbox']") - .click(); - - cy.get("[data-cy='proposal_basis-accordion']") - .find('[data-cy=conflict-icon]') - .should('not.exist'); - - cy.get("[data-cy='proposal_basis-accordion']") - .find('[data-cy=resolved-icon]') - .should('exist'); - - cy.get('[data-cy=import-template-button]').click(); - - cy.contains(resolvedQuestionTitle).should('exist'); - - cy.notification({ - variant: 'success', - text: 'Template imported successfully', - }); - }); - it('should export template in compatible format', () => { cy.login('officer'); cy.visit('/'); @@ -1364,390 +386,5 @@ context('Template tests', () => { }); }); }); - - it('should validate question template relation input', () => { - createTopicWithQuestionsAndRelations(); - - cy.login('officer'); - cy.visit('/ProposalTemplates'); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Edit']") - .first() - .click(); - - cy.contains(initialDBData.questions.fileUpload.text).click(); - - cy.get('[data-cy=max_files] input').clear().type('1'); - cy.get('[data-cy=submit]').should('not.be.disabled'); - - cy.get('[data-cy=max_files] input').clear().type('-1'); - cy.get('[data-cy=submit]').should('be.disabled'); - }); - }); - - describe('Dynamic multiple choice external api call tests', () => { - const createProposalAndClickDropdownBehavior = () => { - cy.login('user1'); - cy.visit('/'); - - cy.contains('New Proposal').click(); - cy.get('[data-cy=call-list]').find('li:first-child').click(); - - cy.finishedLoading(); - - cy.get('[data-cy=title] input').type('title'); - cy.get('[data-cy=abstract] textarea').first().type('abstract'); - - cy.contains(dynamicMultipleChoiceQuestion.title); - cy.contains(dynamicMultipleChoiceQuestion.title).parent().click(); - }; - - beforeEach(() => { - cy.login('officer'); - cy.visit('/'); - cy.navigateToTemplatesSubmenu('Proposal'); - cy.contains(initialDBData.template.name) - .parent() - .find('[aria-label=Edit]') - .first() - .click(); - }); - - it('Should render empty list if JSONPATH syntax is invalid', () => { - cy.task('mockServer', { - interceptUrl: dynamicMultipleChoiceQuestion.url, - fixture: dynamicMultipleChoiceQuestion.answers.arrayObject, - }); - cy.createDynamicMultipleChoiceQuestion( - dynamicMultipleChoiceQuestion.title, - { - url: dynamicMultipleChoiceQuestion.url, - jsonPath: '$.[*].item', - isMultipleSelect: true, - firstTopic: true, - } - ); - - createProposalAndClickDropdownBehavior(); - - cy.get('[data-cy=dropdown-ul]').children().should('not.contain.value'); - }); - - it('Should be able to use JSONPATH library to extract specific data from API response', () => { - cy.task('mockServer', { - interceptUrl: dynamicMultipleChoiceQuestion.url, - fixture: dynamicMultipleChoiceQuestion.answers.arrayObject, - }); - cy.createDynamicMultipleChoiceQuestion( - dynamicMultipleChoiceQuestion.title, - { - url: dynamicMultipleChoiceQuestion.url, - jsonPath: dynamicMultipleChoiceQuestion.jsonPath, - isMultipleSelect: true, - firstTopic: true, - } - ); - createProposalAndClickDropdownBehavior(); - - cy.get('[data-cy=dropdown-ul]').children().should('have.length', 3); - cy.get('[data-cy=dropdown-li]').each(($el) => { - cy.wrap($el).click(); - }); - }); - - it('Should render selectable options from an API response', () => { - cy.task('mockServer', { - interceptUrl: dynamicMultipleChoiceQuestion.url, - fixture: dynamicMultipleChoiceQuestion.answers.arrayString, - }); - - cy.createDynamicMultipleChoiceQuestion( - dynamicMultipleChoiceQuestion.title, - { - url: dynamicMultipleChoiceQuestion.url, - isMultipleSelect: true, - firstTopic: true, - } - ); - createProposalAndClickDropdownBehavior(); - - cy.get('[data-cy=dropdown-ul]').children().should('have.length', 3); - cy.get('[data-cy=dropdown-li]').each(($el) => { - cy.wrap($el).click(); - }); - }); - }); - - describe('File upload tests', () => { - beforeEach(() => { - cy.login('officer'); - cy.visit('/'); - - cy.navigateToTemplatesSubmenu('Proposal'); - - cy.contains(initialDBData.template.name) - .parent() - .find("[aria-label='Edit']") - .first() - .click(); - - cy.createFileUploadQuestion(fileQuestion, ['.pdf', '.docx', 'image/*']); - - cy.login('user1'); - cy.visit('/'); - - cy.contains('New Proposal').click(); - cy.get('[data-cy=call-list]').find('li:first-child').click(); - - cy.get('[data-cy=title] input').type('title'); - - cy.get('[data-cy=abstract] textarea').first().type('abstract'); - - cy.contains(fileQuestion); - }); - - it('File limitation info is displayed', () => { - cy.contains('Accepted formats: .pdf, .docx, any image'); - cy.contains('Maximum 3 PDF page(s) per file'); - cy.contains('Maximum 3 file(s)'); - }); - - it('File without extension cannot be uploaded', () => { - const fileName = 'file_without_ext'; - - // NOTE: Force is needed because file input is not visible and has display: none - cy.contains(fileQuestion) - .parent() - .find('input[type="file"]') - .selectFile( - { - contents: `cypress/fixtures/${fileName}`, - fileName: fileName, - mimeType: 'application/pdf', - }, - { force: true } - ); - - cy.contains('Incorrect file type'); - }); - - it('File with incorrect content header cannot be uploaded', () => { - const fileName = 'file_upload_test.png'; - - // NOTE: Force is needed because file input is not visible and has display: none - cy.contains(fileQuestion) - .parent() - .find('input[type="file"]') - .selectFile( - { - contents: `cypress/fixtures/${fileName}`, - fileName: fileName, - mimeType: 'application/octet-stream', - }, - { force: true } - ); - - cy.contains('Incorrect file type'); - }); - - it('Unidentifiable disguised file is uploaded but not accepted', () => { - const fileName = 'unidentifiable_file.pdf'; - - cy.intercept({ - method: 'POST', - url: '/files/upload', - }).as('upload'); - - // NOTE: Force is needed because file input is not visible and has display: none - cy.contains(fileQuestion) - .parent() - .find('input[type="file"]') - .selectFile( - { - contents: `cypress/fixtures/${fileName}`, - fileName: fileName, - }, - { force: true } - ); - - // wait for the '/files/upload' request, and leave a 30 seconds delay before throwing an error - cy.wait('@upload', { requestTimeout: 30000 }); - - cy.contains(fileName); - - cy.contains('Save and continue').click(); - - cy.notification({ - variant: 'error', - text: 'not satisfying a constraint', - }); - }); - - it('Identifiable disguised file is uploaded but not accepted', () => { - const fileName = 'mp3_file.pdf'; - - cy.intercept({ - method: 'POST', - url: '/files/upload', - }).as('upload'); - - // NOTE: Force is needed because file input is not visible and has display: none - cy.contains(fileQuestion) - .parent() - .find('input[type="file"]') - .selectFile( - { - contents: `cypress/fixtures/${fileName}`, - fileName: fileName, - mimeType: 'application/pdf', - }, - { force: true } - ); - - // wait for the '/files/upload' request, and leave a 30 seconds delay before throwing an error - cy.wait('@upload', { requestTimeout: 30000 }); - - cy.contains(fileName); - - cy.contains('Save and continue').click(); - - cy.notification({ - variant: 'error', - text: 'not satisfying a constraint', - }); - }); - - it('Question is not accepted when one of many files is invalid', () => { - const validFile = 'file_upload_test.png'; - const invalidFile = 'mp3_file.pdf'; - - cy.intercept({ - method: 'POST', - url: '/files/upload', - }).as('upload'); - - // NOTE: Force is needed because file input is not visible and has display: none - cy.contains(fileQuestion) - .parent() - .find('input[type="file"]') - .selectFile( - { - contents: `cypress/fixtures/${validFile}`, - fileName: validFile, - }, - { force: true } - ); - - // wait for the '/files/upload' request, and leave a 30 seconds delay before throwing an error - cy.wait('@upload', { requestTimeout: 30000 }); - - cy.contains(validFile); - - cy.contains('Save and continue').click(); - - cy.notification({ variant: 'success', text: 'Saved' }); - - cy.contains('Back').click(); - - cy.contains(fileQuestion); - cy.contains(validFile); - - cy.intercept({ - method: 'POST', - url: '/files/upload', - }).as('upload'); - - // NOTE: Force is needed because file input is not visible and has display: none - cy.contains(fileQuestion) - .parent() - .find('input[type="file"]') - .selectFile( - { - contents: `cypress/fixtures/${invalidFile}`, - fileName: invalidFile, - mimeType: 'application/pdf', - }, - { force: true } - ); - - // wait for the '/files/upload' request, and leave a 30 seconds delay before throwing an error - cy.wait('@upload', { requestTimeout: 30000 }); - - cy.contains(invalidFile); - - cy.contains('Save and continue').click(); - - cy.notification({ - variant: 'error', - text: 'not satisfying a constraint', - }); - }); - - it('Question is not accepted when PDF file page count is outside limit', () => { - const fileName = 'pdf_5_pages.pdf'; - - cy.intercept({ - method: 'POST', - url: '/files/upload', - }).as('upload'); - - // NOTE: Force is needed because file input is not visible and has display: none - cy.contains(fileQuestion) - .parent() - .find('input[type="file"]') - .selectFile( - { - contents: `cypress/fixtures/${fileName}`, - fileName: fileName, - mimeType: 'application/pdf', - }, - { force: true } - ); - - // wait for the '/files/upload' request, and leave a 30 seconds delay before throwing an error - cy.wait('@upload', { requestTimeout: 30000 }); - - cy.contains(fileName); - - cy.contains('Save and continue').click(); - - cy.notification({ - variant: 'error', - text: 'not satisfying a constraint', - }); - }); - - it('Question accepted when PDF file page count is within limit', () => { - const fileName = 'pdf_3_pages.pdf'; - - cy.intercept({ - method: 'POST', - url: '/files/upload', - }).as('upload'); - - // NOTE: Force is needed because file input is not visible and has display: none - cy.contains(fileQuestion) - .parent() - .find('input[type="file"]') - .selectFile( - { - contents: `cypress/fixtures/${fileName}`, - fileName: fileName, - mimeType: 'application/pdf', - }, - { force: true } - ); - - // wait for the '/files/upload' request, and leave a 30 seconds delay before throwing an error - cy.wait('@upload', { requestTimeout: 30000 }); - - cy.contains(fileName); - - cy.contains('Save and continue').click(); - - cy.notification({ variant: 'success', text: 'Saved' }); - }); }); });