fiaisis / admin-portal

GNU General Public License v3.0
1 stars 0 forks source link

Investigate intermittent test failure for successful PUT on specification file #28

Closed HumzahJavid closed 3 months ago

HumzahJavid commented 3 months ago

Description of the issue

In the setup-ci branch (which included cypress tests) a delay was added to force the test to wait for an async await to resolve before continuing with the test https://github.com/fiaisis/admin-portal/pull/18/commits/769b9c2126a8e78cdb4c9b426b426cf208e3bb13

In a previous investigation of running the failing test 30 times, test #9 and #24 failed. This should be investigated (i.e. run for a sufficient numbe of cases (100?) if any failures occur, then investigate it more thoroughly and find a solution

Issue resolution: There needed to be an explicit check of the contents of the JSON (by accessing the code editor contents) before moving onto the next steps, the failing tests were when the JSON wasn't awaited so attempting to PUT it resulted in no JSON (unexpected end of JSON)

HumzahJavid commented 3 months ago

This test failure showed up when creating the following commit: 0dbf30138e43ca200a43dd8d0199e987841409f9 (to fix all failing tests), but it passed on a rerun with no changes


       A successful specification update:
     SyntaxError: The following error originated from your application code, not from Cypress. It was caused by an unhandled promise rejection.

  > Unexpected end of JSON input

When Cypress detects uncaught errors originating from your application it will automatically fail the current test.

This behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.

https://on.cypress.io/uncaught-exception-from-application
      at JSON.parse (<anonymous>)
      at Object.updateSpecification [as handleSubmit] (webpack-internal:///app-pages-browser/./src/components/EditorContainer.tsx:24:37)
      at handleClick (webpack-internal:///app-pages-browser/./src/components/ButtonAlert.tsx:21:55)
      at HTMLUnknownElement.callCallback (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:20565:14)
      at Object.invokeGuardedCallbackImpl (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:20614:16)
      at invokeGuardedCallback (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:20689:29)
      at invokeGuardedCallbackAndCatchFirstError (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:20703:25)
      at executeDispatch (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:32128:3)
      at processDispatchQueueItemsInOrder (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:32160:7)
      at processDispatchQueue (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:32173:5)
      at dispatchEventsForPlugins (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:32184:3)
      at eval (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:32374:12)
      at batchedUpdates$1 (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:24953:12)
      at batchedUpdates (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:28844:12)
      at dispatchEventForPluginEventSystem (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:32373:3)
      at dispatchEvent (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:30141:5)
      at dispatchDiscreteEvent (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:30112:5)```
HumzahJavid commented 3 months ago

This commit for a different issue https://github.com/fiaisis/admin-portal/pull/45/commits/73e44fbfcf5bf324871cd00a276d5acc5af1efbf ended up triggering the failing tests, in the process of fixing those tests the intermittent tests.

The cause is the GET of a specification, there was no waiting and confirmation of the contents of the specification within the code editor.

A data-cy prop has been added to the component which is used to wait for the specification to exists before continuing with the tests

HumzahJavid commented 3 months ago

This was confirmed with running the local test suite through a loop via bash terminal for i in {1..30}; do yarn cypress run --spec cypress/e2e/spec.cy.ts; done

To keep an eye on this in future, in case it crops up again (unlikely to be related to this issue)