-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GOTH-576 Set up cypress tests (#257)
* install cypress * add tests and fixtures * integrate into circle ci workflow * add a script to update fixtures * update readme
- Loading branch information
Showing
40 changed files
with
20,535 additions
and
736 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,6 @@ nuxt.d.ts | |
.env | ||
coverage | ||
.vscode | ||
.npmrc | ||
.npmrc | ||
cypress/videos/ | ||
cypress/screenshots/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineConfig } from "cypress"; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
baseUrl: 'http://localhost:3000' | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
describe('An article page', () => { | ||
beforeEach(() => { | ||
cy.loadGlobalFixtures() | ||
cy.intercept({ | ||
pathname: '/api/v2/pages/find', | ||
query: { | ||
html_path: 'news/extra-extra-meet-connecticuts-answer-to-pizza-rat' | ||
} | ||
}, {fixture: 'aviary/article.json'}).as('article') | ||
cy.intercept({ | ||
pathname: '/api/v2/pages/find', | ||
query: { | ||
html_path: 'news' | ||
} | ||
}, {fixture: 'aviary/news-page.json'}).as('newsPage') | ||
cy.intercept({ | ||
pathname: '/api/v2/pages', | ||
query: { | ||
type: 'news.ArticlePage', | ||
fields: 'ancestry,description,lead_asset,legacy_id,listing_image,publication_date,show_as_feature,sponsored_content,tags,updated_date,url,uuid,listing_title,listing_summary,related_authors', | ||
order: '-publication_date', | ||
show_on_index_listing: 'true', | ||
sponsored_content: 'false', | ||
descendant_of: '4', | ||
limit: '6' | ||
} | ||
}, {fixture: 'aviary/more-news.json'}).as('moreNews') | ||
}) | ||
it('successfully loads', () => { | ||
cy.visit('/news/extra-extra-meet-connecticuts-answer-to-pizza-rat') | ||
cy.wait('@article') | ||
|
||
cy.get('h1').should('exist') | ||
cy.get('.byline').should('exist') | ||
cy.get('.article-body').should('exist') | ||
cy.get('.tags').should('exist') | ||
cy.get('.author-profile').should('exist') | ||
cy.get('.recirculation').should('exist') | ||
cy.get('.recirculation .gothamist-card:not(.hidden)').should('have.length', 5) | ||
}) | ||
it('shows the marketing CTAs', () => { | ||
cy.intercept( | ||
'/api/v2/system_messages/*', | ||
{fixture: 'aviary/system_messages_bottom.json'} | ||
).as('systemMessagesWithBottomCTA') | ||
|
||
cy.visit('/news/extra-extra-meet-connecticuts-answer-to-pizza-rat') | ||
cy.get('.marketing-modal').should('exist') | ||
cy.get('.p-dialog-header-close').click() | ||
cy.get('.marketing-modal').should('not.exist') | ||
cy.get('.article-donation-marketing-CTA').should('exist') | ||
cy.get('.article-donation-marketing-bottom-CTA').should('exist') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
describe('The home page', () => { | ||
beforeEach(() => { | ||
cy.loadGlobalFixtures() | ||
cy.intercept({ | ||
pathname :'/api/v2/pages/', | ||
query: { | ||
type: 'news.ArticlePage', | ||
fields: 'ancestry,description,lead_asset,legacy_id,listing_image,publication_date,show_as_feature,sponsored_content,tags,updated_date,url,uuid,listing_title,listing_summary,related_authors', | ||
order: '-publication_date', | ||
show_on_index_listing: 'true', | ||
limit: '6' | ||
} | ||
}, {fixture: 'aviary/latest.json'}).as('latest') | ||
cy.intercept({ | ||
pathname :'/api/v2/pages/', | ||
query: { | ||
type: 'news.ArticlePage', | ||
fields: 'ancestry,description,lead_asset,legacy_id,listing_image,publication_date,show_as_feature,sponsored_content,tags,updated_date,url,uuid,listing_title,listing_summary,related_authors', | ||
order: '-publication_date', | ||
show_on_index_listing: 'true', | ||
limit: '6', | ||
offset: '6' | ||
} | ||
}, {fixture: 'aviary/index-more.json'}).as('indexMore') | ||
cy.intercept({ | ||
pathname: '/api/v2/pages/find', | ||
query: { html_path: '/' }, | ||
}, {fixture: 'aviary/index.json'}).as('index') | ||
}) | ||
it('successfully loads', () => { | ||
cy.visit('/') | ||
cy.wait(['@index','@latest']) | ||
cy.get('.homepage-topper').should('exist') | ||
cy.get('.homepage-topper .gothamist-card').should('have.length', 5) | ||
cy.get('.newsletter-home').should('exist') | ||
cy.get('.center-feature').should('exist') | ||
cy.get('.center-feature .gothamist-card:not(.hidden)').should('have.length', 6) | ||
cy.get('.boroughs').should('exist') | ||
cy.get('#articleList').should('exist') | ||
cy.get('#articleList .gothamist-card').should('have.length', 6) | ||
}) | ||
it('loads more', () => { | ||
cy.visit('/') | ||
cy.wait('@latest') | ||
cy.contains('Load More').click() | ||
cy.wait('@indexMore') | ||
cy.get('#articleList .gothamist-card').should('have.length', 12) | ||
cy.get('#articleList .card-title-link').eq(6).should('have.focus') | ||
}) | ||
it('shows the marketing modal', () => { | ||
cy.intercept( | ||
'/api/v2/system_messages/*', | ||
{fixture: 'aviary/system_messages_bottom.json'} | ||
).as('systemMessagesWithBottomCTA') | ||
|
||
cy.visit('/') | ||
cy.get('.marketing-modal').should('exist') | ||
cy.get('.p-dialog-header-close').click() | ||
cy.get('.marketing-modal').should('not.exist') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
describe('A section page', () => { | ||
beforeEach(() => { | ||
cy.loadGlobalFixtures() | ||
cy.intercept({ | ||
pathname: '/api/v2/pages/find', | ||
query: { | ||
html_path: 'news' | ||
} | ||
}, {fixture: 'aviary/section-page.json'}).as('sectionPage') | ||
cy.intercept({ | ||
pathname: '/api/v2/pages', | ||
query: { | ||
type: 'news.ArticlePage', | ||
fields: 'ancestry,description,lead_asset,legacy_id,listing_image,publication_date,show_as_feature,sponsored_content,tags,updated_date,url,uuid,listing_title,listing_summary,related_authors', | ||
order: '-publication_date', | ||
show_on_index_listing: 'true', | ||
sponsored_content: 'false', | ||
descendant_of: '4', | ||
limit: '6' | ||
} | ||
}, {fixture: 'aviary/section-recirculation.json'}).as('sectionRecirculation') | ||
cy.intercept({ | ||
pathname: '/api/v2/pages', | ||
query: { | ||
type: 'news.ArticlePage', | ||
fields: 'ancestry,description,lead_asset,legacy_id,listing_image,publication_date,show_as_feature,sponsored_content,tags,updated_date,url,uuid,listing_title,listing_summary,related_authors', | ||
order: '-publication_date', | ||
show_on_index_listing: 'true', | ||
sponsored_content: 'false', | ||
descendant_of: '4', | ||
offset: '5' | ||
} | ||
}, {fixture: 'aviary/section-articles.json'}).as('sectionArticles') | ||
cy.intercept({ | ||
pathname: '/api/v2/pages', | ||
query: { | ||
type: 'news.ArticlePage', | ||
fields: 'ancestry,description,lead_asset,legacy_id,listing_image,publication_date,show_as_feature,sponsored_content,tags,updated_date,url,uuid,listing_title,listing_summary,related_authors', | ||
order: '-publication_date', | ||
show_on_index_listing: 'true', | ||
sponsored_content: 'false', | ||
descendant_of: '4', | ||
limit: '10', | ||
offset: '25' | ||
} | ||
}, {fixture: 'aviary/section-more.json'}).as('sectionMore') | ||
}) | ||
it('successfully loads', () => { | ||
cy.visit('/news') | ||
cy.wait('@sectionArticles') | ||
cy.get('#article-recirculation').should('exist') | ||
cy.get('#article-recirculation .gothamist-card:not(.hidden)').should('have.length', 5) | ||
cy.get('#articleList').should('exist') | ||
cy.get('#articleList .gothamist-card').should('have.length', 20) | ||
}) | ||
it('loads more', () => { | ||
cy.visit('/news') | ||
cy.wait('@sectionArticles') | ||
cy.contains('Load More').click() | ||
cy.wait('@sectionMore') | ||
cy.get('#articleList .gothamist-card').should('have.length', 30) | ||
cy.get('#articleList .card-title-link').eq(20).should('have.focus') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
describe('A staff page', () => { | ||
beforeEach(() => { | ||
cy.loadGlobalFixtures() | ||
cy.intercept({ | ||
pathname: '/api/v2/pages', | ||
query: { | ||
type: 'news.ArticlePage', | ||
fields: 'ancestry,description,lead_asset,legacy_id,listing_image,publication_date,show_as_feature,sponsored_content,tags,updated_date,url,uuid,listing_title,listing_summary,related_authors', | ||
order: '-publication_date', | ||
show_on_index_listing: 'true', | ||
author_slug: 'jen-chung', | ||
limit: '12', | ||
offset: '0' | ||
} | ||
}, {fixture: 'aviary/staff-articles.json'}).as('staffArticles') | ||
|
||
cy.intercept({ | ||
pathname: '/api/v2/pages', | ||
query: { | ||
type: 'news.ArticlePage', | ||
fields: 'ancestry,description,lead_asset,legacy_id,listing_image,publication_date,show_as_feature,sponsored_content,tags,updated_date,url,uuid,listing_title,listing_summary,related_authors', | ||
order: '-publication_date', | ||
show_on_index_listing: 'true', | ||
author_slug: 'jen-chung', | ||
limit: '12', | ||
offset: '12' | ||
} | ||
}, {fixture: 'aviary/staff-more.json'}).as('staffMore') | ||
}) | ||
it('successfully loads', () => { | ||
cy.visit('/staff/jen-chung') | ||
cy.get('#articleList .gothamist-card').should('have.length', 12) | ||
}) | ||
it('loads more', () => { | ||
cy.visit('/staff/jen-chung') | ||
cy.contains('Load More').click() | ||
cy.wait('@staffMore') | ||
cy.get('#articleList .gothamist-card').should('have.length', 24) | ||
cy.get('#articleList .card-title-link').eq(12).should('have.focus') | ||
}) | ||
}) |
Oops, something went wrong.