37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
|
import { Selector as $ } from 'testcafe'
|
||
|
import { addInstanceButton, getUrl, instanceInput, login, settingsButton } from '../utils'
|
||
|
|
||
|
fixture `02-login-spec.js`
|
||
|
.page `http://localhost:4002`
|
||
|
|
||
|
const formError = $('.form-error')
|
||
|
test('Cannot log in to a fake instance', async t => {
|
||
|
|
||
|
await t.click($('a').withText('log in to an instance'))
|
||
|
.typeText(instanceInput, 'fake.nolanlawson.com')
|
||
|
.click(addInstanceButton)
|
||
|
.expect(formError.exists).ok()
|
||
|
.expect(formError.innerText).contains('Is this a valid Mastodon instance?')
|
||
|
.typeText(instanceInput, '.biz')
|
||
|
.expect(formError.exists).notOk()
|
||
|
.typeText(instanceInput, 'fake.nolanlawson.com', {replace: true})
|
||
|
.expect(formError.exists).ok()
|
||
|
.expect(formError.innerText).contains('Is this a valid Mastodon instance?')
|
||
|
})
|
||
|
|
||
|
test('Logs in to localhost:3000', async t => {
|
||
|
await login(t, 'foobar@localhost:3000', 'foobarfoobar')
|
||
|
.expect($('article.status-article').exists).ok()
|
||
|
})
|
||
|
|
||
|
test('Logs out', async t => {
|
||
|
await login(t, 'foobar@localhost:3000', 'foobarfoobar')
|
||
|
.click(settingsButton)
|
||
|
.click($('a').withText('Instances'))
|
||
|
.click($('a').withText('localhost:3000'))
|
||
|
.expect(getUrl()).contains('/settings/instances/localhost:3000')
|
||
|
.click($('button').withText('Log out'))
|
||
|
.click($('#modal-dialog button').withText('OK'))
|
||
|
.expect($('.container').innerText)
|
||
|
.contains("You're not logged in to any instances")
|
||
|
})
|