forked from cybrespace/pinafore
refactor tests
This commit is contained in:
parent
4e47f3048b
commit
bfc9692667
|
@ -12,28 +12,28 @@ global.FormData = FileApi.FormData
|
|||
|
||||
const instanceName = 'localhost:3000'
|
||||
|
||||
export async function favoriteStatusAsAdmin (statusId) {
|
||||
return favoriteStatus(instanceName, users.admin.accessToken, statusId)
|
||||
export async function favoriteStatusAs (username, statusId) {
|
||||
return favoriteStatus(instanceName, users[username].accessToken, statusId)
|
||||
}
|
||||
|
||||
export async function postAsAdmin (text) {
|
||||
return postStatus(instanceName, users.admin.accessToken, text,
|
||||
export async function postAs (username, text) {
|
||||
return postStatus(instanceName, users[username].accessToken, text,
|
||||
null, null, false, null, 'public')
|
||||
}
|
||||
|
||||
export async function postReplyAsAdmin (text, inReplyTo) {
|
||||
return postStatus(instanceName, users.admin.accessToken, text,
|
||||
export async function postReplyAs (username, text, inReplyTo) {
|
||||
return postStatus(instanceName, users[username].accessToken, text,
|
||||
inReplyTo, null, false, null, 'public')
|
||||
}
|
||||
|
||||
export async function deleteAsAdmin (statusId) {
|
||||
return deleteStatus(instanceName, users.admin.accessToken, statusId)
|
||||
export async function deleteAs (username, statusId) {
|
||||
return deleteStatus(instanceName, users[username].accessToken, statusId)
|
||||
}
|
||||
|
||||
export async function getFollowRequestsAsLockedAccount () {
|
||||
return getFollowRequests(instanceName, users.LockedAccount.accessToken)
|
||||
export async function getFollowRequestsAs (username) {
|
||||
return getFollowRequests(instanceName, users[username].accessToken)
|
||||
}
|
||||
|
||||
export async function authorizeFollowRequestAsLockedAccount (id) {
|
||||
return authorizeFollowRequest(instanceName, users.LockedAccount.accessToken, id)
|
||||
export async function authorizeFollowRequestAs (username, id) {
|
||||
return authorizeFollowRequest(instanceName, users[username].accessToken, id)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { foobarRole } from '../roles'
|
||||
import { getNthStatus, getUrl, homeNavButton, notificationsNavButton, validateTimeline } from '../utils'
|
||||
import { favoriteStatusAsAdmin } from '../serverActions'
|
||||
import { favoriteStatusAs } from '../serverActions'
|
||||
import { notifications } from '../fixtures'
|
||||
|
||||
fixture`102-notifications.js`
|
||||
|
@ -15,7 +15,7 @@ test('shows unread notifications', async t => {
|
|||
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications')
|
||||
let statusId = (await getNthStatus(5).find('.status-relative-date').getAttribute('href'))
|
||||
.split('/').slice(-1)[0]
|
||||
await favoriteStatusAsAdmin(statusId)
|
||||
await favoriteStatusAs('admin', statusId)
|
||||
await t
|
||||
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (1)')
|
||||
.click(notificationsNavButton)
|
||||
|
|
|
@ -2,7 +2,7 @@ import { foobarRole } from '../roles'
|
|||
import {
|
||||
getNthStatus, scrollContainerToTop, showMoreButton, sleep
|
||||
} from '../utils'
|
||||
import { postAsAdmin } from '../serverActions'
|
||||
import { postAs } from '../serverActions'
|
||||
|
||||
fixture`104-streaming.js`
|
||||
.page`http://localhost:4002`
|
||||
|
@ -10,7 +10,7 @@ fixture`104-streaming.js`
|
|||
test('new incoming statuses show up immediately', async t => {
|
||||
await t.useRole(foobarRole)
|
||||
.hover(getNthStatus(0))
|
||||
await postAsAdmin('hello my baby hello my honey')
|
||||
await postAs('admin', 'hello my baby hello my honey')
|
||||
await t.expect(getNthStatus(0).innerText).contains('hello my baby hello my honey')
|
||||
})
|
||||
|
||||
|
@ -20,8 +20,8 @@ test('new incoming toots show a button if scrolled down', async t => {
|
|||
.hover(getNthStatus(2))
|
||||
.hover(getNthStatus(4))
|
||||
await sleep(1000)
|
||||
await postAsAdmin('hello my ragtime gal')
|
||||
await postAsAdmin('send me a kiss by wire')
|
||||
await postAs('admin', 'hello my ragtime gal')
|
||||
await postAs('admin', 'send me a kiss by wire')
|
||||
await sleep(4000)
|
||||
await t.hover(getNthStatus(2))
|
||||
.hover(getNthStatus(0))
|
||||
|
@ -29,7 +29,7 @@ test('new incoming toots show a button if scrolled down', async t => {
|
|||
await sleep(1000)
|
||||
await t
|
||||
.expect(showMoreButton.innerText).contains('Show 2 more')
|
||||
await postAsAdmin("baby my heart's on fire")
|
||||
await postAs('admin', "baby my heart's on fire")
|
||||
await sleep(4000)
|
||||
await t.expect(showMoreButton.innerText).contains('Show 3 more')
|
||||
.click(showMoreButton)
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
notificationsNavButton,
|
||||
sleep
|
||||
} from '../utils'
|
||||
import { deleteAsAdmin, postAsAdmin, postReplyAsAdmin } from '../serverActions'
|
||||
import { deleteAs, postAs, postReplyAs } from '../serverActions'
|
||||
|
||||
fixture`105-deletes.js`
|
||||
.page`http://localhost:4002`
|
||||
|
@ -12,10 +12,10 @@ fixture`105-deletes.js`
|
|||
test('deleted statuses are removed from the timeline', async t => {
|
||||
await t.useRole(foobarRole)
|
||||
.hover(getNthStatus(0))
|
||||
let status = await postAsAdmin("I'm gonna delete this")
|
||||
let status = await postAs('admin', "I'm gonna delete this")
|
||||
await sleep(1000)
|
||||
await t.expect(getNthStatus(0).innerText).contains("I'm gonna delete this")
|
||||
await deleteAsAdmin(status.id)
|
||||
await deleteAs('admin', status.id)
|
||||
await sleep(1000)
|
||||
await t.expect(getNthStatus(0).innerText).notContains("I'm gonna delete this")
|
||||
await clickToNotificationsAndBackHome(t)
|
||||
|
@ -33,8 +33,8 @@ test('deleted statuses are removed from the timeline', async t => {
|
|||
test('deleted statuses are removed from threads', async t => {
|
||||
await t.useRole(foobarRole)
|
||||
.hover(getNthStatus(0))
|
||||
let status = await postAsAdmin("I won't delete this")
|
||||
let reply = await postReplyAsAdmin('But I will delete this', status.id)
|
||||
let status = await postAs('admin', "I won't delete this")
|
||||
let reply = await postReplyAs('admin', 'But I will delete this', status.id)
|
||||
await sleep(5000)
|
||||
await t.expect(getNthStatus(0).innerText).contains('But I will delete this')
|
||||
.expect(getNthStatus(1).innerText).contains("I won't delete this")
|
||||
|
@ -42,7 +42,7 @@ test('deleted statuses are removed from threads', async t => {
|
|||
.expect(getUrl()).contains('/statuses')
|
||||
.expect(getNthStatus(0).innerText).contains("I won't delete this")
|
||||
.expect(getNthStatus(1).innerText).contains('But I will delete this')
|
||||
await deleteAsAdmin(reply.id)
|
||||
await deleteAs('admin', reply.id)
|
||||
await sleep(1000)
|
||||
await t.expect(getNthStatus(1).exists).notOk()
|
||||
.expect(getNthStatus(0).innerText).contains("I won't delete this")
|
||||
|
@ -59,10 +59,10 @@ test('deleted statuses result in deleted notifications', async t => {
|
|||
await t.useRole(foobarRole)
|
||||
.hover(getNthStatus(0))
|
||||
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications')
|
||||
let status = await postAsAdmin("@foobar yo yo foobar what's up")
|
||||
let status = await postAs('admin', "@foobar yo yo foobar what's up")
|
||||
await sleep(2000)
|
||||
await t.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (1)')
|
||||
await deleteAsAdmin(status.id)
|
||||
await deleteAs('admin', status.id)
|
||||
await sleep(5000)
|
||||
await t.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications')
|
||||
})
|
||||
|
|
|
@ -5,7 +5,7 @@ import {
|
|||
sleep
|
||||
} from '../utils'
|
||||
import {
|
||||
authorizeFollowRequestAsLockedAccount, getFollowRequestsAsLockedAccount
|
||||
authorizeFollowRequestAs, getFollowRequestsAs
|
||||
} from '../serverActions'
|
||||
|
||||
fixture`106-follow-requests.js`
|
||||
|
@ -22,8 +22,8 @@ test('can request to follow an account', async t => {
|
|||
.click(accountProfileFollowButton)
|
||||
.expect(accountProfileFollowButton.getAttribute('aria-label')).eql('Unfollow (follow requested)')
|
||||
|
||||
let requests = await getFollowRequestsAsLockedAccount()
|
||||
await authorizeFollowRequestAsLockedAccount(requests.slice(-1)[0].id)
|
||||
let requests = await getFollowRequestsAs('LockedAccount')
|
||||
await authorizeFollowRequestAs('LockedAccount', requests.slice(-1)[0].id)
|
||||
|
||||
await sleep(2000)
|
||||
|
||||
|
|
Loading…
Reference in New Issue