Skip to content

Commit

Permalink
feat: change how-to urls to library
Browse files Browse the repository at this point in the history
  • Loading branch information
benfurber committed Dec 6, 2024
1 parent 0cd2ca3 commit f6b8a74
Show file tree
Hide file tree
Showing 38 changed files with 234 additions and 155 deletions.
2 changes: 1 addition & 1 deletion functions/src/Integrations/firebase-discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IResearchDB, ResearchUpdateStatus } from 'oa-shared/models/research'
import { CONFIG } from '../config/config'

import type { AxiosError, AxiosResponse } from 'axios'
import type { IMapPin,IResearch } from 'oa-shared/models'
import type { IMapPin, IResearch } from 'oa-shared/models'

const SITE_URL = CONFIG.deployment.site_url
// e.g. https://dev.onearmy.world or https://community.preciousplastic.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('Create howto moderation emails', () => {
expect(html).toContain('Mock Howto')
// Check that the email contains the correct howto link
expect(html).toContain(
'https://community.preciousplastic.com/how-to/00_user_1_howto',
'https://community.preciousplastic.com/library/00_user_1_howto',
)
// Check that the email contains the correct PP signoff
expect(html).toContain(PP_SIGNOFF)
Expand Down Expand Up @@ -134,7 +134,7 @@ describe('Create howto moderation emails', () => {
expect(html).toContain('Mock Howto')
// Check that the email contains the correct howto link
expect(html).toContain(
'https://community.preciousplastic.com/how-to/00_user_1_howto',
'https://community.preciousplastic.com/library/00_user_1_howto',
)
// Check that the email contains the correct PP signoff
expect(html).toContain(PP_SIGNOFF)
Expand Down Expand Up @@ -180,7 +180,7 @@ describe('Create howto moderation emails', () => {
)
// Check that the email contains the correct howto link
expect(html).toContain(
'https://community.preciousplastic.com/how-to/00_user_1_howto',
'https://community.preciousplastic.com/library/00_user_1_howto',
)
// Check that the email contains the correct PP signoff
expect(html).toContain(PP_SIGNOFF)
Expand Down Expand Up @@ -225,7 +225,7 @@ describe('Create howto moderation emails', () => {
expect(html).toContain('Mock Howto')
// Check that the email contains the correct howto link
expect(html).toContain(
'https://community.preciousplastic.com/how-to/00_user_1_howto',
'https://community.preciousplastic.com/library/00_user_1_howto',
)
// Check that the email contains the correct howto guidelines link
expect(html).toContain(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<p>
It is visible on the community platform
<a href="{{site.url}}/how-to/{{howto.slug}}">here</a>.
<a href="{{site.url}}/library/{{howto.slug}}">here</a>.
</p>
<p>Users are now be able to comment and mark it as useful.</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p>Hey {{user.displayName}},</p>

<p>
Your project, <a href="{{site.url}}/how-to/{{howto.slug}}">{{howto.title}}</a>,
Your project, <a href="{{site.url}}/library/{{howto.slug}}">{{howto.title}}</a>,
needs more work before we can publish it.
</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<p>
Thank you for submitting your project,
<a href="{{site.url}}/how-to/{{howto.slug}}">{{howto.title}}</a>. We
<a href="{{site.url}}/library/{{howto.slug}}">{{howto.title}}</a>. We
appreciate your contribution and the time and effort you put into creating it.
</p>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<p>
Huzzah! Your project
<a href="{{site.url}}/how-to/{{howto.slug}}">{{howto.title}}</a> has been
<a href="{{site.url}}/library/{{howto.slug}}">{{howto.title}}</a> has been
submitted.
</p>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('UserStatistics', () => {
)
const howtoLink = getByTestId('howto-link')

expect(howtoLink.getAttribute('href')).toBe('/how-to?q=Test User')
expect(howtoLink.getAttribute('href')).toBe('/library?q=Test User')
})

it('renders research link when on research stats', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/UserStatistics/UserStatistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const UserStatistics = (props: UserStatisticsProps) => {

{props.howtoCount > 0 && (
<InternalLink
to={'/how-to?q=' + props.userName}
to={'/library?q=' + props.userName}
sx={{ color: 'black' }}
data-testid="howto-link"
>
Expand Down
18 changes: 9 additions & 9 deletions packages/cypress/src/integration/common.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ describe('[Common]', () => {
})

it('[Page Navigation]', () => {
cy.visit('/how-to')
cy.visit('/library')
cy.wait(2000)

cy.step('Go to Academy page')
cy.get('[data-cy=page-link]').contains('Academy').click()
cy.wait(2000)
cy.url().should('include', '/academy')

cy.get('[data-cy=page-link]').contains('How-to').click()
cy.step('Go to library page')
cy.get('[data-cy=page-link]').contains('Library').click()
cy.wait(2000)
cy.url().should('include', '/how-to')
cy.url().should('include', '/library')

cy.step('Go to Map page')
cy.get('[data-cy=page-link]').contains('Map').click()
Expand All @@ -38,12 +38,12 @@ describe('[Common]', () => {

describe('[User feeback button]', () => {
it('[Desktop]', () => {
cy.visit('/how-to')
cy.visit('/library')
cy.wait(2000)
cy.get('[data-cy=feedback]').should('contain', 'Report a Problem')
cy.get('[data-cy=feedback]')
.should('have.attr', 'href')
.and('contain', '/how-to?sort=Newest')
.and('contain', '/library?sort=Newest')

cy.visit('/map')
cy.wait(2000)
Expand All @@ -55,12 +55,12 @@ describe('[Common]', () => {
it('[Mobile]', () => {
cy.viewport('iphone-6')

cy.visit('/how-to')
cy.visit('/library')
cy.wait(2000)
cy.get('[data-cy=feedback]').should('contain', 'Problem?')
cy.get('[data-cy=feedback]')
.should('have.attr', 'href')
.and('contain', '/how-to?sort=Newest')
.and('contain', '/library?sort=Newest')

cy.visit('/map')
cy.wait(2000)
Expand All @@ -73,15 +73,15 @@ describe('[Common]', () => {
describe('[User Menu]', () => {
it('[By Anonymous]', () => {
cy.step('Login and Join buttons are available')
cy.visit('/how-to')
cy.visit('/library')
cy.wait(2000)
cy.get('[data-cy=login]').should('be.visible')
cy.get('[data-cy=join]').should('be.visible')
cy.get('[data-cy=user-menu]').should('not.exist')
})

it('[By Authenticated]', () => {
cy.visit('/how-to')
cy.visit('/library')

cy.step('Login and Join buttons are unavailable to logged-in users')
const user = generateNewUserDetails()
Expand Down
4 changes: 2 additions & 2 deletions packages/cypress/src/integration/howto/discussions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const howtoDiscussion = Object.values(MOCK_DATA.discussions).find(
describe('[Howto.Discussions]', () => {
it('can open using deep links', () => {
const firstComment = howtoDiscussion.comments[0]
cy.visit(`/how-to/${item.slug}#comment:${firstComment._id}`)
cy.visit(`/library/${item.slug}#comment:${firstComment._id}`)
cy.wait(2000)
cy.checkCommentItem(firstComment.text, 2)
})
Expand All @@ -32,7 +32,7 @@ describe('[Howto.Discussions]', () => {
const newReply = `Thanks Dave and Ben. What does everyone else think? - ${visitor.username}`
const updatedNewReply = `Anyone else? All the best, ${visitor.username}`

const howtoPath = `/how-to/howto-for-discussion-${visitor.username}`
const howtoPath = `/library/howto-for-discussion-${visitor.username}`

cy.step('Can add comment')
cy.visit(howtoPath)
Expand Down
19 changes: 11 additions & 8 deletions packages/cypress/src/integration/howto/read.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('[Library]', () => {

describe('[List projects]', () => {
// const howtoSlug = 'make-glass-like-beams'
// const howtoUrl = `/how-to/${howtoSlug}`
// const howtoUrl = `/library/${howtoSlug}`
// const coverFileRegex = /howto-beams-glass-0-3.jpg/
// it('[By Everyone]', () => {
// cy.step('More projects button is hidden')
Expand Down Expand Up @@ -44,12 +44,12 @@ describe('[Library]', () => {
// })
})

const specificHowtoUrl = '/how-to/make-an-interlocking-brick'
describe('[Read a project]', () => {
const specificHowtoUrl = '/library/make-an-interlocking-brick'
const coverFileRegex = /brick-12-1.jpg/

beforeEach(() => {
cy.visit('/how-to')
cy.visit('/library')
})

describe('[By Everyone]', () => {
Expand All @@ -58,7 +58,10 @@ describe('[Library]', () => {
// Hack to avoid flaky test as the tags are not being loaded on time
cy.queryDocuments('howtos', '_id', '==', howto._id)

cy.visit(specificHowtoUrl)
cy.step('Old url pattern redirects to the new location')
cy.visit('/how-to/make-an-interlocking-brick')
cy.url().should('include', specificHowtoUrl)

cy.step('Edit button is not available')
cy.get('[data-cy=edit]').should('not.exist')

Expand Down Expand Up @@ -94,7 +97,7 @@ describe('[Library]', () => {
.first()
.children()
.should('have.attr', 'href')
.and('equal', `/how-to`)
.and('equal', `/library`)

cy.get('[data-cy=breadcrumbsItem]')
.eq(1)
Expand All @@ -103,7 +106,7 @@ describe('[Library]', () => {
.eq(1)
.children()
.should('have.attr', 'href')
.and('equal', `/how-to?category=${howto.category._id}`)
.and('equal', `/library?category=${howto.category._id}`)

cy.get('[data-cy=breadcrumbsItem]').eq(2).should('contain', howto.title)

Expand Down Expand Up @@ -214,7 +217,7 @@ describe('[Library]', () => {
})

describe('[Read a soft-deleted How-to]', () => {
const deletedHowtoUrl = '/how-to/deleted-how-to'
const deletedHowtoUrl = '/library/deleted-how-to'
beforeEach(() => {
cy.visit(deletedHowtoUrl)
})
Expand Down Expand Up @@ -256,8 +259,8 @@ describe('[Library]', () => {
})
})

const howToNotFoundUrl = `/how-to/this-how-to-does-not-exist`
describe('[Fail to find a project]', () => {
const howToNotFoundUrl = `/library/this-project-does-not-exist`

it('[Redirects to search]', () => {
cy.visit(howToNotFoundUrl)
Expand Down
2 changes: 1 addition & 1 deletion packages/cypress/src/integration/howto/search.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// describe('[Library]', () => {
// beforeEach(() => {
// cy.visit('/how-to')
// cy.visit('/library')
// })

// describe('[By Everyone]', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cypress/src/integration/howto/seo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('[Library]', () => {
const pageTitle = `${title} - Library - Precious Plastic`

it('[Populates title and description tags]', () => {
cy.visit(`/how-to/${slug}`)
cy.visit(`/library/${slug}`)
// General
cy.title().should('eq', pageTitle)
cy.get('meta[name="description"]').should(
Expand Down
24 changes: 12 additions & 12 deletions packages/cypress/src/integration/howto/write.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { generateNewUserDetails } from '../../utils/TestUtils'

describe('[Library]', () => {
beforeEach(() => {
cy.visit('/how-to')
cy.visit('/library')
})
type Category = 'brainstorm' | 'exhibition' | 'product'
type Duration = '<1 week' | '1-2 weeks' | '3-4 weeks'
Expand Down Expand Up @@ -188,10 +188,10 @@ describe('[Library]', () => {
cy.signUpNewUser(creator)
cy.get('[data-cy=loader]').should('not.exist')
cy.get('[data-cy="MemberBadge-member"]').should('be.visible')
cy.visit('/how-to')
cy.visit('/library')

cy.get('a[href="/how-to/create"]').should('be.visible')
cy.step('Access the create project page')
cy.get('a[href="/library/create"]').should('be.visible')
cy.get('[data-cy=create]').click()
cy.contains('Create a Project').should('be.visible')

Expand Down Expand Up @@ -224,7 +224,7 @@ describe('[Library]', () => {
cy.step('A basic draft was created')
cy.fillIntroTitle(`qwerty ${randomId}`)
cy.get('[data-cy=draft]').click()
const firstSlug = `/how-to/qwerty-${randomId}`
const firstSlug = `/library/qwerty-${randomId}`
cy.get('[data-cy=view-howto]:enabled', { timeout: 20000 })
.click()
.url()
Expand Down Expand Up @@ -295,7 +295,7 @@ describe('[Library]', () => {
cy.get('[data-cy=view-howto]:enabled', { timeout: 20000 })
.click()
.url()
.should('include', `/how-to/${slug}`)
.should('include', `/library/${slug}`)

cy.step('Howto was created correctly')
cy.get('[data-cy=file-download-counter]')
Expand Down Expand Up @@ -323,26 +323,26 @@ describe('[Library]', () => {
})

it('[By Anonymous]', () => {
cy.step('Ask users to login before creating an how-to')
cy.visit('/how-to/create')
cy.step('Ask users to login before creating a project')
cy.visit('/library/create')
cy.get('div').contains('Please login to access this page')
})

it('[Warning on leaving page]', () => {
cy.login(creator.email, creator.password)
cy.get('[data-cy=loader]').should('not.exist')
cy.get('a[href="/how-to/create"]').should('be.visible')
cy.step('Access the create project')
cy.get('a[href="/library/create"]').should('be.visible')
cy.get('[data-cy=create]').click()
cy.fillIntroTitle(expected.title)
cy.get('[data-cy=page-link][href*="/how-to"]').click()
cy.get('[data-cy=page-link][href*="/library"]').click()
cy.get('[data-cy="Confirm.modal: Cancel"]').click()
cy.url().should('match', /\/how-to\/create$/)
cy.url().should('match', /\/library\/create$/)

cy.step('Clear title input')
cy.get('[data-cy=intro-title]').clear().blur({ force: true })
cy.get('[data-cy=page-link][href*="/how-to"]').click()
cy.url().should('match', /\/how-to?/)
cy.get('[data-cy=page-link][href*="/library"]').click()
cy.url().should('match', /\/library?/)
})
})
})
Loading

0 comments on commit f6b8a74

Please sign in to comment.