fixup
This commit is contained in:
parent
97fb94dba6
commit
9db0d3547a
|
@ -101,7 +101,18 @@ export const actions = times(30, i => ({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
user: 'foobar',
|
user: 'foobar',
|
||||||
follow: 'quux'
|
post: {
|
||||||
|
text: 'this is followers-only',
|
||||||
|
privacy: 'private'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
user: 'foobar',
|
||||||
|
post: {
|
||||||
|
internalId: 2,
|
||||||
|
text: 'this is unlisted',
|
||||||
|
privacy: 'unlisted'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
user: 'admin',
|
user: 'admin',
|
||||||
|
@ -139,14 +150,6 @@ export const actions = times(30, i => ({
|
||||||
user: 'admin',
|
user: 'admin',
|
||||||
boost: 1
|
boost: 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
user: 'foobar',
|
|
||||||
post: {
|
|
||||||
internalId: 2,
|
|
||||||
text: 'this is unlisted',
|
|
||||||
privacy: 'private'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
user: 'admin',
|
user: 'admin',
|
||||||
favorite: 2
|
favorite: 2
|
||||||
|
|
|
@ -8,6 +8,10 @@ import { reblogStatus } from '../routes/_api/reblog'
|
||||||
import fetch from 'node-fetch'
|
import fetch from 'node-fetch'
|
||||||
import FileApi from 'file-api'
|
import FileApi from 'file-api'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import fs from 'fs'
|
||||||
|
import pify from 'pify'
|
||||||
|
|
||||||
|
const readFile = pify(fs.readFile.bind(fs))
|
||||||
|
|
||||||
global.File = FileApi.File
|
global.File = FileApi.File
|
||||||
global.FormData = FileApi.FormData
|
global.FormData = FileApi.FormData
|
||||||
|
@ -26,7 +30,13 @@ export async function restoreMastodonData () {
|
||||||
inReplyTo = internalIdsToIds[inReplyTo]
|
inReplyTo = internalIdsToIds[inReplyTo]
|
||||||
}
|
}
|
||||||
let mediaIds = media && await Promise.all(media.map(async mediaItem => {
|
let mediaIds = media && await Promise.all(media.map(async mediaItem => {
|
||||||
let file = new File(path.join(__dirname, '../tests/images/' + mediaItem))
|
let type = mediaItem.endsWith('gif') ? 'image/gif'
|
||||||
|
: mediaItem.endsWith('jpg') ? 'image/jpg' : 'video/mp4'
|
||||||
|
let file = new File({
|
||||||
|
name: mediaItem,
|
||||||
|
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)
|
||||||
return mediaResponse.id
|
return mediaResponse.id
|
||||||
}))
|
}))
|
||||||
|
@ -43,4 +53,5 @@ export async function restoreMastodonData () {
|
||||||
await reblogStatus('localhost:3000', accessToken, internalIdsToIds[action.boost])
|
await reblogStatus('localhost:3000', accessToken, internalIdsToIds[action.boost])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log('Restored mastodon data')
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ import pify from 'pify'
|
||||||
import childProcessPromise from 'child-process-promise'
|
import childProcessPromise from 'child-process-promise'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import { waitForMastodonToStart } from './wait-for-mastodon-to-start'
|
import { waitForMastodonApiToStart, waitForMastodonUiToStart } from './wait-for-mastodon-to-start'
|
||||||
import mkdirpCB from 'mkdirp'
|
import mkdirpCB from 'mkdirp'
|
||||||
|
|
||||||
const exec = childProcessPromise.exec
|
const exec = childProcessPromise.exec
|
||||||
|
@ -68,15 +68,15 @@ async function runMastodon () {
|
||||||
childProc = promise.childProcess
|
childProc = promise.childProcess
|
||||||
childProc.stdout.pipe(log)
|
childProc.stdout.pipe(log)
|
||||||
childProc.stderr.pipe(log)
|
childProc.stderr.pipe(log)
|
||||||
|
|
||||||
await waitForMastodonToStart()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
await cloneMastodon()
|
await cloneMastodon()
|
||||||
await setupMastodonDatabase()
|
await setupMastodonDatabase()
|
||||||
await runMastodon()
|
await runMastodon()
|
||||||
|
await waitForMastodonApiToStart()
|
||||||
await restoreMastodonData()
|
await restoreMastodonData()
|
||||||
|
await waitForMastodonUiToStart()
|
||||||
}
|
}
|
||||||
|
|
||||||
process.on('SIGINT', function () {
|
process.on('SIGINT', function () {
|
||||||
|
|
|
@ -1,23 +1,40 @@
|
||||||
import fetch from 'node-fetch'
|
import fetch from 'node-fetch'
|
||||||
|
|
||||||
export async function waitForMastodonToStart () {
|
export async function waitForMastodonUiToStart () {
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
let json = await ((await fetch('http://127.0.0.1:3000/api/v1/instance')).json())
|
|
||||||
let html = await ((await fetch('http://127.0.0.1:3035/packs/common.js')).text())
|
let html = await ((await fetch('http://127.0.0.1:3035/packs/common.js')).text())
|
||||||
if (json.uri && html) {
|
if (html) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('Waiting for Mastodon to start up...')
|
console.log('Waiting for Mastodon UI to start up...')
|
||||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('Mastodon started up')
|
console.log('Mastodon UI started up')
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function waitForMastodonApiToStart () {
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
let json = await ((await fetch('http://127.0.0.1:3000/api/v1/instance')).json())
|
||||||
|
if (json.uri) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('Waiting for Mastodon API to start up...')
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('Mastodon API started up')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
waitForMastodonToStart().catch(err => {
|
Promise.all([
|
||||||
|
waitForMastodonApiToStart(),
|
||||||
|
waitForMastodonUiToStart()
|
||||||
|
]).catch(err => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
"test": "cross-env BROWSER=chrome:headless npm run test-browser",
|
"test": "cross-env BROWSER=chrome:headless npm run test-browser",
|
||||||
"test-browser": "run-p --race run-mastodon dev test-mastodon",
|
"test-browser": "run-p --race run-mastodon dev test-mastodon",
|
||||||
"test-mastodon": "run-s wait-for-mastodon-to-start run-testcafe",
|
"test-mastodon": "run-s wait-for-mastodon-to-start run-testcafe",
|
||||||
"wait-for-mastodon-to-start": "node bin/wait-for-mastodon-to-start.js",
|
"wait-for-mastodon-to-start": "node -r @std/esm bin/wait-for-mastodon-to-start.js",
|
||||||
"globalize-css": "node ./bin/globalize-css.js",
|
"globalize-css": "node ./bin/globalize-css.js",
|
||||||
"deglobalize-css": "node ./bin/globalize-css.js --reverse",
|
"deglobalize-css": "node ./bin/globalize-css.js --reverse",
|
||||||
"backup-mastodon-data": "pg_dump -Fc mastodon_development > fixtures/dump.sql && cd mastodon/public/system && tar -czf ../../../fixtures/system.tgz ."
|
"backup-mastodon-data": "pg_dump -Fc mastodon_development > fixtures/dump.sql && cd mastodon/public/system && tar -czf ../../../fixtures/system.tgz ."
|
||||||
|
|
Loading…
Reference in a new issue