diff --git a/package-lock.json b/package-lock.json index 569902a61..da24eb40d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15725,15 +15725,15 @@ } }, "scratch-gui": { - "version": "0.1.0-prerelease.20200722032238", - "resolved": "https://registry.npmjs.org/scratch-gui/-/scratch-gui-0.1.0-prerelease.20200722032238.tgz", - "integrity": "sha512-s+wcSvbnKwdYSZpa+VY/ki55r6ij+jZ2YmZWT8eqiDJw5VO/QWkmf11IGbEdvTforJgwTBjB+dQm9bWvWH7iYg==", + "version": "0.1.0-prerelease.20200729032223", + "resolved": "https://registry.npmjs.org/scratch-gui/-/scratch-gui-0.1.0-prerelease.20200729032223.tgz", + "integrity": "sha512-enULTkLhNi69oiCEEXteMqxSw12lbKSfcEPifCoDwlFkXCms89M+wyCAUTl/Shvb5j6iYUo6lS0Iq/wcBzJSFQ==", "dev": true }, "scratch-l10n": { - "version": "3.10.20200722030735", - "resolved": "https://registry.npmjs.org/scratch-l10n/-/scratch-l10n-3.10.20200722030735.tgz", - "integrity": "sha512-cjGHaJ5pT7QKxnYg/ItsVL2YU9M1X+Xj2um+qoIkX7nMCI6JWfZ6jXNE4zeSzwD7vGOOF//9ZIMYhxXhlCdljQ==", + "version": "3.10.20200729030742", + "resolved": "https://registry.npmjs.org/scratch-l10n/-/scratch-l10n-3.10.20200729030742.tgz", + "integrity": "sha512-1dwvCHNMN1ycMSOALQNaGgQJvAn7lbyPoM7Atbc+PJrp8dq7MD6GdoZmrA+bVBzncsLuWcBPDL+txCVGyIKPQQ==", "dev": true, "requires": { "@babel/cli": "^7.1.2", diff --git a/package.json b/package.json index 58f8c5bfa..53524a6a7 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "redux-mock-store": "^1.2.3", "redux-thunk": "2.0.1", "sass-loader": "6.0.6", - "scratch-gui": "0.1.0-prerelease.20200722032238", + "scratch-gui": "0.1.0-prerelease.20200729032223", "scratch-l10n": "latest", "selenium-webdriver": "3.6.0", "slick-carousel": "1.6.0", diff --git a/src/lib/jar.js b/src/lib/jar.js index afcc1b277..7947da579 100644 --- a/src/lib/jar.js +++ b/src/lib/jar.js @@ -78,7 +78,8 @@ const Jar = { set: (name, value, opts) => { opts = opts || {}; defaults(opts, { - expires: new Date(new Date().setYear(new Date().getFullYear() + 1)) + expires: new Date(new Date().setYear(new Date().getFullYear() + 1)), + sameSite: 'Strict' // cookie library requires this capitialization of sameSite }); opts.path = '/'; const obj = cookie.serialize(name, value, opts); diff --git a/test/integration-legacy/smoke-testing/test_footer_links.js b/test/integration-legacy/smoke-testing/test_footer_links.js index 5a49d87b6..2c299f758 100644 --- a/test/integration-legacy/smoke-testing/test_footer_links.js +++ b/test/integration-legacy/smoke-testing/test_footer_links.js @@ -140,8 +140,6 @@ tap.test('clickDiscussionForumsLink', options, t => { }); }); -// SCRATCH WIKI test has been removed. - // STATISTICS tap.test('clickStatisticsLink', options, t => { const linkText = 'Statistics'; @@ -194,28 +192,6 @@ tap.test('clickContactUsLink', options, t => { }); }); -// skip this test since it points to an external site -// SCRATCH STORE -tap.test('clickScratchStoreLink', {skip: true}, t => { - const linkText = 'Scratch Store'; - const expectedUrl = 'https://scratch-foundation.myshopify.com/'; - clickFooterLinks(linkText).then(url => { - t.equal(url, expectedUrl); - t.end(); - }); -}); - -// skip this test since it points to an external site -// DONATE -tap.test('clickDonateLink', {skip: true}, t => { - const linkText = 'Donate'; - const expectedUrl = 'https://secure.donationpay.org/scratchfoundation/'; - clickFooterLinks(linkText).then(url => { - t.equal(url, expectedUrl); - t.end(); - }); -}); - // ==== LEGAL column ==== // TERMS OF USE @@ -249,40 +225,6 @@ tap.test('clickDMCALink', options, t => { }); // ==== SCRATCH FAMILY column ==== - -// skip this test since it points to an external site -// SCRATCH ED (SCRATCHED) -tap.test('clickScratchEdLink', {skip: true}, t => { - const linkText = 'ScratchEd'; - const expectedUrl = 'http://scratched.gse.harvard.edu/'; - clickFooterLinks(linkText).then(url => { - t.equal(url, expectedUrl); - t.end(); - }); -}); - -// skip this test since it points to an external site -// SCRATCH JR (SCRATCHJR) -tap.test('clickScratchJrLink', {skip: true}, t => { - const linkText = 'ScratchJr'; - const expectedUrl = 'https://www.scratchjr.org/'; - clickFooterLinks(linkText).then(url => { - t.equal(url, expectedUrl); - t.end(); - }); -}); - -// skip this test since it points to an external site -// SCRATCH DAY -tap.test('clickScratchDayLink', {skip: true}, t => { - const linkText = 'Scratch Day'; - const expectedUrl = 'https://day.scratch.mit.edu/'; - clickFooterLinks(linkText).then(url => { - t.equal(url, expectedUrl); - t.end(); - }); -}); - // SCRATCH CONFERENCE tap.test('clickScratchConferenceLink', options, t => { const linkText = 'Scratch Conference'; @@ -292,14 +234,12 @@ tap.test('clickScratchConferenceLink', options, t => { t.end(); }); }); +// The following links in are skipped because they are not on scratch.mit.edu -// skip this test since it points to an external site +// SCRATCH STORE +// DONATE +// SCRATCH WIKI +// SCRATCH ED (SCRATCHED) +// SCRATCH JR (SCRATCHJR) +// SCRATCH DAY // SCRATCH FOUNDATION -tap.test('clickScratchFoundationLink', {skip: true}, t => { - const linkText = 'Scratch Foundation'; - const expectedUrl = 'https://www.scratchfoundation.org/'; - clickFooterLinks(linkText).then(url => { - t.equal(url, expectedUrl); - t.end(); - }); -}); diff --git a/test/unit/lib/jar.test.js b/test/unit/lib/jar.test.js new file mode 100644 index 000000000..e3c63b91f --- /dev/null +++ b/test/unit/lib/jar.test.js @@ -0,0 +1,53 @@ +const jar = require('../../../src/lib/jar'); +const cookie = require('cookie'); + +jest.mock('cookie', () => ({serialize: jest.fn()})); +describe('unit test lib/jar.js', () => { + + test('simple set test with no opts', () => { + jar.set('name', 'value'); + expect(cookie.serialize).toHaveBeenCalled(); + expect(cookie.serialize).toHaveBeenCalledWith('name', 'value', + expect.objectContaining({ + path: '/', + sameSite: 'Strict', + expires: expect.anything() // not specifically matching the date because it is hard to mock + })); + }); + test('test with opts', () => { + jar.set('a', 'b', {option: 'one'}); + expect(cookie.serialize).toHaveBeenCalled(); + expect(cookie.serialize).toHaveBeenCalledWith('a', 'b', + expect.objectContaining({ + option: 'one', + path: '/', + sameSite: 'Strict', + expires: expect.anything() // not specifically matching the date because it is hard to mock + })); + }); + test('expires opts overrides default', () => { + jar.set('a', 'b', { + option: 'one', + expires: 'someday' + }); + expect(cookie.serialize).toHaveBeenCalled(); + expect(cookie.serialize).toHaveBeenCalledWith('a', 'b', + expect.objectContaining({ + option: 'one', + path: '/', + expires: 'someday' + })); + }); + test('sameSite opts overrides default', () => { + jar.set('a', 'b', { + option: 'one', + sameSite: 'override' + }); + expect(cookie.serialize).toHaveBeenCalled(); + expect(cookie.serialize).toHaveBeenCalledWith('a', 'b', + expect.objectContaining({ + option: 'one', + sameSite: 'override' + })); + }); +});