politics-rewired / Spoke

Politics Rewired's fork of Spoke
GNU General Public License v3.0
34 stars 16 forks source link

feat: support auto reply handling #1663

Open ajohn25 opened 11 months ago

ajohn25 commented 11 months ago

Description

This PR adds all backend changes required to support auto reply handling.

This does not expose any auto reply functionality to users intentionally, to allow for an easier slow rollout of this feature if desired.

Motivation and Context

Part 1 of 2 for #1526

How Has This Been Tested?

See message-sending.spec.ts

Screenshots (if appropriate):

Documentation Changes

Checklist:

ajohn25 commented 11 months ago

@bchrobot @hiemanshu the failing test here requires ENABLE_AUTO_REPLIES = true to pass. I do want to keep the default for that value as false so that we're disabling this feature by default. Do either of you have thoughts about if there's a way to get around that within the test file 🤔 ?

bchrobot commented 11 months ago

@bchrobot @hiemanshu the failing test here requires ENABLE_AUTO_REPLIES = true to pass. I do want to keep the default for that value as false so that we're disabling this feature by default. Do either of you have thoughts about if there's a way to get around that within the test file 🤔 ?

The easy route is to do something similar to what we do in Switchboard: separating the config object itself from the parsed environment variables:

https://github.com/politics-rewired/switchboard/blob/6686f0bc304065e20dbe8a509130e3b746856328/src/config.ts#L96-L100

Another option is to use Jest mocks. I have struggled to make this to work for specific object properties before, but this approach might work:

https://stackoverflow.com/a/67897729 or https://stackoverflow.com/a/65082112

hiemanshu commented 11 months ago

To add to what Chrobot said above, we should have a different config for tests, that enables all the flags possible. We should test with all possible features turned on.

bchrobot commented 11 months ago

@ajohn25 would you update the SQL schema dump? Having a hard time reviewing the auto-assignment views migration on its own

ajohn25 commented 11 months ago

@bchrobot sorry i converted this back to draft to address a few things i thought of - one of those being that update-dump wasn't working for me 😭