From 6dfa63ba48e510e46994de6db7043f7a83415966 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Tue, 6 Mar 2018 23:57:06 -0800 Subject: [PATCH] fix tests --- bin/run-mastodon.js | 2 +- bin/wait-for-mastodon-to-start.js | 6 +++--- tests/spec/001-basic-spec.js | 4 ++-- tests/spec/002-login-spec.js | 7 ++++--- tests/utils.js | 1 + 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bin/run-mastodon.js b/bin/run-mastodon.js index 7f0b732e..a8490a8b 100644 --- a/bin/run-mastodon.js +++ b/bin/run-mastodon.js @@ -79,7 +79,7 @@ async function main () { await waitForMastodonUiToStart() } -function shutdownMastodon() { +function shutdownMastodon () { if (childProc) { console.log('killing child process') childProc.kill() diff --git a/bin/wait-for-mastodon-to-start.js b/bin/wait-for-mastodon-to-start.js index 8f3da02a..9dae6257 100644 --- a/bin/wait-for-mastodon-to-start.js +++ b/bin/wait-for-mastodon-to-start.js @@ -34,7 +34,7 @@ if (require.main === module) { Promise.resolve() .then(waitForMastodonApiToStart) .then(waitForMastodonUiToStart).catch(err => { - console.error(err) - process.exit(1) - }) + console.error(err) + process.exit(1) + }) } diff --git a/tests/spec/001-basic-spec.js b/tests/spec/001-basic-spec.js index 8cf8f211..4a8ad938 100644 --- a/tests/spec/001-basic-spec.js +++ b/tests/spec/001-basic-spec.js @@ -1,5 +1,5 @@ import { Selector as $ } from 'testcafe' -import { getUrl, settingsButton } from '../utils' +import { getUrl, logInToInstanceLink, settingsButton } from '../utils' fixture`001-basic-spec.js` .page`http://localhost:4002` @@ -19,7 +19,7 @@ test('navigates to about', async t => { }) test('navigates to /settings/instances/add', async t => { - await t.click($('a').withText('log in to an instance')) + await t.click(logInToInstanceLink) .expect(getUrl()).contains('/settings/instances/add') }) diff --git a/tests/spec/002-login-spec.js b/tests/spec/002-login-spec.js index e407262b..77d10be7 100644 --- a/tests/spec/002-login-spec.js +++ b/tests/spec/002-login-spec.js @@ -1,6 +1,7 @@ import { Selector as $ } from 'testcafe' import { - authorizeInput, emailInput, formError, getFirstVisibleStatus, getUrl, instanceInput, passwordInput, + authorizeInput, emailInput, formError, getFirstVisibleStatus, getUrl, instanceInput, logInToInstanceLink, + passwordInput, settingsButton } from '../utils' @@ -8,7 +9,7 @@ fixture`002-login-spec.js` .page`http://localhost:4002` function manualLogin (t, username, password) { - return t.click($('a').withText('log in to an instance')) + return t.click(logInToInstanceLink) .expect(getUrl()).contains('/settings/instances/add') .typeText(instanceInput, 'localhost:3000') .pressKey('enter') @@ -22,7 +23,7 @@ function manualLogin (t, username, password) { } test('Cannot log in to a fake instance', async t => { - await t.click($('a').withText('log in to an instance')) + await t.click(logInToInstanceLink) .expect(getUrl()).contains('/settings/instances/add') .typeText(instanceInput, 'fake.nolanlawson.com', {paste: true}) .pressKey('enter') diff --git a/tests/utils.js b/tests/utils.js index 63ae1602..b05d8bca 100644 --- a/tests/utils.js +++ b/tests/utils.js @@ -22,6 +22,7 @@ export const contentWarningButton = $('.compose-box-toolbar button:nth-child(4)' export const emailInput = $('input#user_email') export const passwordInput = $('input#user_password') export const authorizeInput = $('button[type=submit]:not(.negative)') +export const logInToInstanceLink = $('a[href="/settings/instances/add"]') export const favoritesCountElement = $('.status-favs-reblogs:nth-child(3)').addCustomDOMProperties({ innerCount: el => parseInt(el.innerText, 10)