2018-03-01 06:45:42 +00:00
|
|
|
import { Role } from 'testcafe'
|
2018-04-21 21:06:46 +01:00
|
|
|
import {
|
|
|
|
authorizeInput, emailInput, getUrl, instanceInput, mastodonLogInButton,
|
2018-05-25 04:01:34 +01:00
|
|
|
passwordInput,
|
|
|
|
sleep
|
2018-04-21 21:06:46 +01:00
|
|
|
} from './utils'
|
2018-04-28 22:19:39 +01:00
|
|
|
import { users } from './users'
|
2018-02-20 01:18:40 +00:00
|
|
|
|
2018-05-25 04:01:34 +01:00
|
|
|
async function login (t, username, password) {
|
|
|
|
await sleep(500)
|
|
|
|
await t.typeText(instanceInput, 'localhost:3000', {paste: true})
|
|
|
|
await sleep(500)
|
|
|
|
return t
|
|
|
|
.pressKey('enter')
|
2018-04-21 22:57:02 +01:00
|
|
|
.expect(getUrl()).eql('http://localhost:3000/auth/sign_in', {timeout: 30000})
|
2018-03-01 06:45:42 +00:00
|
|
|
.typeText(emailInput, username, {paste: true})
|
|
|
|
.typeText(passwordInput, password, {paste: true})
|
2018-04-21 21:06:46 +01:00
|
|
|
.click(mastodonLogInButton)
|
2018-02-20 01:18:40 +00:00
|
|
|
.expect(getUrl()).contains('/oauth/authorize')
|
2018-03-01 06:45:42 +00:00
|
|
|
.click(authorizeInput)
|
2018-04-21 22:57:02 +01:00
|
|
|
.expect(getUrl()).eql('http://localhost:4002/', {timeout: 30000})
|
2018-02-20 01:18:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const foobarRole = Role('http://localhost:4002/settings/instances/add', async t => {
|
2018-04-28 22:19:39 +01:00
|
|
|
await login(t, users.foobar.email, users.foobar.password)
|
|
|
|
})
|
|
|
|
|
|
|
|
export const lockedAccountRole = Role('http://localhost:4002/settings/instances/add', async t => {
|
|
|
|
await login(t, users.LockedAccount.email, users.LockedAccount.password)
|
2018-02-20 02:25:59 +00:00
|
|
|
})
|