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

102 lines
3.3 KiB
JavaScript
Raw Normal View History

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