Skip to content

Commit

Permalink
test: rewrite flaky 1244 test to no longer be flaky (#28694)
Browse files Browse the repository at this point in the history
* chore: rewrite flaky 1244 test to no longer be flaky

* Update 1244.cy.js
  • Loading branch information
cacieprins authored Jan 11, 2024
1 parent 4b1df35 commit 33f132d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
31 changes: 25 additions & 6 deletions packages/driver/cypress/e2e/issues/1244.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ describe('issue 1244', () => {
cy.on('window:before:unload', (e) => {
const win = cy.state('window')

expect(win.getCounters()).to.deep.equal({ getCounter: 0, setCounter: 0 })
// not all pages that get unloaded during this spec have getCounters()
if (win.location.href.includes('issue-1244.html')) {
expect(win.getCounters()).to.deep.equal({ getCounter: 0, setCounter: 0 })
}
})
})
})
Expand Down Expand Up @@ -33,8 +36,7 @@ describe('issue 1244', () => {

it('correctly redirects when target=_parent inline in dom', () => {
cy.get(`${el}.inline_parent`).click()
cy.get('#dom').should('contain', 'DOM')
cy.url().should('include', 'dom.html')
cy.url().should('include', 'empty.html')
})

it('maintains behavior when target=_self', () => {
Expand Down Expand Up @@ -65,11 +67,17 @@ describe('issue 1244', () => {
$el.trigger('click')
})

cy.get('#dom').should('contain', 'DOM')
cy.url().should('include', 'dom.html')
cy.url().should('include', 'empty.html')
})

// TODO: fix flaky test
// NOTE: a previous test opens dom.html in a new window. This request does not
// receive a cross-domain injection from the proxy, and the browser caches
// it. Top cannot communicate with this iframe, and relies on the cross-
// domain injection to determine href, etc. cy.ts hangs on waiting for
// the cross-domain injection to postMessage back to top, causing
// this test to hang. See: https://github.com/cypress-io/cypress/issues/28681

/*
it('does not strip link _parent', { retries: 15 }, () => {
cy.get('iframe').then(($iframe) => {
const $el = $iframe.contents().find('a.inline_parent')
Expand All @@ -80,5 +88,16 @@ describe('issue 1244', () => {
cy.get('#dom').should('contain', 'DOM')
cy.url().should('include', 'dom.html')
})
*/

it('does not strip link_parent', () => {
cy.get('iframe').then(($iframe) => {
const $el = $iframe.contents().find('a.inline_parent')

$el[0].click()
})

cy.url().should('include', 'empty.html')
})
})
})
4 changes: 2 additions & 2 deletions packages/driver/cypress/fixtures/issue-1244.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<form target="_top" method="GET" action="/fixtures/dom.html">
<button class="inline_top" type="submit">Submit inline top</button>
</form>
<form target="_parent" method="GET" action="/fixtures/dom.html">
<form target="_parent" method="GET" action="/fixtures/empty.html">
<button class="inline_parent" type="submit">Submit inline parent</button>
</form>
<form target="_self" method="GET" action="/fixtures/dom.html">
Expand All @@ -63,7 +63,7 @@
<a class="setTarget" href="/fixtures/dom.html" onclick="handleEventTarget(event)">Link setTarget</a>
<a class="setAttr" href="/fixtures/dom.html" onclick="handleEventAttribute(event)">Link setAttribute</a>
<a class="inline_top" href="/fixtures/dom.html" target="_top">Link top</a>
<a class="inline_parent" href="/fixtures/dom.html" target="_parent">Link parent</a>
<a class="inline_parent" href="/fixtures/empty.html" target="_parent">Link parent</a>
<a class="inline_self" href="/fixtures/dom.html" target="_self">Link self</a>
<a class="inline_blank" href="/fixtures/dom.html" target="_blank">Link _blank</a>
<a class="inline_invalid" href="/fixtures/dom.html" target="invalid">Link invalid</a>
Expand Down

4 comments on commit 33f132d

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 33f132d Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.3/linux-arm64/develop-33f132d7be6201723a1dadfa593c61b44cb249b1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 33f132d Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.3/linux-x64/develop-33f132d7be6201723a1dadfa593c61b44cb249b1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 33f132d Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.3/darwin-x64/develop-33f132d7be6201723a1dadfa593c61b44cb249b1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 33f132d Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.3/darwin-arm64/develop-33f132d7be6201723a1dadfa593c61b44cb249b1/cypress.tgz

Please sign in to comment.