Pinafore-Web-Client-Frontend/tests/roles.js

19 lines
734 B
JavaScript
Raw Normal View History

2018-03-01 07:45:42 +01:00
import { Role } from 'testcafe'
import { authorizeInput, emailInput, getUrl, instanceInput, passwordInput } from './utils'
2018-02-20 02:18:40 +01:00
2018-02-20 03:25:59 +01:00
function login (t, username, password) {
2018-03-01 07:45:42 +01:00
return t.typeText(instanceInput, 'localhost:3000', {paste: true})
.pressKey('enter')
2018-02-20 02:18:40 +01:00
.expect(getUrl()).eql('http://localhost:3000/auth/sign_in')
2018-03-01 07:45:42 +01:00
.typeText(emailInput, username, {paste: true})
.typeText(passwordInput, password, {paste: true})
.pressKey('enter')
2018-02-20 02:18:40 +01:00
.expect(getUrl()).contains('/oauth/authorize')
2018-03-01 07:45:42 +01:00
.click(authorizeInput)
2018-02-20 02:18:40 +01:00
.expect(getUrl()).eql('http://localhost:4002/')
}
export const foobarRole = Role('http://localhost:4002/settings/instances/add', async t => {
await login(t, 'foobar@localhost:3000', 'foobarfoobar')
2018-02-20 03:25:59 +01:00
})