Skip to content

Fast follow to PR #75#77

Merged
ezhangy merged 11 commits intodevfrom
fast-follow-to-75-api-alarms
Aug 26, 2025
Merged

Fast follow to PR #75#77
ezhangy merged 11 commits intodevfrom
fast-follow-to-75-api-alarms

Conversation

@ezhangy
Copy link
Copy Markdown
Contributor

@ezhangy ezhangy commented Aug 20, 2025

This PR fixes the tests written in #75 as well as longer-standing type errors that were causing our test suite to fail.

Changes in files are annotated with comments.

@ezhangy ezhangy changed the title Fast follow to PR (#75)[https://github.com/newjersey/feedback-api/pull/75] Fast follow to PR [#75](https://github.com/newjersey/feedback-api/pull/75) Aug 20, 2025
@ezhangy ezhangy changed the title Fast follow to PR [#75](https://github.com/newjersey/feedback-api/pull/75) Fast follow to PR #75 Aug 20, 2025
Copy link
Copy Markdown
Contributor Author

@ezhangy ezhangy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annotated changes with comments!

let stack: Stack;
let template: Template;

beforeEach(() => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved the logic in the beforeEach to the createStackAndTemplate function, which allows us to mock functions called in the Stack within a test.

also refactored the function to return the stack and template rather than assigning them to variables to avoid any unexpected behavior due to mutability

const app = new App();
const currentWorkingDir = path.basename(path.resolve(process.cwd()));
const rootDir = path.resolve(__dirname, '../../');
const rootDir = path.basename(path.resolve(__dirname, '../../'));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without adding path.basename, the rootDir was the absolute path while currentWorkingDir was only the directory name, causing the conditional below to always fail

});

it('creates an SNS subscription for Slack endpoint', () => {
const valueForStringParameterMock = jest.spyOn(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the previous PR, I refactored the code to get the subscription email from SSM instead of hard-coding it and forgot to update this test

MOCK_SSM_CLIENT.on(GetParameterCommand).resolves({
Parameter: {
Value: null
Value: null as unknown as string | undefined
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Value is of type string | undefined, but we're purposely testing passing the wrong type here. The casting is necessary to avoid a type error.

const auth = new google.auth.JWT(
clientEmail,
null,
undefined,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This argument (it's the keyFile parameter) was causing a type error because it was previously set to null but has type string | undefined.

I changed it to undefined and double-checked that it didn't affect the API by deploying to dev and sending some test requests.

@ezhangy ezhangy marked this pull request as ready for review August 20, 2025 15:41
@mluedke2
Copy link
Copy Markdown

[boulder|dust] Unless there's a reason not to, I think the GitHub CI should not only be running tests on PRs and commits to main but also to dev, so that these issues can be caught earlier. Would that work here?

https://github.com/newjersey/feedback-api/blob/dev/.github/workflows/ci.yml

For example, on this PR for making tests pass, the CI doesn't run tests. I trust you ran them locally and they work, but having that nice ✅ makes it even more instantly clear (and in some cases might catch something local tests don't).

@ezhangy
Copy link
Copy Markdown
Contributor Author

ezhangy commented Aug 20, 2025

[boulder|dust] Unless there's a reason not to, I think the GitHub CI should not only be running tests on PRs and commits to main but also to dev, so that these issues can be caught earlier. Would that work here?

https://github.com/newjersey/feedback-api/blob/dev/.github/workflows/ci.yml

For example, on this PR for making tests pass, the CI doesn't run tests. I trust you ran them locally and they work, but having that nice ✅ makes it even more instantly clear (and in some cases might catch something local tests don't).

yes, such a good point! i think i had mentally filed away our entire CI/CD pipeline in a future ticket about implementing automatic CDK deployments, but you're totally right it's easy to just add the tests to PRs on the dev branch now 🙂 will do!

Copy link
Copy Markdown

@mluedke2 mluedke2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding the tests onto dev too!

Copy link
Copy Markdown
Contributor

@sannidhishukla sannidhishukla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me! added a few comments about adding tests but like i said, feel free to address these later if it doesn't make sense to put time into setting these up right now!

@ezhangy ezhangy merged commit 9cd4ac0 into dev Aug 26, 2025
1 check passed
@ezhangy ezhangy deleted the fast-follow-to-75-api-alarms branch August 26, 2025 01:10
@ezhangy ezhangy mentioned this pull request Aug 26, 2025
ezhangy added a commit that referenced this pull request Aug 26, 2025
This PR fixes the tests written in #75 as well as longer-standing type
errors that were causing our test suite to fail.
ezhangy added a commit that referenced this pull request Aug 26, 2025
@ezhangy ezhangy mentioned this pull request Aug 26, 2025
ezhangy added a commit that referenced this pull request Aug 26, 2025
Merges the following PRs to main: 
- #68 
- #70 
- #69 
- #72 
- #71 
- #73 
- #75 
- #77
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants