From 90d0c14b96b1785d2bc67392913f42f6fa473f43 Mon Sep 17 00:00:00 2001 From: chrisgarrity <chrisg@media.mit.edu> Date: Thu, 8 Nov 2018 11:14:34 -0500 Subject: [PATCH] Add tests --- test/integration/tutorials-shortcut.test.js | 32 +++++++++++++++++++++ test/unit/util/tutorial-from-url.test.js | 7 ++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 test/integration/tutorials-shortcut.test.js diff --git a/test/integration/tutorials-shortcut.test.js b/test/integration/tutorials-shortcut.test.js new file mode 100644 index 000000000..803e1e5ae --- /dev/null +++ b/test/integration/tutorials-shortcut.test.js @@ -0,0 +1,32 @@ +import path from 'path'; +import SeleniumHelper from '../helpers/selenium-helper'; + +const { + clickText, + findByXpath, + getDriver, + loadUri +} = new SeleniumHelper(); + +const uri = path.resolve(__dirname, '../../build/index.html?tutorial=all'); + +let driver; + +describe('Working with shortcut to Tutorials library', () => { + beforeAll(() => { + driver = getDriver(); + }); + + afterAll(async () => { + await driver.quit(); + }); + + test('opens with the Tutorial Library showing', async () => { + await loadUri(uri); + // make sure there is a tutorial visible that doesn't have a shortcut + await clickText('Switch costume'); + await findByXpath('//div[contains(@class, "step-video")]'); + }); + + // @todo navigating cards, etc. +}); diff --git a/test/unit/util/tutorial-from-url.test.js b/test/unit/util/tutorial-from-url.test.js index 70ff88350..cfe2c14fe 100644 --- a/test/unit/util/tutorial-from-url.test.js +++ b/test/unit/util/tutorial-from-url.test.js @@ -36,7 +36,7 @@ test('returns null if no query param', () => { expect(detectTutorialId()).toBe(null); }); -test('returns null if non-numeric template', () => { +test('returns null if unrecognized template', () => { window.location.search = '?tutorial=asdf'; expect(detectTutorialId()).toBe(null); }); @@ -45,3 +45,8 @@ test('takes the first of multiple', () => { window.location.search = '?tutorial=one&tutorial=two'; expect(detectTutorialId()).toBe('foo'); }); + +test('returns all for the tutorial library shortcut', () => { + window.location.search = '?tutorial=all'; + expect(detectTutorialId()).toBe('all'); +}); -- GitLab