fix flaky login tests (#209)
This commit is contained in:
parent
095be79525
commit
209b36c73b
|
@ -1,13 +1,17 @@
|
||||||
import { Role } from 'testcafe'
|
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) {
|
function login (t, username, password) {
|
||||||
return t.typeText(instanceInput, 'localhost:3000', {paste: true})
|
return t.typeText(instanceInput, 'localhost:3000', {paste: true})
|
||||||
.pressKey('enter')
|
.click(addInstanceButton)
|
||||||
.expect(getUrl()).eql('http://localhost:3000/auth/sign_in')
|
.expect(getUrl()).eql('http://localhost:3000/auth/sign_in')
|
||||||
.typeText(emailInput, username, {paste: true})
|
.typeText(emailInput, username, {paste: true})
|
||||||
.typeText(passwordInput, password, {paste: true})
|
.typeText(passwordInput, password, {paste: true})
|
||||||
.pressKey('enter')
|
.click(mastodonLogInButton)
|
||||||
.expect(getUrl()).contains('/oauth/authorize')
|
.expect(getUrl()).contains('/oauth/authorize')
|
||||||
.click(authorizeInput)
|
.click(authorizeInput)
|
||||||
.expect(getUrl()).eql('http://localhost:4002/', {timeout: 20000})
|
.expect(getUrl()).eql('http://localhost:4002/', {timeout: 20000})
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import { Selector as $ } from 'testcafe'
|
import { Selector as $ } from 'testcafe'
|
||||||
import {
|
import {
|
||||||
|
addInstanceButton,
|
||||||
authorizeInput, emailInput, formError, getFirstVisibleStatus, getUrl, instanceInput, logInToInstanceLink,
|
authorizeInput, emailInput, formError, getFirstVisibleStatus, getUrl, instanceInput, logInToInstanceLink,
|
||||||
|
mastodonLogInButton,
|
||||||
passwordInput,
|
passwordInput,
|
||||||
settingsButton
|
settingsButton
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
|
@ -12,11 +14,11 @@ function manualLogin (t, username, password) {
|
||||||
return t.click(logInToInstanceLink)
|
return t.click(logInToInstanceLink)
|
||||||
.expect(getUrl()).contains('/settings/instances/add')
|
.expect(getUrl()).contains('/settings/instances/add')
|
||||||
.typeText(instanceInput, 'localhost:3000')
|
.typeText(instanceInput, 'localhost:3000')
|
||||||
.pressKey('enter')
|
.click(addInstanceButton)
|
||||||
.expect(getUrl()).eql('http://localhost:3000/auth/sign_in')
|
.expect(getUrl()).eql('http://localhost:3000/auth/sign_in')
|
||||||
.typeText(emailInput, username, {paste: true})
|
.typeText(emailInput, username, {paste: true})
|
||||||
.typeText(passwordInput, password, {paste: true})
|
.typeText(passwordInput, password, {paste: true})
|
||||||
.pressKey('enter')
|
.click(mastodonLogInButton)
|
||||||
.expect(getUrl()).contains('/oauth/authorize')
|
.expect(getUrl()).contains('/oauth/authorize')
|
||||||
.click(authorizeInput)
|
.click(authorizeInput)
|
||||||
.expect(getUrl()).eql('http://localhost:4002/')
|
.expect(getUrl()).eql('http://localhost:4002/')
|
||||||
|
@ -26,7 +28,7 @@ test('Cannot log in to a fake instance', async t => {
|
||||||
await t.click(logInToInstanceLink)
|
await t.click(logInToInstanceLink)
|
||||||
.expect(getUrl()).contains('/settings/instances/add')
|
.expect(getUrl()).contains('/settings/instances/add')
|
||||||
.typeText(instanceInput, 'fake.nolanlawson.com', {paste: true})
|
.typeText(instanceInput, 'fake.nolanlawson.com', {paste: true})
|
||||||
.pressKey('enter')
|
.click(addInstanceButton)
|
||||||
.expect(formError.exists).ok()
|
.expect(formError.exists).ok()
|
||||||
.expect(formError.innerText).contains('Is this a valid Mastodon instance?')
|
.expect(formError.innerText).contains('Is this a valid Mastodon instance?')
|
||||||
.typeText(instanceInput, '.biz', {paste: true})
|
.typeText(instanceInput, '.biz', {paste: true})
|
||||||
|
|
|
@ -37,6 +37,8 @@ export const accountProfileFollowedBy = $('.account-profile .account-profile-fol
|
||||||
export const accountProfileFollowButton = $('.account-profile .account-profile-follow button')
|
export const accountProfileFollowButton = $('.account-profile .account-profile-follow button')
|
||||||
export const goBackButton = $('.dynamic-page-go-back')
|
export const goBackButton = $('.dynamic-page-go-back')
|
||||||
export const accountProfileMoreOptionsButton = $('.account-profile-more-options button')
|
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({
|
export const favoritesCountElement = $('.status-favs-reblogs:nth-child(3)').addCustomDOMProperties({
|
||||||
innerCount: el => parseInt(el.innerText, 10)
|
innerCount: el => parseInt(el.innerText, 10)
|
||||||
|
|
Loading…
Reference in a new issue