This commit is contained in:
Nolan Lawson 2018-02-18 15:30:42 -08:00
parent f4eeacdc1c
commit 03073ac846
7 changed files with 39 additions and 34 deletions

View File

@ -19,7 +19,7 @@ const mastodonDir = path.join(dir, '../mastodon')
let childProc let childProc
async function cloneMastodon() { async function cloneMastodon () {
try { try {
await stat(mastodonDir) await stat(mastodonDir)
} catch (e) { } catch (e) {
@ -30,7 +30,7 @@ async function cloneMastodon() {
} }
} }
async function restoreMastodonData() { async function restoreMastodonData () {
console.log('Restoring mastodon data...') console.log('Restoring mastodon data...')
try { try {
await exec('dropdb mastodon_development', {cwd: mastodonDir}) await exec('dropdb mastodon_development', {cwd: mastodonDir})
@ -46,7 +46,7 @@ async function restoreMastodonData() {
await exec(`tar -xzf "${tgzFile}"`, {cwd: systemDir}) await exec(`tar -xzf "${tgzFile}"`, {cwd: systemDir})
} }
async function runMastodon() { async function runMastodon () {
console.log('Running mastodon...') console.log('Running mastodon...')
let cmds = [ let cmds = [
'gem install bundler', 'gem install bundler',
@ -71,7 +71,7 @@ async function runMastodon() {
await waitForMastodonToStart() await waitForMastodonToStart()
} }
async function main() { async function main () {
await cloneMastodon() await cloneMastodon()
await restoreMastodonData() await restoreMastodonData()
await runMastodon() await runMastodon()

View File

@ -1,6 +1,6 @@
const fetch = require('node-fetch') const fetch = require('node-fetch')
async function waitForMastodonToStart() { async function waitForMastodonToStart () {
while (true) { while (true) {
try { try {
let json = await ((await fetch('http://127.0.0.1:3000/api/v1/instance')).json()) let json = await ((await fetch('http://127.0.0.1:3000/api/v1/instance')).json())
@ -22,4 +22,4 @@ if (require.main === module) {
console.error(err) console.error(err)
process.exit(1) process.exit(1)
}) })
} }

View File

@ -1,11 +1,11 @@
describe('Basic spec', () => { describe('Basic spec', () => {
beforeEach(() => { beforeEach(() => {
cy.visit('/') cy.visit('/')
}) })
it('has the correct <h1>', () => { it('has the correct <h1>', () => {
cy.contains('h1', 'Pinafore') cy.contains('h1', 'Pinafore')
}) })
it('navigates to about', () => { it('navigates to about', () => {
cy.get('nav a').contains('Settings').click() cy.get('nav a').contains('Settings').click()
@ -15,10 +15,10 @@ describe('Basic spec', () => {
cy.contains('h1', 'About Pinafore') cy.contains('h1', 'About Pinafore')
}) })
it('navigates to /settings/instances/add', () => { it('navigates to /settings/instances/add', () => {
cy.contains('log in to an instance').click() cy.contains('log in to an instance').click()
cy.url().should('contain', '/settings/instances/add') cy.url().should('contain', '/settings/instances/add')
}) })
it('navigates to settings/instances', () => { it('navigates to settings/instances', () => {
cy.get('nav a').contains('Settings').click() cy.get('nav a').contains('Settings').click()
@ -27,5 +27,4 @@ describe('Basic spec', () => {
cy.url().should('contain', '/settings/instances') cy.url().should('contain', '/settings/instances')
cy.contains("You're not logged in to any instances") cy.contains("You're not logged in to any instances")
}) })
})
})

View File

@ -1,10 +1,10 @@
describe('Login spec', () => { describe('Login spec', () => {
beforeEach(() => { beforeEach(() => {
cy.visit('/') cy.visit('/')
}) })
it('Cannot log in to a fake instance', () => { it('Cannot log in to a fake instance', () => {
cy.get('a').contains('log in to an instance').click() cy.get('a').contains('log in to an instance').click()
cy.get('#instanceInput').clear().type('fake.nolanlawson.com') cy.get('#instanceInput').clear().type('fake.nolanlawson.com')
cy.get('.add-new-instance').submit() cy.get('.add-new-instance').submit()
@ -13,7 +13,7 @@ describe('Login spec', () => {
cy.get('.form-error').should('not.exist') cy.get('.form-error').should('not.exist')
cy.get('#instanceInput').clear().type('fake.nolanlawson.com') cy.get('#instanceInput').clear().type('fake.nolanlawson.com')
cy.get('.form-error').should('exist') cy.get('.form-error').should('exist')
}) })
it('Logs in to localhost:3000', () => { it('Logs in to localhost:3000', () => {
cy.login('foobar@localhost:3000', 'foobarfoobar') cy.login('foobar@localhost:3000', 'foobarfoobar')
@ -33,5 +33,4 @@ describe('Login spec', () => {
cy.url().should('contain', '/settings/instances') cy.url().should('contain', '/settings/instances')
cy.contains("You're not logged in to any instances") cy.contains("You're not logged in to any instances")
}) })
})
})

View File

@ -25,9 +25,9 @@ describe('Basic timeline spec', () => {
cy.getNthVirtualArticle(10).get('.status-content p').should('contain', "here's a secret kitten") cy.getNthVirtualArticle(10).get('.status-content p').should('contain', "here's a secret kitten")
cy.getNthVirtualArticle(11).get('.status-content p').should('contain', "here's a kitten") cy.getNthVirtualArticle(11).get('.status-content p').should('contain', "here's a kitten")
cy.getNthVirtualArticle(11).scrollIntoView() cy.getNthVirtualArticle(11).scrollIntoView()
cy.getNthVirtualArticle(12).get('.status-content p').should('contain', "hello admin") cy.getNthVirtualArticle(12).get('.status-content p').should('contain', 'hello admin')
cy.getNthVirtualArticle(13).get('.status-content p').should('contain', "hello foobar") cy.getNthVirtualArticle(13).get('.status-content p').should('contain', 'hello foobar')
cy.getNthVirtualArticle(14).get('.status-content p').should('contain', "hello world") cy.getNthVirtualArticle(14).get('.status-content p').should('contain', 'hello world')
cy.getNthVirtualArticle(14).scrollIntoView() cy.getNthVirtualArticle(14).scrollIntoView()
for (let i = 0; i < 30; i++) { for (let i = 0; i < 30; i++) {
@ -36,6 +36,5 @@ describe('Basic timeline spec', () => {
} }
cy.get('.virtual-list-item[aria-hidden=false] .status-article:first').should('have.attr', 'aria-setsize', (30 + 15).toString()) cy.get('.virtual-list-item[aria-hidden=false] .status-article:first').should('have.attr', 'aria-setsize', (30 + 15).toString())
}) })
}) })

View File

@ -49,4 +49,4 @@ Cypress.Commands.add('login', (email, password) => {
Cypress.Commands.add('getNthVirtualArticle', (n) => { Cypress.Commands.add('getNthVirtualArticle', (n) => {
return cy.get(`.virtual-list-item[aria-hidden=false] .status-article[aria-posinset=${n}]`) return cy.get(`.virtual-list-item[aria-hidden=false] .status-article[aria-posinset=${n}]`)
}) })

View File

@ -91,11 +91,19 @@
"caches", "caches",
"__routes__", "__routes__",
"__shell__", "__shell__",
"__assets__" "__assets__",
"cy",
"Cypress",
"expect",
"before",
"beforeEach",
"after",
"afterEach",
"describe",
"it"
], ],
"ignore": [ "ignore": [
"dist", "dist",
"cypress",
"routes/_utils/asyncModules.js" "routes/_utils/asyncModules.js"
] ]
} }