Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More ExpressReceiver tests #1407

Merged
merged 2 commits into from
Mar 30, 2022
Merged

More ExpressReceiver tests #1407

merged 2 commits into from
Mar 30, 2022

Conversation

filmaj
Copy link
Contributor

@filmaj filmaj commented Mar 30, 2022

Summary

Just trying to push the code coverage up

@filmaj filmaj added the tests M-T: Testing work only label Mar 30, 2022
@filmaj filmaj requested a review from seratch March 30, 2022 20:51
@filmaj filmaj self-assigned this Mar 30, 2022
const MockApp = await importApp(overrides);
// Act
const app = new MockApp({ token: '', appToken: '', developerMode: true });
const app = new MockApp({ logger: fakeLogger, token: '', appToken: '', developerMode: true });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unrelated to the ExpressReceiver pull requests, but the extra output as I was iterating on tests was annoying me so I decided to silence them.

@codecov
Copy link

codecov bot commented Mar 30, 2022

Codecov Report

Merging #1407 (49436f7) into main (c071816) will increase coverage by 2.42%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1407      +/-   ##
==========================================
+ Coverage   79.61%   82.03%   +2.42%     
==========================================
  Files          17       17              
  Lines        1452     1453       +1     
  Branches      428      428              
==========================================
+ Hits         1156     1192      +36     
+ Misses        199      165      -34     
+ Partials       97       96       -1     
Impacted Files Coverage Δ
src/receivers/ExpressReceiver.ts 88.88% <100.00%> (+19.61%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c071816...49436f7. Read the comment docs.

@@ -211,7 +211,7 @@ describe('App built-in middleware and mechanism', () => {
* @param orderUp The order it should be called when processing middleware up the chain
*/
const assertOrderMiddleware = (orderDown: number, orderUp: number) => async ({ next }: { next?: NextFn }) => {
await delay(100);
await delay(10);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Every millisecond counts!

@@ -258,7 +258,7 @@ export default class ExpressReceiver implements Receiver {
this.app.use(this.router);
}

private async requestHandler(req: Request, res: Response): Promise<void> {
public async requestHandler(req: Request, res: Response): Promise<void> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hope moving this to public is OK, otherwise, testing this was extremely difficult - I would need to orchestrate both the Receiver and the App very specifically, and trigger entire middleware chain processing in order to test this private method.

Copy link
Member

Choose a reason for hiding this comment

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

I'll let Kaz make the call on whether this is okay to move to public.

Copy link
Member

Choose a reason for hiding this comment

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

Ideally, non-public is safer but I don't see any big risks by doing this. Go ahead 👍

@@ -500,7 +500,7 @@ export function verifySignatureAndParseBody(
return parseRequestBody(body, contentType);
}

function buildBodyParserMiddleware(logger: Logger): RequestHandler {
export function buildBodyParserMiddleware(logger: Logger): RequestHandler {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exported this once more for ease of testing. Another option is to move this method to a separate module in its own file. Let me know if anyone has a preference.

Copy link
Member

Choose a reason for hiding this comment

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

Just exporting it looks fine!

Copy link
Member

@mwbrooks mwbrooks left a comment

Choose a reason for hiding this comment

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

Impressive new tests! I'll hold off on an approval so that @seratch can make the call on switching to public

@@ -258,7 +258,7 @@ export default class ExpressReceiver implements Receiver {
this.app.use(this.router);
}

private async requestHandler(req: Request, res: Response): Promise<void> {
public async requestHandler(req: Request, res: Response): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

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

I'll let Kaz make the call on whether this is okay to move to public.

@seratch seratch changed the title Moar ExpressReceiver tests More ExpressReceiver tests Mar 30, 2022
@@ -500,7 +500,7 @@ export function verifySignatureAndParseBody(
return parseRequestBody(body, contentType);
}

function buildBodyParserMiddleware(logger: Logger): RequestHandler {
export function buildBodyParserMiddleware(logger: Logger): RequestHandler {
Copy link
Member

Choose a reason for hiding this comment

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

Just exporting it looks fine!

@@ -258,7 +258,7 @@ export default class ExpressReceiver implements Receiver {
this.app.use(this.router);
}

private async requestHandler(req: Request, res: Response): Promise<void> {
public async requestHandler(req: Request, res: Response): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

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

Ideally, non-public is safer but I don't see any big risks by doing this. Go ahead 👍

@seratch
Copy link
Member

seratch commented Mar 30, 2022

@filmaj Thanks a lot for adding these tests!

@seratch seratch merged commit 5ed91e0 into main Mar 30, 2022
@seratch seratch deleted the expressreceiver-tests branch March 30, 2022 21:20
@seratch seratch added this to the 3.11.0 milestone Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests M-T: Testing work only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants