Skip to content

Commit

Permalink
Update cy.request
Browse files Browse the repository at this point in the history
  • Loading branch information
ddjnw1yu committed Feb 2, 2025
1 parent 18a0d48 commit 187109e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/cypress/e2e/datasets/datasetInfo.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ datasetIds.forEach((datasetId) => {
})
cy.get('@doiLink').invoke('attr', 'href').then((href) => {
cy.request({ url: href, failOnStatusCode: false }).then((resp) => {
expect(resp.redirects, 'Redirect should exist').to.have.length(1)
expect(resp.redirects, 'Redirect should exist').to.have.length.greaterThan(0)
})
})
// Check 'View other version' directs to Versions tab
Expand Down
10 changes: 5 additions & 5 deletions tests/cypress/e2e/datasets/detailtabs.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ datasetIds.forEach((datasetId) => {
})
cy.get('@links').each(($link) => {
cy.wrap($link).invoke('attr', 'href').then((href) => {
cy.request(href).then((resp) => {
cy.request({ url: href, failOnStatusCode: false }).then((resp) => {
const title = $title.text().trim().replaceAll(' ', '.*')
const contributor = $contributor.text().replace(/Contributors:/i, '').split(',').map(name => name.trim().replace(' ', '.*'))
const contributorReversed = contributor.map(name => name.split(' ').reverse().join('.*'))
const regex = new RegExp('\(' + title + '|' + contributor.join('|') + '|' + contributorReversed.join('|') + '\)', 'gi')
expect(resp.status).to.eq(200)
expect(resp.redirects, 'Redirect should exist').to.have.length.greaterThan(0)
expect(resp.body, 'Protocol link should make sense').to.match(regex)
})
})
Expand Down Expand Up @@ -512,8 +512,8 @@ datasetIds.forEach((datasetId) => {
expect($link, 'Citation link should have doi href').to.have.attr('href').to.contain('doi.org')
expect($link, 'Citation link should open a new tab').to.have.attr('target').to.contain('blank')
cy.wrap($link).invoke('attr', 'href').then((href) => {
cy.request(href).then((resp) => {
expect(resp.status).to.eq(200)
cy.request({ url: href, failOnStatusCode: false }).then((resp) => {
expect(resp.redirects, 'Redirect should exist').to.have.length.greaterThan(0)
})
})
})
Expand Down Expand Up @@ -561,7 +561,7 @@ datasetIds.forEach((datasetId) => {
cy.get('.version-table > .table-rows > :nth-child(5) > a').each(($doi) => {
cy.wrap($doi).invoke('attr', 'href').then((href) => {
cy.request({ url: href, failOnStatusCode: false }).then((resp) => {
expect(resp.redirects, 'Redirect should exist').to.have.length(1)
expect(resp.redirects, 'Redirect should exist').to.have.length.greaterThan(0)
})
})
})
Expand Down

0 comments on commit 187109e

Please sign in to comment.