Skip to content

Commit

Permalink
test: add research filtering spec
Browse files Browse the repository at this point in the history
  • Loading branch information
benfurber committed Dec 19, 2024
1 parent 1c44773 commit e1b3c6f
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/cypress/src/fixtures/research.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const research: IResearchDB = {
_modified: '2012-10-27T01:47:57.948Z',
_created: '2012-08-02T07:27:04.609Z',
_id: 'ehdI345E36hWyk3Ockr',
label: 'Best',
label: 'Landscaping',
_deleted: false,
},
updates: [
Expand Down
1 change: 1 addition & 0 deletions packages/cypress/src/integration/howto/read.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('[How To]', () => {

describe('[List how-tos]', () => {
it('[By Everyone]', () => {
cy.step('Has expected page title')
cy.title().should('include', `Library`)

cy.step('Can search for items')
Expand Down
54 changes: 53 additions & 1 deletion packages/cypress/src/integration/research/read.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,61 @@ describe('[Research]', () => {
describe('[Read a research article]', () => {
describe('[By Everyone]', () => {
it('[List View]', () => {
cy.step('Has expected page title')
cy.visit('/research')

cy.step('Has expected page title')
cy.title().should('include', `Research`)

cy.step('Can search for items')
cy.get('[data-cy=research-search-box]').click().type('qwerty')
cy.get('[data-cy=ResearchListItem]').its('length').should('be.eq', 1)

cy.step('All basic info displayed on each card')
const researchTitle = 'Qwerty'
const researchUrl = '/research/qwerty'
const coverImageFileName = '1426018318_414579695-17fcd6de5f7'

cy.get('[data-cy=ResearchListItem]').within(() => {
cy.contains(researchTitle).should('be.visible')
cy.get('img')
.should('have.attr', 'src')
.and('include', coverImageFileName)
cy.get('[data-cy=Username]').contains('event_reader')
cy.get('[data-cy=category]').contains('Landscaping')
cy.get('a').should('have.attr', 'href').and('eq', researchUrl)
cy.get('[data-cy=ItemResearchStatus]').contains('In progress')
cy.get('[data-tooltip-content="How useful is it"]')
cy.get('[data-tooltip-content="Total comments"]')
cy.get('[data-tooltip-content="Amount of updates"]')
})

cy.step('Can clear search')
cy.get('[data-cy=close]').click()
cy.get('[data-cy=ResearchListItem]').its('length').should('be.above', 1)

cy.step('Can select a category to limit items displayed')
cy.get('[data-cy=category]').contains('Food')
cy.get('[data-cy=CategoryVerticalList]').within(() => {
cy.contains('Landscaping').click()
})
cy.get('[data-cy=CategoryVerticalList-Item-active]')
cy.get('[data-cy=category]').contains('Landscaping')
cy.get('[data-cy=category]').contains('Food').should('not.exist')

cy.step('Can remove the category filter by selecting it again')
cy.get('[data-cy=CategoryVerticalList]').within(() => {
cy.contains('Landscaping').click()
})
cy.get('[data-cy=category]').contains('Food')

cy.step('Can filter by research status')
cy.get('[data-cy=ItemResearchStatus]').contains('In progress')
cy.contains('Filter by status').click({ force: true })
cy.contains('Completed').click({ force: true })
cy.get('[data-cy=ItemResearchStatus]').contains('Completed')
cy.get('[data-cy=ItemResearchStatus]')
.contains('In progress')
.should('not.exist')
})

it('[Visible to everyone]', () => {
Expand Down
5 changes: 4 additions & 1 deletion packages/cypress/src/integration/research/write.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('[Research]', () => {

cy.step('Warn if title is identical to an existing one')
cy.contains('Start your Research')
cy.fillIntroTitle('qwerty')
cy.fillIntroTitle('Qwerty')
cy.contains(
'Titles must be unique, please try being more specific',
).should('be.visible')
Expand Down Expand Up @@ -261,6 +261,7 @@ describe('[Research]', () => {
const updateDescription = 'This is the description for the update.'
const updateVideoUrl = 'http://youtube.com/watch?v=sbcWY7t-JX8'
const expected = {
category: 'Food',
description: 'After creating, the research will be deleted.',
title: `${randomId} Create research article test`,
slug: `${randomId}-create-research-article-test`,
Expand All @@ -277,6 +278,7 @@ describe('[Research]', () => {
cy.step('Enter research article details')
cy.get('[data-cy=intro-title').clear().type(expected.title).blur()
cy.get('[data-cy=intro-description]').clear().type(expected.description)
cy.selectTag(expected.category, '[data-cy=category-select]')
cy.get('[data-cy=submit]').click()

cy.get('[data-cy=view-research]:enabled', { timeout: 20000 }).click()
Expand All @@ -287,6 +289,7 @@ describe('[Research]', () => {
cy.step('Research article displays correctly')
cy.contains(expected.title)
cy.contains(expected.description)
cy.contains(expected.category)

cy.get('[data-cy=addResearchUpdateButton]').click()

Expand Down
4 changes: 2 additions & 2 deletions shared/mocks/data/research.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export const research = {
_modified: '2012-10-27T01:47:57.948Z',
_created: '2012-08-02T07:27:04.609Z',
_id: 'ehdI345E36hWyk3Ockr',
label: 'Best',
label: 'Landscaping',
_deleted: false,
},
title: 'qwerty',
title: 'Qwerty',
updates: [
{
_created: '2022-03-27T22:10:11.271Z',
Expand Down

0 comments on commit e1b3c6f

Please sign in to comment.