diff --git a/tests/roles.js b/tests/roles.js index 24815f8..7673af7 100644 --- a/tests/roles.js +++ b/tests/roles.js @@ -1,13 +1,17 @@ import { Role } from 'testcafe' -import { authorizeInput, emailInput, getUrl, instanceInput, passwordInput } from './utils' +import { + addInstanceButton, + authorizeInput, emailInput, getUrl, instanceInput, mastodonLogInButton, + passwordInput +} from './utils' function login (t, username, password) { return t.typeText(instanceInput, 'localhost:3000', {paste: true}) - .pressKey('enter') + .click(addInstanceButton) .expect(getUrl()).eql('http://localhost:3000/auth/sign_in') .typeText(emailInput, username, {paste: true}) .typeText(passwordInput, password, {paste: true}) - .pressKey('enter') + .click(mastodonLogInButton) .expect(getUrl()).contains('/oauth/authorize') .click(authorizeInput) .expect(getUrl()).eql('http://localhost:4002/', {timeout: 20000}) diff --git a/tests/spec/002-login-spec.js b/tests/spec/002-login-spec.js index ec2d5e2..a660611 100644 --- a/tests/spec/002-login-spec.js +++ b/tests/spec/002-login-spec.js @@ -1,6 +1,8 @@ import { Selector as $ } from 'testcafe' import { + addInstanceButton, authorizeInput, emailInput, formError, getFirstVisibleStatus, getUrl, instanceInput, logInToInstanceLink, + mastodonLogInButton, passwordInput, settingsButton } from '../utils' @@ -12,11 +14,11 @@ function manualLogin (t, username, password) { return t.click(logInToInstanceLink) .expect(getUrl()).contains('/settings/instances/add') .typeText(instanceInput, 'localhost:3000') - .pressKey('enter') + .click(addInstanceButton) .expect(getUrl()).eql('http://localhost:3000/auth/sign_in') .typeText(emailInput, username, {paste: true}) .typeText(passwordInput, password, {paste: true}) - .pressKey('enter') + .click(mastodonLogInButton) .expect(getUrl()).contains('/oauth/authorize') .click(authorizeInput) .expect(getUrl()).eql('http://localhost:4002/') @@ -26,7 +28,7 @@ test('Cannot log in to a fake instance', async t => { await t.click(logInToInstanceLink) .expect(getUrl()).contains('/settings/instances/add') .typeText(instanceInput, 'fake.nolanlawson.com', {paste: true}) - .pressKey('enter') + .click(addInstanceButton) .expect(formError.exists).ok() .expect(formError.innerText).contains('Is this a valid Mastodon instance?') .typeText(instanceInput, '.biz', {paste: true}) diff --git a/tests/utils.js b/tests/utils.js index 13a75c5..9ff0cf5 100644 --- a/tests/utils.js +++ b/tests/utils.js @@ -37,6 +37,8 @@ export const accountProfileFollowedBy = $('.account-profile .account-profile-fol export const accountProfileFollowButton = $('.account-profile .account-profile-follow button') export const goBackButton = $('.dynamic-page-go-back') export const accountProfileMoreOptionsButton = $('.account-profile-more-options button') +export const addInstanceButton = $('#submitButton') +export const mastodonLogInButton = $('button[type="submit"]') export const favoritesCountElement = $('.status-favs-reblogs:nth-child(3)').addCustomDOMProperties({ innerCount: el => parseInt(el.innerText, 10)