Skip to content

Commit

Permalink
feat: update research page titles
Browse files Browse the repository at this point in the history
  • Loading branch information
benfurber committed Jun 13, 2024
1 parent 9c926e9 commit c36dd01
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 28 deletions.
87 changes: 60 additions & 27 deletions packages/cypress/src/integration/research/read.spec.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,66 @@
import { MOCK_DATA } from '../../data'

const research = Object.values(MOCK_DATA.research)
const article = Object.values(MOCK_DATA.research)[0]

describe('[Research]', () => {
const researchArticleUrl = `/research/${research[0].slug}`
const authoredResearchArticleUrl = '/research/a-test-research'
const { description, updates, researchCategory, slug, title } = article

beforeEach(() => {
cy.visit('/research')
})
const authoredResearchArticleUrl = '/research/a-test-research'
const image = updates[0].images[0].downloadUrl
const pageTitle = `${title} - Research - Community Platform`
const researchArticleUrl = `/research/${slug}`

describe('[Read a research article]', () => {
describe('[By Everyone]', () => {
beforeEach(() => {
it('[Visible to everyone]', () => {
cy.step('Can visit research')
cy.visit(researchArticleUrl)
})
cy.title().should(
'eq',
`${article.title} - Research - Community Platform`,
)
cy.step('[Populates title, SEO and social tags]')
cy.title().should('eq', pageTitle)
cy.get('meta[name="description"]').should(
'have.attr',
'content',
description,
)

// OpenGraph (facebook)
cy.get('meta[property="og:title"]').should(
'have.attr',
'content',
pageTitle,
)
cy.get('meta[property="og:description"]').should(
'have.attr',
'content',
description,
)
cy.get('meta[property="og:image"]').should(
'have.attr',
'content',
image,
)

// Twitter
cy.get('meta[name="twitter:title"]').should(
'have.attr',
'content',
pageTitle,
)
cy.get('meta[name="twitter:description"]').should(
'have.attr',
'content',
description,
)
cy.get('meta[name="twitter:image"]').should(
'have.attr',
'content',
image,
)

it('[Visible to everyone]', () => {
const article = research[0]
cy.step('Delete button should not be visible')
cy.get('[data-cy="Research: delete button"]').should('not.exist')

Expand All @@ -33,12 +76,12 @@ describe('[Research]', () => {

cy.get('[data-cy=breadcrumbsItem]')
.eq(1)
.should('contain', article.researchCategory.label)
.should('contain', researchCategory.label)
cy.get('[data-cy=breadcrumbsItem]')
.eq(1)
.children()
.should('have.attr', 'href')
.and('equal', `/research?category=${article.researchCategory._id}`)
.and('equal', `/research?category=${researchCategory._id}`)

cy.get('[data-cy=breadcrumbsItem]')
.eq(2)
Expand All @@ -59,35 +102,25 @@ describe('[Research]', () => {
})
})

describe('[By Beta-tester]', () => {
beforeEach(() => {
cy.login('[email protected]', 'demo_beta_tester')
cy.visit(researchArticleUrl)
})
})

describe('[By Admin]', () => {
beforeEach(() => {
beforeEach(() => {})

it('[Delete button is visible]', () => {
cy.login('[email protected]', 'demo_admin')
cy.visit(researchArticleUrl)
})

it('[Delete button is visible]', () => {
cy.step('Delete button should be visible to the author of the article')

cy.get('[data-cy="Research: delete button"]').should('be.visible')
cy.get('[data-cy="Research: delete button"]').should('exist')
})
})
})

describe('[Read a soft-deleted Research Article]', () => {
const deletedResearchUrl = '/research/a-deleted-test-research'
beforeEach(() => {
cy.visit(deletedResearchUrl)
})

describe('[By Everyone]', () => {
it('[Marked for deletion message]', () => {
cy.visit(deletedResearchUrl)
cy.step(
'There should be a message stating the research is marked for deletion',
)
Expand Down
4 changes: 4 additions & 0 deletions shared/mocks/data/research.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ export const research = {
h1wCs0o9j60lkw3AYPB1: true,
},
title: 'A test research',
updates: [],
researchCategory: {},
},
'0up6oJCYY3M9bDYx34Et': {
_created: '2023-02-27T22:08:25.999Z',
Expand All @@ -337,5 +339,7 @@ export const research = {
h1wCs0o9j60lkw3AYPB1: true,
},
title: 'A deleted test research',
updates: [],
researchCategory: {},
},
}
2 changes: 1 addition & 1 deletion src/pages/Research/Content/ResearchArticle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const ResearchArticle = observer(() => {
.filter((url: string) => !!url)
.pop()
seoTagsUpdate({
title: researchItem.title,
title: `${researchItem.title} - Research`,
description: researchItem.description,
imageUrl: latestImage,
})
Expand Down

0 comments on commit c36dd01

Please sign in to comment.