From 5a24e9d7d6b9f54306221845fa185ae82dc35ac1 Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Fri, 26 Apr 2019 16:34:22 -0400 Subject: [PATCH 1/8] change studios for project API request to use admin status, owner status and token --- src/redux/preview.js | 5 +++-- src/views/preview/project-view.jsx | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/redux/preview.js b/src/redux/preview.js index 0a3eb2a5d..4fbf21241 100644 --- a/src/redux/preview.js +++ b/src/redux/preview.js @@ -763,10 +763,11 @@ module.exports.getRemixes = id => (dispatch => { }); }); -module.exports.getProjectStudios = id => (dispatch => { +module.exports.getProjectStudios = (id, ownerUsername, isAdmin, token) => (dispatch => { dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.FETCHING)); api({ - uri: `/projects/${id}/studios` + uri: `${isAdmin ? '/admin' : `/users/${ownerUsername}`}/projects/${id}/studios`, + authentication: token }, (err, body, res) => { if (err) { dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.ERROR)); diff --git a/src/views/preview/project-view.jsx b/src/views/preview/project-view.jsx index 903d01fd4..eac5fe7aa 100644 --- a/src/views/preview/project-view.jsx +++ b/src/views/preview/project-view.jsx @@ -160,7 +160,10 @@ class Preview extends React.Component { if (typeof this.props.projectInfo.id === 'undefined') { this.initCounts(0, 0); } else { + const token = this.props.user ? this.props.user.token : null; this.initCounts(this.props.projectInfo.stats.favorites, this.props.projectInfo.stats.loves); + this.props.getProjectStudios(this.props.projectInfo.id, + this.props.authorUsername, this.props.isAdmin, token); if (this.props.projectInfo.remix.parent !== null) { this.props.getParentInfo(this.props.projectInfo.remix.parent); } @@ -216,7 +219,6 @@ class Preview extends React.Component { } this.props.getProjectInfo(this.state.projectId, token); this.props.getRemixes(this.state.projectId, token); - this.props.getProjectStudios(this.state.projectId, token); this.props.getCuratedStudios(username); this.props.getFavedStatus(this.state.projectId, username, token); this.props.getLovedStatus(this.state.projectId, username, token); @@ -228,7 +230,6 @@ class Preview extends React.Component { } this.props.getProjectInfo(this.state.projectId); this.props.getRemixes(this.state.projectId); - this.props.getProjectStudios(this.state.projectId); } } setScreenFromOrientation () { @@ -984,8 +985,8 @@ const mapDispatchToProps = dispatch => ({ getRemixes: id => { dispatch(previewActions.getRemixes(id)); }, - getProjectStudios: id => { - dispatch(previewActions.getProjectStudios(id)); + getProjectStudios: (id, ownerUsername, isAdmin, token) => { + dispatch(previewActions.getProjectStudios(id, ownerUsername, isAdmin, token)); }, getCuratedStudios: (username, token) => { dispatch(previewActions.getCuratedStudios(username, token)); From 975a9c964555523616055e6287a46ccfc16e6a1c Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Tue, 28 May 2019 15:11:17 -0400 Subject: [PATCH 2/8] omit token if null or falsy --- src/redux/preview.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/redux/preview.js b/src/redux/preview.js index 4fbf21241..239a4a93e 100644 --- a/src/redux/preview.js +++ b/src/redux/preview.js @@ -763,12 +763,16 @@ module.exports.getRemixes = id => (dispatch => { }); }); + module.exports.getProjectStudios = (id, ownerUsername, isAdmin, token) => (dispatch => { dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.FETCHING)); - api({ - uri: `${isAdmin ? '/admin' : `/users/${ownerUsername}`}/projects/${id}/studios`, - authentication: token - }, (err, body, res) => { + const opts = { + uri: `${isAdmin ? '/admin' : `/users/${ownerUsername}`}/projects/${id}/studios` + }; + if (token) { + Object.assign(opts, {authentication: token}); + } + api(opts, (err, body, res) => { if (err) { dispatch(module.exports.setFetchStatus('projectStudios', module.exports.Status.ERROR)); dispatch(module.exports.setError(err)); From 1b995908a28e816f5ecef85c556dedd015ad608d Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Mon, 20 May 2019 12:01:15 -0400 Subject: [PATCH 3/8] update react-modal --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cfeeae5aa..80c8c5a6a 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "react": "16.2.0", "react-dom": "16.2.0", "react-intl": "2.8.0", - "react-modal": "3.1.11", + "react-modal": "3.4.1", "react-onclickoutside": "6.7.1", "react-redux": "5.0.7", "react-responsive": "3.0.0", From 9ae9177ae5bdf66ca0e5fad855aa44b18bdd330e Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Mon, 20 May 2019 17:16:34 -0400 Subject: [PATCH 4/8] added tests --- test/integration/selenium-helpers.js | 31 +++++++---- .../smoke-testing/test_project_page.js | 55 +++++++++++++++++++ 2 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 test/integration/smoke-testing/test_project_page.js diff --git a/test/integration/selenium-helpers.js b/test/integration/selenium-helpers.js index 14e8a0a63..1edc54b98 100644 --- a/test/integration/selenium-helpers.js +++ b/test/integration/selenium-helpers.js @@ -12,19 +12,20 @@ const {By, Key, until} = webdriver; class SeleniumHelper { constructor () { bindAll(this, [ - 'getDriver', - 'getSauceDriver', - 'getKey', 'buildDriver', - 'clickXpath', - 'findByXpath', - 'clickText', - 'findText', 'clickButton', - 'findByCss', 'clickCss', - 'urlMatches', - 'getLogs' + 'clickText', + 'clickXpath', + 'dragFromXpathToXpath', + 'findByCss', + 'findByXpath', + 'findText', + 'getKey', + 'getDriver', + 'getLogs', + 'getSauceDriver', + 'urlMatches' ]); } buildDriver (name) { @@ -113,6 +114,16 @@ class SeleniumHelper { return this.findByCss(css).then(el => el.click()); } + dragFromXpathToXpath (startXpath, endXpath) { + return this.findByXpath(startXpath).then(startEl => { + return this.findByXpath(endXpath).then(endEl => { + return this.driver.actions() + .dragAndDrop(startEl, endEl) + .perform(); + }); + }); + } + urlMatches (regex) { return this.driver.wait(until.urlMatches(regex), 1000 * 5); } diff --git a/test/integration/smoke-testing/test_project_page.js b/test/integration/smoke-testing/test_project_page.js new file mode 100644 index 000000000..0ec9f1373 --- /dev/null +++ b/test/integration/smoke-testing/test_project_page.js @@ -0,0 +1,55 @@ +const SeleniumHelper = require('../selenium-helpers.js'); +const helper = new SeleniumHelper(); + +var tap = require('tap'); +const test = tap.test; + +const driver = helper.buildDriver('www-smoke test_sign_in_out_homepage'); + +const { + clickText, + clickXpath, + dragFromXpathToXpath +} = helper; + +const rootUrl = process.env.ROOT_URL || 'https://scratch.ly'; +const projectId = 1; +const projectUrl = `${rootUrl}/projects/${projectId}`; + +tap.plan(3); + +tap.tearDown(function () { + driver.quit(); +}); + +tap.beforeEach(function () { + return driver.get(projectUrl); +}); + +test('Find fullscreen button', t => { + clickXpath('//div[starts-with(@class, "loader_background")]') + .then(() => clickXpath('//div[starts-with(@class, "stage_green-flag-overlay")]')) + .then(() => clickXpath('//img[contains(@alt, "Enter full screen mode")]')) + .then(() => t.end()); +}); + +test('Open and close Copy Link modal', t => { + clickText('Copy Link') + .then(() => clickXpath('//div[contains(@class, "social-label-title")]')) + .then(() => clickXpath('//img[contains(@alt, "close-icon")]')) + .then(() => clickXpath('//img[contains(@alt, "Enter full screen mode")]')) + .then(() => t.end()); +}); + +test('Dragging out of modal should not close modal', t => { + clickXpath('//div[starts-with(@class, "loader_background")]') + .then(() => clickXpath('//div[starts-with(@class, "stage_green-flag-overlay")]')) + .then(() => clickText('Copy Link')) + .then(() => clickXpath('//div[contains(@class, "social-label-title")]')) + .then(() => dragFromXpathToXpath( + '//div[contains(@class, "social-label-title")]', + '//li[contains(@class, "logo")]' + )) + .then(() => clickXpath('//div[contains(@class, "social-label-title")]')) + .then(() => t.end()); +}); From 54d4c020f33052eff80963be7381cfd25e9e5770 Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Fri, 31 May 2019 11:30:39 -0400 Subject: [PATCH 5/8] removed all footer link tests for external sites --- .../cypress/smoke-tests/test-footer-links.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/integration-cypress/cypress/smoke-tests/test-footer-links.js b/test/integration-cypress/cypress/smoke-tests/test-footer-links.js index d178372fb..3b6fa29f7 100644 --- a/test/integration-cypress/cypress/smoke-tests/test-footer-links.js +++ b/test/integration-cypress/cypress/smoke-tests/test-footer-links.js @@ -71,7 +71,7 @@ describe('test About links in footer', function () { .should('eq', baseUrl + '/jobs'); }); - it('click Press', function (){ + it.skip('click Press', function (){ cy .get('.lists :first-child :nth-child(8) :first-child :first-child') .click(); @@ -112,7 +112,7 @@ describe('test Community links in footer', function () { .should('eq', baseUrl + '/discuss/'); }); - it('click Scratch Wiki', function (){ + it.skip('click Scratch Wiki', function (){ cy .get('.lists :nth-child(2) :nth-child(4) :first-child :first-child') .click(); @@ -247,7 +247,7 @@ describe('test Scratch Family links in footer', function () { cy.visit('/'); }); - it('click ScratchEd', function (){ + it.skip('click ScratchEd', function (){ cy .get('.lists :nth-child(5) :nth-child(2) a') .click(); @@ -256,7 +256,7 @@ describe('test Scratch Family links in footer', function () { .should('match', /^http:\/\/scratched\.gse\.harvard\.edu\/?$/); }); - it('click For ScratchJr', function (){ + it.skip('click For ScratchJr', function (){ cy .get('.lists :nth-child(5) :nth-child(3) a') .click(); @@ -285,7 +285,7 @@ describe('test Scratch Family links in footer', function () { .should('eq', baseUrl + '/conference'); }); - it('click Scratch Foundation', function (){ + it.skip('click Scratch Foundation', function (){ cy .get('.lists :nth-child(5) :nth-child(6) :first-child :first-child') .click(); From 7673bf9086dbbbb1ccab3339a8be810211c8f329 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 4 Jun 2019 20:41:19 +0000 Subject: [PATCH 6/8] chore(package): update scratch-gui to version 0.1.0-prerelease.20190604202002 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e52e12965..1afa241dc 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "react-responsive": "3.0.0", "react-slick": "0.16.0", "react-string-replace": "0.4.1", - "scratch-gui": "0.1.0-prerelease.20190530174801", + "scratch-gui": "0.1.0-prerelease.20190604202002", "react-telephone-input": "4.3.4", "redux": "3.5.2", "redux-thunk": "2.0.1", From 772ab75b12b91701c558f5a398e37c8d32712f81 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 5 Jun 2019 15:09:39 +0000 Subject: [PATCH 7/8] chore(package): update scratch-gui to version 0.1.0-prerelease.20190605144936 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1afa241dc..7c983b26f 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "react-responsive": "3.0.0", "react-slick": "0.16.0", "react-string-replace": "0.4.1", - "scratch-gui": "0.1.0-prerelease.20190604202002", + "scratch-gui": "0.1.0-prerelease.20190605144936", "react-telephone-input": "4.3.4", "redux": "3.5.2", "redux-thunk": "2.0.1", From f5c16181a72eb7ad74fa0cf862ed9f286a9fae55 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 5 Jun 2019 19:05:04 +0000 Subject: [PATCH 8/8] chore(package): update scratch-gui to version 0.1.0-prerelease.20190605185254 Closes #3033 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7c983b26f..2f730a6e0 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "react-responsive": "3.0.0", "react-slick": "0.16.0", "react-string-replace": "0.4.1", - "scratch-gui": "0.1.0-prerelease.20190605144936", + "scratch-gui": "0.1.0-prerelease.20190605185254", "react-telephone-input": "4.3.4", "redux": "3.5.2", "redux-thunk": "2.0.1",