Loading cypress/integration/comments/comment-threads.spec.js +112 −14 Original line number Original line Diff line number Diff line import generateRandomId from '../../support/utilities'; /** /** * @author Ben Hayward * @author Ben Hayward * @create date 2019-08-09 14:42:51 * @create date 2019-08-09 14:42:51 Loading @@ -6,6 +8,9 @@ */ */ context('Comment Threads', () => { context('Comment Threads', () => { const testUsername = generateRandomId(); const testPassword = generateRandomId() + 'rR.7'; const testMessage = { const testMessage = { 1: 'test tier 1', 1: 'test tier 1', 2: 'test tier 2', 2: 'test tier 2', Loading @@ -17,8 +22,6 @@ context('Comment Threads', () => { const deletePostButton = ".m-modal-confirm-buttons > button:contains('Delete')"; const deletePostButton = ".m-modal-confirm-buttons > button:contains('Delete')"; const postCommentButton = 'm-comment__poster > div > div.minds-body > div > div > a.m-post-button'; const postCommentButton = 'm-comment__poster > div > div.minds-body > div > div > a.m-post-button'; const thumbsUpCounters = '.m-comment__toolbar > div > minds-button-thumbs-up > a > span'; const thumbsDownCounters = '.m-comment__toolbar > div > minds-button-thumbs-down > a > span'; // pass in tier / tree depth. // pass in tier / tree depth. const replyButton = `minds-activity:first .m-comment__toolbar > div > span`; const replyButton = `minds-activity:first .m-comment__toolbar > div > span`; Loading @@ -26,6 +29,11 @@ context('Comment Threads', () => { const commentInput = `minds-activity:first m-text-input--autocomplete-container > minds-textarea > div`; const commentInput = `minds-activity:first m-text-input--autocomplete-container > minds-textarea > div`; const commentContent = `minds-activity:first m-comments__tree .m-comment__bubble > p`; const commentContent = `minds-activity:first m-comments__tree .m-comment__bubble > p`; const thumbsUpCounters = '[data-cy=data-minds-thumbs-up-counter]' //'minds-button-thumbs-up > a > span'; const thumbsDownCounters = '[data-cy=data-minds-thumbs-down-counter]'; const thumbsUpButton = '[data-cy=data-minds-thumbs-up-button]' const thumbsDownButton = '[data-cy=data-minds-thumbs-down-button]' before(() => { before(() => { //make a post new. //make a post new. cy.getCookie('minds_sess') cy.getCookie('minds_sess') Loading @@ -44,6 +52,10 @@ context('Comment Threads', () => { beforeEach(()=> { beforeEach(()=> { cy.preserveCookies(); cy.preserveCookies(); cy.server(); cy.route('GET', '**/api/v2/comments/**').as('commentsOpen'); cy.route('POST', '**/api/v1/comments/**').as('postComment'); cy.route('PUT', '**/api/v1/thumbs/**').as('thumbsPut'); }); }); after(() => { after(() => { Loading @@ -63,13 +75,21 @@ context('Comment Threads', () => { cy.get(commentContent).contains(testMessage[1]); cy.get(commentContent).contains(testMessage[1]); //Add the second level of comments //Add the second level of comments cy.get(replyButton).click(); cy.get(replyButton) .click() .wait('@commentsOpen') .then(xhr => { expect(xhr.status).to.equal(200); }); cy.get(commentInput) cy.get(commentInput) .first() .first() .type(testMessage[2]); .type(testMessage[2]); cy.get(postCommentButton) cy.get(postCommentButton) .first() .first() .click(); .click(); cy.get(commentContent).contains(testMessage[2]); cy.get(commentContent).contains(testMessage[2]); Loading @@ -78,30 +98,108 @@ context('Comment Threads', () => { .find('m-comments__tree m-comments__thread m-comment') .find('m-comments__tree m-comments__thread m-comment') .find('m-comments__thread m-comment:nth-child(2) .m-comment__toolbar > div > span') .find('m-comments__thread m-comment:nth-child(2) .m-comment__toolbar > div > span') .last() .last() .click(); .click() .wait('@commentsOpen') .then(xhr => { expect(xhr.status).to.equal(200); }); cy.get(commentInput) cy.get(commentInput) .first() .first() .type(testMessage[3]); .type(testMessage[3]); cy.get(postCommentButton) cy.get(postCommentButton) .first() .first() .click(); .click(); cy.get(commentContent).contains(testMessage[3]); cy.get(commentContent).contains(testMessage[3]); //click thumbs up and down // Waiting on component init here. cy.get('.m-comment__toolbar') // If still not fully loaded will not break, .find('minds-button-thumbs-up') // but may mean some of the buttons aren't tested. cy.wait(1000); // scope further get requests down to within the comments toolbar // avoids clicking thumbs in activity feed. cy.get('.m-comment__toolbar').within(($list) => { // thumbs up and down cy.get(thumbsUpButton) .click({multiple: true}); .click({multiple: true}); cy.get('.m-comment__toolbar') cy.get(thumbsDownButton) .find('minds-button-thumbs-down') .click({multiple: true}); .click({multiple: true}); // check the values // check counters cy.get(thumbsUpCounters) cy.get(thumbsUpCounters) .each((counter) => expect(counter.context.innerHTML).to.eql('1')); .each((counter) => { expect(counter[0].innerHTML).to.eql('1'); }); }); cy.get(thumbsDownCounters) cy.get(thumbsDownCounters) .each((counter) => expect(counter.context.innerHTML).to.eql('1')); .each((counter) => { expect(counter[0].innerHTML).to.eql('1'); }); }); it('should allow the user to make a mature comment', () => { // type message cy.get('minds-textarea') .last() .type("naughty message"); // click mature cy.get('.m-mature-button') .last() .click(); // post and await response cy.get('.m-post-button') .last() .click() .wait('@postComment') .then(xhr => { expect(xhr.status).to.equal(200); }); // Making sure we don't act upon other comments cy.get('.m-comment__bubble').parent().within($list => { cy.contains('naughty message') .should('not.have.class', 'm-mature-text'); cy.get('.m-redButton') .click(); cy.contains('naughty message') .should('have.class', 'm-mature-text'); }); // get share link cy.get(postMenu).click(); cy.contains('Share').click(); // store share link cy.get('.m-share__copyableLinkText') .invoke('val') .then(val => { // log out cy.logout(); // visit link cy.visit(val); // assert toggle works. cy.contains('naughty message') .should('have.class', 'm-mature-text'); cy.get('.m-mature-text-toggle') .click(); cy.contains('naughty message') .should('not.have.class', 'm-mature-text'); }); }); }); }) }) cypress/integration/groups/groups.spec.js +40 −27 Original line number Original line Diff line number Diff line import generateRandomId from '../../support/utilities'; const groupId = generateRandomId(); context('Groups', () => { context('Groups', () => { before(() => { before(() => { cy.getCookie('minds_sess') cy.getCookie('minds_sess') Loading Loading @@ -25,7 +29,7 @@ context('Groups', () => { cy.uploadFile('minds-banner #file', '../fixtures/international-space-station-1776401_1920.jpg', 'image/jpg'); cy.uploadFile('minds-banner #file', '../fixtures/international-space-station-1776401_1920.jpg', 'image/jpg'); // add a name // add a name cy.get('.m-group-info-name > input').type('test'); cy.get('.m-group-info-name > input').type(groupId); // add a description // add a description cy.get('.m-group-info-brief-description > textarea').type('This is a test'); cy.get('.m-group-info-brief-description > textarea').type('This is a test'); Loading @@ -41,6 +45,8 @@ context('Groups', () => { cy.get('.m-groups-save > button').contains('Create').click(); cy.get('.m-groups-save > button').contains('Create').click(); cy.route("POST", "**/api/v1/groups/group/*/banner*").as("postBanner"); cy.route("POST", "**/api/v1/groups/group/*/banner*").as("postBanner"); // get current groups count of sidebar cy.get('.m-groupSidebarMarkers__list').children().its('length').then((size) => { cy.wait('@postGroup').then((xhr) => { cy.wait('@postGroup').then((xhr) => { expect(xhr.status).to.equal(200); expect(xhr.status).to.equal(200); expect(xhr.response.body.status).to.equal('success'); expect(xhr.response.body.status).to.equal('success'); Loading @@ -49,7 +55,10 @@ context('Groups', () => { expect(xhr.response.body.status).to.equal('success'); expect(xhr.response.body.status).to.equal('success'); }); }); cy.get('.m-groupInfo__name').contains('test'); //check count changed. cy.get('.m-groupSidebarMarkers__list').children().should('have.length', size + 1); }); cy.get('.m-groupInfo__name').contains(groupId); cy.get('.m-groupInfo__description').contains('This is a test'); cy.get('.m-groupInfo__description').contains('This is a test'); // open settings button // open settings button Loading @@ -58,7 +67,7 @@ context('Groups', () => { cy.get('minds-groups-settings-button ul.minds-dropdown-menu li:first-child').contains('Edit').click(); cy.get('minds-groups-settings-button ul.minds-dropdown-menu li:first-child').contains('Edit').click(); // edit name // edit name cy.get('.m-groupInfo__name input').type(' group'); cy.get('.m-groupInfo__name input').type(' edit'); // edit description // edit description cy.get('.m-groupInfo__description textarea').type(' group'); cy.get('.m-groupInfo__description textarea').type(' group'); Loading @@ -68,16 +77,12 @@ context('Groups', () => { cy.get('minds-groups-settings-button ul.minds-dropdown-menu li:first-child').contains('Save').click(); cy.get('minds-groups-settings-button ul.minds-dropdown-menu li:first-child').contains('Save').click(); cy.get('.m-groupInfo__name').contains('test group'); cy.get('.m-groupInfo__name').contains(groupId + ' edit'); cy.get('.m-groupInfo__description').contains('This is a test group'); cy.get('.m-groupInfo__description').contains('This is a test group'); }) }) it('should be able to toggle conversation and comment on it', () => { it('should be able to toggle conversation and comment on it', () => { cy.contains(groupId).click(); cy.get("m-group--sidebar-markers li:contains('test group')") .first() .click(); // toggle the conversation // toggle the conversation cy.get('.m-groupGrid__right').should('be.visible'); cy.get('.m-groupGrid__right').should('be.visible'); Loading @@ -98,9 +103,7 @@ context('Groups', () => { }) }) it('should post an activity inside the group and record the view when scrolling', () => { it('should post an activity inside the group and record the view when scrolling', () => { cy.get("m-group--sidebar-markers li:contains('test group')") cy.contains(groupId).click(); .first() .click(); cy.server(); cy.server(); cy.route("POST", "**/api/v2/analytics/views/activity/*").as("view"); cy.route("POST", "**/api/v2/analytics/views/activity/*").as("view"); Loading @@ -110,7 +113,7 @@ context('Groups', () => { cy.get('.m-posterActionBar__PostButton').click(); cy.get('.m-posterActionBar__PostButton').click(); // the activity should show that it was posted in this group // the activity should show that it was posted in this group cy.get('.minds-list minds-activity .body a:nth-child(2)').contains('(test group)'); cy.get('.minds-list minds-activity .body a:nth-child(2)').contains(`(${groupId} edit)`); cy.get('.minds-list minds-activity .m-mature-message-content').contains('This is a post'); cy.get('.minds-list minds-activity .m-mature-message-content').contains('This is a post'); Loading @@ -127,15 +130,25 @@ context('Groups', () => { }); }); }); }); it('should delete a group', () => { it('should navigate to discovery when Find a Group clicked', () => { cy.get('m-group--sidebar-markers li:nth-child(3)').contains('test group').click(); cy.contains('Find a Group').click() cy.location('pathname') .should('eq', '/newsfeed/global/top%3Bperiod%3D12h%3Btype%3Dgroups%3Ball%3D1'); }); it('should delete a group', () => { cy.get('.m-groupSidebarMarkers__list').children().its('length').then((size) => { // cy.get(`m-group--sidebar-markers li:nth-child(${size - 2})`).click(); cy.contains(groupId).click(); // cleanup // cleanup cy.get('minds-groups-settings-button > button').click(); cy.get('minds-groups-settings-button > button').click(); cy.get('minds-groups-settings-button ul.minds-dropdown-menu > li:nth-child(8)').contains('Delete Group').click(); cy.contains('Delete Group').click(); cy.get('minds-groups-settings-button m-modal .mdl-button--raised').contains('Confirm').click(); cy.contains('Confirm').click(); cy.location('pathname').should('eq', '/groups/member'); cy.location('pathname').should('eq', '/groups/member'); }) cy.get('.m-groupSidebarMarkers__list').children().should('have.length', size - 1); }); }); }) }) cypress/integration/login.spec.js +6 −6 Original line number Original line Diff line number Diff line Loading @@ -5,36 +5,36 @@ context('Login', () => { }) }) it('should login', () => { it('should login', () => { cy.get('.m-v2-topbar__Container__LoginWrapper > a').click(); cy.get('.m-v2-topbar__Container__LoginWrapper > a').contains('Login').click(); cy.location('pathname').should('eq', '/login'); cy.location('pathname').should('eq', '/login'); // it should have a login form // it should have a login form cy.get('.m-login').should('be.visible'); cy.get('.m-login__wrapper').should('be.visible'); cy.get('minds-form-login .m-login-box .mdl-cell:first-child input').type(Cypress.env().username); cy.get('minds-form-login .m-login-box .mdl-cell:first-child input').type(Cypress.env().username); cy.get('minds-form-login .m-login-box .mdl-cell:last-child input').type(Cypress.env().password); cy.get('minds-form-login .m-login-box .mdl-cell:last-child input').type(Cypress.env().password); cy.get('minds-form-login .m-btn--login').click(); cy.get('minds-form-login .mf-button--alt').click(); cy.location('pathname') cy.location('pathname') .should('eq', '/newsfeed/subscriptions'); .should('eq', '/newsfeed/subscriptions'); }) }) it('should fail to login because of incorrect password', () => { it('should fail to login because of incorrect password', () => { cy.get('.m-v2-topbar__Container__LoginWrapper > a').click(); cy.get('.m-v2-topbar__Container__LoginWrapper > a').contains('Login').click(); cy.location('pathname').should('eq', '/login'); cy.location('pathname').should('eq', '/login'); // it should have a login form // it should have a login form cy.get('.m-login').should('be.visible'); cy.get('.m-login__wrapper').should('be.visible'); cy.get('minds-form-login .m-login-box .mdl-cell:first-child input').type(Cypress.env().username); cy.get('minds-form-login .m-login-box .mdl-cell:first-child input').type(Cypress.env().username); cy.get('minds-form-login .m-login-box .mdl-cell:last-child input').type(Cypress.env().password + '1'); cy.get('minds-form-login .m-login-box .mdl-cell:last-child input').type(Cypress.env().password + '1'); cy.get('minds-form-login .m-btn--login').click(); cy.get('minds-form-login .mf-button--alt').click(); cy.wait(500); cy.wait(500); Loading cypress/integration/onboarding.spec.jsdeleted 100644 → 0 +0 −75 Original line number Original line Diff line number Diff line context('Onboarding', () => { const email = 'test@minds.com'; const password = 'Passw0rd!'; const name = "Tester"; const description = "I am a tester, with a not so lengthy description"; const welcomeText = "Welcome to Minds!"; const usernameField = 'minds-form-register #username'; const emailField = 'minds-form-register #email'; const passwordField = 'minds-form-register #password'; const password2Field = 'minds-form-register #password2'; const nameField = '#display-name'; const descriptionfield = '#description'; const phoneNumberInput = '#phone'; const countryDropdown = 'm-phone-input--country > div'; const ukOption = 'm-phone-input--country > ul > li:nth-child(2)'; const dialcode = '.m-phone-input--dial-code'; const checkbox = 'minds-form-register label:nth-child(2) .mdl-ripple--center'; const submitButton = 'minds-form-register .mdl-card__actions button'; const nextButton = '.m-channelOnboarding__next'; const submitPhoneButton = 'm-channel--onboarding--rewards > div > div > button'; const loadingSpinner = '.mdl-spinner__gap-patch'; const getTopic = (i) => `m-onboarding--topics > div > ul > li:nth-child(${i}) span`; before(() => { cy.clearCookies(); cy.visit('/login'); //type values cy.get(usernameField).focus().type(Math.random().toString(36).replace('0.', '')); cy.get(emailField).focus().type(email); cy.get(passwordField).focus().type(password); cy.get(password2Field).focus().type(password); cy.get(checkbox).click(); //submit cy.get(submitButton).click(); //onboarding modal shown cy.get('m-onboarding--topics > div > h2:nth-child(1)') .contains(welcomeText); }); it('should allow a user to run through onboarding modals', () => { //select topics cy.get(getTopic(3)).click().should('have.class', 'selected') cy.get(getTopic(4)).click().should('have.class', 'selected') cy.get(getTopic(5)).click().should('have.class', 'selected') //click cy.get(nextButton).click(); //TODO: Skipped over for now as subscribed channels is not working on staging environment. cy.get(nextButton).click(); cy.get(nameField).clear().type(name); cy.get(descriptionfield).type(description); cy.get(nextButton).click(); //set dialcode cy.get(countryDropdown).click(); cy.get(ukOption).click(); cy.get(dialcode).contains('+44'); //type number cy.get(phoneNumberInput).type('7700000000'); //submit and check loading spinner. cy.get(submitPhoneButton).click(); cy.get(loadingSpinner).should('be.visible'); cy.get(nextButton).click(); }); }); cypress/integration/onboarding/onboarding.spec.js 0 → 100644 +128 −0 Original line number Original line Diff line number Diff line context('Onboarding', () => { const remindText = 'remind test text'; before(() => { cy.getCookie('minds_sess') .then((sessionCookie) => { if (sessionCookie === null) { return cy.login(true); } }); cy.visit(`/onboarding`); // create two test groups }); beforeEach(() => { cy.preserveCookies(); }); it('should go through the process of onboarding', () => { // notice should appear cy.get('h1.m-onboarding__noticeTitle').contains('Welcome to the Minds Community'); cy.get('h2.m-onboarding__noticeTitle').contains(`@${Cypress.env().username}`); // should redirect to /hashtags cy.get('.m-onboarding__form button.mf-button').contains("Let's Get Setup").click(); cy.wait(1000); // should be in the hashtags step // should have a Profile Setup title cy.get('.m-onboarding__form > h2').contains('Profile Setup'); // should have a progressbar, with the hashtags step highlighted cy.get('.m-onboardingProgressbar__item--selected span').contains('1'); cy.get('.m-onboardingProgressbar__item--selected span').contains('Hashtags'); // should have a description cy.get('.m-onboarding__form .m-onboarding__description').contains('Select some hashtags that are of interest to you.'); // should have a list of selectable hashtags cy.get('.m-hashtags__list li.m-hashtagsList__item').contains('Art').click(); cy.get('.m-hashtags__list li.m-hashtagsList__item.m-hashtagsList__item--selected').contains('Art'); cy.get('.m-hashtags__list li.m-hashtagsList__item').contains('Journalism').click(); cy.get('.m-hashtags__list li.m-hashtagsList__item.m-hashtagsList__item--selected'); cy.get('.m-hashtags__list li.m-hashtagsList__item').contains('Music').click(); cy.get('.m-hashtags__list li.m-hashtagsList__item.m-hashtagsList__item--selected'); // should have a continue and a skip button cy.get('button.mf-button--hollow').contains('Skip'); cy.get('button.mf-button--alt').contains('Continue').click(); // should be in the info step cy.get('.m-onboardingProgressbar__item--selected span').contains('2'); cy.get('.m-onboardingProgressbar__item--selected span').contains('Info'); // should have a Mobile Phone Number input cy.get('.m-onboarding__controls .m-onboarding__control label').contains('Mobile Phone Number'); // open country dropdown cy.get('.m-onboarding__controls .m-phone-input--selected-flag').click(); // click on UK cy.get('.m-phone-input--country-list li span[data-minds=54]').click(); // Uk should be selected cy.get('.m-phone-input--selected-flag .m-phone-input--dial-code').contains('+54'); // add the number cy.get('#phone').type('012345678'); // should have a Location input cy.get('.m-onboarding__controls > .m-onboarding__control label[data-minds=location]').contains('Location'); cy.get('.m-onboarding__controls > .m-onboarding__control input[data-minds=locationInput]').type('London'); // should have Date of Birth inputs cy.get('.m-onboarding__controls > .m-onboarding__control label[data-minds=dateOfBirth]').contains('Date of Birth'); // open month selection and pick February cy.get('.m-onboarding__controls > .m-onboarding__control select[data-minds=monthDropdown]').select('February'); // open day selection and pick 2nd cy.get('.m-onboarding__controls > .m-onboarding__control select[data-minds=dayDropdown]').select('2'); // open year selection and pick 1991 cy.get('.m-onboarding__controls > .m-onboarding__control select[data-minds=yearDropdown]').select('1991'); // should have a continue and a skip button cy.get('button.mf-button--hollow').contains('Skip'); cy.get('button.mf-button--alt').contains('Continue').click(); // should be in the Groups step // should have a groups list // cy.get('.m-groupList__list').should('exist'); // clicking on a group join button should join the group // cy.get('.m-groupList__list .m-groupList__item:first-child .m-join__subscribe').contains('add').click(); // // button should change to a check, and clicking on it should leave the group // cy.get('.m-groupList__list .m-groupList__item:first-child .m-join__subscribed').contains('check').click(); // cy.get('.m-groupList__list .m-groupList__item:first-child .m-join__subscribe i').contains('add'); // should have a continue and a skip button cy.get('button.mf-button--hollow').contains('Skip'); cy.get('button.mf-button--alt').contains('Continue').click(); // should be in the Channels step // should have a channels list // cy.get('.m-channelList__list').should('exist'); // // clicking on a group join button should join the group // cy.get('.m-channelList__list .m-channelList__item:first-child .m-join__subscribe').contains('add').click(); // // button should change to a check, and clicking on it should leave the channel // cy.get('.m-channelList__list .m-channelList__item:first-child .m-join__subscribed').contains('check').click(); // cy.get('.m-channelList__list .m-channelList__item:first-child .m-join__subscribe i').contains('add'); // should have a continue and a skip button cy.get('button.mf-button--hollow').contains('Skip'); cy.get('button.mf-button--alt').contains('Finish').click(); // should be in the newsfeed cy.location('pathname').should('eq', '/newsfeed/subscriptions'); }); }); Loading
cypress/integration/comments/comment-threads.spec.js +112 −14 Original line number Original line Diff line number Diff line import generateRandomId from '../../support/utilities'; /** /** * @author Ben Hayward * @author Ben Hayward * @create date 2019-08-09 14:42:51 * @create date 2019-08-09 14:42:51 Loading @@ -6,6 +8,9 @@ */ */ context('Comment Threads', () => { context('Comment Threads', () => { const testUsername = generateRandomId(); const testPassword = generateRandomId() + 'rR.7'; const testMessage = { const testMessage = { 1: 'test tier 1', 1: 'test tier 1', 2: 'test tier 2', 2: 'test tier 2', Loading @@ -17,8 +22,6 @@ context('Comment Threads', () => { const deletePostButton = ".m-modal-confirm-buttons > button:contains('Delete')"; const deletePostButton = ".m-modal-confirm-buttons > button:contains('Delete')"; const postCommentButton = 'm-comment__poster > div > div.minds-body > div > div > a.m-post-button'; const postCommentButton = 'm-comment__poster > div > div.minds-body > div > div > a.m-post-button'; const thumbsUpCounters = '.m-comment__toolbar > div > minds-button-thumbs-up > a > span'; const thumbsDownCounters = '.m-comment__toolbar > div > minds-button-thumbs-down > a > span'; // pass in tier / tree depth. // pass in tier / tree depth. const replyButton = `minds-activity:first .m-comment__toolbar > div > span`; const replyButton = `minds-activity:first .m-comment__toolbar > div > span`; Loading @@ -26,6 +29,11 @@ context('Comment Threads', () => { const commentInput = `minds-activity:first m-text-input--autocomplete-container > minds-textarea > div`; const commentInput = `minds-activity:first m-text-input--autocomplete-container > minds-textarea > div`; const commentContent = `minds-activity:first m-comments__tree .m-comment__bubble > p`; const commentContent = `minds-activity:first m-comments__tree .m-comment__bubble > p`; const thumbsUpCounters = '[data-cy=data-minds-thumbs-up-counter]' //'minds-button-thumbs-up > a > span'; const thumbsDownCounters = '[data-cy=data-minds-thumbs-down-counter]'; const thumbsUpButton = '[data-cy=data-minds-thumbs-up-button]' const thumbsDownButton = '[data-cy=data-minds-thumbs-down-button]' before(() => { before(() => { //make a post new. //make a post new. cy.getCookie('minds_sess') cy.getCookie('minds_sess') Loading @@ -44,6 +52,10 @@ context('Comment Threads', () => { beforeEach(()=> { beforeEach(()=> { cy.preserveCookies(); cy.preserveCookies(); cy.server(); cy.route('GET', '**/api/v2/comments/**').as('commentsOpen'); cy.route('POST', '**/api/v1/comments/**').as('postComment'); cy.route('PUT', '**/api/v1/thumbs/**').as('thumbsPut'); }); }); after(() => { after(() => { Loading @@ -63,13 +75,21 @@ context('Comment Threads', () => { cy.get(commentContent).contains(testMessage[1]); cy.get(commentContent).contains(testMessage[1]); //Add the second level of comments //Add the second level of comments cy.get(replyButton).click(); cy.get(replyButton) .click() .wait('@commentsOpen') .then(xhr => { expect(xhr.status).to.equal(200); }); cy.get(commentInput) cy.get(commentInput) .first() .first() .type(testMessage[2]); .type(testMessage[2]); cy.get(postCommentButton) cy.get(postCommentButton) .first() .first() .click(); .click(); cy.get(commentContent).contains(testMessage[2]); cy.get(commentContent).contains(testMessage[2]); Loading @@ -78,30 +98,108 @@ context('Comment Threads', () => { .find('m-comments__tree m-comments__thread m-comment') .find('m-comments__tree m-comments__thread m-comment') .find('m-comments__thread m-comment:nth-child(2) .m-comment__toolbar > div > span') .find('m-comments__thread m-comment:nth-child(2) .m-comment__toolbar > div > span') .last() .last() .click(); .click() .wait('@commentsOpen') .then(xhr => { expect(xhr.status).to.equal(200); }); cy.get(commentInput) cy.get(commentInput) .first() .first() .type(testMessage[3]); .type(testMessage[3]); cy.get(postCommentButton) cy.get(postCommentButton) .first() .first() .click(); .click(); cy.get(commentContent).contains(testMessage[3]); cy.get(commentContent).contains(testMessage[3]); //click thumbs up and down // Waiting on component init here. cy.get('.m-comment__toolbar') // If still not fully loaded will not break, .find('minds-button-thumbs-up') // but may mean some of the buttons aren't tested. cy.wait(1000); // scope further get requests down to within the comments toolbar // avoids clicking thumbs in activity feed. cy.get('.m-comment__toolbar').within(($list) => { // thumbs up and down cy.get(thumbsUpButton) .click({multiple: true}); .click({multiple: true}); cy.get('.m-comment__toolbar') cy.get(thumbsDownButton) .find('minds-button-thumbs-down') .click({multiple: true}); .click({multiple: true}); // check the values // check counters cy.get(thumbsUpCounters) cy.get(thumbsUpCounters) .each((counter) => expect(counter.context.innerHTML).to.eql('1')); .each((counter) => { expect(counter[0].innerHTML).to.eql('1'); }); }); cy.get(thumbsDownCounters) cy.get(thumbsDownCounters) .each((counter) => expect(counter.context.innerHTML).to.eql('1')); .each((counter) => { expect(counter[0].innerHTML).to.eql('1'); }); }); it('should allow the user to make a mature comment', () => { // type message cy.get('minds-textarea') .last() .type("naughty message"); // click mature cy.get('.m-mature-button') .last() .click(); // post and await response cy.get('.m-post-button') .last() .click() .wait('@postComment') .then(xhr => { expect(xhr.status).to.equal(200); }); // Making sure we don't act upon other comments cy.get('.m-comment__bubble').parent().within($list => { cy.contains('naughty message') .should('not.have.class', 'm-mature-text'); cy.get('.m-redButton') .click(); cy.contains('naughty message') .should('have.class', 'm-mature-text'); }); // get share link cy.get(postMenu).click(); cy.contains('Share').click(); // store share link cy.get('.m-share__copyableLinkText') .invoke('val') .then(val => { // log out cy.logout(); // visit link cy.visit(val); // assert toggle works. cy.contains('naughty message') .should('have.class', 'm-mature-text'); cy.get('.m-mature-text-toggle') .click(); cy.contains('naughty message') .should('not.have.class', 'm-mature-text'); }); }); }); }) })
cypress/integration/groups/groups.spec.js +40 −27 Original line number Original line Diff line number Diff line import generateRandomId from '../../support/utilities'; const groupId = generateRandomId(); context('Groups', () => { context('Groups', () => { before(() => { before(() => { cy.getCookie('minds_sess') cy.getCookie('minds_sess') Loading Loading @@ -25,7 +29,7 @@ context('Groups', () => { cy.uploadFile('minds-banner #file', '../fixtures/international-space-station-1776401_1920.jpg', 'image/jpg'); cy.uploadFile('minds-banner #file', '../fixtures/international-space-station-1776401_1920.jpg', 'image/jpg'); // add a name // add a name cy.get('.m-group-info-name > input').type('test'); cy.get('.m-group-info-name > input').type(groupId); // add a description // add a description cy.get('.m-group-info-brief-description > textarea').type('This is a test'); cy.get('.m-group-info-brief-description > textarea').type('This is a test'); Loading @@ -41,6 +45,8 @@ context('Groups', () => { cy.get('.m-groups-save > button').contains('Create').click(); cy.get('.m-groups-save > button').contains('Create').click(); cy.route("POST", "**/api/v1/groups/group/*/banner*").as("postBanner"); cy.route("POST", "**/api/v1/groups/group/*/banner*").as("postBanner"); // get current groups count of sidebar cy.get('.m-groupSidebarMarkers__list').children().its('length').then((size) => { cy.wait('@postGroup').then((xhr) => { cy.wait('@postGroup').then((xhr) => { expect(xhr.status).to.equal(200); expect(xhr.status).to.equal(200); expect(xhr.response.body.status).to.equal('success'); expect(xhr.response.body.status).to.equal('success'); Loading @@ -49,7 +55,10 @@ context('Groups', () => { expect(xhr.response.body.status).to.equal('success'); expect(xhr.response.body.status).to.equal('success'); }); }); cy.get('.m-groupInfo__name').contains('test'); //check count changed. cy.get('.m-groupSidebarMarkers__list').children().should('have.length', size + 1); }); cy.get('.m-groupInfo__name').contains(groupId); cy.get('.m-groupInfo__description').contains('This is a test'); cy.get('.m-groupInfo__description').contains('This is a test'); // open settings button // open settings button Loading @@ -58,7 +67,7 @@ context('Groups', () => { cy.get('minds-groups-settings-button ul.minds-dropdown-menu li:first-child').contains('Edit').click(); cy.get('minds-groups-settings-button ul.minds-dropdown-menu li:first-child').contains('Edit').click(); // edit name // edit name cy.get('.m-groupInfo__name input').type(' group'); cy.get('.m-groupInfo__name input').type(' edit'); // edit description // edit description cy.get('.m-groupInfo__description textarea').type(' group'); cy.get('.m-groupInfo__description textarea').type(' group'); Loading @@ -68,16 +77,12 @@ context('Groups', () => { cy.get('minds-groups-settings-button ul.minds-dropdown-menu li:first-child').contains('Save').click(); cy.get('minds-groups-settings-button ul.minds-dropdown-menu li:first-child').contains('Save').click(); cy.get('.m-groupInfo__name').contains('test group'); cy.get('.m-groupInfo__name').contains(groupId + ' edit'); cy.get('.m-groupInfo__description').contains('This is a test group'); cy.get('.m-groupInfo__description').contains('This is a test group'); }) }) it('should be able to toggle conversation and comment on it', () => { it('should be able to toggle conversation and comment on it', () => { cy.contains(groupId).click(); cy.get("m-group--sidebar-markers li:contains('test group')") .first() .click(); // toggle the conversation // toggle the conversation cy.get('.m-groupGrid__right').should('be.visible'); cy.get('.m-groupGrid__right').should('be.visible'); Loading @@ -98,9 +103,7 @@ context('Groups', () => { }) }) it('should post an activity inside the group and record the view when scrolling', () => { it('should post an activity inside the group and record the view when scrolling', () => { cy.get("m-group--sidebar-markers li:contains('test group')") cy.contains(groupId).click(); .first() .click(); cy.server(); cy.server(); cy.route("POST", "**/api/v2/analytics/views/activity/*").as("view"); cy.route("POST", "**/api/v2/analytics/views/activity/*").as("view"); Loading @@ -110,7 +113,7 @@ context('Groups', () => { cy.get('.m-posterActionBar__PostButton').click(); cy.get('.m-posterActionBar__PostButton').click(); // the activity should show that it was posted in this group // the activity should show that it was posted in this group cy.get('.minds-list minds-activity .body a:nth-child(2)').contains('(test group)'); cy.get('.minds-list minds-activity .body a:nth-child(2)').contains(`(${groupId} edit)`); cy.get('.minds-list minds-activity .m-mature-message-content').contains('This is a post'); cy.get('.minds-list minds-activity .m-mature-message-content').contains('This is a post'); Loading @@ -127,15 +130,25 @@ context('Groups', () => { }); }); }); }); it('should delete a group', () => { it('should navigate to discovery when Find a Group clicked', () => { cy.get('m-group--sidebar-markers li:nth-child(3)').contains('test group').click(); cy.contains('Find a Group').click() cy.location('pathname') .should('eq', '/newsfeed/global/top%3Bperiod%3D12h%3Btype%3Dgroups%3Ball%3D1'); }); it('should delete a group', () => { cy.get('.m-groupSidebarMarkers__list').children().its('length').then((size) => { // cy.get(`m-group--sidebar-markers li:nth-child(${size - 2})`).click(); cy.contains(groupId).click(); // cleanup // cleanup cy.get('minds-groups-settings-button > button').click(); cy.get('minds-groups-settings-button > button').click(); cy.get('minds-groups-settings-button ul.minds-dropdown-menu > li:nth-child(8)').contains('Delete Group').click(); cy.contains('Delete Group').click(); cy.get('minds-groups-settings-button m-modal .mdl-button--raised').contains('Confirm').click(); cy.contains('Confirm').click(); cy.location('pathname').should('eq', '/groups/member'); cy.location('pathname').should('eq', '/groups/member'); }) cy.get('.m-groupSidebarMarkers__list').children().should('have.length', size - 1); }); }); }) })
cypress/integration/login.spec.js +6 −6 Original line number Original line Diff line number Diff line Loading @@ -5,36 +5,36 @@ context('Login', () => { }) }) it('should login', () => { it('should login', () => { cy.get('.m-v2-topbar__Container__LoginWrapper > a').click(); cy.get('.m-v2-topbar__Container__LoginWrapper > a').contains('Login').click(); cy.location('pathname').should('eq', '/login'); cy.location('pathname').should('eq', '/login'); // it should have a login form // it should have a login form cy.get('.m-login').should('be.visible'); cy.get('.m-login__wrapper').should('be.visible'); cy.get('minds-form-login .m-login-box .mdl-cell:first-child input').type(Cypress.env().username); cy.get('minds-form-login .m-login-box .mdl-cell:first-child input').type(Cypress.env().username); cy.get('minds-form-login .m-login-box .mdl-cell:last-child input').type(Cypress.env().password); cy.get('minds-form-login .m-login-box .mdl-cell:last-child input').type(Cypress.env().password); cy.get('minds-form-login .m-btn--login').click(); cy.get('minds-form-login .mf-button--alt').click(); cy.location('pathname') cy.location('pathname') .should('eq', '/newsfeed/subscriptions'); .should('eq', '/newsfeed/subscriptions'); }) }) it('should fail to login because of incorrect password', () => { it('should fail to login because of incorrect password', () => { cy.get('.m-v2-topbar__Container__LoginWrapper > a').click(); cy.get('.m-v2-topbar__Container__LoginWrapper > a').contains('Login').click(); cy.location('pathname').should('eq', '/login'); cy.location('pathname').should('eq', '/login'); // it should have a login form // it should have a login form cy.get('.m-login').should('be.visible'); cy.get('.m-login__wrapper').should('be.visible'); cy.get('minds-form-login .m-login-box .mdl-cell:first-child input').type(Cypress.env().username); cy.get('minds-form-login .m-login-box .mdl-cell:first-child input').type(Cypress.env().username); cy.get('minds-form-login .m-login-box .mdl-cell:last-child input').type(Cypress.env().password + '1'); cy.get('minds-form-login .m-login-box .mdl-cell:last-child input').type(Cypress.env().password + '1'); cy.get('minds-form-login .m-btn--login').click(); cy.get('minds-form-login .mf-button--alt').click(); cy.wait(500); cy.wait(500); Loading
cypress/integration/onboarding.spec.jsdeleted 100644 → 0 +0 −75 Original line number Original line Diff line number Diff line context('Onboarding', () => { const email = 'test@minds.com'; const password = 'Passw0rd!'; const name = "Tester"; const description = "I am a tester, with a not so lengthy description"; const welcomeText = "Welcome to Minds!"; const usernameField = 'minds-form-register #username'; const emailField = 'minds-form-register #email'; const passwordField = 'minds-form-register #password'; const password2Field = 'minds-form-register #password2'; const nameField = '#display-name'; const descriptionfield = '#description'; const phoneNumberInput = '#phone'; const countryDropdown = 'm-phone-input--country > div'; const ukOption = 'm-phone-input--country > ul > li:nth-child(2)'; const dialcode = '.m-phone-input--dial-code'; const checkbox = 'minds-form-register label:nth-child(2) .mdl-ripple--center'; const submitButton = 'minds-form-register .mdl-card__actions button'; const nextButton = '.m-channelOnboarding__next'; const submitPhoneButton = 'm-channel--onboarding--rewards > div > div > button'; const loadingSpinner = '.mdl-spinner__gap-patch'; const getTopic = (i) => `m-onboarding--topics > div > ul > li:nth-child(${i}) span`; before(() => { cy.clearCookies(); cy.visit('/login'); //type values cy.get(usernameField).focus().type(Math.random().toString(36).replace('0.', '')); cy.get(emailField).focus().type(email); cy.get(passwordField).focus().type(password); cy.get(password2Field).focus().type(password); cy.get(checkbox).click(); //submit cy.get(submitButton).click(); //onboarding modal shown cy.get('m-onboarding--topics > div > h2:nth-child(1)') .contains(welcomeText); }); it('should allow a user to run through onboarding modals', () => { //select topics cy.get(getTopic(3)).click().should('have.class', 'selected') cy.get(getTopic(4)).click().should('have.class', 'selected') cy.get(getTopic(5)).click().should('have.class', 'selected') //click cy.get(nextButton).click(); //TODO: Skipped over for now as subscribed channels is not working on staging environment. cy.get(nextButton).click(); cy.get(nameField).clear().type(name); cy.get(descriptionfield).type(description); cy.get(nextButton).click(); //set dialcode cy.get(countryDropdown).click(); cy.get(ukOption).click(); cy.get(dialcode).contains('+44'); //type number cy.get(phoneNumberInput).type('7700000000'); //submit and check loading spinner. cy.get(submitPhoneButton).click(); cy.get(loadingSpinner).should('be.visible'); cy.get(nextButton).click(); }); });
cypress/integration/onboarding/onboarding.spec.js 0 → 100644 +128 −0 Original line number Original line Diff line number Diff line context('Onboarding', () => { const remindText = 'remind test text'; before(() => { cy.getCookie('minds_sess') .then((sessionCookie) => { if (sessionCookie === null) { return cy.login(true); } }); cy.visit(`/onboarding`); // create two test groups }); beforeEach(() => { cy.preserveCookies(); }); it('should go through the process of onboarding', () => { // notice should appear cy.get('h1.m-onboarding__noticeTitle').contains('Welcome to the Minds Community'); cy.get('h2.m-onboarding__noticeTitle').contains(`@${Cypress.env().username}`); // should redirect to /hashtags cy.get('.m-onboarding__form button.mf-button').contains("Let's Get Setup").click(); cy.wait(1000); // should be in the hashtags step // should have a Profile Setup title cy.get('.m-onboarding__form > h2').contains('Profile Setup'); // should have a progressbar, with the hashtags step highlighted cy.get('.m-onboardingProgressbar__item--selected span').contains('1'); cy.get('.m-onboardingProgressbar__item--selected span').contains('Hashtags'); // should have a description cy.get('.m-onboarding__form .m-onboarding__description').contains('Select some hashtags that are of interest to you.'); // should have a list of selectable hashtags cy.get('.m-hashtags__list li.m-hashtagsList__item').contains('Art').click(); cy.get('.m-hashtags__list li.m-hashtagsList__item.m-hashtagsList__item--selected').contains('Art'); cy.get('.m-hashtags__list li.m-hashtagsList__item').contains('Journalism').click(); cy.get('.m-hashtags__list li.m-hashtagsList__item.m-hashtagsList__item--selected'); cy.get('.m-hashtags__list li.m-hashtagsList__item').contains('Music').click(); cy.get('.m-hashtags__list li.m-hashtagsList__item.m-hashtagsList__item--selected'); // should have a continue and a skip button cy.get('button.mf-button--hollow').contains('Skip'); cy.get('button.mf-button--alt').contains('Continue').click(); // should be in the info step cy.get('.m-onboardingProgressbar__item--selected span').contains('2'); cy.get('.m-onboardingProgressbar__item--selected span').contains('Info'); // should have a Mobile Phone Number input cy.get('.m-onboarding__controls .m-onboarding__control label').contains('Mobile Phone Number'); // open country dropdown cy.get('.m-onboarding__controls .m-phone-input--selected-flag').click(); // click on UK cy.get('.m-phone-input--country-list li span[data-minds=54]').click(); // Uk should be selected cy.get('.m-phone-input--selected-flag .m-phone-input--dial-code').contains('+54'); // add the number cy.get('#phone').type('012345678'); // should have a Location input cy.get('.m-onboarding__controls > .m-onboarding__control label[data-minds=location]').contains('Location'); cy.get('.m-onboarding__controls > .m-onboarding__control input[data-minds=locationInput]').type('London'); // should have Date of Birth inputs cy.get('.m-onboarding__controls > .m-onboarding__control label[data-minds=dateOfBirth]').contains('Date of Birth'); // open month selection and pick February cy.get('.m-onboarding__controls > .m-onboarding__control select[data-minds=monthDropdown]').select('February'); // open day selection and pick 2nd cy.get('.m-onboarding__controls > .m-onboarding__control select[data-minds=dayDropdown]').select('2'); // open year selection and pick 1991 cy.get('.m-onboarding__controls > .m-onboarding__control select[data-minds=yearDropdown]').select('1991'); // should have a continue and a skip button cy.get('button.mf-button--hollow').contains('Skip'); cy.get('button.mf-button--alt').contains('Continue').click(); // should be in the Groups step // should have a groups list // cy.get('.m-groupList__list').should('exist'); // clicking on a group join button should join the group // cy.get('.m-groupList__list .m-groupList__item:first-child .m-join__subscribe').contains('add').click(); // // button should change to a check, and clicking on it should leave the group // cy.get('.m-groupList__list .m-groupList__item:first-child .m-join__subscribed').contains('check').click(); // cy.get('.m-groupList__list .m-groupList__item:first-child .m-join__subscribe i').contains('add'); // should have a continue and a skip button cy.get('button.mf-button--hollow').contains('Skip'); cy.get('button.mf-button--alt').contains('Continue').click(); // should be in the Channels step // should have a channels list // cy.get('.m-channelList__list').should('exist'); // // clicking on a group join button should join the group // cy.get('.m-channelList__list .m-channelList__item:first-child .m-join__subscribe').contains('add').click(); // // button should change to a check, and clicking on it should leave the channel // cy.get('.m-channelList__list .m-channelList__item:first-child .m-join__subscribed').contains('check').click(); // cy.get('.m-channelList__list .m-channelList__item:first-child .m-join__subscribe i').contains('add'); // should have a continue and a skip button cy.get('button.mf-button--hollow').contains('Skip'); cy.get('button.mf-button--alt').contains('Finish').click(); // should be in the newsfeed cy.location('pathname').should('eq', '/newsfeed/subscriptions'); }); });