getting closer

This commit is contained in:
Nolan Lawson 2018-03-05 22:36:54 -08:00
parent 32e47a0bb7
commit 8eeb7da186
7 changed files with 69 additions and 39 deletions

View File

@ -12,6 +12,10 @@ export const actions = times(30, i => ({
text: 'hello world'
}
},
{
user: 'admin',
follow: 'foobar'
},
{
user: 'admin',
post: {
@ -19,6 +23,10 @@ export const actions = times(30, i => ({
privacy: 'unlisted'
}
},
{
user: 'quux',
follow: 'foobar'
},
{
user: 'foobar',
post: {
@ -93,29 +101,18 @@ export const actions = times(30, i => ({
spoiler: 'kitten CW'
}
},
// notifications for foobar
{
user: 'admin',
follow: 'foobar'
},
{
user: 'admin',
user: 'foobar',
post: {
text: '@foobar direct',
internalId: 11,
text: 'direct',
privacy: 'direct'
}
},
{
user: 'quux',
follow: 'foobar'
},
{
user: 'admin',
follow: 'quux'
},
{
user: 'foobar',
post: {
internalId: 10,
text: 'this is followers-only',
privacy: 'private'
}
@ -128,6 +125,10 @@ export const actions = times(30, i => ({
privacy: 'unlisted'
}
},
{
user: 'admin',
follow: 'quux'
},
{
user: 'admin',
post: {
@ -171,7 +172,16 @@ export const actions = times(30, i => ({
{
user: 'admin',
favorite: 2
},
}
]).concat(times(25, i => ({
user: 'quux',
post: {
internalId: 100 + i,
text: 'unlisted thread ' + (i + 1),
privacy: 'unlisted',
inReplyTo: i > 0 && (100 + i)
}
}))).concat([
{
user: 'quux',
post: {
@ -187,16 +197,7 @@ export const actions = times(30, i => ({
text: 'pinned toot 2',
privacy: 'unlisted'
}
}
]).concat(times(25, i => ({
user: 'quux',
post: {
internalId: 100 + i,
text: 'unlisted thread ' + (i + 1),
privacy: 'unlisted',
inReplyTo: i > 0 && (100 + i)
}
}))).concat([
},
{
user: 'quux',
pin: 5
@ -213,13 +214,29 @@ export const actions = times(30, i => ({
user: 'admin',
favorite: 5
},
{
user: 'admin',
favorite: 6
},
{
user: 'foobar',
favorite: 5
},
{
user: 'admin',
favorite: 6
user: 'foobar',
favorite: 2
},
{
user: 'foobar',
favorite: 10
},
{
user: 'foobar',
favorite: 3
},
{
user: 'foobar',
pin: 2
},
{
user: 'ExternalLinks',

View File

@ -1,6 +1,6 @@
import { actions } from './mastodon-data'
import { users } from '../tests/users'
import { postStatus } from '../routes/_api/statuses'
import { pinStatus, postStatus } from '../routes/_api/statuses'
import { uploadMedia } from '../routes/_api/media'
import { followAccount } from '../routes/_api/follow'
import { favoriteStatus } from '../routes/_api/favorite'
@ -37,7 +37,7 @@ export async function restoreMastodonData () {
type: type,
buffer: await readFile(path.join(__dirname, '../tests/images/' + mediaItem))
})
let mediaResponse = await uploadMedia('localhost:3000', accessToken, file)
let mediaResponse = await uploadMedia('localhost:3000', accessToken, file, 'kitten')
return mediaResponse.id
}))
let status = await postStatus('localhost:3000', accessToken, text, inReplyTo, mediaIds,
@ -51,8 +51,10 @@ export async function restoreMastodonData () {
await favoriteStatus('localhost:3000', accessToken, internalIdsToIds[action.favorite])
} else if (action.boost) {
await reblogStatus('localhost:3000', accessToken, internalIdsToIds[action.boost])
} else if (action.pin) {
await pinStatus('localhost:3000', accessToken, internalIdsToIds[action.pin])
}
await new Promise(resolve => setTimeout(resolve, 2000))
await new Promise(resolve => setTimeout(resolve, 1500))
}
console.log('Restored mastodon data')
}

View File

@ -1,9 +1,10 @@
import { auth, basename } from './utils'
import { postWithTimeout } from '../_utils/ajax'
export async function uploadMedia (instanceName, accessToken, file) {
export async function uploadMedia (instanceName, accessToken, file, description) {
let formData = new FormData()
formData.append('file', file)
formData.append('description', description)
let url = `${basename(instanceName)}/api/v1/media`
return postWithTimeout(url, formData, auth(accessToken))
}

View File

@ -23,3 +23,13 @@ export async function postStatus (instanceName, accessToken, text, inReplyToId,
return postWithTimeout(url, body, auth(accessToken))
}
export async function pinStatus (instanceName, accessToken, statusId) {
let url = `${basename(instanceName)}/api/v1/statuses/${statusId}/pin`
return postWithTimeout(url, null, auth(accessToken))
}
export async function unpinStatus (instanceName, accessToken, statusId) {
let url = `${basename(instanceName)}/api/v1/statuses/${statusId}/unpin`
return postWithTimeout(url, null, auth(accessToken))
}

View File

@ -13,7 +13,7 @@ test('Shows a thread', async t => {
await scrollToBottomOfTimeline(t)
await t
.click(getNthStatus(26))
.expect(getUrl()).contains('/statuses/99549257018049016')
.expect(getUrl()).contains('/statuses/')
await validateTimeline(t, quuxThread)
@ -30,7 +30,7 @@ test('Scrolls to proper point in thread', async t => {
.hover(getNthStatus(8))
.hover(getNthStatus(10))
.click(getNthStatus(10))
.expect(getUrl()).contains('/statuses/99549263341916700')
.expect(getUrl()).contains('/statuses/')
.expect(getNthStatus(16).innerText).contains('unlisted thread 17')
.expect(Math.round(getNthStatus(16).boundingClientRect.top))
.eql(Math.round($('.container').boundingClientRect.top))

View File

@ -18,7 +18,7 @@ test('modal preserves focus', async t => {
test('timeline preserves focus', async t => {
await t.useRole(foobarRole)
.click(getNthStatus(0))
.expect(getUrl()).contains('/statuses/99549266679020981')
.expect(getUrl()).contains('/statuses/')
await goBack()
await t.expect(getActiveElementClass()).eql('status-article status-in-timeline')

View File

@ -8,11 +8,11 @@ fixture`11-reblog-favorites-count.js`
test('shows favorites', async t => {
await t.useRole(foobarRole)
.click(getNthStatus(0))
.expect(getUrl()).contains('/statuses/99549266679020981')
.expect(getUrl()).contains('/statuses/')
.expect(getFavoritesCount()).eql(2)
.expect($('.icon-button[aria-label="Favorite"]').getAttribute('aria-pressed')).eql('true')
.click($('.status-favs-reblogs').nth(1))
.expect(getUrl()).contains('/statuses/99549266679020981/favorites')
.expect(getUrl()).match(/\/statuses\/[^\/]+\/favorites/)
.expect($('.search-result-account-name').nth(0).innerText).eql('foobar')
.expect($('.search-result-account-username').nth(0).innerText).eql('@foobar')
.expect($('.search-result-account-name').nth(1).innerText).eql('admin')
@ -22,11 +22,11 @@ test('shows favorites', async t => {
test('shows boosts', async t => {
await t.useRole(foobarRole)
.click(getNthStatus(0))
.expect(getUrl()).contains('/statuses/99549266679020981')
.expect(getUrl()).contains('/statuses/')
.expect(getReblogsCount()).eql(1)
.expect($('.icon-button[aria-label="Boost"]').getAttribute('aria-pressed')).eql('false')
.click($('.status-favs-reblogs').nth(0))
.expect(getUrl()).contains('/statuses/99549266679020981/reblogs')
.expect(getUrl()).match(/\/statuses\/[^\/]+\/reblogs/)
.expect($('.search-result-account-name').nth(0).innerText).eql('admin')
.expect($('.search-result-account-username').nth(0).innerText).eql('@admin')
})