From 2cb2b2aad64537648d3340cb2d38f8c41576af70 Mon Sep 17 00:00:00 2001 From: Phan An Date: Fri, 13 May 2022 14:40:04 +0200 Subject: [PATCH] fix: integration tests --- cypress/integration/albums.spec.ts | 8 ++++---- cypress/integration/artists.spec.ts | 8 ++++---- cypress/integration/shortcut-keys.spec.ts | 2 +- cypress/integration/uploading.spec.ts | 2 +- cypress/integration/users.spec.ts | 4 ++-- cypress/integration/youtube.spec.ts | 4 ++-- cypress/support/commands.ts | 4 ++-- .../components/layout/app-footer/FooterPlayerControls.vue | 3 +++ 8 files changed, 19 insertions(+), 16 deletions(-) diff --git a/cypress/integration/albums.spec.ts b/cypress/integration/albums.spec.ts index 27da1ef1..66bd5597 100644 --- a/cypress/integration/albums.spec.ts +++ b/cypress/integration/albums.spec.ts @@ -9,13 +9,13 @@ context('Albums', { scrollBehavior: false }, () => { cy.get('.screen-header').should('be.visible').and('contain.text', 'Albums') cy.findByTestId('view-mode-thumbnail').should('be.visible').and('have.class', 'active') cy.findByTestId('view-mode-list').should('be.visible').and('not.have.class', 'active') - cy.findByTestId('album-card').should('have.length', 7) + cy.findAllByTestId('album-card').should('have.length', 7) }) }) it('changes display mode', () => { cy.get('#albumsWrapper').should('be.visible').within(() => { - cy.findByTestId('album-card').should('have.length', 7) + cy.findAllByTestId('album-card').should('have.length', 7) cy.findByTestId('view-mode-list').click() cy.get('[data-testid=album-card].compact').should('have.length', 7) cy.findByTestId('view-mode-thumbnail').click() @@ -58,10 +58,10 @@ context('Albums', { scrollBehavior: false }, () => { cy.get('.cover').should('be.visible') cy.findByTestId('album-info-tracks').should('be.visible').within(() => { - // out of 4 tracks, 3 are already available in Koel. The last one has a link to iTunes. + // out of 4 tracks, 3 are already available in Koel. The last one has a link to Apple Music. cy.get('li').should('have.length', 4) cy.get('li.available').should('have.length', 3) - cy.get('li:last-child a.view-on-itunes').should('be.visible') + cy.get('li:last-child a[title="Preview and buy this song on Apple Music"]').should('be.visible') }) }) diff --git a/cypress/integration/artists.spec.ts b/cypress/integration/artists.spec.ts index 252be1c3..27d3312c 100644 --- a/cypress/integration/artists.spec.ts +++ b/cypress/integration/artists.spec.ts @@ -9,17 +9,17 @@ context('Artists', { scrollBehavior: false }, () => { cy.get('.screen-header').should('be.visible').and('contain.text', 'Artists') cy.findByTestId('view-mode-thumbnail').should('be.visible').and('have.class', 'active') cy.findByTestId('view-mode-list').should('be.visible').and('not.have.class', 'active') - cy.findByTestId('artist-card').should('have.length', 1) + cy.findAllByTestId('artist-card').should('have.length', 1) }) }) it('changes display mode', () => { cy.get('#artistsWrapper').should('be.visible').within(() => { - cy.findByTestId('artist-card').should('have.length', 1) + cy.findAllByTestId('artist-card').should('have.length', 1) cy.findByTestId('view-mode-list').click() - cy.findByTestId('artist-card].compact').should('have.length', 1) + cy.get('[data-testid=artist-card].compact').should('have.length', 1) cy.findByTestId('view-mode-thumbnail').click() - cy.$findInTestId('artist-card .full').should('have.length', 1) + cy.get('[data-testid=artist-card].full').should('have.length', 1) }) }) diff --git a/cypress/integration/shortcut-keys.spec.ts b/cypress/integration/shortcut-keys.spec.ts index 148e69e9..2ad2c6ab 100644 --- a/cypress/integration/shortcut-keys.spec.ts +++ b/cypress/integration/shortcut-keys.spec.ts @@ -11,7 +11,7 @@ context('Shortcut Keys', () => { it('shuffles all songs by default when Space is pressed', () => { cy.fixture('data.get.200.json').then(data => { - cy.get('body').type(' ', { force: true }) + cy.get('body').type(' ') cy.$assertSidebarItemActive('Current Queue') cy.$assertPlaying() cy.get('#queueWrapper .screen-header').should('contain.text', `${data.songs.length} songs`) diff --git a/cypress/integration/uploading.spec.ts b/cypress/integration/uploading.spec.ts index 0bf653cb..ef1785f5 100644 --- a/cypress/integration/uploading.spec.ts +++ b/cypress/integration/uploading.spec.ts @@ -34,7 +34,7 @@ context('Uploading', () => { cy.findByTestId('upload-item').should('have.length', 1).and('be.visible') cy.wait('@failedUpload') - cy.findByTestId('upload-item').should('have.length', 1).should('have.class', 'Errored') + cy.findByTestId('upload-item').should('have.length', 1).should('have.class', 'errored') } it('uploads songs', () => { diff --git a/cypress/integration/users.spec.ts b/cypress/integration/users.spec.ts index 75770915..bd6ce3f5 100644 --- a/cypress/integration/users.spec.ts +++ b/cypress/integration/users.spec.ts @@ -6,7 +6,7 @@ context('User Management', () => { it('shows the list of users', () => { cy.get('#usersWrapper').within(() => { - cy.findByTestId('user-card').should('have.length', 3).and('be.visible') + cy.findAllByTestId('user-card').should('have.length', 3).and('be.visible') cy.get('[data-testid=user-card].me').within(() => { cy.findByTitle('This is you!').should('be.visible') @@ -31,7 +31,7 @@ context('User Management', () => { }) cy.findByText('New user "Charles" created.').should('be.visible') - cy.findByTestId('user-card').should('have.length', 4) + cy.findAllByTestId('user-card').should('have.length', 4) cy.get('#usersWrapper [data-testid=user-card]:first-child').within(() => { cy.findByText('Charles').should('be.visible') diff --git a/cypress/integration/youtube.spec.ts b/cypress/integration/youtube.spec.ts index 20572092..c23e905a 100644 --- a/cypress/integration/youtube.spec.ts +++ b/cypress/integration/youtube.spec.ts @@ -21,9 +21,9 @@ context('YouTube', () => { cy.get('#extra').within(() => { cy.get('#extraTabYouTube').click() - cy.findByTestId('youtube-search-result').should('have.length', 2) + cy.findAllByTestId('youtube-search-result').should('have.length', 2) cy.findByTestId('youtube-search-more-btn').click() - cy.findByTestId('youtube-search-result').should('have.length', 4) + cy.findAllByTestId('youtube-search-result').should('have.length', 4) }) }) diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index fd41bfa9..73280fba 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -98,13 +98,13 @@ Cypress.Commands.add( Cypress.Commands.add('$assertPlaying', () => { cy.findByTestId('pause-btn').should('exist') cy.findByTestId('play-btn').should('not.exist') - cy.findByTestId('sound-bar-play').should('be.visible') + cy.$findInTestId('other-controls [data-testid=soundbars]').should('be.visible') }) Cypress.Commands.add('$assertNotPlaying', () => { cy.findByTestId('pause-btn').should('not.exist') cy.findByTestId('play-btn').should('exist') - cy.findByTestId('sound-bar-play').should('not.exist') + cy.$findInTestId('other-controls [data-testid=soundbars]').should('not.exist') }) Cypress.Commands.add('$assertSidebarItemActive', (text: string) => { diff --git a/resources/assets/js/components/layout/app-footer/FooterPlayerControls.vue b/resources/assets/js/components/layout/app-footer/FooterPlayerControls.vue index ae321d8b..298985ae 100644 --- a/resources/assets/js/components/layout/app-footer/FooterPlayerControls.vue +++ b/resources/assets/js/components/layout/app-footer/FooterPlayerControls.vue @@ -2,6 +2,7 @@