diff --git a/cypress/integration/sidebar.js b/cypress/integration/sidebar.js new file mode 100644 index 0000000000..e05f1877bf --- /dev/null +++ b/cypress/integration/sidebar.js @@ -0,0 +1,57 @@ +context('Sidebar', () => { + before(() => { + cy.visit('/login'); + cy.login(); + cy.visit('/app/doctype'); + }); + + it('Test for checking "Assigned To" counter value, adding filter and adding & removing an assignment', () => { + cy.click_sidebar_button(0); + + //To check if no filter is available in "Assigned To" dropdown + cy.get('.empty-state').should('contain', 'No filters found'); + + cy.click_sidebar_button(1); + + //To check if "Created By" dropdown contains filter + cy.get('.group-by-item > .dropdown-item').should('contain', 'Me'); + + //Assigning a doctype to a user + cy.click_listview_row_item(0); + cy.get('.form-assignments > .flex > .text-muted').click(); + cy.get_field('assign_to_me', 'Check').click(); + cy.get('.modal-footer > .standard-actions > .btn-primary').click(); + cy.visit('/app/doctype'); + cy.click_sidebar_button(0); + + //To check if filter is added in "Assigned To" dropdown after assignment + cy.get('.group-by-field.show > .dropdown-menu > .group-by-item > .dropdown-item').should('contain', '1'); + + //To check if there is no filter added to the listview + cy.get('.filter-selector > .btn').should('contain', 'Filter'); + + //To add a filter to display data into the listview + cy.get('.group-by-field.show > .dropdown-menu > .group-by-item > .dropdown-item').click(); + + //To check if filter is applied + cy.click_filter_button().should('contain', '1 filter'); + cy.get('.fieldname-select-area > .awesomplete > .form-control').should('have.value', 'Assigned To'); + cy.get('.condition').should('have.value', 'like'); + cy.get('.filter-field > .form-group > .input-with-feedback').should('have.value', '%Administrator%'); + + //To remove the applied filter + cy.get('.filter-action-buttons > div > .btn-secondary').contains('Clear Filters').click(); + cy.click_filter_button(); + cy.get('.filter-selector > .btn').should('contain', 'Filter'); + + //To remove the assignment + cy.visit('/app/doctype'); + cy.click_listview_row_item(0); + cy.get('.assignments > .avatar-group > .avatar > .avatar-frame').click(); + cy.get('.remove-btn').click({force: true}); + cy.get('.modal.show > .modal-dialog > .modal-content > .modal-header > .modal-actions > .btn-modal-close').click(); + cy.visit('/app/doctype'); + cy.click_sidebar_button(0); + cy.get('.empty-state').should('contain', 'No filters found'); + }); +}); \ No newline at end of file diff --git a/cypress/integration/table_multiselect.js b/cypress/integration/table_multiselect.js index 25cab78ba2..f873461efb 100644 --- a/cypress/integration/table_multiselect.js +++ b/cypress/integration/table_multiselect.js @@ -9,6 +9,7 @@ context('Table MultiSelect', () => { cy.new_form('Assignment Rule'); cy.fill_field('__newname', name); cy.fill_field('document_type', 'Blog Post'); + cy.get('.section-head').contains('Assignment Rules').scrollIntoView(); cy.fill_field('assign_condition', 'status=="Open"', 'Code'); cy.get('input[data-fieldname="users"]').focus().as('input'); cy.get('input[data-fieldname="users"] + ul').should('be.visible'); diff --git a/cypress/integration/timeline.js b/cypress/integration/timeline.js new file mode 100644 index 0000000000..84616cfbe6 --- /dev/null +++ b/cypress/integration/timeline.js @@ -0,0 +1,53 @@ +context('Timeline', () => { + before(() => { + cy.visit('/login'); + cy.login(); + cy.visit('/app/todo'); + }); + + it('Adding new ToDo, adding new comment, verifying comment addition & deletion and deleting ToDo', () => { + //Adding new ToDo + cy.click_listview_primary_button('Add ToDo'); + cy.get('.modal-footer > .custom-actions > .btn').contains('Edit in full page').click(); + cy.get('.row > .section-body > .form-column > form > .frappe-control > .form-group > .control-input-wrapper > .control-input > .ql-container > .ql-editor').eq(0).type('Test ToDo', {force: true}); + cy.wait(200); + cy.get('#page-ToDo > .page-head > .container > .row > .col > .standard-actions > .primary-action').contains('Save').click(); + cy.wait(700); + cy.visit('/app/todo'); + cy.get('.list-row > .level-left > .list-subject > .level-item.ellipsis > .ellipsis').eq(0).click(); + + //To check if the comment box is initially empty and tying some text into it + cy.get('.comment-input-container > .frappe-control > .ql-container > .ql-editor').should('contain', '').type('Testing Timeline'); + + //Adding new comment + cy.get('.comment-input-wrapper > .btn').contains('Comment').click(); + + //To check if the commented text is visible in the timeline content + cy.get('.timeline-content').should('contain', 'Testing Timeline'); + + //Editing comment + cy.click_timeline_action_btn(0); + cy.get('.timeline-content > .timeline-message-box > .comment-edit-box > .frappe-control > .ql-container > .ql-editor').first().type(' 123'); + cy.click_timeline_action_btn(0); + + //To check if the edited comment text is visible in timeline content + cy.get('.timeline-content').should('contain', 'Testing Timeline 123'); + + //Discarding comment + cy.click_timeline_action_btn(0); + cy.get('.actions > .btn').eq(1).first().click(); + + //To check if after discarding the timeline content is same as previous + cy.get('.timeline-content').should('contain', 'Testing Timeline 123'); + + //Deleting the added comment + cy.get('.actions > .btn > .icon').first().click(); + cy.get('.modal-footer > .standard-actions > .btn-primary').contains('Yes').click(); + cy.click_modal_primary_button('Yes'); + + //Deleting the added ToDo + cy.get('#page-ToDo > .page-head > .container > .row > .col > .standard-actions > .menu-btn-group > .btn').click({force: true}); + cy.get('.menu-btn-group > .dropdown-menu > li > .grey-link').eq(17).click({force: true}); + cy.get('.modal.show > .modal-dialog > .modal-content > .modal-footer > .standard-actions > .btn-primary').contains('Yes').click({force: true}); + }); +}); \ No newline at end of file diff --git a/cypress/integration/timeline_email.js b/cypress/integration/timeline_email.js new file mode 100644 index 0000000000..e5b3ebeb7c --- /dev/null +++ b/cypress/integration/timeline_email.js @@ -0,0 +1,71 @@ +context('Timeline Email', () => { + before(() => { + cy.visit('/login'); + cy.login(); + cy.visit('/app/todo'); + }); + + it('Adding new ToDo, adding email and verifying timeline content for email attachment, deleting attachment and ToDo', () => { + //Adding new ToDo + cy.click_listview_primary_button('Add ToDo'); + cy.get('.custom-actions > .btn').trigger('click', {delay: 500}); + cy.get('.row > .section-body > .form-column > form > .frappe-control > .form-group > .control-input-wrapper > .control-input > .ql-container > .ql-editor').eq(0).type('Test ToDo', {force: true}); + cy.wait(500); + //cy.click_listview_primary_button('Save'); + cy.get('.primary-action').contains('Save').click({force: true}); + cy.wait(700); + cy.visit('/app/todo'); + cy.get('.list-row > .level-left > .list-subject > .level-item.ellipsis > .ellipsis').eq(0).click(); + + //Creating a new email + cy.get('.timeline-actions > .btn').click(); + cy.fill_field('recipients', 'test@example.com', 'MultiSelect'); + cy.get('.modal.show > .modal-dialog > .modal-content > .modal-body > :nth-child(1) > .form-layout > .form-page > :nth-child(3) > .section-body > .form-column > form > [data-fieldtype="Text Editor"] > .form-group > .control-input-wrapper > .control-input > .ql-container > .ql-editor').type('Test Mail'); + + //Adding attachment to the email + cy.get('.add-more-attachments > .btn').click(); + cy.get('.mt-2 > .btn > .mt-1').eq(2).click(); + cy.get('.input-group > .form-control').type('https://wallpaperplay.com/walls/full/8/2/b/72402.jpg'); + cy.get('.btn-primary').contains('Upload').click(); + + //Sending the email + cy.click_modal_primary_button('Send', {delay: 500}); + + //To check if the sent mail content is shown in the timeline content + cy.get('[data-doctype="Communication"] > .timeline-content').should('contain', 'Test Mail'); + + //To check if the attachment of email is shown in the timeline content + cy.get('.timeline-content').should('contain', 'Added 72402.jpg'); + + //Deleting the sent email + cy.get('[title="Open Communication"] > .icon').first().click({force: true}); + cy.get('#page-Communication > .page-head > .container > .row > .col > .standard-actions > .menu-btn-group > .btn').click(); + cy.get('#page-Communication > .page-head > .container > .row > .col > .standard-actions > .menu-btn-group > .dropdown-menu > li > .grey-link').eq(9).click(); + cy.get('.modal.show > .modal-dialog > .modal-content > .modal-footer > .standard-actions > .btn-primary').click(); + cy.visit('/app/todo'); + cy.get('.list-row > .level-left > .list-subject > .level-item.ellipsis > .ellipsis').eq(0).click(); + + //Removing the added attachment + cy.get('.attachment-row > .data-pill > .remove-btn > .icon').click(); + cy.get('.modal-dialog > .modal-content > .modal-footer > .standard-actions > .btn-primary').contains('Yes').click(); + + //To check if the removed attachment is shown in the timeline content + cy.get('.timeline-content').should('contain', 'Removed 72402.jpg'); + cy.wait(500); + + //To check if the discard button functionality in email is working correctly + cy.get('.timeline-actions > .btn').click(); + cy.fill_field('recipients', 'test@example.com', 'MultiSelect'); + cy.get('.modal-footer > .standard-actions > .btn-secondary').contains('Discard').click(); + cy.wait(500); + cy.get('.timeline-actions > .btn').click(); + cy.wait(500); + cy.get_field('recipients', 'MultiSelect').should('have.text', ''); + cy.get('.modal.show > .modal-dialog > .modal-content > .modal-header > .modal-actions > .btn-modal-close > .icon').click(); + + //Deleting the added ToDo + cy.get('#page-ToDo > .page-head > .container > .row > .col > .standard-actions > .menu-btn-group > .btn').click(); + cy.get('.menu-btn-group > .dropdown-menu > li > .grey-link').eq(17).click(); + cy.get('.modal.show > .modal-dialog > .modal-content > .modal-footer > .standard-actions > .btn-primary').click(); + }); +}); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 1964b96d70..a81ba60fb0 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -192,16 +192,16 @@ Cypress.Commands.add('fill_field', (fieldname, value, fieldtype = 'Data') => { }); Cypress.Commands.add('get_field', (fieldname, fieldtype = 'Data') => { - let selector = `.form-control[data-fieldname="${fieldname}"]`; + let selector = `[data-fieldname="${fieldname}"] input:visible`; if (fieldtype === 'Text Editor') { - selector = `[data-fieldname="${fieldname}"] .ql-editor[contenteditable=true]`; + selector = `[data-fieldname="${fieldname}"] .ql-editor[contenteditable=true]:visible`; } if (fieldtype === 'Code') { selector = `[data-fieldname="${fieldname}"] .ace_text-input`; } - return cy.get(selector); + return cy.get(selector).first(); }); Cypress.Commands.add('fill_table_field', (tablefieldname, row_idx, fieldname, value, fieldtype = 'Data') => { @@ -323,4 +323,30 @@ Cypress.Commands.add('clear_filters', () => { cy.window().its('cur_list').then(cur_list => { cur_list && cur_list.filter_area && cur_list.filter_area.clear(); }); + + +}); + +Cypress.Commands.add('click_modal_primary_button', (btn_name) => { + cy.get('.modal-footer > .standard-actions > .btn-primary').contains(btn_name).trigger('click', {force: true}); }); + +Cypress.Commands.add('click_sidebar_button', (btn_no) => { + cy.get('.list-group-by-fields > .group-by-field > .btn').eq(btn_no).click(); +}); + +Cypress.Commands.add('click_listview_row_item', (row_no) => { + cy.get('.list-row > .level-left > .list-subject > .bold > .ellipsis').eq(row_no).click({force: true}); +}); + +Cypress.Commands.add('click_filter_button', () => { + cy.get('.filter-selector > .btn').click(); +}); + +Cypress.Commands.add('click_listview_primary_button', (btn_name) => { + cy.get('.primary-action').contains(btn_name).click({force: true}); +}); + +Cypress.Commands.add('click_timeline_action_btn', (btn_no) => { + cy.get('.timeline-content > .timeline-message-box > .justify-between > .actions > .btn').eq(btn_no).first().click(); +}); \ No newline at end of file