slackapi / node-tasks-app

Tasks App is a sample Task Management app built on the Slack Platform.
MIT License
99 stars 50 forks source link

[#35] add listener tests #74

Closed kian2attari closed 3 years ago

kian2attari commented 3 years ago

Summary

Adding the jest tests on the app and listeners.

Changes

There are a lot of line changes because the commit updates the package-lock.json to version 2 (which is backwards compatible with v1). You can read on the difference here.

Tasks

Requirements (place an x in each [ ])

kian2attari commented 3 years ago

Not sure why that one test case is failing on the CI. All the tests pass successfully on my local machine. I even tried using the exact same versions of node as the two build tests that are failing (12.x and 14.x builds) and all runs well image image

kian2attari commented 3 years ago

I've resolved the mystery of the failing test on CI! It was because the CI pipeline wasn't generating the database. I added the DB migration command as the npm build script which the workflow already runs with npm run build before the npm test command

colmdoyle commented 3 years ago

@kian2attari - What else needs to be done before we can safely merge this? It changes quite a bit of the structure of the codebase, so I'd like to get it in soon to unblock some other work that's happening.

kian2attari commented 3 years ago

Incredible work, very thorough!

I did get one test failure when running locally, though, across all of node v12, v14 and v16:

 FAIL  listeners/actions/__tests__/block_open_task_list_home.test.js
  ● Console

    console.error
      TypeError: client.chat.deleteScheduledMessage is not a function
          at map (/Users/fmaj/src/tasks-app/nodejs/utilities/complete-tasks.js:22:27)
          at Array.map (<anonymous>)
          at Object.<anonymous>.module.exports (/Users/fmaj/src/tasks-app/nodejs/utilities/complete-tasks.js:19:15)
          at openTaskCheckboxClickedCallback (/Users/fmaj/src/tasks-app/nodejs/listeners/actions/block_open_task_list_home.js:14:5)
          at Object.<anonymous>.global.testListener (/Users/fmaj/src/tasks-app/nodejs/.jest/setup.js:79:3)
          at testAction (/Users/fmaj/src/tasks-app/nodejs/listeners/actions/__tests__/__utils__/action-test-util-funcs.js:35:3)
          at Object.<anonymous> (/Users/fmaj/src/tasks-app/nodejs/listeners/actions/__tests__/block_open_task_list_home.test.js:15:5)

      27 |       } catch (error) {
      28 |         // eslint-disable-next-line no-console
    > 29 |         console.error(error);
         |                 ^
      30 |       }
      31 |     }
      32 |   });

      at map (utilities/complete-tasks.js:29:17)
          at Array.map (<anonymous>)
      at Object.<anonymous>.module.exports (utilities/complete-tasks.js:19:15)
      at openTaskCheckboxClickedCallback (listeners/actions/block_open_task_list_home.js:14:5)
      at Object.<anonymous>.global.testListener (.jest/setup.js:79:3)
      at testAction (listeners/actions/__tests__/__utils__/action-test-util-funcs.js:35:3)
      at Object.<anonymous> (listeners/actions/__tests__/block_open_task_list_home.test.js:15:5)

  ● App home nav completed action callback function test  › Logs an error when the the new view fails to be published

    expect(jest.fn()).toBeCalledTimes(expected)

    Expected number of calls: 1
    Received number of calls: 2

      110 |   if (usesAck) expect(global.ackMockFunc).toBeCalledTimes(1);
      111 |   expect(methodToFail).toBeCalledTimes(1);
    > 112 |   expect(errorSpy).toBeCalledTimes(1);
          |                    ^
      113 |   errorSpy.mockRestore();
      114 | };
      115 |

      at Object.<anonymous>.global.testErrorLog (.jest/setup.js:112:20)
      at testActionError (listeners/actions/__tests__/__utils__/action-test-util-funcs.js:48:3)
      at Object.<anonymous> (listeners/actions/__tests__/block_open_task_list_home.test.js:21:5)

Hmm I wasn't able to recreate this, could you try running it locally again when you get the chance?