pinafore/cypress/integration/03-basic-timeline-spec.js

71 lines
2.1 KiB
JavaScript
Raw Normal View History

2018-02-19 01:43:39 +01:00
const times = require('lodash/times')
2018-02-19 00:28:42 +01:00
describe('Basic timeline spec', () => {
beforeEach(() => {
2018-02-19 01:43:39 +01:00
cy.login('foobar@localhost:3000', 'foobarfoobar')
2018-02-19 00:28:42 +01:00
cy.visit('/')
2018-02-19 02:54:38 +01:00
cy.wait(500)
2018-02-19 00:28:42 +01:00
})
2018-02-19 01:43:39 +01:00
const homeTimeline = [
{content: 'this is unlisted'},
{content: 'this is followers-only'},
{content: 'direct'},
{spoiler: 'kitten CW'},
{content: 'secret video'},
{content: "here's a video"},
{spoiler: 'CW'},
{content: "here's a secret animated kitten gif"},
{content: "here's an animated kitten gif"},
{content: "here's 2 kitten photos"},
{content: "here's a secret kitten"},
{content: "here's a kitten"},
{content: 'hello admin'},
{content: 'hello foobar'},
{content: 'hello world'}
].concat(times(30, i => ({content: (30 - i).toString()})))
const localTimeline = homeTimeline.slice()
localTimeline.splice(0, 3)
localTimeline.splice(9, 2)
2018-02-19 01:57:38 +01:00
const notifications = [
{followedBy: 'quux'},
{content: 'hello foobar'},
{followedBy: 'admin'}
]
2018-02-19 01:43:39 +01:00
it('Shows the home timeline', () => {
2018-02-19 00:28:42 +01:00
cy.get('.virtual-list-item[aria-hidden=false] .status-article:first').should('have.attr', 'aria-setsize')
cy.get('.virtual-list-item[aria-hidden=false] .status-article:first').should('have.attr', 'aria-posinset', '0')
2018-02-19 01:43:39 +01:00
cy.validateTimeline(homeTimeline)
2018-02-19 00:28:42 +01:00
cy.get('.virtual-list-item[aria-hidden=false] .status-article:first').should('have.attr', 'aria-setsize', (30 + 15).toString())
})
2018-02-19 01:43:39 +01:00
2018-02-19 01:57:38 +01:00
it('Shows notifications', () => {
2018-02-19 02:28:08 +01:00
cy.get('nav a[aria-label=Notifications]').click()
2018-02-19 01:57:38 +01:00
cy.url().should('contain', '/notifications')
cy.validateTimeline(notifications)
})
2018-02-19 01:43:39 +01:00
it('Shows the local timeline', () => {
2018-02-19 02:28:08 +01:00
cy.get('nav a[aria-label=Local]').click()
2018-02-19 01:43:39 +01:00
cy.url().should('contain', '/local')
cy.validateTimeline(localTimeline)
})
it('Shows the federated timeline', () => {
2018-02-19 02:28:08 +01:00
cy.get('nav a[aria-label=Community]').click()
2018-02-19 01:43:39 +01:00
cy.url().should('contain', '/community')
cy.get('a').contains('Federated').click()
cy.url().should('contain', '/federated')
cy.validateTimeline(localTimeline) // local is same as federated in this case
})
2018-02-19 00:30:42 +01:00
})