Adding tests.
This commit is contained in:
31
cypress/e2e/episodePage.cy.js
Normal file
31
cypress/e2e/episodePage.cy.js
Normal file
@@ -0,0 +1,31 @@
|
||||
describe('Podcast episode page', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/podcast/mechanics-of-react-a-beginners-intro-to-react')
|
||||
})
|
||||
|
||||
it('loads correctly', () => {
|
||||
// Check that the page title is correct
|
||||
cy.title().should('equal', `Mechanics of React: A Beginner's Intro To React | The React Show`)
|
||||
|
||||
// Check that the date is displayed
|
||||
cy.get('[data-cy=date]').should('contain', 'March 31, 2023')
|
||||
|
||||
// Check that the YouTube video is embedded and playable
|
||||
cy.get('iframe[src^="https://www.youtube.com/embed/"]').should('be.visible')
|
||||
|
||||
// Check that the title is correct
|
||||
cy.get('[data-cy=title]').should('contain', `[87] Mechanics of React: A Beginner's Intro To React`)
|
||||
|
||||
// Check that the description is correct
|
||||
cy.get('[data-cy=description]').should('contain', 'Learn the fundamentals of React')
|
||||
|
||||
// Check that the transcript is correct
|
||||
cy.get('[data-cy=transcript]').should('contain', '00:00:05 Brought to you from occupied Miwok territory by me')
|
||||
})
|
||||
|
||||
it('should play the audio player when the "Listen" button is clicked', () => {
|
||||
cy.get('[data-cy=audio-player-button]').first().should('have.attr', 'aria-label', 'Play')
|
||||
cy.get('[data-cy=audio-player-button]').first().click()
|
||||
cy.get('[data-cy=audio-player-button]').first().should('have.attr', 'aria-label', 'Pause')
|
||||
})
|
||||
})
|
||||
26
cypress/e2e/episodes.cy.js
Normal file
26
cypress/e2e/episodes.cy.js
Normal file
@@ -0,0 +1,26 @@
|
||||
describe('Episodes component', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/')
|
||||
})
|
||||
|
||||
it.only('should render the component with episodes data', () => {
|
||||
cy.get('[data-cy=episode-entry]').should('have.length', 15)
|
||||
|
||||
cy.get('[data-cy=episode-title]').first().should('contain', `[87] Mechanics of React: A Beginner's Intro To React`)
|
||||
cy.get('[data-cy=episode-description]').first().should('contain', 'Learn the fundamentals of React by')
|
||||
cy.get('[data-cy=episode-date]').first().should('contain', 'March 31, 2023')
|
||||
|
||||
cy.get('[data-cy=episode-title]').last().should('contain', '[73] A Fundamentally New React: My Journey with React Server Components')
|
||||
cy.get('[data-cy=episode-description]').last().should('contain', 'React Sever Components are')
|
||||
})
|
||||
|
||||
it('should navigate to the show notes page when the "Show notes" link is clicked', () => {
|
||||
cy.get('[data-cy=show-notes-link]').first().click()
|
||||
cy.url().should('include', '/podcast/mechanics-of-react-a-beginners-intro-to-react')
|
||||
})
|
||||
|
||||
it('should navigate to the transcript section when the "Transcript" link is clicked', () => {
|
||||
cy.get('[data-cy=transcript-link]').last().click()
|
||||
cy.url().should('include', '/podcast/a-fundamentally-new-react-my-journey-with-react-server-components#transcript')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user