fix issue in /escalate Slack command when selecting a team (#3381)
# Which issue(s) this PR fixes Closes https://github.com/grafana/support-escalations/issues/8380 ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
This commit is contained in:
parent
3b90c6544b
commit
05ec0f97b5
3 changed files with 29 additions and 13 deletions
|
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Fixed
|
||||
|
||||
- Fixes forwarding of Amazon SNS headers @mderynck ([#3371](https://github.com/grafana/oncall/pull/3371))
|
||||
- Fixes issue when using the `/escalate` Slack command and selecting a team by @joeyorlando ([#3381](https://github.com/grafana/oncall/pull/3381))
|
||||
- Fix issue when RBAC is enabled where Viewers with "Notifications Receiver" role do not properly show up in schedule
|
||||
rotations by @joeyorlando ([#3378](https://github.com/grafana/oncall/pull/3378))
|
||||
|
||||
|
|
|
|||
|
|
@ -570,9 +570,8 @@ def _get_team_select_blocks(
|
|||
initial_option_idx = 0
|
||||
for idx, team in enumerate(teams):
|
||||
team_pk, team_name = team
|
||||
team_pk_str = str(team_pk)
|
||||
|
||||
if value == team_pk_str:
|
||||
if value and value.pk == team_pk:
|
||||
initial_option_idx = idx
|
||||
team_options.append(
|
||||
{
|
||||
|
|
@ -581,7 +580,7 @@ def _get_team_select_blocks(
|
|||
"text": team_name,
|
||||
"emoji": True,
|
||||
},
|
||||
"value": team_pk_str,
|
||||
"value": str(team_pk),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -318,24 +318,40 @@ def test_get_team_select_blocks(
|
|||
|
||||
# team selected
|
||||
organization, _, _, slack_user_identity = make_organization_and_user_with_slack_identities()
|
||||
team = make_team(organization)
|
||||
arc = make_alert_receive_channel(organization, team=team, integration=AlertReceiveChannel.INTEGRATION_DIRECT_PAGING)
|
||||
escalation_chain = make_escalation_chain(organization)
|
||||
make_channel_filter(arc, is_default=True, escalation_chain=escalation_chain)
|
||||
team1 = make_team(organization)
|
||||
team2 = make_team(organization)
|
||||
|
||||
blocks = _get_team_select_blocks(slack_user_identity, organization, True, team.pk, input_id_prefix)
|
||||
def _setup_direct_paging_integration(team):
|
||||
arc = make_alert_receive_channel(
|
||||
organization, team=team, integration=AlertReceiveChannel.INTEGRATION_DIRECT_PAGING
|
||||
)
|
||||
escalation_chain = make_escalation_chain(organization)
|
||||
make_channel_filter(arc, is_default=True, escalation_chain=escalation_chain)
|
||||
return arc
|
||||
|
||||
_setup_direct_paging_integration(team1)
|
||||
team2_direct_paging_arc = _setup_direct_paging_integration(team2)
|
||||
|
||||
blocks = _get_team_select_blocks(slack_user_identity, organization, True, team2, input_id_prefix)
|
||||
|
||||
assert len(blocks) == 2
|
||||
input_block, context_block = blocks
|
||||
|
||||
team_option = {"text": {"emoji": True, "text": team.name, "type": "plain_text"}, "value": str(team.pk)}
|
||||
def _contstruct_team_option(team):
|
||||
return {"text": {"emoji": True, "text": team.name, "type": "plain_text"}, "value": str(team.pk)}
|
||||
|
||||
team1_option = _contstruct_team_option(team1)
|
||||
team2_option = _contstruct_team_option(team2)
|
||||
|
||||
def _sort_team_options(options):
|
||||
return sorted(options, key=lambda o: o["value"])
|
||||
|
||||
assert input_block["type"] == "input"
|
||||
assert len(input_block["element"]["options"]) == 1
|
||||
assert input_block["element"]["options"] == [team_option]
|
||||
assert input_block["element"]["initial_option"] == team_option
|
||||
assert len(input_block["element"]["options"]) == 2
|
||||
assert _sort_team_options(input_block["element"]["options"]) == _sort_team_options([team1_option, team2_option])
|
||||
assert input_block["element"]["initial_option"] == team2_option
|
||||
|
||||
assert (
|
||||
context_block["elements"][0]["text"]
|
||||
== f"Integration <{arc.web_link}|{arc.verbal_name}> will be used for notification."
|
||||
== f"Integration <{team2_direct_paging_arc.web_link}|{team2_direct_paging_arc.verbal_name}> will be used for notification."
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue