Skip to content

Commit 40bc66c

Browse files
mfredericclaude
andcommitted
fix(PLT-4375): retry welcome button click in mobile widget e2e
The form's ok-button exists before its handlers are attached, so a single click could be lost and the fullscreen close button never appeared. Retry the forced click until the close button is visible. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 1056e26 commit 40bc66c

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

‎packages/embed/e2e/cypress-utils.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,19 @@ export const openOnMobile = (url: string) => {
3131
},
3232
})
3333
}
34+
35+
// Clicks the form's welcome screen button until the widget goes fullscreen (close button visible).
36+
// The button exists before the form's handlers are attached, so a single click can be lost; and it
37+
// can be scrolled out of the iframe viewport, hence `force`.
38+
export const startWidgetOnMobile = (attempts = 5) => {
39+
cy.get('iframe').then(($iframe) => {
40+
const $body = $iframe.contents().find('body')
41+
cy.wrap($body).find('[data-qa="ok-button"]').click({ force: true })
42+
})
43+
cy.wait(1000)
44+
cy.get('.tf-v1-widget-close').then(($close) => {
45+
if (!$close.is(':visible') && attempts > 1) {
46+
startWidgetOnMobile(attempts - 1)
47+
}
48+
})
49+
}

‎packages/embed/e2e/spec/functional/widget-newui.cy.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { openOnMobile } from '../../cypress-utils'
1+
import { openOnMobile, startWidgetOnMobile } from '../../cypress-utils'
22

33
describe('Widget', () => {
44
testWidget('/widget-newui-html.html', 'html')
@@ -53,11 +53,8 @@ function testMobile(path: string, title: string) {
5353
})
5454

5555
it('should reset the form when closing it', () => {
56-
cy.get('iframe').then(($iframe) => {
57-
const $body = $iframe.contents().find('body')
58-
cy.wrap($body).find('[data-qa="ok-button"]').click({ force: true })
59-
cy.get('.tf-v1-widget-close').click()
60-
})
56+
startWidgetOnMobile()
57+
cy.get('.tf-v1-widget-close').should('be.visible').click()
6158
cy.wait(1000)
6259
cy.get('iframe').then(($iframe) => {
6360
const $body = $iframe.contents().find('body')

‎packages/embed/e2e/spec/functional/widget.cy.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { openOnMobile } from '../../cypress-utils'
1+
import { openOnMobile, startWidgetOnMobile } from '../../cypress-utils'
22

33
describe('Widget', () => {
44
testWidget('/widget-html.html', 'html')
@@ -53,11 +53,8 @@ function testMobile(path: string, title: string) {
5353
})
5454

5555
it('should reset the form when closing it', () => {
56-
cy.get('iframe').then(($iframe) => {
57-
const $body = $iframe.contents().find('body')
58-
cy.wrap($body).find('[data-qa="ok-button"]').click()
59-
cy.get('.tf-v1-widget-close').click()
60-
})
56+
startWidgetOnMobile()
57+
cy.get('.tf-v1-widget-close').should('be.visible').click()
6158
cy.wait(1000)
6259
cy.get('iframe').then(($iframe) => {
6360
const $body = $iframe.contents().find('body')

0 commit comments

Comments
 (0)