Преглед изворни кода

Merge pull request #8524 from overleaf/ae-detached-test

Attempt to fix flaky Cypress test

GitOrigin-RevId: c49ec0b763e5dd3dde8c207021f1cb1a504f426c
Alf Eaton пре 4 година
родитељ
комит
34f15ba016

+ 1 - 1
services/web/test/frontend/components/pdf-preview/pdf-preview-detached-root.spec.tsx

@@ -62,7 +62,7 @@ describe('<PdfPreviewDetachedRoot/>', function () {
     cy.findByRole('button', { name: 'Clear cached files' })
       .should('not.be.disabled')
       .click()
-      .then(() => {
+      .should(() => {
         expect(sysendTestHelper.getLastBroacastMessage()).to.deep.equal({
           role: 'detached',
           event: 'action-clearCache',

+ 2 - 2
services/web/test/frontend/helpers/sysend.js

@@ -22,7 +22,7 @@ function getLastDetachCall(method) {
 }
 
 function getLastBroacastMessage() {
-  return getLastDetachCall('broadcast').args[1]
+  return getLastDetachCall('broadcast')?.args[1]
 }
 
 function getAllBroacastMessages() {
@@ -32,7 +32,7 @@ function getAllBroacastMessages() {
 // this fakes receiving a message by calling the handler add to `on`. A bit
 // funky, but works for now
 function receiveMessage(message) {
-  getLastDetachCall('on').args[1](message)
+  getLastDetachCall('on')?.args[1](message)
 }
 
 export default {