diff --git a/frontend/e2e/cypress/common.js b/frontend/e2e/cypress/common.js index eb5a49b..be0df3a 100644 --- a/frontend/e2e/cypress/common.js +++ b/frontend/e2e/cypress/common.js @@ -6,8 +6,8 @@ export const TEST_USER = { givenname: 'Timo *Teppo Tellervo', mail: '', hypersonstudentid: '012345678', - sn: 'Testaaja' - } + sn: 'Testaaja', + }, } export const TEST_USER2 = { @@ -18,8 +18,8 @@ export const TEST_USER2 = { givenname: 'Donald John', mail: '', hypersonstudentid: '012345698', - sn: 'Trump' - } + sn: 'Trump', + }, } export const TEST_USER3 = { @@ -30,8 +30,8 @@ export const TEST_USER3 = { givenname: 'Volodymyr', mail: 'volodymy.testerskyy@fakemail.not', hypersonstudentid: '918273645', - sn: 'Testerskyy' - } + sn: 'Testerskyy', + }, } export const TEST_ADMIN = { @@ -42,6 +42,6 @@ export const TEST_ADMIN = { givenname: 'Angela', mail: '', hypersonstudentid: '012345688', - sn: 'Merkel' - } -} \ No newline at end of file + sn: 'Merkel', + }, +} diff --git a/frontend/e2e/cypress/fixtures/example.json b/frontend/e2e/cypress/fixtures/example.json index da18d93..02e4254 100644 --- a/frontend/e2e/cypress/fixtures/example.json +++ b/frontend/e2e/cypress/fixtures/example.json @@ -2,4 +2,4 @@ "name": "Using fixtures to represent data", "email": "hello@cypress.io", "body": "Fixtures are a great way to mock data for responses to routes" -} \ No newline at end of file +} diff --git a/frontend/e2e/cypress/integration/answerPeerReview.spec.js b/frontend/e2e/cypress/integration/answerPeerReview.spec.js index 790d055..bd27e4d 100644 --- a/frontend/e2e/cypress/integration/answerPeerReview.spec.js +++ b/frontend/e2e/cypress/integration/answerPeerReview.spec.js @@ -33,21 +33,10 @@ describe('Answering peer review', () => { header: 'Ok and with option', description: 'Choose a radio button you want', type: 'radio', - options: [ - 'Cant say', - 'Not at all', - 'Little', - 'Decent', - 'Good', - 'Super', - ], + options: ['Cant say', 'Not at all', 'Little', 'Decent', 'Good', 'Super'], }, ]) - cy.setPeerReviewOneActive( - 'Konfiguraatio 1', - 1, - 'Super nice review questions' - ) + cy.setPeerReviewOneActive('Konfiguraatio 1', 1, 'Super nice review questions') }) it('peer review is open', () => { @@ -66,9 +55,7 @@ describe('Answering peer review', () => { it('shows an error if only one of the fields is filled', () => { cy.loginAsRegisteredUser() cy.visit('/peerreview') - cy.get( - '[data-cy="input_number_Previous experiene in software developement"]' - ) + cy.get('[data-cy="input_number_Previous experiene in software developement"]') .type('{backspace}') .type('123') cy.contains('Submit').click() @@ -78,17 +65,11 @@ describe('Answering peer review', () => { it('shows an error if not all of the radio button questions is answered', () => { cy.loginAsRegisteredUser() cy.visit('/peerreview') - cy.get( - '[data-cy="input_number_Previous experiene in software developement"]' - ) + cy.get('[data-cy="input_number_Previous experiene in software developement"]') .type('{backspace}') .type('123') - cy.get('[data-cy="input_number_Without option?"]') - .type('{backspace}') - .type('123') - cy.get('[name="Ok and with optionTimo *Teppo Tellervo Testaaja"]') - .eq(3) - .click() + cy.get('[data-cy="input_number_Without option?"]').type('{backspace}').type('123') + cy.get('[name="Ok and with optionTimo *Teppo Tellervo Testaaja"]').eq(3).click() cy.contains('Submit').click() cy.contains('You must answer all questions') }) @@ -96,17 +77,11 @@ describe('Answering peer review', () => { it('shows a submit confimation when all field and butotns are filled properly', () => { cy.loginAsRegisteredUser() cy.visit('/peerreview') - cy.get( - '[data-cy="input_number_Previous experiene in software developement"]' - ) + cy.get('[data-cy="input_number_Previous experiene in software developement"]') .type('{backspace}') .type('123') - cy.get('[data-cy="input_number_Without option?"]') - .type('{backspace}') - .type('123') - cy.get('[name="Ok and with optionTimo *Teppo Tellervo Testaaja"]') - .eq(2) - .click() + cy.get('[data-cy="input_number_Without option?"]').type('{backspace}').type('123') + cy.get('[name="Ok and with optionTimo *Teppo Tellervo Testaaja"]').eq(2).click() cy.get('[name="Ok and with optionDonald John Trump"]').eq(5).click() cy.contains('Submit').click() cy.contains('Peer review saved!') diff --git a/frontend/e2e/cypress/integration/customerReview.spec.js b/frontend/e2e/cypress/integration/customerReview.spec.js index c199a2d..b6b9093 100644 --- a/frontend/e2e/cypress/integration/customerReview.spec.js +++ b/frontend/e2e/cypress/integration/customerReview.spec.js @@ -41,7 +41,7 @@ const submitCustomerReview = () => { const answerTextInput = (text) => { cy.get('[data-cy="textInput-Mitä mieltä olit tykittelystä?"]').within(() => { - cy.get('textarea').type(text) + cy.get('textarea:not([aria-hidden="true"])').type(text) }) } @@ -52,21 +52,17 @@ const answerOnelinerInput = (text) => { } const answerNumberInput = (number) => { - cy.get( - '[data-cy="numberInput-Monta tuntia viikossa olit yhteydessä tiimiin?"]' - ) + cy.get('[data-cy="numberInput-Monta tuntia viikossa olit yhteydessä tiimiin?"]') .clear() .type(number) } const answerRangeInput = (number) => { - cy.get('[data-cy="rangeInput-Minkä arvosanan antaisit tiimille?"]').within( - () => { - cy.get('input') - .eq(number - 1) - .click() - } - ) + cy.get('[data-cy="rangeInput-Minkä arvosanan antaisit tiimille?"]').within(() => { + cy.get('input') + .eq(number - 1) + .click() + }) } const expectNotification = (text) => { @@ -99,27 +95,21 @@ describe('Customer review page', () => { }) it('shows error when oneliner fields are under 5 characters long', () => { - answerTextInput( - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.' - ) + answerTextInput('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.') answerOnelinerInput('spam') submitCustomerReview() expectNotification('Short text answers must be over 5 characters long.') }) it('shows error when text fields are filled but there are other unfilled fields', () => { - answerTextInput( - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.' - ) + answerTextInput('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.') answerOnelinerInput('spammiosoite') submitCustomerReview() expectNotification('You must answer all questions') }) it('submits customer review when all fields are filled', () => { - answerTextInput( - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.' - ) + answerTextInput('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.') answerNumberInput(1337) answerRangeInput(3) answerOnelinerInput('spammittanne@helsinki.foo') diff --git a/frontend/e2e/cypress/integration/customerReviewQuestionsPage.spec.js b/frontend/e2e/cypress/integration/customerReviewQuestionsPage.spec.js index 10dbaee..3d195bd 100644 --- a/frontend/e2e/cypress/integration/customerReviewQuestionsPage.spec.js +++ b/frontend/e2e/cypress/integration/customerReviewQuestionsPage.spec.js @@ -3,10 +3,10 @@ const escapeJsonForCypressType = (json) => json.replace(/\{/g, '{{}') const submitCreationForm = (name, questionsJson) => { - cy.get('.question-set-form .question-set-form__name').type(name) - cy.get('.question-set-form .question-set-form__questions').type( - escapeJsonForCypressType(questionsJson) - ) + cy.get('.question-set-form .question-set-form__name input').type(name) + cy.get( + '.question-set-form .question-set-form__questions textarea:not([aria-hidden="true"])', + ).type(escapeJsonForCypressType(questionsJson)) cy.get('.question-set-form button[type="submit"]').click() } @@ -15,66 +15,46 @@ const createQuestionSet = (name, questions) => { } const editQuestionSet = (questionSetItemSelector) => { - cy.get(questionSetItemSelector) - .find('.question-set-item-controls__menu-button') - .click() + cy.get(questionSetItemSelector).find('.question-set-item-controls__menu-button').click() cy.get('#question-set-item-controls__menu') .find('.question-set-item-controls__edit-button') .click() } const replaceEditingQuestionSetName = (questionSetItemSelector, newName) => { - cy.get(questionSetItemSelector) - .find('.question-set-form__name') - .clear() - .type(newName) + cy.get(questionSetItemSelector).find('.question-set-form__name input').clear().type(newName) } const replaceEditingQuestionSetJson = (questionSetItemSelector, json) => { cy.get(questionSetItemSelector) - .find('.question-set-form__questions') + .find('.question-set-form__questions textarea:not([aria-hidden="true"])') .clear() .type(escapeJsonForCypressType(json)) } const replaceEditingQuestionSet = (questionSetItemSelector, newQuestions) => { - replaceEditingQuestionSetJson( - questionSetItemSelector, - JSON.stringify(newQuestions) - ) + replaceEditingQuestionSetJson(questionSetItemSelector, JSON.stringify(newQuestions)) } const clearEditingQuestionSetInputs = (selector) => { - cy.get(selector) - .find('.question-set-form__name') - .clear() - cy.get(selector) - .find('.question-set-form__questions') - .clear() + cy.get(selector).find('.question-set-form__name input').clear() + cy.get(selector).find('.question-set-form__questions textarea:not([aria-hidden="true"])').clear() } const clearEditingQuestionSetName = (selector) => { - cy.get(selector) - .find('.question-set-form__name') - .clear() + cy.get(selector).find('.question-set-form__name input').clear() } const clearEditingQuestionSetQuestions = (selector) => { - cy.get(selector) - .find('.question-set-form__questions') - .clear() + cy.get(selector).find('.question-set-form__questions textarea:not([aria-hidden="true"])').clear() } const saveEditingQuestionSet = (questionSetItemSelector) => { - cy.get(questionSetItemSelector) - .find('.question-set-item-editor__save-button') - .click() + cy.get(questionSetItemSelector).find('.question-set-item-editor__save-button').click() } const cancelEditingQuestionSet = (selector) => { - cy.get(selector) - .find('.question-set-item-editor__cancel-button') - .click() + cy.get(selector).find('.question-set-item-editor__cancel-button').click() } describe('Customer review questions page', () => { @@ -93,25 +73,19 @@ describe('Customer review questions page', () => { { type: 'text', header: 'Mitä mieltä tykittelystä?', - description: 'Vastaa lyhyesti 1000 sanan verran' - } + description: 'Vastaa lyhyesti 1000 sanan verran', + }, ]) - cy.get('.notification').contains( - 'Created new customer review question set "creview1000"' - ) - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 1) - cy.get('.question-set-item .question-set-item__title').should( - 'have.text', - 'creview1000' + cy.get('.notification').contains('Created new customer review question set "creview1000"') + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 1, ) + cy.get('.question-set-item .question-set-item__title').should('have.text', 'creview1000') + cy.get('.question-set-item .question-set-item__content').contains('Mitä mieltä tykittelystä?') cy.get('.question-set-item .question-set-item__content').contains( - 'Mitä mieltä tykittelystä?' - ) - cy.get('.question-set-item .question-set-item__content').contains( - 'Vastaa lyhyesti 1000 sanan verran' + 'Vastaa lyhyesti 1000 sanan verran', ) cy.get('.question-set-item .question-set-item__content').contains('text') cy.get('.customer-review-question-set-list') @@ -125,16 +99,17 @@ describe('Customer review questions page', () => { type: 'range', header: 'This is header', description: 'This is description', - options: ['pwned', 'owned', 'pk\'d', 'noob', 'elite', '1337'] - } + options: ['pwned', 'owned', "pk'd", 'noob', 'elite', '1337'], + }, ]) - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 1) + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 1, + ) cy.get('.question-set-item__content').contains('This is header') cy.get('.question-set-item__content').contains('This is description') cy.get('.question-set-item__content').contains('range') - cy.get('.question-set-item__content').contains('pk\'d') + cy.get('.question-set-item__content').contains("pk'd") cy.get('.question-set-item__content').contains('1337') }) @@ -143,15 +118,15 @@ describe('Customer review questions page', () => { { type: 'text', header: 'Just a text field plz?', - description: 'Right?' - } + description: 'Right?', + }, ]) createQuestionSet('creview3000', [ { type: 'text', header: 'Just a text field plz?', - description: 'Right?' - } + description: 'Right?', + }, ]) cy.get('.notification').contains('name already in use') cy.get('.customer-review-question-set-list') @@ -172,7 +147,7 @@ describe('Customer review questions page', () => { describe('Customer review question set editing', () => { beforeEach(() => { cy.createCustomerReviewQuestionSet('creview5000', [ - { type: 'text', header: 'foo', description: 'bar' } + { type: 'text', header: 'foo', description: 'bar' }, ]) cy.visit('/administration/customer-review-questions') editQuestionSet('.question-set-item') @@ -206,10 +181,7 @@ describe('Customer review questions page', () => { }) it('shows error if new JSON is invalid', () => { - replaceEditingQuestionSetJson( - '.question-set-item-editor', - '..-12.31-23.1-23.asdasc' - ) + replaceEditingQuestionSetJson('.question-set-item-editor', '..-12.31-23.1-23.asdasc') saveEditingQuestionSet('.question-set-item-editor') cy.get('.question-set-form').contains('Field contains invalid JSON') }) @@ -225,39 +197,38 @@ describe('Customer review questions page', () => { saveEditingQuestionSet('.question-set-item-editor') cy.get('.question-set-item__title').should('have.text', 'creview1337') - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 1) + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 1, + ) cy.get('.question-set-item__content').contains('foo') cy.get('.question-set-item__content').contains('bar') cy.get('.question-set-item__content').contains('text') }) it('edits questions without changing name', () => { - replaceEditingQuestionSet('.question-set-item-editor', [ - { header: 'baz', type: 'range' } - ]) + replaceEditingQuestionSet('.question-set-item-editor', [{ header: 'baz', type: 'range' }]) saveEditingQuestionSet('.question-set-item-editor') cy.get('.question-set-item__title').should('have.text', 'creview5000') - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 1) + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 1, + ) cy.get('.question-set-item__content').contains('baz') cy.get('.question-set-item__content').contains('range') }) it('does not modify set if cancel is clicked', () => { replaceEditingQuestionSetName('.question-set-item-editor', 'creview7321') - replaceEditingQuestionSet('.question-set-item-editor', [ - { header: 'baz!', type: 'range' } - ]) + replaceEditingQuestionSet('.question-set-item-editor', [{ header: 'baz!', type: 'range' }]) cancelEditingQuestionSet('.question-set-item-editor') cy.get('.question-set-item__title').should('have.text', 'creview5000') - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 1) + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 1, + ) cy.get('.question-set-item__content').contains('foo') cy.get('.question-set-item__content').contains('bar') cy.get('.question-set-item__content').contains('text') @@ -267,14 +238,15 @@ describe('Customer review questions page', () => { replaceEditingQuestionSetName('.question-set-item-editor', 'creview5001') replaceEditingQuestionSet('.question-set-item-editor', [ { header: 'asd?', type: 'text' }, - { header: 'das!', type: 'range' } + { header: 'das!', type: 'range' }, ]) saveEditingQuestionSet('.question-set-item-editor') cy.get('.question-set-item__title').should('have.text', 'creview5001') - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 2) + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 2, + ) cy.get('.question-set-item__content').contains('asd?') cy.get('.question-set-item__content').contains('range') }) diff --git a/frontend/e2e/cypress/integration/emailConfigurationPage.spec.js b/frontend/e2e/cypress/integration/emailConfigurationPage.spec.js index cb8766e..30dccd4 100644 --- a/frontend/e2e/cypress/integration/emailConfigurationPage.spec.js +++ b/frontend/e2e/cypress/integration/emailConfigurationPage.spec.js @@ -1,25 +1,21 @@ /* eslint-disable */ -const getEmailTemplate = (name) => - cy.get(`.email-template[data-cy-template="${name}"]`) +const getEmailTemplate = (name) => cy.get(`.email-template[data-cy-template="${name}"]`) const findTemplateTextarea = (templateTitle, templateLanguage) => getEmailTemplate(templateTitle).find( - `.email-template__field--${templateLanguage} textarea` + `.email-template__field--${templateLanguage} textarea:not([aria-hidden="true"])`, ) // cy.type supports keystrokes e.g. {enter} sends enter key -> need to escape { const escapeCurlyBracesForCypress = (text) => text.replace(/\{/g, '{{}') const writeToTemplate = (templateTitle, templateLanguage, text) => - findTemplateTextarea(templateTitle, templateLanguage).type( - escapeCurlyBracesForCypress(text) - ) + findTemplateTextarea(templateTitle, templateLanguage).type(escapeCurlyBracesForCypress(text)) const clickSave = () => cy.get('.email-templates-form__submit-button').click() -const visitEmailTemplatesPage = () => - cy.visit('/administration/email-templates') +const visitEmailTemplatesPage = () => cy.visit('/administration/email-templates') describe('Email configuration page', () => { beforeEach(() => { @@ -33,18 +29,10 @@ describe('Email configuration page', () => { }) it('shows empty fields when no configurations have been made', () => { - findTemplateTextarea('Topic proposal accepted', 'finnish').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal accepted', 'english').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal rejected', 'finnish').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal rejected', 'english').should( - 'be.empty' - ) + findTemplateTextarea('Topic proposal accepted', 'finnish').should('be.empty') + findTemplateTextarea('Topic proposal accepted', 'english').should('be.empty') + findTemplateTextarea('Topic proposal rejected', 'finnish').should('be.empty') + findTemplateTextarea('Topic proposal rejected', 'english').should('be.empty') findTemplateTextarea('Customer review link', 'finnish').should('be.empty') findTemplateTextarea('Customer review link', 'english').should('be.empty') }) @@ -56,20 +44,11 @@ describe('Email configuration page', () => { visitEmailTemplatesPage() - findTemplateTextarea('Topic proposal accepted', 'finnish').should( - 'have.value', - templateText - ) + findTemplateTextarea('Topic proposal accepted', 'finnish').should('have.value', templateText) - findTemplateTextarea('Topic proposal accepted', 'english').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal rejected', 'finnish').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal rejected', 'english').should( - 'be.empty' - ) + findTemplateTextarea('Topic proposal accepted', 'english').should('be.empty') + findTemplateTextarea('Topic proposal rejected', 'finnish').should('be.empty') + findTemplateTextarea('Topic proposal rejected', 'english').should('be.empty') findTemplateTextarea('Customer review link', 'finnish').should('be.empty') findTemplateTextarea('Customer review link', 'english').should('be.empty') }) @@ -81,20 +60,11 @@ describe('Email configuration page', () => { visitEmailTemplatesPage() - findTemplateTextarea('Topic proposal accepted', 'english').should( - 'have.value', - templateText - ) + findTemplateTextarea('Topic proposal accepted', 'english').should('have.value', templateText) - findTemplateTextarea('Topic proposal accepted', 'finnish').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal rejected', 'finnish').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal rejected', 'english').should( - 'be.empty' - ) + findTemplateTextarea('Topic proposal accepted', 'finnish').should('be.empty') + findTemplateTextarea('Topic proposal rejected', 'finnish').should('be.empty') + findTemplateTextarea('Topic proposal rejected', 'english').should('be.empty') findTemplateTextarea('Customer review link', 'finnish').should('be.empty') findTemplateTextarea('Customer review link', 'english').should('be.empty') }) @@ -106,20 +76,11 @@ describe('Email configuration page', () => { visitEmailTemplatesPage() - findTemplateTextarea('Topic proposal rejected', 'finnish').should( - 'have.value', - templateText - ) + findTemplateTextarea('Topic proposal rejected', 'finnish').should('have.value', templateText) - findTemplateTextarea('Topic proposal accepted', 'finnish').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal accepted', 'english').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal rejected', 'english').should( - 'be.empty' - ) + findTemplateTextarea('Topic proposal accepted', 'finnish').should('be.empty') + findTemplateTextarea('Topic proposal accepted', 'english').should('be.empty') + findTemplateTextarea('Topic proposal rejected', 'english').should('be.empty') findTemplateTextarea('Customer review link', 'finnish').should('be.empty') findTemplateTextarea('Customer review link', 'english').should('be.empty') }) @@ -131,97 +92,52 @@ describe('Email configuration page', () => { visitEmailTemplatesPage() - findTemplateTextarea('Topic proposal rejected', 'english').should( - 'have.value', - templateText - ) + findTemplateTextarea('Topic proposal rejected', 'english').should('have.value', templateText) - findTemplateTextarea('Topic proposal accepted', 'finnish').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal accepted', 'english').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal rejected', 'finnish').should( - 'be.empty' - ) + findTemplateTextarea('Topic proposal accepted', 'finnish').should('be.empty') + findTemplateTextarea('Topic proposal accepted', 'english').should('be.empty') + findTemplateTextarea('Topic proposal rejected', 'finnish').should('be.empty') findTemplateTextarea('Customer review link', 'finnish').should('be.empty') findTemplateTextarea('Customer review link', 'english').should('be.empty') }) it('updates only customer review link (finnish) successfully', () => { - const templateText = - 'Hei, vastaathan loppuarviointiin osoitteessa {{secretLink}}' + const templateText = 'Hei, vastaathan loppuarviointiin osoitteessa {{secretLink}}' writeToTemplate('Customer review link', 'finnish', templateText) clickSave() visitEmailTemplatesPage() - findTemplateTextarea('Customer review link', 'finnish').should( - 'have.value', - templateText - ) + findTemplateTextarea('Customer review link', 'finnish').should('have.value', templateText) - findTemplateTextarea('Topic proposal accepted', 'finnish').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal accepted', 'english').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal rejected', 'finnish').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal rejected', 'english').should( - 'be.empty' - ) + findTemplateTextarea('Topic proposal accepted', 'finnish').should('be.empty') + findTemplateTextarea('Topic proposal accepted', 'english').should('be.empty') + findTemplateTextarea('Topic proposal rejected', 'finnish').should('be.empty') + findTemplateTextarea('Topic proposal rejected', 'english').should('be.empty') findTemplateTextarea('Customer review link', 'english').should('be.empty') }) it('updates only customer review link (english) successfully', () => { - const templateText = - 'Hello, please answer the final review at {{secretLink}}' + const templateText = 'Hello, please answer the final review at {{secretLink}}' writeToTemplate('Customer review link', 'english', templateText) clickSave() visitEmailTemplatesPage() - findTemplateTextarea('Customer review link', 'english').should( - 'have.value', - templateText - ) + findTemplateTextarea('Customer review link', 'english').should('have.value', templateText) - findTemplateTextarea('Topic proposal accepted', 'finnish').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal accepted', 'english').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal rejected', 'finnish').should( - 'be.empty' - ) - findTemplateTextarea('Topic proposal rejected', 'english').should( - 'be.empty' - ) + findTemplateTextarea('Topic proposal accepted', 'finnish').should('be.empty') + findTemplateTextarea('Topic proposal accepted', 'english').should('be.empty') + findTemplateTextarea('Topic proposal rejected', 'finnish').should('be.empty') + findTemplateTextarea('Topic proposal rejected', 'english').should('be.empty') findTemplateTextarea('Customer review link', 'finnish').should('be.empty') }) it('simultaneously updates all email templates successfully', () => { const texts = [ - [ - 'Topic proposal accepted', - 'finnish', - 'Hei,\n\nProjekti "{{topicName}}" hyväksyttiin.', - ], - [ - 'Topic proposal accepted', - 'english', - 'Hello,\n\nProject "{{topicName}}" was accepted.', - ], - [ - 'Topic proposal rejected', - 'finnish', - 'Hei,\n\nProjektia "{{topicName}}" ei hyväksytty.', - ], + ['Topic proposal accepted', 'finnish', 'Hei,\n\nProjekti "{{topicName}}" hyväksyttiin.'], + ['Topic proposal accepted', 'english', 'Hello,\n\nProject "{{topicName}}" was accepted.'], + ['Topic proposal rejected', 'finnish', 'Hei,\n\nProjektia "{{topicName}}" ei hyväksytty.'], [ 'Topic proposal rejected', 'english', @@ -245,9 +161,9 @@ describe('Email configuration page', () => { clickSave() visitEmailTemplatesPage() - cy.get("h1").should("contain.text", "Configure email templates", { timeout: 15000 }) + cy.get('h1').should('contain.text', 'Configure email templates', { timeout: 15000 }) texts.forEach(([templateTitle, templateLanguage, text]) => { - findTemplateTextarea(templateTitle, templateLanguage).should("contain.text", text) + findTemplateTextarea(templateTitle, templateLanguage).should('contain.text', text) }) }) }) diff --git a/frontend/e2e/cypress/integration/groupAssignmentIndicator.spec.js b/frontend/e2e/cypress/integration/groupAssignmentIndicator.spec.js index 0dffb33..26c86a6 100644 --- a/frontend/e2e/cypress/integration/groupAssignmentIndicator.spec.js +++ b/frontend/e2e/cypress/integration/groupAssignmentIndicator.spec.js @@ -57,10 +57,8 @@ describe('Group assignment indicator tests', () => { }) it('does not render group indicator when visited', () => { - cy.get('[data-cy=groupname_display_assigned]') - .should('not.exist') - cy.get('[data-cy=groupname_display_unassigned]') - .should('not.exist') + cy.get('[data-cy=groupname_display_assigned]').should('not.exist') + cy.get('[data-cy=groupname_display_unassigned]').should('not.exist') }) afterEach(() => { diff --git a/frontend/e2e/cypress/integration/groupManagementPage.spec.js b/frontend/e2e/cypress/integration/groupManagementPage.spec.js index a19fe9a..9485921 100644 --- a/frontend/e2e/cypress/integration/groupManagementPage.spec.js +++ b/frontend/e2e/cypress/integration/groupManagementPage.spec.js @@ -13,22 +13,18 @@ describe('Group Management Page', () => { cy.get('.configuration-1').click() cy.get('.create-group-form-topic__selector').click() cy.get('.topic-menu-item').contains('Aihe A').click() - cy.get('.create-group-form__name').clear().type('Ryhmä A') - cy.get('.create-group-form__student-input').type('012345678, 012345688') + cy.get('.create-group-form__name input').clear().type('Ryhmä A') + cy.get('.create-group-form__student-input textarea:not([aria-hidden="true"])').type( + '012345678, 012345688', + ) cy.get('.create-group-form__instructor').click() - cy.get('.create-group-form__instructor') - .find('input') - .type('Angela', { force: true }) + cy.get('.create-group-form__instructor').find('input').type('Angela', { force: true }) - cy.get('.create-group-form__instructor').find( - '.create-group-form__instructor__option' - ) + cy.get('.create-group-form__instructor').find('.create-group-form__instructor__option') - cy.get('.create-group-form__instructor') - .find('input') - .type('{enter}', { force: true }) + cy.get('.create-group-form__instructor').find('input').type('{enter}', { force: true }) cy.get('.create-group-submit').click() cy.get('.notification').should('have.text', 'Group saved!') @@ -50,9 +46,7 @@ describe('Group Management Page', () => { it('deletes an instructor', () => { cy.get('[data-cy=delete-instructor-button]').eq(0).click() cy.get('.group-instructor').eq(0).should('not.contain', '012345698') - cy.get('.group-instructor') - .eq(0) - .should('contain', 'No instructor assigned') + cy.get('.group-instructor').eq(0).should('contain', 'No instructor assigned') cy.get('.notification').should('have.text', 'Instructor deleted!') }) }) @@ -62,31 +56,27 @@ describe('Group Management Page', () => { cy.get('.configuration-selector').click() cy.get('.configuration-1').click() cy.get('[data-cy=edit-group-button]').eq(0).click() - cy.get('.notification') - .should('contain', 'Editing for group') - .should('contain', 'enabled!') + cy.get('.notification').should('contain', 'Editing for group').should('contain', 'enabled!') }) it('changes group name', () => { - cy.get('[data-cy=edit-group-name-field]').clear().type('Ryhmä B') + cy.get('[data-cy=edit-group-name-field] input').clear().type('Ryhmä B') cy.get('[data-cy=edit-group-save-button]').click() cy.get('.notification').should('have.text', 'Group updated!') cy.get('.group-name').eq(0).should('contain', 'Ryhmä B') }) it('changes project length', () => { - cy.get('[data-cy=edit-project-length-short]').check() + cy.get('[data-cy=edit-project-length-short] input').check() cy.get('[data-cy=edit-group-save-button]').click() cy.get('.notification').should('have.text', 'Group updated!') cy.get('[data-cy=edit-group-button]').eq(0).click() - cy.get('[data-cy=edit-project-length-short]').should('be.checked') + cy.get('[data-cy=edit-project-length-short] input').should('be.checked') }) it('changes topic', () => { - cy.get('.edit-group-form-topic__selector') - .should('be.visible') - .click() + cy.get('.edit-group-form-topic__selector').should('be.visible').click() cy.get('.topic-menu-item') .first() .should('be.visible') @@ -94,32 +84,22 @@ describe('Group Management Page', () => { cy.wait(500) cy.contains('Aihe B').click() }) - cy.get('[data-cy=edit-group-name-field]') - .clear() - .type('Ryhmä B') + cy.get('[data-cy=edit-group-name-field] input').clear().type('Ryhmä B') cy.get('[data-cy=edit-group-save-button]').click() cy.get('.notification').should('have.text', 'Group updated!') - cy.get('.group-topic') - .eq(0) - .should('contain', 'Aihe B') + cy.get('.group-topic').eq(0).should('contain', 'Aihe B') }) it('changes instructor', () => { cy.get('.edit-group-instructor').click() - cy.get('.edit-group-instructor') - .find('input') - .type('{backspace}', { force: true }) + cy.get('.edit-group-instructor').find('input').type('{backspace}', { force: true }) - cy.get('.edit-group-instructor') - .find('input') - .type('Testaaja', { force: true }) + cy.get('.edit-group-instructor').find('input').type('Testaaja', { force: true }) cy.get('.edit-group-instructor__option') - cy.get('.edit-group-instructor') - .find('input') - .type('{enter}', { force: true }) + cy.get('.edit-group-instructor').find('input').type('{enter}', { force: true }) cy.get('[data-cy=edit-group-save-button]').click() cy.get('.notification').should('have.text', 'Group updated!') @@ -127,7 +107,7 @@ describe('Group Management Page', () => { }) it('adds new student', () => { - cy.get('[data-cy=edit-students-input]').type(', 012345698') + cy.get('[data-cy=edit-students-input] textarea:not([aria-hidden="true"])').type(', 012345698') cy.get('[data-cy=edit-group-save-button]').click() cy.get('.notification').should('have.text', 'Group updated!') cy.get('.group-students').should('contain', '012345698') diff --git a/frontend/e2e/cypress/integration/instructorPage.spec.js b/frontend/e2e/cypress/integration/instructorPage.spec.js index b1b9a16..bb775d2 100644 --- a/frontend/e2e/cypress/integration/instructorPage.spec.js +++ b/frontend/e2e/cypress/integration/instructorPage.spec.js @@ -41,8 +41,7 @@ const initTests = () => { { id: 2, type: 'text', - answer: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.', + answer: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.', questionHeader: 'Mitä kaikkea teknistä tää jäbä osas tehdä?', }, { @@ -85,8 +84,7 @@ const initTests = () => { { id: 2, type: 'text', - answer: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.', + answer: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.', questionHeader: 'Mitä kaikkea teknistä tää jäbä osas tehdä?', }, { @@ -134,8 +132,7 @@ const initTests = () => { { id: 2, type: 'text', - answer: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.', + answer: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.', questionHeader: 'Mitä kaikkea teknistä tää jäbä osas tehdä?', }, { @@ -178,8 +175,7 @@ const initTests = () => { { id: 2, type: 'text', - answer: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.', + answer: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.', questionHeader: 'Mitä kaikkea teknistä tää jäbä osas tehdä?', }, { @@ -227,8 +223,7 @@ const initTests = () => { { id: 2, type: 'text', - answer: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.', + answer: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.', questionHeader: 'Mitä kaikkea teknistä tää jäbä osas tehdä?', }, { @@ -271,8 +266,7 @@ const initTests = () => { { id: 2, type: 'text', - answer: - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.', + answer: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.', questionHeader: 'Mitä kaikkea teknistä tää jäbä osas tehdä?', }, { @@ -335,9 +329,7 @@ describe('Instructor page', () => { cy.get('[data-cy=configuration-selector]').click() cy.get('.configuration-menu-item').contains('Konfiguraatio 2').click() cy.contains('Kämmäilijät') - cy.contains( - "This group has not answered to the second peer review round yet." - ) + cy.contains('This group has not answered to the second peer review round yet.') cy.get('[data-cy=configuration-selector]').click() cy.get('.configuration-menu-item').contains('Konfiguraatio 1').click() cy.contains('4.00') @@ -370,18 +362,18 @@ describe('Instructor page', () => { cy.get('.configuration-menu-item').contains('Konfiguraatio 1').click() cy.get('[data-cy=group-selector]').click() cy.get('.specified-group-menu-item').contains('Tykittelijät').click() - + cy.contains('Student View').click() - cy.contains('Question View') + cy.contains('Question View') cy.contains('/ 1st Round') cy.contains('Tykittelijät') - + cy.contains('Question View').click() cy.contains('Student View') }) - + after(() => { cy.deleteAllGroups() cy.deleteAllPeerReviews() }) -}) \ No newline at end of file +}) diff --git a/frontend/e2e/cypress/integration/instructorReview.spec.js b/frontend/e2e/cypress/integration/instructorReview.spec.js index f795efd..7600745 100644 --- a/frontend/e2e/cypress/integration/instructorReview.spec.js +++ b/frontend/e2e/cypress/integration/instructorReview.spec.js @@ -15,13 +15,13 @@ const submitInstructorReview = () => { } const answerTextInput = (text, index) => { - cy.get(`[data-cy="textInput-Vertaisarvion arvosanat ja keskiarvo user:${index}"]`).first().within( - () => { - cy.get('textarea') + cy.get(`[data-cy="textInput-Vertaisarvion arvosanat ja keskiarvo user:${index}"]`) + .first() + .within(() => { + cy.get('textarea:not([aria-hidden="true"])') // .clear() .type(text) - } - ) + }) } const answerNumberInput = (number, index) => { cy.get(`[data-cy="numberInput-Tekninen kontribuutio: arvosana user:${index}"]`) @@ -31,34 +31,31 @@ const answerNumberInput = (number, index) => { const fillRemainingFields = (text, number, index) => { const textFieldNames = [ - "Vertaisarvion arvosanat ja keskiarvo", - "Poimintoja sanallisista vertaisarvioista", - "Ohjaajan kommentit", + 'Vertaisarvion arvosanat ja keskiarvo', + 'Poimintoja sanallisista vertaisarvioista', + 'Ohjaajan kommentit', ] const numberFieldNames = [ - "Tekninen kontribuutio: arvosana", - "Prosessin noudattaminen: arvosana", - "Prosessin kehittäminen: arvosana", - "Ryhmätyöskentely: arvosana", - "Asiakastyöskentely: arvosana", - "arvosana" + 'Tekninen kontribuutio: arvosana', + 'Prosessin noudattaminen: arvosana', + 'Prosessin kehittäminen: arvosana', + 'Ryhmätyöskentely: arvosana', + 'Asiakastyöskentely: arvosana', + 'arvosana', ] - // Without this the test doesn't work // if /api/instructorreview/getAllAnsweredGroupId // resolves during execution, filled textboxes reset cy.wait(5000) - textFieldNames.forEach(field => { - cy.get(`[data-cy="textInput-${field} user:${index}"]`).each($el => { + textFieldNames.forEach((field) => { + cy.get(`[data-cy="textInput-${field} user:${index}"]`).each(($el) => { cy.wait(50) - cy.wrap($el).find("textarea").type(text) + cy.wrap($el).find('textarea:not([aria-hidden="true"])').type(text) }) }) - numberFieldNames.forEach(field => { - cy.get(`[data-cy="numberInput-${field} user:${index}"]`) - .clear() - .type(number) + numberFieldNames.forEach((field) => { + cy.get(`[data-cy="numberInput-${field} user:${index}"]`).clear().type(number) }) } @@ -79,8 +76,8 @@ describe('Instructor review page', () => { it('shows the correct students to give reviews for', () => { cy.wait(1000) - cy.get("h2").should('contain', "Timo *Teppo Tellervo Testaaja") - cy.get("h2").should('contain', "Donald John Trump") + cy.get('h2').should('contain', 'Timo *Teppo Tellervo Testaaja') + cy.get('h2').should('contain', 'Donald John Trump') }) it('requires text fields to be filled', () => { @@ -91,7 +88,7 @@ describe('Instructor review page', () => { }) it('shows error when text fields are under 5 characters long', () => { - cy.contains("Timo *Teppo Tellervo Testaaja", { timeout: 10000 }).first().click() + cy.contains('Timo *Teppo Tellervo Testaaja', { timeout: 10000 }).first().click() answerTextInput('foo', 0) submitInstructorReview() @@ -99,47 +96,44 @@ describe('Instructor review page', () => { }) it('shows error when text fields are filled but there are other unfilled fields', () => { - cy.contains("Timo *Teppo Tellervo Testaaja", { timeout: 10000 }).first().click() - answerTextInput( - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.', - 0 - ) + cy.contains('Timo *Teppo Tellervo Testaaja', { timeout: 10000 }).first().click() + answerTextInput('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce at.', 0) submitInstructorReview() expectNotification('You must answer all questions') }) it('shows error when number fields are filled but are higher than 5', () => { - cy.contains("Timo *Teppo Tellervo Testaaja", { timeout: 10000 }).first().click() - fillRemainingFields("Lorem ipsum", 3, 0) + cy.contains('Timo *Teppo Tellervo Testaaja', { timeout: 10000 }).first().click() + fillRemainingFields('Lorem ipsum', 3, 0) answerNumberInput(6, 0) - cy.contains("Donald John Trump").first().click() - fillRemainingFields("Lorem ipsum", 3, 1) + cy.contains('Donald John Trump').first().click() + fillRemainingFields('Lorem ipsum', 3, 1) submitInstructorReview() expectNotification('Grade can not be over 5.') }) it('shows error when number fields are filled but are lower than 5', () => { - cy.contains("Timo *Teppo Tellervo Testaaja", { timeout: 10000 }).first().click() + cy.contains('Timo *Teppo Tellervo Testaaja', { timeout: 10000 }).first().click() - fillRemainingFields("Lorem ipsum", 3, 0) + fillRemainingFields('Lorem ipsum', 3, 0) answerNumberInput(-1, 0) - cy.contains("Donald John Trump").first().click() - fillRemainingFields("Lorem ipsum", 3, 1) + cy.contains('Donald John Trump').first().click() + fillRemainingFields('Lorem ipsum', 3, 1) submitInstructorReview() expectNotification('Number answer can not be negative') }) it('submits instructor review when all fields are filled', () => { - cy.contains("Timo *Teppo Tellervo Testaaja").first().click() - fillRemainingFields("Lorem ipsum", 5, 0) + cy.contains('Timo *Teppo Tellervo Testaaja').first().click() + fillRemainingFields('Lorem ipsum', 5, 0) - cy.contains("Donald John Trump").first().click() - fillRemainingFields("Lorem ipsum", 3, 1) + cy.contains('Donald John Trump').first().click() + fillRemainingFields('Lorem ipsum', 3, 1) submitInstructorReview() diff --git a/frontend/e2e/cypress/integration/menuItems.spec.js b/frontend/e2e/cypress/integration/menuItems.spec.js index 3d90a13..6cacb8c 100644 --- a/frontend/e2e/cypress/integration/menuItems.spec.js +++ b/frontend/e2e/cypress/integration/menuItems.spec.js @@ -1,6 +1,5 @@ /* eslint-disable */ - describe('Menu items for different user roles', () => { describe('Main menu of admin', () => { beforeEach(() => { @@ -8,13 +7,11 @@ describe('Menu items for different user roles', () => { cy.visit('/') }) - it('Admin should see admin menu items', () => { cy.get('#hamburger-menu-button') .click() .then(() => { cy.get('#hamburger-menu-popper').within(() => { - cy.contains('Admin').should('exist') cy.contains('Create Topic').should('exist') cy.contains('Topics').should('exist') @@ -30,7 +27,7 @@ describe('Menu items for different user roles', () => { cy.contains('Peer Review Questions').should('exist') cy.contains('Email Templates').should('exist') }) - }) + }) }) it('Admin should see instructor menu items', () => { @@ -46,7 +43,6 @@ describe('Menu items for different user roles', () => { }) }) - it('Admin should see student menu items', () => { cy.get('#hamburger-menu-button') .click() @@ -82,7 +78,6 @@ describe('Menu items for different user roles', () => { cy.visit('/') }) - it('Student should not see admin menu items', () => { cy.get('#hamburger-menu-button') .click() @@ -103,7 +98,7 @@ describe('Menu items for different user roles', () => { cy.contains('Peer Review Questions').should('not.exist') cy.contains('Email Templates').should('not.exist') }) - }) + }) }) it('Student should not see instructor menu items', () => { @@ -140,7 +135,6 @@ describe('Menu items for different user roles', () => { cy.visit('/') }) - it('Student without group should not see admin menu items', () => { cy.get('#hamburger-menu-button') .click() @@ -161,7 +155,7 @@ describe('Menu items for different user roles', () => { cy.contains('Peer Review Questions').should('not.exist') cy.contains('Email Templates').should('not.exist') }) - }) + }) }) it('Student without group should not see instructor menu items', () => { diff --git a/frontend/e2e/cypress/integration/pageAccess.spec.js b/frontend/e2e/cypress/integration/pageAccess.spec.js index 6b6aea6..c60bdf5 100644 --- a/frontend/e2e/cypress/integration/pageAccess.spec.js +++ b/frontend/e2e/cypress/integration/pageAccess.spec.js @@ -5,8 +5,8 @@ const assertIsOnLandingPage = () => { } const assertIsUnauthorized = () => { - cy.get("[class=unauthorized-page]").should('be.visible') - cy.contains("Unauthorized.") + cy.get('[class=unauthorized-page]').should('be.visible') + cy.contains('Unauthorized.') } const assertIsOnLoginPage = () => { diff --git a/frontend/e2e/cypress/integration/registrationQuestionsPage.spec.js b/frontend/e2e/cypress/integration/registrationQuestionsPage.spec.js index 575944c..f847c1e 100644 --- a/frontend/e2e/cypress/integration/registrationQuestionsPage.spec.js +++ b/frontend/e2e/cypress/integration/registrationQuestionsPage.spec.js @@ -3,10 +3,10 @@ const escapeJsonForCypressType = (json) => json.replace(/\{/g, '{{}') const submitCreationForm = (name, questionsJson) => { - cy.get('.question-set-form .question-set-form__name').type(name) - cy.get('.question-set-form .question-set-form__questions').type( - escapeJsonForCypressType(questionsJson) - ) + cy.get('.question-set-form .question-set-form__name input').type(name) + cy.get( + '.question-set-form .question-set-form__questions textarea:not([aria-hidden="true"])', + ).type(escapeJsonForCypressType(questionsJson)) cy.get('.question-set-form button[type="submit"]').click() } @@ -15,44 +15,34 @@ const createQuestionSet = (name, questions) => { } const editQuestionSet = (questionSetItemSelector) => { - cy.get(questionSetItemSelector) - .find('.question-set-item-controls__menu-button') - .click() + cy.get(questionSetItemSelector).find('.question-set-item-controls__menu-button').click() cy.get('#question-set-item-controls__menu') .find('.question-set-item-controls__edit-button') .click() } const replaceEditingQuestionSetName = (questionSetItemSelector, newName) => { - cy.get(questionSetItemSelector) - .find('.question-set-form__name') - .clear() - .type(newName) + cy.get(questionSetItemSelector).find('.question-set-form__name input').clear().type(newName) } const replaceEditingQuestionSetJson = (questionSetItemSelector, json) => { cy.get(questionSetItemSelector) - .find('.question-set-form__questions') + .find('.question-set-form__questions textarea:not([aria-hidden="true"])') .clear() .type(escapeJsonForCypressType(json)) } const replaceEditingQuestionSet = (questionSetItemSelector, newQuestions) => { - replaceEditingQuestionSetJson( - questionSetItemSelector, - JSON.stringify(newQuestions) - ) + replaceEditingQuestionSetJson(questionSetItemSelector, JSON.stringify(newQuestions)) } const clearEditingQuestionSetInputs = (selector) => { - cy.get(selector).find('.question-set-form__name').clear() - cy.get(selector).find('.question-set-form__questions').clear() + cy.get(selector).find('.question-set-form__name input').clear() + cy.get(selector).find('.question-set-form__questions textarea:not([aria-hidden="true"])').clear() } const saveEditingQuestionSet = (questionSetItemSelector) => { - cy.get(questionSetItemSelector) - .find('.question-set-item-editor__save-button') - .click() + cy.get(questionSetItemSelector).find('.question-set-item-editor__save-button').click() } const cancelEditingQuestionSet = (selector) => { @@ -73,21 +63,15 @@ describe('Registration-questions page', () => { it('creates a new registration question set', () => { createQuestionSet('k2000', [{ question: 'foo?', type: 'scale' }]) - cy.get('.notification').contains( - 'Created new registration question set "k2000"' - ) - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 1) - cy.get('.question-set-item .question-set-item__title').should( - 'have.text', - 'k2000' + cy.get('.notification').contains('Created new registration question set "k2000"') + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 1, ) + cy.get('.question-set-item .question-set-item__title').should('have.text', 'k2000') cy.get('.question-set-item .question-set-item__content').contains('foo?') cy.get('.question-set-item .question-set-item__content').contains('scale') - cy.get('.registration-question-set-list') - .find('.question-set-item') - .should('have.length', 1) + cy.get('.registration-question-set-list').find('.question-set-item').should('have.length', 1) }) it('creates questions of type scale, text and ', () => { @@ -102,9 +86,10 @@ describe('Registration-questions page', () => { { question: 'Your life story plz', type: 'text' }, ]) - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 3) + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 3, + ) cy.get('.question-set-item__content').contains('This is a title') cy.get('.question-set-item__content').contains('Rate your yeet 1-5') cy.get('.question-set-item__content').contains('scale') @@ -117,26 +102,20 @@ describe('Registration-questions page', () => { createQuestionSet('k2000', [{ question: 'foo?', type: 'scale' }]) cy.get('.notification').contains('name already in use') - cy.get('.registration-question-set-list') - .find('.question-set-item') - .should('have.length', 1) + cy.get('.registration-question-set-list').find('.question-set-item').should('have.length', 1) }) it('does not allow creation if JSON is malformed', () => { submitCreationForm('k3000', '.-a,1:"#123-') cy.get('.question-set-form').contains('Field contains invalid JSON') - cy.get('.registration-question-set-list') - .find('.question-set-item') - .should('have.length', 0) + cy.get('.registration-question-set-list').find('.question-set-item').should('have.length', 0) }) }) describe('Registration question set editing', () => { beforeEach(() => { - cy.createRegistrationQuestionSet('k2000', [ - { question: 'foo?', type: 'text' }, - ]) + cy.createRegistrationQuestionSet('k2000', [{ question: 'foo?', type: 'text' }]) cy.visit('/administration/registration-questions') }) @@ -152,10 +131,7 @@ describe('Registration-questions page', () => { it('shows error if new JSON is invalid', () => { editQuestionSet('.question-set-item') - replaceEditingQuestionSetJson( - '.question-set-item-editor', - '..-12.31-23.1-23.asdasc' - ) + replaceEditingQuestionSetJson('.question-set-item-editor', '..-12.31-23.1-23.asdasc') saveEditingQuestionSet('.question-set-item-editor') cy.get('.question-set-form').contains('Field contains invalid JSON') }) @@ -173,23 +149,23 @@ describe('Registration-questions page', () => { saveEditingQuestionSet('.question-set-item-editor') cy.get('.question-set-item__title').should('have.text', 'k2021') - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 1) + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 1, + ) cy.get('.question-set-item__content').contains('foo?') }) it('edits questions without changing name', () => { editQuestionSet('.question-set-item') - replaceEditingQuestionSet('.question-set-item-editor', [ - { question: 'foo!', type: 'text' }, - ]) + replaceEditingQuestionSet('.question-set-item-editor', [{ question: 'foo!', type: 'text' }]) saveEditingQuestionSet('.question-set-item-editor') cy.get('.question-set-item__title').should('have.text', 'k2000') - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 1) + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 1, + ) cy.get('.question-set-item__content').contains('foo!') cy.get('.question-set-item__content').contains('text') }) @@ -197,15 +173,14 @@ describe('Registration-questions page', () => { it('does not modify set if cancel is clicked', () => { editQuestionSet('.question-set-item') replaceEditingQuestionSetName('.question-set-item-editor', 'foobar') - replaceEditingQuestionSet('.question-set-item-editor', [ - { question: 'foo!', type: 'text' }, - ]) + replaceEditingQuestionSet('.question-set-item-editor', [{ question: 'foo!', type: 'text' }]) cancelEditingQuestionSet('.question-set-item-editor') cy.get('.question-set-item__title').should('have.text', 'k2000') - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 1) + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 1, + ) cy.get('.question-set-item__content').contains('foo?') cy.get('.question-set-item__content').contains('text') }) @@ -220,9 +195,10 @@ describe('Registration-questions page', () => { saveEditingQuestionSet('.question-set-item-editor') cy.get('.question-set-item__title').should('have.text', 'k5555') - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 2) + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 2, + ) cy.get('.question-set-item__content').contains('this is a title') cy.get('.question-set-item__content').contains('this is a scale') }) diff --git a/frontend/e2e/cypress/integration/reviewQuestionsPage.spec.js b/frontend/e2e/cypress/integration/reviewQuestionsPage.spec.js index 7ee567a..4487d6f 100644 --- a/frontend/e2e/cypress/integration/reviewQuestionsPage.spec.js +++ b/frontend/e2e/cypress/integration/reviewQuestionsPage.spec.js @@ -3,10 +3,10 @@ const escapeJsonForCypressType = (json) => json.replace(/\{/g, '{{}') const submitCreationForm = (name, questionsJson) => { - cy.get('.question-set-form .question-set-form__name').type(name) - cy.get('.question-set-form .question-set-form__questions').type( - escapeJsonForCypressType(questionsJson) - ) + cy.get('.question-set-form .question-set-form__name input').type(name) + cy.get( + '.question-set-form .question-set-form__questions textarea:not([aria-hidden="true"])', + ).type(escapeJsonForCypressType(questionsJson)) cy.get('.question-set-form button[type="submit"]').click() } @@ -15,44 +15,34 @@ const createQuestionSet = (name, questions) => { } const editQuestionSet = (questionSetItemSelector) => { - cy.get(questionSetItemSelector) - .find('.question-set-item-controls__menu-button') - .click() + cy.get(questionSetItemSelector).find('.question-set-item-controls__menu-button').click() cy.get('#question-set-item-controls__menu') .find('.question-set-item-controls__edit-button') .click() } const replaceEditingQuestionSetName = (questionSetItemSelector, newName) => { - cy.get(questionSetItemSelector) - .find('.question-set-form__name') - .clear() - .type(newName) + cy.get(questionSetItemSelector).find('.question-set-form__name input').clear().type(newName) } const replaceEditingQuestionSetJson = (questionSetItemSelector, json) => { cy.get(questionSetItemSelector) - .find('.question-set-form__questions') + .find('.question-set-form__questions textarea:not([aria-hidden="true"])') .clear() .type(escapeJsonForCypressType(json)) } const replaceEditingQuestionSet = (questionSetItemSelector, newQuestions) => { - replaceEditingQuestionSetJson( - questionSetItemSelector, - JSON.stringify(newQuestions) - ) + replaceEditingQuestionSetJson(questionSetItemSelector, JSON.stringify(newQuestions)) } const clearEditingQuestionSetInputs = (selector) => { - cy.get(selector).find('.question-set-form__name').clear() - cy.get(selector).find('.question-set-form__questions').clear() + cy.get(selector).find('.question-set-form__name input').clear() + cy.get(selector).find('.question-set-form__questions textarea:not([aria-hidden="true"])').clear() } const saveEditingQuestionSet = (questionSetItemSelector) => { - cy.get(questionSetItemSelector) - .find('.question-set-item-editor__save-button') - .click() + cy.get(questionSetItemSelector).find('.question-set-item-editor__save-button').click() } const cancelEditingQuestionSet = (selector) => { @@ -79,23 +69,18 @@ describe('Review-questions page', () => { }, ]) - cy.get('.notification').contains( - 'Created new peer review question set "No options tester 1"' + cy.get('.notification').contains('Created new peer review question set "No options tester 1"') + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 1, ) - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 1) cy.get('.question-set-item .question-set-item__title').should( 'have.text', - 'No options tester 1' - ) - cy.get('.question-set-item .question-set-item__content').contains( - 'Generate options 1 to 5' + 'No options tester 1', ) + cy.get('.question-set-item .question-set-item__content').contains('Generate options 1 to 5') cy.get('.question-set-item .question-set-item__content').contains('radio') - cy.get('.peer-review-question-set-list') - .find('.question-set-item') - .should('have.length', 1) + cy.get('.peer-review-question-set-list').find('.question-set-item').should('have.length', 1) }) it('creates questions set with options', () => { @@ -104,26 +89,16 @@ describe('Review-questions page', () => { header: 'Do we have a right header here?', description: 'I hope we do have a descirption also', type: 'radio', - options: [ - 'Dont know', - 'Not at all', - 'Little', - 'Decent', - 'Much', - 'Super', - ], + options: ['Dont know', 'Not at all', 'Little', 'Decent', 'Much', 'Super'], }, ]) - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 1) - cy.get('.question-set-item__content').contains( - 'Do we have a right header here?' - ) - cy.get('.question-set-item__content').contains( - 'I hope we do have a descirption also' + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 1, ) + cy.get('.question-set-item__content').contains('Do we have a right header here?') + cy.get('.question-set-item__content').contains('I hope we do have a descirption also') cy.get('.question-set-item__content').contains('radio') cy.get('.question-set-item__content').contains('Dont know') cy.get('.question-set-item__content').contains('Super') @@ -145,18 +120,14 @@ describe('Review-questions page', () => { }, ]) cy.get('.notification').contains('name already in use') - cy.get('.peer-review-question-set-list') - .find('.question-set-item') - .should('have.length', 1) + cy.get('.peer-review-question-set-list').find('.question-set-item').should('have.length', 1) }) it('does not allow creation if JSON is malformed', () => { submitCreationForm('Malformed json', '.-a,1:"#123-') cy.get('.question-set-form').contains('Field contains invalid JSON') - cy.get('.peer-review-question-set-list') - .find('.question-set-item') - .should('have.length', 0) + cy.get('.peer-review-question-set-list').find('.question-set-item').should('have.length', 0) }) }) @@ -171,14 +142,7 @@ describe('Review-questions page', () => { header: 'Do we have a right header here?', description: 'I hope we do have a descirption also', type: 'radio', - options: [ - 'Dont know', - 'Not at all', - 'Little', - 'Decent', - 'Much', - 'Super', - ], + options: ['Dont know', 'Not at all', 'Little', 'Decent', 'Much', 'Super'], }, ]) editQuestionSet('.question-set-item') @@ -199,10 +163,7 @@ describe('Review-questions page', () => { }, ]) editQuestionSet('.question-set-item') - replaceEditingQuestionSetJson( - '.question-set-item-editor', - '..-12.31-23.1-23.asdasc' - ) + replaceEditingQuestionSetJson('.question-set-item-editor', '..-12.31-23.1-23.asdasc') saveEditingQuestionSet('.question-set-item-editor') cy.get('.question-set-form').contains('Field contains invalid JSON') }) @@ -227,14 +188,7 @@ describe('Review-questions page', () => { header: 'Do we have a right header here?', description: 'I hope we do have a descirption also', type: 'radio', - options: [ - 'Dont know', - 'Not at all', - 'Little', - 'Decent', - 'Much', - 'Super', - ], + options: ['Dont know', 'Not at all', 'Little', 'Decent', 'Much', 'Super'], }, ]) editQuestionSet('.question-set-item') @@ -242,9 +196,10 @@ describe('Review-questions page', () => { saveEditingQuestionSet('.question-set-item-editor') cy.get('.question-set-item__title').should('have.text', 'New name') - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 1) + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 1, + ) cy.get('.question-set-item__content').contains('Little') }) @@ -266,13 +221,11 @@ describe('Review-questions page', () => { ]) saveEditingQuestionSet('.question-set-item-editor') - cy.get('.question-set-item__title').should( - 'have.text', - 'Number question tester' + cy.get('.question-set-item__title').should('have.text', 'Number question tester') + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 1, ) - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 1) cy.get('.question-set-item__content').contains('radio') }) @@ -296,9 +249,10 @@ describe('Review-questions page', () => { cancelEditingQuestionSet('.question-set-item-editor') cy.get('.question-set-item__title').should('have.text', 'Info tester') - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 1) + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 1, + ) cy.get('.question-set-item__content').contains('tester') cy.get('.question-set-item__content').contains('info') }) @@ -323,9 +277,10 @@ describe('Review-questions page', () => { saveEditingQuestionSet('.question-set-item-editor') cy.get('.question-set-item__title').should('have.text', 'New name 2') - cy.get( - '.question-set-item__content .registration-questions-table-row' - ).should('have.length', 1) + cy.get('.question-set-item__content .registration-questions-table-row').should( + 'have.length', + 1, + ) cy.get('.question-set-item__content').contains('Radio tester edited') cy.get('.question-set-item__content').contains('radio') }) diff --git a/frontend/e2e/cypress/integration/setPeerReview.spec.js b/frontend/e2e/cypress/integration/setPeerReview.spec.js index 6a2813e..61fd670 100644 --- a/frontend/e2e/cypress/integration/setPeerReview.spec.js +++ b/frontend/e2e/cypress/integration/setPeerReview.spec.js @@ -29,14 +29,7 @@ describe('Review-questions page', () => { header: 'Ok and with option', description: 'Choose a radio button you want', type: 'radio', - options: [ - 'Cant say', - 'Not at all', - 'Little', - 'Decent', - 'Good', - 'Super', - ], + options: ['Cant say', 'Not at all', 'Little', 'Decent', 'Good', 'Super'], }, ]) diff --git a/frontend/e2e/cypress/integration/staffTagPage.spec.js b/frontend/e2e/cypress/integration/staffTagPage.spec.js index 6cb32f2..133c967 100644 --- a/frontend/e2e/cypress/integration/staffTagPage.spec.js +++ b/frontend/e2e/cypress/integration/staffTagPage.spec.js @@ -60,7 +60,7 @@ describe('Staff tag page', () => { tags: ['Meeting'], groupId: createdGroup.id, }) - + cy.loginAsRegisteredIndicatedUser() cy.addTimelogEntryAlt({ studentNumber: '918273645', @@ -101,10 +101,7 @@ describe('Staff tag page', () => { cy.contains('Tag statistics').click() }) // Ignore ResizeObserver loop limit error which happens randomly - cy.on( - 'uncaught:exception', - (err) => !err.message.includes('ResizeObserver loop'), - ) + cy.on('uncaught:exception', (err) => !err.message.includes('ResizeObserver loop')) }) it('opens staff tag page', () => { @@ -129,20 +126,14 @@ describe('Staff tag page', () => { }) cy.contains('Tag usage for Brand New Group').should('exist') cy.get('#bar-Coding').trigger('mouseover') - cy.get('.recharts-tooltip-wrapper') - .should('be.visible') - .and('contain.text', '6 h') + cy.get('.recharts-tooltip-wrapper').should('be.visible').and('contain.text', '6 h') cy.get('#bar-Meeting').trigger('mouseover') - cy.get('.recharts-tooltip-wrapper') - .should('be.visible') - .and('contain.text', '6 h') + cy.get('.recharts-tooltip-wrapper').should('be.visible').and('contain.text', '6 h') - cy.get('#tag-usage-line-chart .recharts-cartesian-grid-vertical').trigger( - 'mouseover', - 'left', - { force: true }, - ) + cy.get('#tag-usage-line-chart .recharts-cartesian-grid-vertical').trigger('mouseover', 'left', { + force: true, + }) cy.get('.recharts-tooltip-wrapper') .should('be.visible') .and('contain.text', 'Coding : 6 h') @@ -177,20 +168,14 @@ describe('Staff tag page', () => { }) cy.contains('Tag usage for Volodymyr').should('exist') cy.get('#bar-Coding').trigger('mouseover') - cy.get('.recharts-tooltip-wrapper') - .should('be.visible') - .and('contain.text', '4 h') + cy.get('.recharts-tooltip-wrapper').should('be.visible').and('contain.text', '4 h') cy.get('#bar-Meeting').trigger('mouseover') - cy.get('.recharts-tooltip-wrapper') - .should('be.visible') - .and('contain.text', '3 h') + cy.get('.recharts-tooltip-wrapper').should('be.visible').and('contain.text', '3 h') - cy.get('#tag-usage-line-chart .recharts-cartesian-grid-vertical').trigger( - 'mouseover', - 'left', - { force: true }, - ) + cy.get('#tag-usage-line-chart .recharts-cartesian-grid-vertical').trigger('mouseover', 'left', { + force: true, + }) cy.get('.recharts-tooltip-wrapper') .should('be.visible') .and('contain.text', 'Coding : 4 h') @@ -207,10 +192,8 @@ describe('Staff tag page', () => { .and('contain.text', 'Meeting : 1 h') }) - after(() => { cy.deleteAllGroups() cy.deleteAllTags() }) - -}) \ No newline at end of file +}) diff --git a/frontend/e2e/cypress/integration/studentTagPage.spec.js b/frontend/e2e/cypress/integration/studentTagPage.spec.js index cb53a1a..2c7861d 100644 --- a/frontend/e2e/cypress/integration/studentTagPage.spec.js +++ b/frontend/e2e/cypress/integration/studentTagPage.spec.js @@ -77,10 +77,7 @@ describe('Student tag page', () => { cy.contains('Tags').click() }) // Ignore ResizeObserver loop limit error which happens randomly - cy.on( - 'uncaught:exception', - (err) => !err.message.includes('ResizeObserver loop'), - ) + cy.on('uncaught:exception', (err) => !err.message.includes('ResizeObserver loop')) }) it('opens student tag page', () => { @@ -94,22 +91,16 @@ describe('Student tag page', () => { it('displays correct amount of minutes for each tag in bar chart', () => { cy.get('#bar-Coding').trigger('mouseover') - cy.get('.recharts-tooltip-wrapper') - .should('be.visible') - .and('contain.text', '2 h') + cy.get('.recharts-tooltip-wrapper').should('be.visible').and('contain.text', '2 h') cy.get('#bar-Meeting').trigger('mouseover') - cy.get('.recharts-tooltip-wrapper') - .should('be.visible') - .and('contain.text', '3 h') + cy.get('.recharts-tooltip-wrapper').should('be.visible').and('contain.text', '3 h') }) it('displays correct amount of minutes for each tag in line chart', () => { - cy.get('#tag-usage-line-chart .recharts-cartesian-grid-vertical').trigger( - 'mouseover', - 'left', - { force: true }, - ) + cy.get('#tag-usage-line-chart .recharts-cartesian-grid-vertical').trigger('mouseover', 'left', { + force: true, + }) cy.get('.recharts-tooltip-wrapper') .should('be.visible') .and('contain.text', 'Coding : 2 h') diff --git a/frontend/e2e/cypress/integration/tagManagement.spec.js b/frontend/e2e/cypress/integration/tagManagement.spec.js index e9e559e..b816013 100644 --- a/frontend/e2e/cypress/integration/tagManagement.spec.js +++ b/frontend/e2e/cypress/integration/tagManagement.spec.js @@ -1,7 +1,6 @@ /* eslint-disable */ describe('Tag management', () => { - beforeEach(() => { cy.loginAsAdmin() cy.visit('/') @@ -14,7 +13,6 @@ describe('Tag management', () => { cy.contains('Tag management').click() }) cy.contains('Add new tag').should('exist') - }) it('admin can add a new tag', () => { cy.get('#hamburger-menu-button') @@ -70,7 +68,7 @@ describe('Tag management', () => { cy.contains('Yes').click() cy.contains('New tag').should('not.exist') }) - // missing test: tag associated with existing time log cannot be deleted + // missing test: tag associated with existing time log cannot be deleted // is not tested. This is because the test would require a time log to be created and associated with a tag.' // and cannot be done before adding tag to time logs front end is implemented. // all backend functionality is there diff --git a/frontend/e2e/cypress/integration/theme.spec.js b/frontend/e2e/cypress/integration/theme.spec.js index deb1be6..ca519f7 100644 --- a/frontend/e2e/cypress/integration/theme.spec.js +++ b/frontend/e2e/cypress/integration/theme.spec.js @@ -12,7 +12,7 @@ describe('Theme switch', () => { cy.get('body').should(($body) => { const bg = getComputedStyle($body[0]).backgroundColor - expect(bg).to.equal('rgb(250, 250, 250)') + expect(bg).to.equal('rgb(255, 255, 255)') }) }) @@ -26,7 +26,7 @@ describe('Theme switch', () => { cy.window().its('localStorage.theme').should('eq', 'dark') cy.get('body').should(($body) => { const bg = getComputedStyle($body[0]).backgroundColor - expect(bg).to.equal('rgb(48, 48, 48)') + expect(bg).to.equal('rgb(18, 18, 18)') }) }) diff --git a/frontend/e2e/cypress/integration/timeLogs.spec.js b/frontend/e2e/cypress/integration/timeLogs.spec.js index 316b3e0..47371e1 100644 --- a/frontend/e2e/cypress/integration/timeLogs.spec.js +++ b/frontend/e2e/cypress/integration/timeLogs.spec.js @@ -29,10 +29,10 @@ describe('Time logs & sprints', () => { beforeEach(() => { cy.loginAsRegisteredUser() cy.visit('/') - cy.get("h4", { timeout: 15000 }) - .should("include.text", "Brand New Group") - .should("include.text", "testertester3") - cy.get(".registration-details-container").should("exist") + cy.get('h4', { timeout: 15000 }) + .should('include.text', 'Brand New Group') + .should('include.text', 'testertester3') + cy.get('.registration-details-container').should('exist') }) it('add 2 sprints', () => { @@ -42,8 +42,7 @@ describe('Time logs & sprints', () => { cy.contains('Sprint Dashboard').click() }) - - cy.get("h4").should("include.text", "Add new sprint") + cy.get('h4').should('include.text', 'Add new sprint') const dateToday = new Date() const dateYesterday = addDaysToDate(dateToday, -1) @@ -52,14 +51,14 @@ describe('Time logs & sprints', () => { cy.get('#startDate').type(formatDate(addWeeksToDate(dateYesterday, -1))) cy.get('#endDate').type(formatDate(dateYesterday)) cy.get('#add-sprint-button').click() - cy.get("[data-cy=sprint-1]").should("exist") - + cy.get('[data-cy=sprint-1]').should('exist') + cy.get('#sprintNumber').type('2') cy.get('#startDate').type(formatDate(dateToday)) cy.get('#endDate').type(formatDate(addWeeksToDate(dateToday, 1))) cy.get('#add-sprint-button').click() - cy.get("[data-cy=sprint-2]").should("exist") + cy.get('[data-cy=sprint-2]').should('exist') }) it('renders current sprint by default', () => { @@ -68,7 +67,7 @@ describe('Time logs & sprints', () => { .then(() => { cy.contains('Time Log').click() }) - cy.get("h4", { timeout: 15000 }).should("include.text", "Time Logs") + cy.get('h4', { timeout: 15000 }).should('include.text', 'Time Logs') cy.get('.timelogs-sprint-select').contains('SPRINT 2') }) @@ -80,7 +79,7 @@ describe('Time logs & sprints', () => { cy.contains('Time Log').click() }) - cy.get("h4", { timeout: 15000 }).should("include.text", "Time Logs") + cy.get('h4', { timeout: 15000 }).should('include.text', 'Time Logs') cy.get('#previous-sprint-button').click() cy.get('#date').should('be.disabled') @@ -96,28 +95,24 @@ describe('Time logs & sprints', () => { cy.contains('Time Log').click() }) - cy.get("h4", { timeout: 15000 }).should("include.text", "Time Logs") + cy.get('h4', { timeout: 15000 }).should('include.text', 'Time Logs') cy.get('#date').type(formatDate(new Date())) cy.get('#time').type('01:00') cy.get('#description').type('test description 1') cy.get('#time-log-submit-button').click() - cy.get('.notification') - .should('exist') - .should('have.text', 'Time log created successfully') + cy.get('.notification').should('exist').should('have.text', 'Time log created successfully') cy.get('#date').type(formatDate(addDaysToDate(new Date(), 1))) cy.get('#time').type('02:00') cy.get('#description').type('test description 2') cy.get('#time-log-submit-button').click() - cy.get('.notification') - .should('exist') - .should('have.text', 'Time log created successfully') + cy.get('.notification').should('exist').should('have.text', 'Time log created successfully') - cy.get("#timelog-rows").should('include.text', "test description 1") - cy.get("#timelog-rows").should('include.text', "test description 2") + cy.get('#timelog-rows').should('include.text', 'test description 1') + cy.get('#timelog-rows').should('include.text', 'test description 2') }) it('should display 2 time logs', () => { @@ -127,7 +122,7 @@ describe('Time logs & sprints', () => { cy.contains('Time Log').click() }) - cy.get("h4", { timeout: 15000 }).should("include.text", "Time Logs") + cy.get('h4', { timeout: 15000 }).should('include.text', 'Time Logs') cy.get('.timelogs-container-1', { timeout: 15000 }).should('contain', 'test description 1') cy.get('.timelogs-container-1', { timeout: 15000 }).should('contain', 'test description 2') @@ -137,7 +132,7 @@ describe('Time logs & sprints', () => { it('shows error from backend when creating timeLog fails with data outside sprint', () => { cy.visit('/timelogs') - cy.get("h4", { timeout: 15000 }).should("include.text", "Time Logs") + cy.get('h4', { timeout: 15000 }).should('include.text', 'Time Logs') cy.get('.timelogs-container-1').should('exist') cy.get('.input-container').should('exist') @@ -149,7 +144,7 @@ describe('Time logs & sprints', () => { cy.get('.notification').should('exist') cy.get('.notification').should( 'have.text', - 'The log date is not within sprint start and end date.' + 'The log date is not within sprint start and end date.', ) }) @@ -160,7 +155,7 @@ describe('Time logs & sprints', () => { cy.contains('Time Log').click() }) - cy.get("h4", { timeout: 15000 }).should("include.text", "Time Logs") + cy.get('h4', { timeout: 15000 }).should('include.text', 'Time Logs') cy.get('.timelogs-container-1').should('contain', 'test description 2') cy.get('#previous-sprint-button').click() @@ -170,33 +165,24 @@ describe('Time logs & sprints', () => { it('asks for confirmation before deleting a time log and aborts deletion when canceled', () => { cy.get('#hamburger-menu-button') - .click() - .then(() => { - cy.contains('Time Log').click() - }) - - cy.get("h4", { timeout: 15000 }).should("include.text", "Time Logs") - - cy.get('.timelogs-description') - .first() - .invoke('text') - .as('testedLogDescription') - - cy.get('#timelog-rows') - .find('[id^="timelog-remove-button-"]') - .first() .click() - cy.get('.confirmation-dialog').should( - 'contain', - 'Delete this time log? It cannot be restored.' - ) + .then(() => { + cy.contains('Time Log').click() + }) + + cy.get('h4', { timeout: 15000 }).should('include.text', 'Time Logs') + + cy.get('.timelogs-description').first().invoke('text').as('testedLogDescription') + + cy.get('#timelog-rows').find('[id^="timelog-remove-button-"]').first().click() + cy.get('.confirmation-dialog').should('contain', 'Delete this time log? It cannot be restored.') cy.get('.confirmation-dialog').find('#confirmation-dialog-no-button').click() cy.get('@testedLogDescription').then((testedLogDescription) => { cy.get('#timelog-rows') - .find(".timelogs-description") + .find('.timelogs-description') .first() - .should("be.text", testedLogDescription) + .should('be.text', testedLogDescription) }) cy.get('#timelog-rows').children().should('have.length', 2) }) @@ -208,28 +194,21 @@ describe('Time logs & sprints', () => { cy.contains('Time Log').click() }) - cy.get("h4", { timeout: 15000 }).should("include.text", "Time Logs") + cy.get('h4', { timeout: 15000 }).should('include.text', 'Time Logs') - cy.get('#timelog-rows') - .find('[id^="timelog-remove-button-"]') - .first() - .click() + cy.get('#timelog-rows').find('[id^="timelog-remove-button-"]').first().click() - cy.get('.confirmation-dialog').should( - 'contain', - 'Delete this time log? It cannot be restored.' - ) + cy.get('.confirmation-dialog').should('contain', 'Delete this time log? It cannot be restored.') cy.get('.confirmation-dialog').find('#confirmation-dialog-yes-button').click() - cy.get('.timelogs-description') - .should('not.contain.text', "test description 2") + cy.get('.timelogs-description').should('not.contain.text', 'test description 2') cy.get('#timelog-rows').children().should('have.length', 1) }) it('displays error on time field of form when input is negative hours', () => { cy.visit('/timelogs') - cy.get("h4", { timeout: 15000 }).should("include.text", "Time Logs") + cy.get('h4', { timeout: 15000 }).should('include.text', 'Time Logs') cy.get('.timelogs-container-1').should('exist') cy.get('.input-container').should('exist') @@ -244,7 +223,7 @@ describe('Time logs & sprints', () => { it('displays error on time field of form when input is letters', () => { cy.visit('/timelogs') - cy.get("h4", { timeout: 15000 }).should("include.text", "Time Logs") + cy.get('h4', { timeout: 15000 }).should('include.text', 'Time Logs') cy.get('.timelogs-container-1').should('exist') cy.get('.input-container').should('exist') @@ -259,7 +238,7 @@ describe('Time logs & sprints', () => { it('displays error on time field of form when input is missing a colon', () => { cy.visit('/timelogs') - cy.get("h4", { timeout: 15000 }).should("include.text", "Time Logs") + cy.get('h4', { timeout: 15000 }).should('include.text', 'Time Logs') cy.get('.timelogs-container-1').should('exist') cy.get('.input-container').should('exist') @@ -274,7 +253,7 @@ describe('Time logs & sprints', () => { it('displays error on time field of form when input has over 60 minutes', () => { cy.visit('/timelogs') - cy.get("h4", { timeout: 15000 }).should("include.text", "Time Logs") + cy.get('h4', { timeout: 15000 }).should('include.text', 'Time Logs') cy.get('.timelogs-container-1').should('exist') cy.get('.input-container').should('exist') @@ -289,7 +268,7 @@ describe('Time logs & sprints', () => { it('displays error on description field of form when input is under 5 characters long', () => { cy.visit('/timelogs') - cy.get("h4", { timeout: 15000 }).should("include.text", "Time Logs") + cy.get('h4', { timeout: 15000 }).should('include.text', 'Time Logs') cy.get('.timelogs-container-1').should('exist') cy.get('.input-container').should('exist') @@ -308,12 +287,9 @@ describe('Time logs & sprints', () => { .then(() => { cy.contains('Sprint Dashboard').click() }) - cy.get("h4", { timeout: 15000 }).should("include.text", "Add new sprint") + cy.get('h4', { timeout: 15000 }).should('include.text', 'Add new sprint') - cy.get('.sprints-container') - .find('[id^="sprint-remove-button-"]') - .last() - .click() + cy.get('.sprints-container').find('[id^="sprint-remove-button-"]').last().click() cy.get('.sprints-container') .find('[id^="sprint-remove-button-"]') @@ -321,24 +297,22 @@ describe('Time logs & sprints', () => { .click() .then(() => { cy.get('.notification').should('exist') - cy.get('[data-testid="notification-message"]', { timeout: 10000 }).should('contain', 'Sprint has time logs, cannot delete.') - } - ) + cy.get('[data-testid="notification-message"]', { timeout: 10000 }).should( + 'contain', + 'Sprint has time logs, cannot delete.', + ) + }) }) - it('remove sprints, should not display sprints or time logs', () => { cy.get('#hamburger-menu-button') - .click() - .then(() => { - cy.contains('Time Log').click() - }) - cy.get("h4", { timeout: 15000 }).should("include.text", "Time Logs") - - cy.get('#timelog-rows') - .find('[id^="timelog-remove-button-"]') - .first() .click() + .then(() => { + cy.contains('Time Log').click() + }) + cy.get('h4', { timeout: 15000 }).should('include.text', 'Time Logs') + + cy.get('#timelog-rows').find('[id^="timelog-remove-button-"]').first().click() cy.get('.confirmation-dialog').should('contain', 'Delete this time log? It cannot be restored.') cy.get('.confirmation-dialog').find('#confirmation-dialog-yes-button').click() @@ -349,14 +323,12 @@ describe('Time logs & sprints', () => { .then(() => { cy.contains('Sprint Dashboard').click() }) - cy.get("h4", { timeout: 15000 }).should("include.text", "Add new sprint") + cy.get('h4', { timeout: 15000 }).should('include.text', 'Add new sprint') cy.get('.sprints-container') .find('[id^="sprint-remove-button-"]') .click({ multiple: true }) - .then(() => - cy.get('#app-content').should('not.contain', '.sprint-list-container') - ) + .then(() => cy.get('#app-content').should('not.contain', '.sprint-list-container')) cy.get('#hamburger-menu-button') .click() @@ -365,7 +337,7 @@ describe('Time logs & sprints', () => { }) cy.get('#app-content', { timeout: 15000 }).should( 'contain', - 'Your group has no sprints. Add a sprint using Sprint Dashboard.' + 'Your group has no sprints. Add a sprint using Sprint Dashboard.', ) }) diff --git a/frontend/e2e/cypress/integration/topicListPage.spec.js b/frontend/e2e/cypress/integration/topicListPage.spec.js index b543579..67ad480 100644 --- a/frontend/e2e/cypress/integration/topicListPage.spec.js +++ b/frontend/e2e/cypress/integration/topicListPage.spec.js @@ -2,40 +2,26 @@ const visitTopicsPage = (visitArgs) => cy.visit('/topics', visitArgs) const findTopicActiveCheckbox = (topicName) => - cy - .get(`[data-cy-topic-name="${topicName}"]`) - .find('[data-cy="toggle-active"]') + cy.get(`[data-cy-topic-name="${topicName}"]`).find('[data-cy="toggle-active"] input') const getSendAcceptButton = (topicName) => - cy - .get(`[data-cy-topic-name="${topicName}"]`) - .find('[data-cy="send-accept-mail"]') + cy.get(`[data-cy-topic-name="${topicName}"]`).find('[data-cy="send-accept-mail"]') const getSendRejectButton = (topicName) => - cy - .get(`[data-cy-topic-name="${topicName}"]`) - .find('[data-cy="send-reject-mail"]') + cy.get(`[data-cy-topic-name="${topicName}"]`).find('[data-cy="send-reject-mail"]') const getSendReviewLinkButton = (topicName) => - cy - .get(`[data-cy-topic-name="${topicName}"]`) - .find('[data-cy="send-customer-review-link-email"]') + cy.get(`[data-cy-topic-name="${topicName}"]`).find('[data-cy="send-customer-review-link-email"]') -const clickSendAcceptEmail = (topicName) => - getSendAcceptButton(topicName).click() +const clickSendAcceptEmail = (topicName) => getSendAcceptButton(topicName).click() -const clickSendRejectEmail = (topicName) => - getSendRejectButton(topicName).click() +const clickSendRejectEmail = (topicName) => getSendRejectButton(topicName).click() -const clickSendReviewLinkEmail = (topicName) => - getSendReviewLinkButton(topicName).click() +const clickSendReviewLinkEmail = (topicName) => getSendReviewLinkButton(topicName).click() /** @param {'finnish' | 'english'} language */ const clickEmailLanguage = (language) => - cy - .get('[data-cy="email-language-menu"]') - .find(`[data-cy-send-mail-lang="${language}"]`) - .click() + cy.get('[data-cy="email-language-menu"]').find(`[data-cy-send-mail-lang="${language}"]`).click() describe('Topic list page', () => { beforeEach(() => { @@ -49,8 +35,7 @@ describe('Topic list page', () => { }) it('renders the configuration selector', () => { - cy.get('[data-cy="configurations-filter"]') - .should('be.visible') + cy.get('[data-cy="configurations-filter"]').should('be.visible') }) it('renders option "All configurations"', () => { @@ -71,11 +56,7 @@ describe('Topic list page', () => { .eq(1) .should('be.visible') .and('include.text', '2024 Spring') - cy.get('ul') - .children() - .eq(2) - .should('be.visible') - .and('include.text', '2023 Autumn') + cy.get('ul').children().eq(2).should('be.visible').and('include.text', '2023 Autumn') }) }) @@ -90,9 +71,7 @@ describe('Topic list page', () => { }) it('after loading the topics page, message should be rendered without topics', () => { - cy.get('h1') - .should('be.visible') - .and('have.text', 'None available') + cy.get('h1').should('be.visible').and('have.text', 'None available') }) }) @@ -131,9 +110,7 @@ describe('Topic list page', () => { it('toggles topic active state correctly', () => { // get initial checked state findTopicActiveCheckbox(toggleTestTopicName).then(($input) => { - const desiredState = $input.prop('checked') - ? 'not.be.checked' - : 'be.checked' + const desiredState = $input.prop('checked') ? 'not.be.checked' : 'be.checked' // toggle active findTopicActiveCheckbox(toggleTestTopicName).click() @@ -152,26 +129,16 @@ describe('Topic list page', () => { }) it('renders correct number of topics', () => { - cy.get('tbody') - .children() - .should('have.length', 5) + cy.get('tbody').children().should('have.length', 5) }) it('renders topics in correct order', () => { - cy.get('tbody') - .children() - .eq(0) - .invoke('attr','data-cy-topic-name') - .should('eq', 'Aihe A') - cy.get('tbody') - .children() - .eq(1) - .invoke('attr','data-cy-topic-name') - .should('eq', 'Aihe B') + cy.get('tbody').children().eq(0).invoke('attr', 'data-cy-topic-name').should('eq', 'Aihe A') + cy.get('tbody').children().eq(1).invoke('attr', 'data-cy-topic-name').should('eq', 'Aihe B') cy.get('tbody') .children() .eq(2) - .invoke('attr','data-cy-topic-name') + .invoke('attr', 'data-cy-topic-name') .should('eq', 'Ohjelmistotuotantoprojektin laajennus') }) }) @@ -188,24 +155,22 @@ describe('Topic list page', () => { cy.updateAllEmailTemplates({ topicAccepted: { finnish: 'Projekti {{topicName}} hyväksytty.', - english: 'Project {{topicName}} was accepted.' + english: 'Project {{topicName}} was accepted.', }, topicRejected: { finnish: 'Projekti {{topicName}} hylätty.', - english: 'Project {{topicName}} was rejected.' + english: 'Project {{topicName}} was rejected.', }, customerReviewLink: { - finnish: - 'Arviointi on nyt auki projektille {{topicName}} osoitteessa {{secretLink}}', - english: - 'Review is now open for project {{topicName}}, go to {{secretLink}}' - } + finnish: 'Arviointi on nyt auki projektille {{topicName}} osoitteessa {{secretLink}}', + english: 'Review is now open for project {{topicName}}, go to {{secretLink}}', + }, }) visitTopicsPage({ // spy window.confirm for email preview tests onBeforeLoad(win) { cy.spy(win, 'confirm') - } + }, }) cy.wait(2500) cy.get('[data-cy="configurations-filter"]').click() @@ -298,14 +263,10 @@ describe('Topic list page', () => { cy.wait(2500) cy.get('[data-cy="acceptance-filter-rejected"]').click() cy.wait(2500) - cy.get('h1') - .should('be.visible') - .and('have.text', 'None available') + cy.get('h1').should('be.visible').and('have.text', 'None available') cy.get('[data-cy="acceptance-filter-accepted"]').click() cy.wait(2500) - cy.get('h1') - .should('be.visible') - .and('have.text', 'None available') + cy.get('h1').should('be.visible').and('have.text', 'None available') }) it('shows only accepted topics after filtering', () => { clickSendAcceptEmail('Aihe A') @@ -351,9 +312,7 @@ describe('Topic list page', () => { .its('confirm') .should((confirmSpy) => { expect(confirmSpy).to.be.calledOnce - expect(confirmSpy.getCall(0).args[0]).to.contain( - `Projekti ${topicName} hyväksytty.` - ) + expect(confirmSpy.getCall(0).args[0]).to.contain(`Projekti ${topicName} hyväksytty.`) }) }) @@ -364,9 +323,7 @@ describe('Topic list page', () => { .its('confirm') .should((confirmSpy) => { expect(confirmSpy).to.be.calledOnce - expect(confirmSpy.getCall(0).args[0]).to.contain( - `Project ${topicName} was accepted.` - ) + expect(confirmSpy.getCall(0).args[0]).to.contain(`Project ${topicName} was accepted.`) }) }) @@ -377,9 +334,7 @@ describe('Topic list page', () => { .its('confirm') .should((confirmSpy) => { expect(confirmSpy).to.be.calledOnce - expect(confirmSpy.getCall(0).args[0]).to.contain( - `Projekti ${topicName} hylätty.` - ) + expect(confirmSpy.getCall(0).args[0]).to.contain(`Projekti ${topicName} hylätty.`) }) }) @@ -390,9 +345,7 @@ describe('Topic list page', () => { .its('confirm') .should((confirmSpy) => { expect(confirmSpy).to.be.calledOnce - expect(confirmSpy.getCall(0).args[0]).to.contain( - `Project ${topicName} was rejected.` - ) + expect(confirmSpy.getCall(0).args[0]).to.contain(`Project ${topicName} was rejected.`) }) }) @@ -404,7 +357,7 @@ describe('Topic list page', () => { .should((confirmSpy) => { expect(confirmSpy).to.be.calledOnce expect(confirmSpy.getCall(0).args[0]).to.contain( - `Arviointi on nyt auki projektille ${topicName} osoitteessa ${secretReviewLink}` + `Arviointi on nyt auki projektille ${topicName} osoitteessa ${secretReviewLink}`, ) }) }) @@ -417,7 +370,7 @@ describe('Topic list page', () => { .should((confirmSpy) => { expect(confirmSpy).to.be.calledOnce expect(confirmSpy.getCall(0).args[0]).to.contain( - `Review is now open for project ${topicName}, go to ${secretReviewLink}` + `Review is now open for project ${topicName}, go to ${secretReviewLink}`, ) }) }) diff --git a/frontend/e2e/cypress/integration/viewCustomerReviewsPage.spec.js b/frontend/e2e/cypress/integration/viewCustomerReviewsPage.spec.js index 04075e2..efb9082 100644 --- a/frontend/e2e/cypress/integration/viewCustomerReviewsPage.spec.js +++ b/frontend/e2e/cypress/integration/viewCustomerReviewsPage.spec.js @@ -33,8 +33,7 @@ const mockAnswers = [ type: 'text', answer: 'Your satisfaction to the resulting product compared to your intial expectations:Your satisfaction to the resulting product compared to your intial expectations:', - questionHeader: - 'What was the technical skill level of the team compared to your expectations?', + questionHeader: 'What was the technical skill level of the team compared to your expectations?', }, { id: 5, @@ -87,7 +86,7 @@ describe('Customer review is shown', () => { specialRequests: '', additionalInfo: '', }, - configuration1.id + configuration1.id, ).as('conf1_topic1') cy.get('@conf1_topic1').then((topic1) => { @@ -112,7 +111,7 @@ describe('Customer review is shown', () => { specialRequests: '', additionalInfo: '', }, - configuration2.id + configuration2.id, ).as('conf2_topic1') cy.createTopic( @@ -125,7 +124,7 @@ describe('Customer review is shown', () => { specialRequests: '', additionalInfo: '', }, - configuration2.id + configuration2.id, ).as('conf2_topic2') getAll('@conf2_topic1', '@conf2_topic2').spread((topic1, topic2) => { @@ -187,8 +186,7 @@ describe('Customer review is shown', () => { cy.get('[data-cy="customer-reviews-select"]').click() cy.get('[data-cy="all-configurations"]').click() - const { conf1_topic1_group, conf2_topic1_group, conf2_topic2_group } = - locals + const { conf1_topic1_group, conf2_topic1_group, conf2_topic2_group } = locals cy.contains(conf1_topic1_group.name) cy.contains(conf2_topic1_group.name) diff --git a/frontend/e2e/cypress/support/index.js b/frontend/e2e/cypress/support/index.js index 6dbf6d7..21b2a4b 100644 --- a/frontend/e2e/cypress/support/index.js +++ b/frontend/e2e/cypress/support/index.js @@ -23,14 +23,14 @@ const postLogin = (user) => { return cy.request({ url: '/api/login', method: 'POST', - headers + headers, }) } const loginAsUser = (user) => { postLogin(user).then((res) => { const userData = res.body - cy.window().then(win => { + cy.window().then((win) => { win.localStorage.setItem('loggedInUser', JSON.stringify(userData)) }) }) @@ -84,13 +84,13 @@ const withLoggedAdminTokenSuperHack = () => { Cypress.Commands.add('deleteRegistrationQuestions', () => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/registrationQuestions', method: 'GET', - headers: authHeaders + headers: authHeaders, }).then((res) => { const { questionSets } = res.body @@ -98,7 +98,7 @@ Cypress.Commands.add('deleteRegistrationQuestions', () => { cy.request({ url: `/api/registrationQuestions/${set.id}`, method: 'DELETE', - headers: authHeaders + headers: authHeaders, }) } }) @@ -108,7 +108,7 @@ Cypress.Commands.add('deleteRegistrationQuestions', () => { Cypress.Commands.add('createRegistrationQuestionSet', (name, questions) => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ @@ -117,8 +117,8 @@ Cypress.Commands.add('createRegistrationQuestionSet', (name, questions) => { headers: authHeaders, body: { name, - questions - } + questions, + }, }) }) }) @@ -126,13 +126,13 @@ Cypress.Commands.add('createRegistrationQuestionSet', (name, questions) => { Cypress.Commands.add('deleteReviewQuestions', () => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/reviewQuestions', method: 'GET', - headers: authHeaders + headers: authHeaders, }).then((res) => { const { questionSets } = res.body @@ -140,7 +140,7 @@ Cypress.Commands.add('deleteReviewQuestions', () => { cy.request({ url: `/api/reviewQuestions/${set.id}`, method: 'DELETE', - headers: authHeaders + headers: authHeaders, }) } }) @@ -150,7 +150,7 @@ Cypress.Commands.add('deleteReviewQuestions', () => { Cypress.Commands.add('createReviewQuestionSet', (name, questions) => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ @@ -159,8 +159,8 @@ Cypress.Commands.add('createReviewQuestionSet', (name, questions) => { headers: authHeaders, body: { name, - questions - } + questions, + }, }) }) }) @@ -168,57 +168,54 @@ Cypress.Commands.add('createReviewQuestionSet', (name, questions) => { Cypress.Commands.add('deleteAllGroups', () => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/groups', method: 'GET', - headers: authHeaders + headers: authHeaders, }).then((res) => { const allGroups = res.body for (const group of allGroups) { cy.request({ url: `/api/groups/${group.id}`, method: 'DELETE', - headers: authHeaders + headers: authHeaders, }) } }) }) }) -Cypress.Commands.add( - 'createNewTopic', - (newTopicName, customerName, topicDescription) => { - withLoggedAdminToken((token) => { - const authHeaders = { - Authorization: 'Bearer ' + token - } - cy.request({ - url: '/api/topics', - method: 'POST', - headers: authHeaders, - active: true, - body: { - content: { - email: 'asiakas@asiakas.com', - title: newTopicName, - description: topicDescription, - environment: 'Web', - customerName: customerName, - additionalInfo: '', - specialRequests: '' - } - } - }) +Cypress.Commands.add('createNewTopic', (newTopicName, customerName, topicDescription) => { + withLoggedAdminToken((token) => { + const authHeaders = { + Authorization: 'Bearer ' + token, + } + cy.request({ + url: '/api/topics', + method: 'POST', + headers: authHeaders, + active: true, + body: { + content: { + email: 'asiakas@asiakas.com', + title: newTopicName, + description: topicDescription, + environment: 'Web', + customerName: customerName, + additionalInfo: '', + specialRequests: '', + }, + }, }) - } -) + }) +}) Cypress.Commands.add('setTopicActive', (topicId) => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: `api/topics/${topicId}`, @@ -226,9 +223,9 @@ Cypress.Commands.add('setTopicActive', (topicId) => { headers: authHeaders, body: { topic: { - active: true - } - } + active: true, + }, + }, }) }) }) @@ -238,7 +235,7 @@ Cypress.Commands.add( (configurationName, configurationId, questionSetName) => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } findReviewQuestionId(authHeaders, questionSetName).then((setId) => { cy.request({ @@ -247,8 +244,8 @@ Cypress.Commands.add( headers: authHeaders, body: { name: configurationName, - review_question_set1_id: setId - } + review_question_set1_id: setId, + }, }) cy.request({ url: '/api/registrationManagement', @@ -262,35 +259,34 @@ Cypress.Commands.add( project_registration_conf: 1, project_registration_open: true, project_registration_message: '', - project_registration_info: - 'Project registration will be open until DD.MM.2019.', + project_registration_info: 'Project registration will be open until DD.MM.2019.', topic_registration_conf: 1, topic_registration_open: true, - topic_registration_message: '' - } - } + topic_registration_message: '', + }, + }, }) }) }) - } + }, ) Cypress.Commands.add('deleteAllPeerReviews', () => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/peerreview/all', method: 'GET', - headers: authHeaders + headers: authHeaders, }).then((res) => { const allReviews = res.body for (const review of allReviews) { cy.request({ url: `/api/peerreview/${review.id}`, method: 'DELETE', - headers: authHeaders + headers: authHeaders, }) } }) @@ -302,7 +298,7 @@ const findReviewQuestionId = (authHeaders, questionSetName) => { .request({ url: '/api/reviewQuestions', method: 'GET', - headers: authHeaders + headers: authHeaders, }) .then((res) => { const { questionSets } = res.body @@ -318,53 +314,50 @@ const findReviewQuestionId = (authHeaders, questionSetName) => { Cypress.Commands.add('deleteAllEmailTemplates', () => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/email/templates', method: 'DELETE', - headers: authHeaders + headers: authHeaders, }) }) }) const defaultEmailTemplates = () => ({ topicAccepted: { finnish: '', english: '' }, - topicRejected: { finnish: '', english: '' } + topicRejected: { finnish: '', english: '' }, }) -Cypress.Commands.add( - 'updateEmailTemplate', - (templateName, templateLanguage, text) => { - withLoggedAdminToken((token) => { - const authHeaders = { - Authorization: 'Bearer ' + token - } +Cypress.Commands.add('updateEmailTemplate', (templateName, templateLanguage, text) => { + withLoggedAdminToken((token) => { + const authHeaders = { + Authorization: 'Bearer ' + token, + } - const body = defaultEmailTemplates() - body[templateName][templateLanguage] = text + const body = defaultEmailTemplates() + body[templateName][templateLanguage] = text - cy.request({ - url: '/api/email/templates', - method: 'POST', - headers: authHeaders, - body - }) + cy.request({ + url: '/api/email/templates', + method: 'POST', + headers: authHeaders, + body, }) - } -) + }) +}) Cypress.Commands.add('updateAllEmailTemplates', (body) => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/email/templates', method: 'POST', headers: authHeaders, - body + body, }) }) }) @@ -372,13 +365,13 @@ Cypress.Commands.add('updateAllEmailTemplates', (body) => { Cypress.Commands.add('deleteSentEmails', () => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/email/sent-emails', method: 'DELETE', - headers: authHeaders + headers: authHeaders, }) }) }) @@ -386,13 +379,13 @@ Cypress.Commands.add('deleteSentEmails', () => { Cypress.Commands.add('deleteCustomerReviewQuestions', () => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/customerReviewQuestions', method: 'GET', - headers: authHeaders + headers: authHeaders, }).then((res) => { const { questionSets } = res.body @@ -400,7 +393,7 @@ Cypress.Commands.add('deleteCustomerReviewQuestions', () => { cy.request({ url: `/api/customerReviewQuestions/${set.id}`, method: 'DELETE', - headers: authHeaders + headers: authHeaders, }) } }) @@ -410,7 +403,7 @@ Cypress.Commands.add('deleteCustomerReviewQuestions', () => { Cypress.Commands.add('createCustomerReviewQuestionSet', (name, questions) => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ @@ -419,54 +412,51 @@ Cypress.Commands.add('createCustomerReviewQuestionSet', (name, questions) => { headers: authHeaders, body: { name, - questions - } + questions, + }, }) }) }) -Cypress.Commands.add( - 'setCustomerReviewQuestionSetToConfiguration', - (configurationId) => { - withLoggedAdminToken((token) => { - const authHeaders = { - Authorization: 'Bearer ' + token - } +Cypress.Commands.add('setCustomerReviewQuestionSetToConfiguration', (configurationId) => { + withLoggedAdminToken((token) => { + const authHeaders = { + Authorization: 'Bearer ' + token, + } + cy.request({ + url: '/api/customerReviewQuestions', + method: 'GET', + headers: authHeaders, + }).then((res) => { + const questionSet = res.body.questionSets[0] cy.request({ - url: '/api/customerReviewQuestions', - method: 'GET', - headers: authHeaders - }).then((res) => { - const questionSet = res.body.questionSets[0] - cy.request({ - url: `/api/configurations/${configurationId}`, - method: 'PUT', - headers: authHeaders, - body: { - content: null, - customer_review_question_set_id: questionSet.id, - name: 'Konfiguraatio 1', - registration_question_set_id: null, - review_question_set1_id: null, - review_question_set2_id: null - } - }) + url: `/api/configurations/${configurationId}`, + method: 'PUT', + headers: authHeaders, + body: { + content: null, + customer_review_question_set_id: questionSet.id, + name: 'Konfiguraatio 1', + registration_question_set_id: null, + review_question_set1_id: null, + review_question_set2_id: null, + }, }) }) - } -) + }) +}) Cypress.Commands.add('deleteCustomerReviews', () => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/customerReview/', method: 'GET', - headers: authHeaders + headers: authHeaders, }).then((res) => { const { reviews } = res.body if (reviews) { @@ -474,7 +464,7 @@ Cypress.Commands.add('deleteCustomerReviews', () => { cy.request({ url: `/api/customerReview/${review.id}`, method: 'DELETE', - headers: authHeaders + headers: authHeaders, }) } } @@ -485,13 +475,13 @@ Cypress.Commands.add('deleteCustomerReviews', () => { Cypress.Commands.add('deleteInstructorReviews', () => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/instructorReview/', method: 'GET', - headers: authHeaders + headers: authHeaders, }).then((res) => { const { reviews } = res.body if (reviews) { @@ -499,7 +489,7 @@ Cypress.Commands.add('deleteInstructorReviews', () => { cy.request({ url: `/api/instructorReview/${review.id}`, method: 'DELETE', - headers: authHeaders + headers: authHeaders, }) } } @@ -510,14 +500,14 @@ Cypress.Commands.add('deleteInstructorReviews', () => { Cypress.Commands.add('createPeerReviews', (peerReviews) => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/peerreview/insertTestData', method: 'POST', headers: authHeaders, - body: peerReviews + body: peerReviews, }) }) }) @@ -525,7 +515,7 @@ Cypress.Commands.add('createPeerReviews', (peerReviews) => { Cypress.Commands.add('createConfiguration', (configurationData) => { return withLoggedAdminTokenSuperHack().then((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } const { name, @@ -533,7 +523,7 @@ Cypress.Commands.add('createConfiguration', (configurationData) => { registration_question_set_id, review_question_set1_id, review_question_set2_id, - customer_review_question_set_id + customer_review_question_set_id, } = configurationData return cy @@ -547,8 +537,8 @@ Cypress.Commands.add('createConfiguration', (configurationData) => { registration_question_set_id, review_question_set1_id, review_question_set2_id, - customer_review_question_set_id - } + customer_review_question_set_id, + }, }) .then((res) => res.body.configuration) }) @@ -557,7 +547,7 @@ Cypress.Commands.add('createConfiguration', (configurationData) => { Cypress.Commands.add('createTopic', (topicContent, topicConfigurationId) => { return withLoggedAdminTokenSuperHack().then((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } return cy .request({ @@ -566,8 +556,8 @@ Cypress.Commands.add('createTopic', (topicContent, topicConfigurationId) => { headers: authHeaders, body: { content: topicContent, - configuration_id: topicConfigurationId - } + configuration_id: topicConfigurationId, + }, }) .then((res) => res.body.topic) }) @@ -576,12 +566,12 @@ Cypress.Commands.add('createTopic', (topicContent, topicConfigurationId) => { Cypress.Commands.add('deleteConfiguration', (configurationId) => { withLoggedAdminTokenSuperHack().then((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: `/api/configurations/${configurationId}`, method: 'DELETE', - headers: authHeaders + headers: authHeaders, }) }) }) @@ -589,12 +579,12 @@ Cypress.Commands.add('deleteConfiguration', (configurationId) => { Cypress.Commands.add('deleteCustomerReview', (customerReviewId) => { withLoggedAdminTokenSuperHack().then((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: `/api/customerreviews/delete/${customerReviewId}`, method: 'DELETE', - headers: authHeaders + headers: authHeaders, }) }) }) @@ -602,7 +592,7 @@ Cypress.Commands.add('deleteCustomerReview', (customerReviewId) => { Cypress.Commands.add('createCustomerReview', (customerReview) => { withLoggedAdminTokenSuperHack().then((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } //const { answerSheet, group_id, topic_id, configuration_id } = customerReview cy.request({ @@ -610,8 +600,8 @@ Cypress.Commands.add('createCustomerReview', (customerReview) => { method: 'POST', headers: authHeaders, body: { - customerReview - } + customerReview, + }, }) }) }) @@ -619,7 +609,7 @@ Cypress.Commands.add('createCustomerReview', (customerReview) => { Cypress.Commands.add('createGroupHack', (groupData) => { return withLoggedAdminTokenSuperHack().then((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } const { name, @@ -627,7 +617,7 @@ Cypress.Commands.add('createGroupHack', (groupData) => { configurationId, instructorId, isShortProject = false, - studentIds + studentIds, } = groupData return cy @@ -641,8 +631,8 @@ Cypress.Commands.add('createGroupHack', (groupData) => { configurationId, instructorId, isShortProject, - studentIds - } + studentIds, + }, }) .then((res) => res.body) }) @@ -651,12 +641,12 @@ Cypress.Commands.add('createGroupHack', (groupData) => { Cypress.Commands.add('deleteCustomerReview', (customerReviewId) => { withLoggedAdminToken().then((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: `/api/customerreviews/delete/${customerReviewId}`, method: 'DELETE', - headers: authHeaders + headers: authHeaders, }) }) }) @@ -664,7 +654,7 @@ Cypress.Commands.add('deleteCustomerReview', (customerReviewId) => { Cypress.Commands.add('createCustomerReview', (customerReview) => { withLoggedAdminTokenSuperHack().then((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } //const { answerSheet, group_id, topic_id, configuration_id } = customerReview cy.request({ @@ -672,8 +662,8 @@ Cypress.Commands.add('createCustomerReview', (customerReview) => { method: 'POST', headers: authHeaders, body: { - customerReview - } + customerReview, + }, }) }) }) @@ -681,7 +671,7 @@ Cypress.Commands.add('createCustomerReview', (customerReview) => { Cypress.Commands.add('createGroupHack', (groupData) => { return withLoggedAdminTokenSuperHack().then((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } const { name, @@ -689,7 +679,7 @@ Cypress.Commands.add('createGroupHack', (groupData) => { configurationId, instructorId, isShortProject = false, - studentIds + studentIds, } = groupData return cy @@ -703,8 +693,8 @@ Cypress.Commands.add('createGroupHack', (groupData) => { configurationId, instructorId, isShortProject, - studentIds - } + studentIds, + }, }) .then((res) => res.body) }) @@ -715,7 +705,7 @@ Cypress.Commands.add('createGroupHack', (groupData) => { Cypress.Commands.add('createGroup', (groupData) => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } const { name, @@ -723,7 +713,7 @@ Cypress.Commands.add('createGroup', (groupData) => { configurationId, instructorId, isShortProject = false, - studentIds + studentIds, } = groupData cy.request({ @@ -736,8 +726,8 @@ Cypress.Commands.add('createGroup', (groupData) => { configurationId, instructorId, isShortProject, - studentIds - } + studentIds, + }, }).then((res) => { cy.wrap(res.body) }) @@ -749,16 +739,18 @@ Cypress.Commands.add('createGroup', (groupData) => { Cypress.Commands.add('getGroups', () => { return withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } - return cy.request({ - url: '/api/groups', - method: 'GET', - headers: authHeaders - }).then((res) => { - return cy.wrap(res.body) - }) + return cy + .request({ + url: '/api/groups', + method: 'GET', + headers: authHeaders, + }) + .then((res) => { + return cy.wrap(res.body) + }) }) }) @@ -767,7 +759,7 @@ Cypress.Commands.add('getGroups', () => { Cypress.Commands.add('createSprint', (sprintData) => { withLoggedRegisteredUserToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } const { sprint, start_date, end_date } = sprintData const user_id = TEST_USER2.headers.hypersonstudentid @@ -780,8 +772,8 @@ Cypress.Commands.add('createSprint', (sprintData) => { start_date, end_date, sprint, - user_id - } + user_id, + }, }) }) }) @@ -791,16 +783,18 @@ Cypress.Commands.add('createSprint', (sprintData) => { Cypress.Commands.add('getSprints', () => { return withLoggedRegisteredUserTokenAlt((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } - return cy.request({ - url: '/api/sprints', - method: 'GET', - headers: authHeaders - }).then((res) => { - return cy.wrap(res.body) - }) + return cy + .request({ + url: '/api/sprints', + method: 'GET', + headers: authHeaders, + }) + .then((res) => { + return cy.wrap(res.body) + }) }) }) @@ -809,32 +803,31 @@ Cypress.Commands.add('getSprints', () => { Cypress.Commands.add('deleteAllSprintsChartTest', () => { withLoggedRegisteredUserTokenAlt((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/sprints', method: 'GET', - headers: authHeaders + headers: authHeaders, }).then((res) => { const allSprints = res.body for (const sprint of allSprints) { cy.request({ url: `/api/sprints/${sprint.id}`, method: 'DELETE', - headers: authHeaders + headers: authHeaders, }) } }) }) }) - /* TIMELOGS ENTRY CREATION FOR TESTING */ Cypress.Commands.add('addTimelogEntry', (timeLogEntryData) => { withLoggedRegisteredUserToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } const { studentNumber, sprint, date, minutes, description, tags, groupId } = timeLogEntryData @@ -849,8 +842,8 @@ Cypress.Commands.add('addTimelogEntry', (timeLogEntryData) => { minutes, description, tags, - groupId - } + groupId, + }, }) }) }) @@ -858,7 +851,7 @@ Cypress.Commands.add('addTimelogEntry', (timeLogEntryData) => { Cypress.Commands.add('addTimelogEntryAlt', (timeLogEntryData) => { withLoggedRegisteredUserTokenAlt((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } const { studentNumber, sprint, date, minutes, description, tags, groupId } = timeLogEntryData @@ -873,8 +866,8 @@ Cypress.Commands.add('addTimelogEntryAlt', (timeLogEntryData) => { minutes, description, tags, - groupId - } + groupId, + }, }) }) }) @@ -884,19 +877,19 @@ Cypress.Commands.add('addTimelogEntryAlt', (timeLogEntryData) => { Cypress.Commands.add('deleteAllTimelogs', () => { withLoggedRegisteredUserTokenAlt((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/timelogs', method: 'GET', - headers: authHeaders + headers: authHeaders, }).then((res) => { const allTimelogs = res.body for (const timelog of allTimelogs) { cy.request({ url: `/api/timelogs/${timelog.id}`, method: 'DELETE', - headers: authHeaders + headers: authHeaders, }) } }) @@ -906,12 +899,12 @@ Cypress.Commands.add('deleteAllTimelogs', () => { Cypress.Commands.add('deleteAllSprints', () => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/sprints', method: 'GET', - headers: authHeaders + headers: authHeaders, }).then((res) => { const allSprints = res.body for (const sprint of allSprints) { @@ -919,7 +912,7 @@ Cypress.Commands.add('deleteAllSprints', () => { url: `/api/sprints/${sprint.id}`, method: 'DELETE', failOnStatusCode: false, - headers: authHeaders + headers: authHeaders, }) } }) @@ -931,15 +924,15 @@ Cypress.Commands.add('deleteAllSprints', () => { Cypress.Commands.add('createTag', (tagTitle) => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/tags', method: 'POST', headers: authHeaders, body: { - title: tagTitle - } + title: tagTitle, + }, }) }) }) @@ -949,19 +942,19 @@ Cypress.Commands.add('createTag', (tagTitle) => { Cypress.Commands.add('deleteAllTags', () => { withLoggedAdminToken((token) => { const authHeaders = { - Authorization: 'Bearer ' + token + Authorization: 'Bearer ' + token, } cy.request({ url: '/api/tags', method: 'GET', - headers: authHeaders + headers: authHeaders, }).then((res) => { const allTags = res.body for (const tag of allTags) { cy.request({ url: `/api/tags/${tag.id}`, method: 'DELETE', - headers: authHeaders + headers: authHeaders, }) } }) diff --git a/frontend/package.json b/frontend/package.json index 8a590bc..2132a66 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -35,8 +35,8 @@ "test:headless": "CYPRESS_VIDEO=false CYPRESS_baseUrl=http://localhost:5000 npx cypress run", "lint": "oxlint src/", "lint:fix": "oxlint --fix src/", - "format": "oxfmt src/", - "format:check": "oxfmt --check src/" + "format": "oxfmt src/ e2e/", + "format:check": "oxfmt --check src/ e2e/" }, "devDependencies": { "@vitejs/plugin-react": "^4.7.0", diff --git a/frontend/src/components/GroupManagementPage/GroupCreationForm.jsx b/frontend/src/components/GroupManagementPage/GroupCreationForm.jsx index b5d2b76..06ac17e 100644 --- a/frontend/src/components/GroupManagementPage/GroupCreationForm.jsx +++ b/frontend/src/components/GroupManagementPage/GroupCreationForm.jsx @@ -35,7 +35,7 @@ const StudentInput = ({ value, onChange }) => { onChange={(e) => onChange(e.target.value)} multiline rows="8" - inputProps={{ className: 'create-group-form__student-input' }} + className="create-group-form__student-input" fullWidth={true} /> @@ -47,7 +47,8 @@ const NameInput = ({ value, onChange, inputProps, ...textFieldProps }) => ( value={value} onChange={(e) => onChange(e.target.value)} variant="standard" - inputProps={inputProps} + className={inputProps?.className} + data-cy={inputProps?.['data-cy']} fullWidth={true} {...textFieldProps} /> @@ -157,9 +158,7 @@ const GroupCreationForm = ({ diff --git a/frontend/src/components/GroupManagementPage/SingleGroupEdit.jsx b/frontend/src/components/GroupManagementPage/SingleGroupEdit.jsx index 8ee3fe9..ff543d5 100644 --- a/frontend/src/components/GroupManagementPage/SingleGroupEdit.jsx +++ b/frontend/src/components/GroupManagementPage/SingleGroupEdit.jsx @@ -141,10 +141,8 @@ class SingleGroupEdit extends React.Component {

Edit group name

} + control={} label="short" /> } + control={} label="long" />

Add new students

{ /> - + ) diff --git a/package.json b/package.json index 8e8653d..2aae1b8 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "lint": "npm --prefix frontend run lint && npm --prefix backend run lint" }, "lint-staged": { - "frontend/**/*.{js,jsx}": [ + "frontend/{src,e2e}/**/*.{js,jsx}": [ "npm --prefix frontend run format:check", "npm --prefix frontend run lint" ],