Skip to content

Fix #1283 - Add conversations (slack connect) and admin.auth.policy API methods#1284

Merged
srajiang merged 5 commits intoslackapi:mainfrom
srajiang:sj-add-api-endpoints
Jul 14, 2021
Merged

Fix #1283 - Add conversations (slack connect) and admin.auth.policy API methods#1284
srajiang merged 5 commits intoslackapi:mainfrom
srajiang:sj-add-api-endpoints

Conversation

@srajiang
Copy link
Copy Markdown
Contributor

@srajiang srajiang commented Jul 12, 2021

Summary

This PR fixes #1283 with the addition of the following Slack Connect conversations.* + Admin admin.auth.policy.* methods:

  • conversations.acceptSharedInvite
  • conversations.approveSharedInvite
  • conversations.declineSharedInvite
  • conversations.listConnectInvites
  • conversations.inviteShared
  • admin.auth.policy.getEntities
  • admin.auth.policy.assignEntities
  • admin.auth.policy.removeEntities

Requirements (place an x in each [ ])

@gitwave gitwave bot added the untriaged label Jul 12, 2021
@srajiang srajiang added enhancement M-T: A feature request for new functionality pkg:web-api applies to `@slack/web-api` semver:minor and removed untriaged labels Jul 12, 2021
@srajiang srajiang added this to the web-api@6.3 milestone Jul 12, 2021
Copy link
Copy Markdown
Contributor Author

@srajiang srajiang left a comment

Choose a reason for hiding this comment

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

Thanks in advance for taking a look!

}
cursorPaginationEnabledMethods.add('conversations.list');
export interface ConversationsListConnectInvitesArguments extends WebAPICallOptions, TokenOverridable {
count?: number;
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 method accepts a count and a cursor option, and so it doesn't to conform to CursorPaginationEnabled or TraditionalPagingEnabled interface.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh... the 3rd pattern came here.

@@ -0,0 +1,9 @@
/* tslint:disable */
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.

Generated by generate-web-api-types.sh

attachments?: MatchAttachment[];
is_mpim?: boolean;
score?: number;
files?: File[];
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.

Changes here aren't relevant to PR, but auto-generated by generate-web-api-types.sh
See also, SearchMessagesResponse.ts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, this is fine. We've detected this pattern and updated the type def very recently.

@srajiang srajiang marked this pull request as ready for review July 12, 2021 07:13
@srajiang srajiang requested review from misscoded and seratch July 12, 2021 07:13
@srajiang srajiang self-assigned this Jul 12, 2021
@srajiang srajiang requested a review from stevengill July 12, 2021 07:16
Copy link
Copy Markdown
Contributor

@seratch seratch left a comment

Choose a reason for hiding this comment

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

I cannot leave comments on the Slack Connect APIs as I haven't verified how they work yet (I will do early next week!). The others already look good to me 👍

If you want to add integration tests with the prod Slack APIs, you can have some code here. https://github.com/slackapi/node-slack-sdk/tree/main/prod-server-integration-tests/test

For the admin.auth.policy.*, you can do the same with Python SDK: https://github.com/slackapi/python-slack-sdk/blob/main/integration_tests/web/test_admin_auth_policy.py

As for the Slack Connect APIs, running tests without human interactions may not be feasible (I'm not sure in detail yet, though).

}
cursorPaginationEnabledMethods.add('conversations.list');
export interface ConversationsListConnectInvitesArguments extends WebAPICallOptions, TokenOverridable {
count?: number;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh... the 3rd pattern came here.

attachments?: MatchAttachment[];
is_mpim?: boolean;
score?: number;
files?: File[];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, this is fine. We've detected this pattern and updated the type def very recently.

@seratch
Copy link
Copy Markdown
Contributor

seratch commented Jul 12, 2021

@srajiang There is a lint error. Can you fix it? https://github.com/slackapi/node-slack-sdk/pull/1284/checks?check_run_id=3044242462

> @slack/web-api@6.2.4 lint /home/runner/work/node-slack-sdk/node-slack-sdk/packages/web-api
> tslint --project .


ERROR: /home/runner/work/node-slack-sdk/node-slack-sdk/packages/web-api/src/methods.ts:777:1 - Exceeds maximum line length of 120

Copy link
Copy Markdown
Contributor

@seratch seratch left a comment

Choose a reason for hiding this comment

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

Having the integration tests for admin.auth.policy endpoints is a great addition 👍

entity_type: "USER",
policy_name: "email_password",
});
assert.equal(res.ok, true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Having the following assertion is a bit easier to check the result than just knowing false

assert.isUndefined(res.error);

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.

I have added these assertions!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@srajiang Thanks. Perhaps, you can remove assert.equal(res.ok, true); in L88 because the old assertion fails before the newly added one 😸

});
assert.equal(res.ok, true);
} catch (error) {
console.log(error);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can imagine the reason why you went this way (accepting the possible errors due to the data state, right?). This is fine for now 👍 Ideally, we can make these to be more like a robust scenario test but we don't need to put so much efforts for the perfection here.

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.

Yes, the try catch was helpful here in inspecting the error state (more than just the error reason), but since tests that should fail due to error show as passing, I think it's probably best to avoid false positives in our tests, so I have removed the try catch.

Copy link
Copy Markdown
Member

@stevengill stevengill left a comment

Choose a reason for hiding this comment

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

Great work!

@srajiang srajiang merged commit df61f14 into slackapi:main Jul 14, 2021
seratch added a commit that referenced this pull request Aug 17, 2021
* Add Slack Connect API response types to #1284 (#1283)

* Fix lint erorrs

* Fix lint errors again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement M-T: A feature request for new functionality pkg:web-api applies to `@slack/web-api` semver:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add missing slack connect and admin.auth.policy.* endpoints

3 participants