fix tests

This commit is contained in:
Nolan Lawson 2018-03-06 23:57:06 -08:00
parent 9c14a0abd5
commit 6dfa63ba48
5 changed files with 11 additions and 9 deletions

View File

@ -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')
})

View File

@ -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')

View File

@ -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)