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

102 lines
3.3 KiB
JavaScript
Raw Normal View History

2018-02-19 01:43:39 +01:00
const times = require('lodash/times')
2018-02-19 19:34:36 +01:00
describe('03-basic-timeline-spec.js', () => {
2018-02-19 00:28:42 +01:00
beforeEach(() => {
2018-02-19 01:43:39 +01:00
cy.login('foobar@localhost:3000', 'foobarfoobar')
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 = [
2018-02-19 18:01:02 +01:00
{content: 'pinned toot 1'},
{content: 'notification of unlisted message'},
{content: 'notification of followers-only message'},
{content: 'notification of direct message'},
2018-02-19 01:43:39 +01:00
{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()})))
2018-02-19 18:01:02 +01:00
const localTimeline = [
{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 world'}
].concat(times(30, i => ({content: (30 - i).toString()})))
2018-02-19 01:43:39 +01:00
2018-02-19 01:57:38 +01:00
const notifications = [
2018-02-19 18:01:02 +01:00
{favoritedBy: 'admin'},
{rebloggedBy: 'admin'},
{content: 'notification of unlisted message'},
{content: 'notification of followers-only message'},
{content: 'notification of direct message'},
2018-02-19 01:57:38 +01:00
{followedBy: 'quux'},
{content: 'hello foobar'},
{followedBy: 'admin'}
]
2018-02-19 18:01:02 +01:00
const favorites = [
{content: 'notification of direct message'},
{content: 'notification of followers-only message'},
{content: 'notification of unlisted message'},
{content: 'pinned toot 1'}
]
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
2018-02-19 18:01:02 +01:00
cy.get('.virtual-list-item[aria-hidden=false] .status-article:first').should('have.attr', 'aria-setsize', '49')
2018-02-19 00:28:42 +01:00
})
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 18:01:02 +01:00
it('Shows favorites', () => {
cy.get('nav a[aria-label=Community]').click()
cy.url().should('contain', '/community')
cy.get('a').contains('Favorites').click()
cy.url().should('contain', '/favorites')
cy.validateTimeline(favorites)
})
2018-02-19 00:30:42 +01:00
})