test: skip unnecessary navigations in readwrite tests

skip-navigations-2
Nolan Lawson 2021-07-04 18:00:39 -07:00
rodzic c5de673990
commit 67fcd6b876
15 zmienionych plików z 30 dodań i 56 usunięć

Wyświetl plik

@ -1,6 +1,8 @@
import { getUrl } from './utils'
import { users } from './users'
export const foobarURL = `http://localhost:4002/?instanceName=localhost:3000&accessToken=${users.foobar.accessToken}`
// quick login using a secret page and a known access token (makes tests run faster)
async function login (t, user) {
await t.navigateTo(`/?instanceName=localhost:3000&accessToken=${user.accessToken}`)

Wyświetl plik

@ -1,4 +1,4 @@
import { loginAsFoobar } from '../roles'
import { foobarURL } from '../roles'
import {
composeInput, getNthComposeReplyButton, getNthComposeReplyInput, getNthReplyButton, getNthStatus, getUrl,
homeNavButton, notificationsNavButton,
@ -6,10 +6,9 @@ import {
} from '../utils'
fixture`103-compose.js`
.page`http://localhost:4002`
.page`${foobarURL}`
test('statuses show up in home timeline', async t => {
await loginAsFoobar(t)
await t
.typeText(composeInput, 'hello world', { paste: true })
.click(postStatusButton)
@ -24,7 +23,6 @@ test('statuses show up in home timeline', async t => {
})
test('statuses in threads show up in right order', async t => {
await loginAsFoobar(t)
await t
.navigateTo('/accounts/5')
.click(getNthStatus(3))

Wyświetl plik

@ -1,14 +1,13 @@
import { loginAsFoobar } from '../roles'
import { foobarURL } from '../roles'
import {
getNthStatus, scrollToTop, showMoreButton, sleep
} from '../utils'
import { postAs } from '../serverActions'
fixture`104-streaming.js`
.page`http://localhost:4002`
.page`${foobarURL}`
test('new incoming statuses show up immediately', async t => {
await loginAsFoobar(t)
await t
.hover(getNthStatus(1))
await postAs('admin', 'hello my baby hello my honey')
@ -16,7 +15,6 @@ test('new incoming statuses show up immediately', async t => {
})
test('new incoming toots show a button if scrolled down', async t => {
await loginAsFoobar(t)
await t
.hover(getNthStatus(1))
.hover(getNthStatus(3))

Wyświetl plik

@ -1,4 +1,4 @@
import { loginAsFoobar } from '../roles'
import { foobarURL } from '../roles'
import {
clickToNotificationsAndBackHome, forceOffline, forceOnline, getNthStatus, getUrl, homeNavButton,
notificationsNavButton
@ -6,11 +6,10 @@ import {
import { deleteAs, postAs, postReplyAs } from '../serverActions'
fixture`105-deletes.js`
.page`http://localhost:4002`
.page`${foobarURL}`
test('deleted statuses are removed from the timeline', async t => {
const timeout = 20000
await loginAsFoobar(t)
await t
.hover(getNthStatus(1))
const status = await postAs('admin', "I'm gonna delete this")
@ -31,7 +30,6 @@ test('deleted statuses are removed from the timeline', async t => {
test('deleted statuses are removed from threads', async t => {
const timeout = 20000
await loginAsFoobar(t)
await t
.hover(getNthStatus(1))
const status = await postAs('admin', "I won't delete this")
@ -56,7 +54,6 @@ test('deleted statuses are removed from threads', async t => {
test('deleted statuses result in deleted notifications', async t => {
const timeout = 20000
await loginAsFoobar(t)
await t
.hover(getNthStatus(1))
.expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications')

Wyświetl plik

@ -1,4 +1,4 @@
import { loginAsFoobar } from '../roles'
import { foobarURL } from '../roles'
import {
forceOffline,
forceOnline,
@ -16,12 +16,11 @@ import {
} from '../serverActions'
fixture`107-streaming-gap.js`
.page`http://localhost:4002`
.page`${foobarURL}`
const timeout = 30000
test('fills timeline gap while away from local timeline', async t => {
await loginAsFoobar(t)
await t
.click(localTimelineNavButton)
.expect(getNthStatus(1).exists).ok({ timeout })
@ -41,7 +40,6 @@ test('fills timeline gap while away from local timeline', async t => {
})
test('fills timeline gap while away from home timeline', async t => {
await loginAsFoobar(t)
await t
.expect(getNthStatus(1).exists).ok({ timeout })
.hover(getNthStatus(1))
@ -56,7 +54,6 @@ test('fills timeline gap while away from home timeline', async t => {
})
test('fills timeline gap while away from notifications timeline', async t => {
await loginAsFoobar(t)
await t
.click(notificationsNavButton)
.expect(getNthStatus(1).exists).ok({ timeout })
@ -72,7 +69,6 @@ test('fills timeline gap while away from notifications timeline', async t => {
})
test('fills timeline gap while away from notifications timeline - badge updates', async t => {
await loginAsFoobar(t)
await t
.expect(getNthStatus(1).exists).ok({ timeout })
.hover(getNthStatus(1))
@ -91,7 +87,6 @@ test('fills timeline gap while away from notifications timeline - badge updates'
})
test('fills a large gap while away from home timeline', async t => {
await loginAsFoobar(t)
await t
.expect(getNthStatus(1).exists).ok({ timeout })
.hover(getNthStatus(1))

Wyświetl plik

@ -11,14 +11,13 @@ import {
composeModalInput,
composeModalComposeButton, emojiSearchInput, firstEmojiInPicker
} from '../utils'
import { loginAsFoobar } from '../roles'
import { foobarURL } from '../roles'
import { Selector as $ } from 'testcafe'
fixture`108-compose-dialog.js`
.page`http://localhost:4002`
.page`${foobarURL}`
test('can compose using a dialog', async t => {
await loginAsFoobar(t)
await scrollToStatus(t, 16)
await t.expect(modalDialog.exists).notOk()
.expect(composeButton.getAttribute('aria-label')).eql('Compose toot')
@ -38,7 +37,6 @@ test('can compose using a dialog', async t => {
// Skipped because TestCafé seems to believe the elements are not visible when they are.
// Tested manually and it's fine; probably a TestCafé bug.
test.skip('can use emoji dialog within compose dialog', async t => {
await loginAsFoobar(t)
await scrollToStatus(t, 16)
await t.expect(composeButton.getAttribute('aria-label')).eql('Compose toot')
await sleep(2000)

Wyświetl plik

@ -2,14 +2,13 @@ import {
composeButton, composeContentWarning, composeInput, contentWarningButton,
getNthShowOrHideButton, getNthStatus, getNthStatusSelector
} from '../utils'
import { loginAsFoobar } from '../roles'
import { foobarURL } from '../roles'
import { Selector as $ } from 'testcafe'
fixture`110-compose-content-warnings.js`
.page`http://localhost:4002`
.page`${foobarURL}`
test('content warnings are posted', async t => {
await loginAsFoobar(t)
await t
.typeText(composeInput, 'hello this is a toot', { paste: true })
.click(contentWarningButton)
@ -23,7 +22,6 @@ test('content warnings are posted', async t => {
})
test('content warnings are not posted if removed', async t => {
await loginAsFoobar(t)
await t
.typeText(composeInput, 'hi this is another toot', { paste: true })
.click(contentWarningButton)
@ -37,7 +35,6 @@ test('content warnings are not posted if removed', async t => {
})
test('content warnings can have emoji', async t => {
await loginAsFoobar(t)
await t
.typeText(composeInput, 'I can: :blobnom: ')
.click(contentWarningButton)
@ -52,7 +49,6 @@ test('content warnings can have emoji', async t => {
test('no XSS in content warnings or text', async t => {
const pwned1 = '<script>alert("pwned!")</script>'
const pwned2 = '<script>alert("pwned from CW!")</script>'
await loginAsFoobar(t)
await t
.typeText(composeInput, pwned1)
.click(contentWarningButton)

Wyświetl plik

@ -4,14 +4,13 @@ import {
getNthComposeReplyInput, getNthReplyButton,
getNthStatusSelector
} from '../utils'
import { loginAsFoobar } from '../roles'
import { foobarURL } from '../roles'
import { Selector as $ } from 'testcafe'
fixture`111-focus.js`
.page`http://localhost:4002`
.page`${foobarURL}`
test('replying to a toot returns focus to reply button', async t => {
await loginAsFoobar(t)
await t
.typeText(composeInput, 'I would like, if I may, to take you on a strange journey', { paste: true })
.pressKey('ctrl+enter')

Wyświetl plik

@ -3,11 +3,11 @@ import {
composeInput,
getNthStatus, getNthStatusSelector
} from '../utils'
import { loginAsFoobar } from '../roles'
import { foobarURL } from '../roles'
import { Selector as $ } from 'testcafe'
fixture`112-status-links.js`
.page`http://localhost:4002`
.page`${foobarURL}`
test('External links, hashtags, and mentions have correct attributes', async t => {
const text = 'Why hello there @admin and @baz and @quux ' +
@ -17,7 +17,6 @@ test('External links, hashtags, and mentions have correct attributes', async t =
const nthAnchor = n => $(`${getNthStatusSelector(1)} .status-content a`).nth(n)
await loginAsFoobar(t)
await t
.typeText(composeInput, text, { paste: true })
.click(composeButton)

Wyświetl plik

@ -12,14 +12,13 @@ import {
confirmationDialogOKButton, sleep
} from '../utils'
import { Selector as $ } from 'testcafe'
import { loginAsFoobar } from '../roles'
import { foobarURL } from '../roles'
import { postAs } from '../serverActions'
fixture`114-mute-unmute.js`
.page`http://localhost:4002`
.page`${foobarURL}`
test('Can mute and unmute an account', async t => {
await loginAsFoobar(t)
const post = 'blah blah blah'
await postAs('admin', post)

Wyświetl plik

@ -15,14 +15,13 @@ import {
sleep,
getNthStatus
} from '../utils'
import { loginAsFoobar } from '../roles'
import { foobarURL } from '../roles'
import { POLL_EXPIRY_DEFAULT } from '../../src/routes/_static/polls'
fixture`127-compose-polls.js`
.page`http://localhost:4002`
.page`${foobarURL}`
test('Can add and remove poll', async t => {
await loginAsFoobar(t)
await t
.expect(getNthStatus(1).exists).ok()
.expect(composePoll.exists).notOk()
@ -43,7 +42,6 @@ test('Can add and remove poll', async t => {
})
test('Can add and remove poll options', async t => {
await loginAsFoobar(t)
await t
.expect(getNthStatus(1).exists).ok()
.expect(composePoll.exists).notOk()
@ -86,7 +84,6 @@ test('Can add and remove poll options', async t => {
})
test('Properly escapes HTML and emojos in polls', async t => {
await loginAsFoobar(t)
await t
.expect(getNthStatus(1).exists).ok()
.click(pollButton)

Wyświetl plik

@ -6,15 +6,14 @@ import {
getUrl,
showMoreButton, getNthStatusContent
} from '../utils'
import { loginAsFoobar } from '../roles'
import { foobarURL } from '../roles'
import { Selector as $ } from 'testcafe'
import { postAs } from '../serverActions'
fixture`128-disable-infinite-load.js`
.page`http://localhost:4002`
.page`${foobarURL}`
test('Can disable loading items at top of timeline', async t => {
await loginAsFoobar(t)
await t.click(settingsNavButton)
.click($('a').withText('General'))
.click(disableInfiniteScroll)

Wyświetl plik

@ -6,15 +6,14 @@ import {
getUrl,
notificationsNavButton, getTitleText, sleep
} from '../utils'
import { loginAsFoobar } from '../roles'
import { foobarURL } from '../roles'
import { Selector as $ } from 'testcafe'
import { postAs } from '../serverActions'
fixture`129-wellness.js`
.page`http://localhost:4002`
.page`${foobarURL}`
test('Can disable unread notification counts', async t => {
await loginAsFoobar(t)
await t.click(settingsNavButton)
.click($('a').withText('Wellness'))
.click(disableUnreadNotifications)

Wyświetl plik

@ -13,13 +13,12 @@ import {
getNthStatusContent,
getNthStatusAndImage
} from '../utils'
import { loginAsFoobar } from '../roles'
import { foobarURL } from '../roles'
fixture`130-focal-point.js`
.page`http://localhost:4002`
.page`${foobarURL}`
test('Can set a focal point', async t => {
await loginAsFoobar(t)
await t
.typeText(composeInput, 'here is a focal point')
.click(mediaButton)

Wyświetl plik

@ -2,14 +2,13 @@ import {
getNthStatus, sleep,
timeline
} from '../utils'
import { loginAsFoobar } from '../roles'
import { foobarURL } from '../roles'
import { postStatusWithMediaAs } from '../serverActions'
fixture`136-empty-list.js`
.page`http://localhost:4002`
.page`${foobarURL}`
test('An empty list can become non-empty as results stream in', async t => {
await loginAsFoobar(t)
await t
.expect(getNthStatus(1).exists).ok()
.navigateTo('/tags/sweetkitty')