From 9dfe76692f1ed6f59787f66611aa57f7d15a965e Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Mon, 19 Feb 2018 09:17:22 -0800 Subject: [PATCH] add test for pinned statuses --- cypress/integration/03-basic-timeline-spec.js | 4 -- cypress/integration/04-pinned-statuses.js | 37 +++++++++++++++++++ .../_components/timeline/PinnedStatuses.html | 2 +- routes/pinned.html | 4 +- 4 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 cypress/integration/04-pinned-statuses.js diff --git a/cypress/integration/03-basic-timeline-spec.js b/cypress/integration/03-basic-timeline-spec.js index b7e9265..aa8187e 100644 --- a/cypress/integration/03-basic-timeline-spec.js +++ b/cypress/integration/03-basic-timeline-spec.js @@ -60,10 +60,6 @@ describe('Basic timeline spec', () => { {content: 'pinned toot 1'} ] - const pinnedStatuses = [ - {content: 'this is unlisted'} - ] - it('Shows the home timeline', () => { 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') diff --git a/cypress/integration/04-pinned-statuses.js b/cypress/integration/04-pinned-statuses.js new file mode 100644 index 0000000..5e96947 --- /dev/null +++ b/cypress/integration/04-pinned-statuses.js @@ -0,0 +1,37 @@ +describe('Pinned statuses', () => { + beforeEach(() => { + cy.login('foobar@localhost:3000', 'foobarfoobar') + cy.visit('/') + cy.wait(500) + }) + + it("shows a user's pinned statuses", () => { + cy.get('nav a[aria-label=Community]').click() + cy.url().should('contain', '/community') + cy.get('a').contains('Pinned').click() + cy.url().should('contain', '/pinned') + + cy.get('.status-article').should('have.attr', 'aria-posinset', '0') + cy.get('.status-article').should('have.attr', 'aria-setsize', '1') + cy.get('.status-article .status-content').should('contain', 'this is unlisted') + }) + + it("shows pinned statuses on a user's account page", () => { + cy.visit('/accounts/2') + cy.wait(500) + cy.get('.pinned-statuses .status-article').should('have.attr', 'aria-posinset', '0') + cy.get('.pinned-statuses .status-article').should('have.attr', 'aria-setsize', '1') + cy.get('.pinned-statuses .status-article').should('contain', 'this is unlisted') + }) + + it("shows pinned statuses on a user's account page 2", () => { + cy.visit('/accounts/3') + cy.wait(500) + cy.get('.pinned-statuses .status-article').should('have.attr', 'aria-posinset', '0') + cy.get('.pinned-statuses .status-article').should('have.attr', 'aria-setsize', '2') + cy.get('.pinned-statuses .status-article').should('contain', 'pinned toot 1') + + cy.get('.pinned-statuses .status-article[aria-posinset=1]').should('have.attr', 'aria-setsize', '2') + cy.get('.pinned-statuses .status-article[aria-posinset=1]').should('contain', 'pinned toot 2') + }) +}) \ No newline at end of file diff --git a/routes/_components/timeline/PinnedStatuses.html b/routes/_components/timeline/PinnedStatuses.html index cad2419..7693bd5 100644 --- a/routes/_components/timeline/PinnedStatuses.html +++ b/routes/_components/timeline/PinnedStatuses.html @@ -1,4 +1,4 @@ -
+
{{#if pinnedStatuses}} {{#each pinnedStatuses as status, index}} {{elseif statuses && statuses.length}}
    - {{#each statuses as status}} - + {{#each statuses as status, index}} + {{/each}}
{{/if}}