forked from cybrespace/pinafore
tests: quicker login, tweak test setup (#372)
* make tests faster by logging in directly * downgrade testcafe * Revert "downgrade testcafe" This reverts commit 0f78f5ef63f25b6428de2faba476a353a338c695. * try a delay * the delay does not do anything * disable concurrency in testcafe * make setup script less noisy * try transparency of 2? * Revert "the delay does not do anything" This reverts commit 438b3519a4e0c325e89f0c2a0eff6a7a4ae11ebd. * try a delay of 400ms * okay fine delay of 1s * try concurrency of 4 again
This commit is contained in:
parent
992c3a890d
commit
e8d2cd9ffc
|
@ -45,6 +45,7 @@ export async function restoreMastodonData () {
|
||||||
console.log('Restoring mastodon data...')
|
console.log('Restoring mastodon data...')
|
||||||
let internalIdsToIds = {}
|
let internalIdsToIds = {}
|
||||||
for (let action of actions) {
|
for (let action of actions) {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000)) // delay so that notifications have proper order
|
||||||
console.log(JSON.stringify(action))
|
console.log(JSON.stringify(action))
|
||||||
let accessToken = users[action.user].accessToken
|
let accessToken = users[action.user].accessToken
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -x
|
|
||||||
|
|
||||||
if [[ "$COMMAND" = deploy-dev-travis ]]; then
|
if [[ "$COMMAND" = deploy-dev-travis ]]; then
|
||||||
exit 0 # no need to setup mastodon in this case
|
exit 0 # no need to setup mastodon in this case
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!-- this is only used in the tests, to log in quickly -->
|
||||||
|
<script>
|
||||||
|
import { store } from '../_store/store'
|
||||||
|
import { goto } from 'sapper/runtime.js'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
oncreate () {
|
||||||
|
let accessToken = location.search.match(/accessToken=([^&]+)/)[1]
|
||||||
|
let instanceName = location.search.match(/instanceName=([^&]+)/)[1]
|
||||||
|
let {
|
||||||
|
loggedInInstances,
|
||||||
|
loggedInInstancesInOrder
|
||||||
|
} = store.get()
|
||||||
|
|
||||||
|
loggedInInstances[instanceName] = {
|
||||||
|
access_token: accessToken
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!loggedInInstancesInOrder.includes(instanceName)) {
|
||||||
|
loggedInInstancesInOrder.push(instanceName)
|
||||||
|
}
|
||||||
|
|
||||||
|
store.set({
|
||||||
|
currentInstance: instanceName,
|
||||||
|
loggedInInstances,
|
||||||
|
loggedInInstancesInOrder
|
||||||
|
})
|
||||||
|
store.save()
|
||||||
|
goto('/')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -1,22 +1,9 @@
|
||||||
import {
|
import { getUrl } from './utils'
|
||||||
authorizeInput, emailInput, getUrl, instanceInput, mastodonLogInButton,
|
|
||||||
passwordInput,
|
|
||||||
sleep
|
|
||||||
} from './utils'
|
|
||||||
import { users } from './users'
|
import { users } from './users'
|
||||||
|
|
||||||
async function login (t, username, password) {
|
// quick login using a secret page and a known access token (makes tests run faster)
|
||||||
await sleep(500)
|
async function login (t, user) {
|
||||||
await t.typeText(instanceInput, 'localhost:3000', {paste: true})
|
await t.navigateTo(`/settings/quick-login?instanceName=localhost:3000&accessToken=${user.accessToken}`)
|
||||||
await sleep(500)
|
|
||||||
return t
|
|
||||||
.pressKey('enter')
|
|
||||||
.expect(getUrl()).eql('http://localhost:3000/auth/sign_in', {timeout: 30000})
|
|
||||||
.typeText(emailInput, username, {paste: true})
|
|
||||||
.typeText(passwordInput, password, {paste: true})
|
|
||||||
.click(mastodonLogInButton)
|
|
||||||
.expect(getUrl()).contains('/oauth/authorize')
|
|
||||||
.click(authorizeInput)
|
|
||||||
.expect(getUrl()).eql('http://localhost:4002/', {timeout: 30000})
|
.expect(getUrl()).eql('http://localhost:4002/', {timeout: 30000})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,11 +17,9 @@ async function login (t, username, password) {
|
||||||
// })
|
// })
|
||||||
|
|
||||||
export async function loginAsFoobar (t) {
|
export async function loginAsFoobar (t) {
|
||||||
await t.navigateTo('/settings/instances/add')
|
await login(t, users.foobar)
|
||||||
await login(t, users.foobar.email, users.foobar.password)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loginAsLockedAccount (t) {
|
export async function loginAsLockedAccount (t) {
|
||||||
await t.navigateTo('/settings/instances/add')
|
await login(t, users.LockedAccount)
|
||||||
await login(t, users.LockedAccount.email, users.LockedAccount.password)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue