Loading cypress/integration/newsfeed.spec.js +40 −17 Original line number Original line Diff line number Diff line Loading @@ -10,6 +10,9 @@ context('Newsfeed', () => { beforeEach(()=> { beforeEach(()=> { cy.preserveCookies(); cy.preserveCookies(); cy.server(); cy.route("POST", "**/api/v1/newsfeed").as("newsfeedPOST"); cy.route("POST", "**/api/v1/media").as("mediaPOST"); }); }); it('should post an activity picking hashtags from the dropdown', () => { it('should post an activity picking hashtags from the dropdown', () => { Loading @@ -26,14 +29,18 @@ context('Newsfeed', () => { // type in another hashtag manually // type in another hashtag manually cy.get('minds-newsfeed-poster m-hashtags-selector m-form-tags-input input').type('hashtag{enter}').click(); cy.get('minds-newsfeed-poster m-hashtags-selector m-form-tags-input input').type('hashtag{enter}').click(); // click away // click away on arbitrary area. cy.get('minds-newsfeed-poster m-hashtags-selector .minds-bg-overlay').click(); cy.get('minds-newsfeed-poster m-hashtags-selector .minds-bg-overlay').click({force: true}); // define request cy.get('.m-posterActionBar__PostButton').click(); cy.get('.m-posterActionBar__PostButton').click(); cy.wait(100); //await response cy.wait('@newsfeedPOST').then((xhr) => { expect(xhr.status).to.equal(200); }); cy.get('.minds-list > minds-activity:first-child .message').contains('This is a post #art #hashtag'); cy.get('.mdl-card__supporting-text.message.m-mature-message > span').first().contains('This is a post #art #hashtag'); cy.get('.minds-list > minds-activity:first-child .message a:first-child').contains('#art').should('have.attr', 'href', '/newsfeed/global/top;hashtag=art;period=24h'); cy.get('.minds-list > minds-activity:first-child .message a:first-child').contains('#art').should('have.attr', 'href', '/newsfeed/global/top;hashtag=art;period=24h'); cy.get('.minds-list > minds-activity:first-child .message a:last-child').contains('#hashtag').should('have.attr', 'href', '/newsfeed/global/top;hashtag=hashtag;period=24h'); cy.get('.minds-list > minds-activity:first-child .message a:last-child').contains('#hashtag').should('have.attr', 'href', '/newsfeed/global/top;hashtag=hashtag;period=24h'); Loading @@ -51,11 +58,16 @@ context('Newsfeed', () => { cy.uploadFile('#attachment-input-poster', '../fixtures/international-space-station-1776401_1920.jpg', 'image/jpg'); cy.uploadFile('#attachment-input-poster', '../fixtures/international-space-station-1776401_1920.jpg', 'image/jpg'); cy.wait(1000); cy.wait('@mediaPOST').then((xhr) => { expect(xhr.status).to.equal(200); }); cy.get('.m-posterActionBar__PostButton').click(); cy.get('.m-posterActionBar__PostButton').click(); cy.wait(300); //await response cy.wait('@newsfeedPOST').then((xhr) => { expect(xhr.status).to.equal(200); }); cy.get('.minds-list > minds-activity:first-child .message').contains('This is a post with an image'); cy.get('.minds-list > minds-activity:first-child .message').contains('This is a post with an image'); Loading Loading @@ -83,7 +95,10 @@ context('Newsfeed', () => { cy.get('.m-posterActionBar__PostButton').click(); cy.get('.m-posterActionBar__PostButton').click(); cy.wait(100); //await response cy.wait('@newsfeedPOST').then((xhr) => { expect(xhr.status).to.equal(200); }); // should have the mature text toggle // should have the mature text toggle cy.get('.minds-list > minds-activity:first-child .message .m-mature-text-toggle').should('not.have.class', 'mdl-color-text--red-500'); cy.get('.minds-list > minds-activity:first-child .message .m-mature-text-toggle').should('not.have.class', 'mdl-color-text--red-500'); Loading Loading @@ -145,6 +160,7 @@ context('Newsfeed', () => { }) }) it('should have a "Buy Tokens" button and it should redirect to /token', () => { it('should have a "Buy Tokens" button and it should redirect to /token', () => { cy.visit('/'); cy.get('.m-page--sidebar--navigation a.m-page--sidebar--navigation--item:last-child span') cy.get('.m-page--sidebar--navigation a.m-page--sidebar--navigation--item:last-child span') .contains('Buy Tokens'); .contains('Buy Tokens'); Loading @@ -155,6 +171,8 @@ context('Newsfeed', () => { }) }) it('"create blog" button in poster should redirect to /blog/edit/new', () => { it('"create blog" button in poster should redirect to /blog/edit/new', () => { cy.visit('/'); cy.get('minds-newsfeed-poster .m-posterActionBar__CreateBlog') cy.get('minds-newsfeed-poster .m-posterActionBar__CreateBlog') .contains('Create blog') .contains('Create blog') .click(); .click(); Loading @@ -163,6 +181,8 @@ context('Newsfeed', () => { }) }) it('clicking on "create blog" button in poster should prompt a confirm dialog and open a new blog with the currently inputted text', () => { it('clicking on "create blog" button in poster should prompt a confirm dialog and open a new blog with the currently inputted text', () => { cy.visit('/'); cy.get('minds-newsfeed-poster textarea').type('thegreatmigration'); // TODO: fix UX issue when hashtag element is overlapping input cy.get('minds-newsfeed-poster textarea').type('thegreatmigration'); // TODO: fix UX issue when hashtag element is overlapping input const stub = cy.stub(); const stub = cy.stub(); Loading @@ -179,6 +199,8 @@ context('Newsfeed', () => { }) }) it('should record a view when the user scrolls and an activity is visible', () => { it('should record a view when the user scrolls and an activity is visible', () => { cy.visit('/'); cy.server(); cy.server(); cy.route("POST", "**/api/v2/analytics/views/activity/*").as("view"); cy.route("POST", "**/api/v2/analytics/views/activity/*").as("view"); // create the post // create the post Loading @@ -186,12 +208,13 @@ context('Newsfeed', () => { cy.get('.m-posterActionBar__PostButton').click(); cy.get('.m-posterActionBar__PostButton').click(); cy.wait(200); //await response cy.wait('@newsfeedPOST').then((xhr) => { expect(xhr.status).to.equal(200); }); cy.scrollTo(0, '20px'); cy.scrollTo(0, '20px'); cy.wait(600); cy.wait('@view', { requestTimeout: 2000 }).then((xhr) => { cy.wait('@view', { requestTimeout: 2000 }).then((xhr) => { expect(xhr.status).to.equal(200); expect(xhr.status).to.equal(200); expect(xhr.response.body).to.deep.equal({ status: 'success' }); expect(xhr.response.body).to.deep.equal({ status: 'success' }); Loading Loading
cypress/integration/newsfeed.spec.js +40 −17 Original line number Original line Diff line number Diff line Loading @@ -10,6 +10,9 @@ context('Newsfeed', () => { beforeEach(()=> { beforeEach(()=> { cy.preserveCookies(); cy.preserveCookies(); cy.server(); cy.route("POST", "**/api/v1/newsfeed").as("newsfeedPOST"); cy.route("POST", "**/api/v1/media").as("mediaPOST"); }); }); it('should post an activity picking hashtags from the dropdown', () => { it('should post an activity picking hashtags from the dropdown', () => { Loading @@ -26,14 +29,18 @@ context('Newsfeed', () => { // type in another hashtag manually // type in another hashtag manually cy.get('minds-newsfeed-poster m-hashtags-selector m-form-tags-input input').type('hashtag{enter}').click(); cy.get('minds-newsfeed-poster m-hashtags-selector m-form-tags-input input').type('hashtag{enter}').click(); // click away // click away on arbitrary area. cy.get('minds-newsfeed-poster m-hashtags-selector .minds-bg-overlay').click(); cy.get('minds-newsfeed-poster m-hashtags-selector .minds-bg-overlay').click({force: true}); // define request cy.get('.m-posterActionBar__PostButton').click(); cy.get('.m-posterActionBar__PostButton').click(); cy.wait(100); //await response cy.wait('@newsfeedPOST').then((xhr) => { expect(xhr.status).to.equal(200); }); cy.get('.minds-list > minds-activity:first-child .message').contains('This is a post #art #hashtag'); cy.get('.mdl-card__supporting-text.message.m-mature-message > span').first().contains('This is a post #art #hashtag'); cy.get('.minds-list > minds-activity:first-child .message a:first-child').contains('#art').should('have.attr', 'href', '/newsfeed/global/top;hashtag=art;period=24h'); cy.get('.minds-list > minds-activity:first-child .message a:first-child').contains('#art').should('have.attr', 'href', '/newsfeed/global/top;hashtag=art;period=24h'); cy.get('.minds-list > minds-activity:first-child .message a:last-child').contains('#hashtag').should('have.attr', 'href', '/newsfeed/global/top;hashtag=hashtag;period=24h'); cy.get('.minds-list > minds-activity:first-child .message a:last-child').contains('#hashtag').should('have.attr', 'href', '/newsfeed/global/top;hashtag=hashtag;period=24h'); Loading @@ -51,11 +58,16 @@ context('Newsfeed', () => { cy.uploadFile('#attachment-input-poster', '../fixtures/international-space-station-1776401_1920.jpg', 'image/jpg'); cy.uploadFile('#attachment-input-poster', '../fixtures/international-space-station-1776401_1920.jpg', 'image/jpg'); cy.wait(1000); cy.wait('@mediaPOST').then((xhr) => { expect(xhr.status).to.equal(200); }); cy.get('.m-posterActionBar__PostButton').click(); cy.get('.m-posterActionBar__PostButton').click(); cy.wait(300); //await response cy.wait('@newsfeedPOST').then((xhr) => { expect(xhr.status).to.equal(200); }); cy.get('.minds-list > minds-activity:first-child .message').contains('This is a post with an image'); cy.get('.minds-list > minds-activity:first-child .message').contains('This is a post with an image'); Loading Loading @@ -83,7 +95,10 @@ context('Newsfeed', () => { cy.get('.m-posterActionBar__PostButton').click(); cy.get('.m-posterActionBar__PostButton').click(); cy.wait(100); //await response cy.wait('@newsfeedPOST').then((xhr) => { expect(xhr.status).to.equal(200); }); // should have the mature text toggle // should have the mature text toggle cy.get('.minds-list > minds-activity:first-child .message .m-mature-text-toggle').should('not.have.class', 'mdl-color-text--red-500'); cy.get('.minds-list > minds-activity:first-child .message .m-mature-text-toggle').should('not.have.class', 'mdl-color-text--red-500'); Loading Loading @@ -145,6 +160,7 @@ context('Newsfeed', () => { }) }) it('should have a "Buy Tokens" button and it should redirect to /token', () => { it('should have a "Buy Tokens" button and it should redirect to /token', () => { cy.visit('/'); cy.get('.m-page--sidebar--navigation a.m-page--sidebar--navigation--item:last-child span') cy.get('.m-page--sidebar--navigation a.m-page--sidebar--navigation--item:last-child span') .contains('Buy Tokens'); .contains('Buy Tokens'); Loading @@ -155,6 +171,8 @@ context('Newsfeed', () => { }) }) it('"create blog" button in poster should redirect to /blog/edit/new', () => { it('"create blog" button in poster should redirect to /blog/edit/new', () => { cy.visit('/'); cy.get('minds-newsfeed-poster .m-posterActionBar__CreateBlog') cy.get('minds-newsfeed-poster .m-posterActionBar__CreateBlog') .contains('Create blog') .contains('Create blog') .click(); .click(); Loading @@ -163,6 +181,8 @@ context('Newsfeed', () => { }) }) it('clicking on "create blog" button in poster should prompt a confirm dialog and open a new blog with the currently inputted text', () => { it('clicking on "create blog" button in poster should prompt a confirm dialog and open a new blog with the currently inputted text', () => { cy.visit('/'); cy.get('minds-newsfeed-poster textarea').type('thegreatmigration'); // TODO: fix UX issue when hashtag element is overlapping input cy.get('minds-newsfeed-poster textarea').type('thegreatmigration'); // TODO: fix UX issue when hashtag element is overlapping input const stub = cy.stub(); const stub = cy.stub(); Loading @@ -179,6 +199,8 @@ context('Newsfeed', () => { }) }) it('should record a view when the user scrolls and an activity is visible', () => { it('should record a view when the user scrolls and an activity is visible', () => { cy.visit('/'); cy.server(); cy.server(); cy.route("POST", "**/api/v2/analytics/views/activity/*").as("view"); cy.route("POST", "**/api/v2/analytics/views/activity/*").as("view"); // create the post // create the post Loading @@ -186,12 +208,13 @@ context('Newsfeed', () => { cy.get('.m-posterActionBar__PostButton').click(); cy.get('.m-posterActionBar__PostButton').click(); cy.wait(200); //await response cy.wait('@newsfeedPOST').then((xhr) => { expect(xhr.status).to.equal(200); }); cy.scrollTo(0, '20px'); cy.scrollTo(0, '20px'); cy.wait(600); cy.wait('@view', { requestTimeout: 2000 }).then((xhr) => { cy.wait('@view', { requestTimeout: 2000 }).then((xhr) => { expect(xhr.status).to.equal(200); expect(xhr.status).to.equal(200); expect(xhr.response.body).to.deep.equal({ status: 'success' }); expect(xhr.response.body).to.deep.equal({ status: 'success' }); Loading