-
-
Notifications
You must be signed in to change notification settings - Fork 535
Add Slack channels to Projects and Chapters page #3958
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
Open
Mr-Rahul-Paul
wants to merge
15
commits into
OWASP:main
Choose a base branch
from
Mr-Rahul-Paul:add_slack_channels
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a62aaef
added slack link to chapters
Mr-Rahul-Paul 79f55b6
added slack link to projects
Mr-Rahul-Paul 005170d
revert package json change
Mr-Rahul-Paul 3c1e517
ran check-test
Mr-Rahul-Paul 2f0c141
ran check-test
Mr-Rahul-Paul ec280f6
fix url color
Mr-Rahul-Paul 239aac4
ran check-test
Mr-Rahul-Paul 64d39b3
rremove file
Mr-Rahul-Paul 43e983f
fix frontend ambiguity
Mr-Rahul-Paul 5abc72f
use prefetch cache
Mr-Rahul-Paul cd9fa5d
add tests
Mr-Rahul-Paul 3c0ef09
add e2e tests
Mr-Rahul-Paul 36d5ad1
Update frontend/__tests__/unit/pages/ChapterDetails.test.tsx
Mr-Rahul-Paul 02d5825
remove redundant mock overrides and add missing rel assertion
Mr-Rahul-Paul 72dc3c1
Merge branch 'main' into add_slack_channels
ahmedxgouda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| """OWASP app entity channel GraphQL node.""" | ||
|
|
||
| import strawberry | ||
| import strawberry_django | ||
|
|
||
| from apps.owasp.models.entity_channel import EntityChannel | ||
|
|
||
|
|
||
| @strawberry_django.type( | ||
| EntityChannel, | ||
| fields=[ | ||
| "is_active", | ||
| "is_default", | ||
| "is_reviewed", | ||
| "platform", | ||
| ], | ||
| ) | ||
| class EntityChannelNode(strawberry.relay.Node): | ||
| """Entity channel node.""" | ||
|
|
||
| @strawberry_django.field | ||
| def name(self, root: EntityChannel) -> str: | ||
| """Channel display name from the linked Slack Conversation.""" | ||
| conv = root.channel | ||
| return conv.name if conv else "" | ||
|
|
||
| @strawberry_django.field | ||
| def slack_channel_id(self, root: EntityChannel) -> str: | ||
| """Slack channel ID for linking (e.g. C123ABC).""" | ||
| conv = root.channel | ||
| return conv.slack_channel_id if conv else "" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
backend/tests/apps/owasp/api/internal/nodes/entity_channel_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| """Tests for EntityChannel GraphQL node resolvers.""" | ||
|
|
||
| from unittest.mock import Mock | ||
|
|
||
| from apps.owasp.api.internal.nodes.entity_channel import EntityChannelNode | ||
|
|
||
|
|
||
| class TestEntityChannelNodeResolvers: | ||
| def _get_resolver(self, field_name): | ||
| """Get the resolver function for a field.""" | ||
| for field in EntityChannelNode.__strawberry_definition__.fields: | ||
| if field.name == field_name: | ||
| return field.base_resolver.wrapped_func if field.base_resolver else None | ||
| return None | ||
|
|
||
| def test_name_and_slack_channel_id_resolvers_return_values_from_channel(self): | ||
| """Return channel name and slack channel id when channel is present.""" | ||
| mock_channel = Mock(name="mock-conversation") | ||
| mock_channel.name = "chapter-general" | ||
| mock_channel.slack_channel_id = "C123ABC" | ||
|
|
||
| mock_entity_channel = Mock() | ||
| mock_entity_channel.channel = mock_channel | ||
|
|
||
| name_resolver = self._get_resolver("name") | ||
| slack_channel_id_resolver = self._get_resolver("slack_channel_id") | ||
|
|
||
| assert name_resolver is not None | ||
| assert slack_channel_id_resolver is not None | ||
| assert name_resolver(None, mock_entity_channel) == "chapter-general" | ||
| assert slack_channel_id_resolver(None, mock_entity_channel) == "C123ABC" | ||
|
|
||
| def test_name_and_slack_channel_id_resolvers_return_empty_when_channel_missing(self): | ||
| """Return empty strings when no linked channel exists.""" | ||
| mock_entity_channel = Mock() | ||
| mock_entity_channel.channel = None | ||
|
|
||
| name_resolver = self._get_resolver("name") | ||
| slack_channel_id_resolver = self._get_resolver("slack_channel_id") | ||
|
|
||
| assert name_resolver is not None | ||
| assert slack_channel_id_resolver is not None | ||
| assert name_resolver(None, mock_entity_channel) == "" | ||
| assert slack_channel_id_resolver(None, mock_entity_channel) == "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.