Skip to content

Commit

Permalink
Add favorite test and fix aria-label (#3817)
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondjacobson committed Jul 29, 2023
1 parent d64d8a2 commit f145d99
Show file tree
Hide file tree
Showing 10 changed files with 349 additions and 328 deletions.
2 changes: 1 addition & 1 deletion apps/audius-client/.circleci/src/@continue_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2.1
orbs:
aws-cli: circleci/aws-cli@3.1.5
ruby: circleci/ruby@1.2.0
cypress: cypress-io/cypress@3.0.0
cypress: cypress-io/cypress@3.1.3

# the default pipeline parameters, which will be updated according to
# the results of the path-filtering orb in config.yml
Expand Down
6 changes: 4 additions & 2 deletions apps/audius-client/packages/probers/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ export default defineConfig({
defaultCommandTimeout: 10000,
retries: {
runMode: 2,
openMode: 0,
openMode: 0
},
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.ts').default(on, config)
},
baseUrl: 'http://localhost:3001',
baseUrl: 'http://localhost:3001'
},
viewportHeight: 800,
viewportWidth: 1300
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import track from '../fixtures/track.json'
import user from '../fixtures/user.json'

import { waitForTransaction } from './uilts'

describe('Favorite Track', () => {
beforeEach(() => {
localStorage.setItem('HAS_REQUESTED_BROWSER_PUSH_PERMISSION', 'true')
})

it('should favorite and unfavorite track correctly', () => {
const base64Entropy = Buffer.from(user.entropy).toString('base64')
cy.visit(`${track.route}?login=${base64Entropy}`)

cy.findByText(user.name, { timeout: 20000 }).should('exist')
cy.findByRole('heading', { name: track.name, timeout: 20000 }).should(
'exist'
)

cy.findByRole('group', { name: /track actions/i }).within(() => {
cy.findByRole('button', { name: /favorite$/i }).click()
cy.findByRole('button', { name: /favorited/i }).should('exist')
})
waitForTransaction(1)
cy.reload()

cy.findByRole('group', { name: /track actions/i }).within(() => {
cy.findByRole('button', { name: /favorited/i }).click()
cy.findByRole('button', { name: /favorite$/i }).should('exist')
})

waitForTransaction(2)
cy.reload()

cy.findByRole('group', { name: /track actions/i }).within(() => {
cy.findByRole('button', { name: /favorite$/i }).should('exist')
})
})
})
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
import track from '../fixtures/track.json'
import user from '../fixtures/user.json'

function waitForTransaction(transactionNumber: number) {
cy.intercept({ method: 'POST', url: '**/relay' }).as(
`relayCheck-${transactionNumber}`
)
cy.wait(`@relayCheck-${transactionNumber}`).then((xhr) => {
const { blockHash, blockNumber } = xhr.response.body.receipt
cy.intercept({
url: '**/block_confirmation*',
query: { blockhash: blockHash, blocknumber: String(blockNumber) }
}).as(`blockConfirmation-${blockNumber}`)

waitForBlockConfirmation(`@blockConfirmation-${blockNumber}`)
})
}

function waitForBlockConfirmation(routeAlias, retries = 3) {
cy.wait(routeAlias).then((xhr) => {
const { block_found, block_passed } = xhr.response.body.data
if (block_found && block_passed) {
} else if (retries > 0) waitForBlockConfirmation(routeAlias, retries - 1)
// wait for the next response
else throw new Error('All requests returned non-200 response')
})
}
import { waitForTransaction } from './uilts'

describe('Repost Track', () => {
beforeEach(() => {
Expand Down
24 changes: 24 additions & 0 deletions apps/audius-client/packages/probers/cypress/e2e/uilts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const waitForTransaction = (transactionNumber: number) => {
cy.intercept({ method: 'POST', url: '**/relay' }).as(
`relayCheck-${transactionNumber}`
)
cy.wait(`@relayCheck-${transactionNumber}`).then((xhr) => {
const { blockHash, blockNumber } = xhr.response.body.receipt
cy.intercept({
url: '**/block_confirmation*',
query: { blockhash: blockHash, blocknumber: String(blockNumber) }
}).as(`blockConfirmation-${blockNumber}`)

waitForBlockConfirmation(`@blockConfirmation-${blockNumber}`)
})
}

const waitForBlockConfirmation = (routeAlias, retries = 3) => {
cy.wait(routeAlias).then((xhr) => {
const { block_found, block_passed } = xhr.response.body.data
if (block_found && block_passed) {
} else if (retries > 0) waitForBlockConfirmation(routeAlias, retries - 1)
// wait for the next response
else throw new Error('All requests returned non-200 response')
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ describe('Upload Track', () => {

cy.findByRole('button', { name: /continue/i }).click()

// Gated content prompt
cy.findByRole('button', { name: /got it/i }).click()

cy.findByRole('combobox', { name: /pick a genre/i }).click()
cy.findByRole('option', { name: /rock/i }).click()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"route": "chrisyu321/happy-buddy-987/remixes"
"route": "mb430/traektoria-source-2217/remixes"
}
Loading

0 comments on commit f145d99

Please sign in to comment.