Co-authored-by: Joey Orlando <joseph.t.orlando@gmail.com>
Co-authored-by: Yulya Artyukhina <Ferril.darkdiver@gmail.com>
This commit is contained in:
Vadim Stepanov 2023-07-11 11:38:09 +01:00 committed by GitHub
parent 44f96d2681
commit 8809cde920
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 6 deletions

View file

@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Address issue where we were improperly parsing Grafana feature flags that were enabled via the `feature_flags.enabled`
method by @joeyorlando ([#2477](https://github.com/grafana/oncall/pull/2477))
- Fix cuddled list Markdown issue by @vadimkerr ([#2488](https://github.com/grafana/oncall/pull/2488))
- Fixed schedules slack notifications for deleted organizations ([#2493](https://github.com/grafana/oncall/pull/2493))
## v1.3.7 (2023-07-06)

View file

@ -186,6 +186,9 @@ def notify_ical_schedule_shift(schedule_pk):
if schedule.organization.slack_team_identity is None:
task_logger.info(f"Trying to notify ical schedule shift with no slack team identity {schedule_pk}")
return
elif schedule.organization.deleted_at:
task_logger.info(f"Trying to notify ical schedule shift from deleted organization {schedule_pk}")
return
MIN_DAYS_TO_LOOKUP_FOR_THE_END_OF_EVENT = 3

View file

@ -16,7 +16,7 @@ def start_refresh_ical_files():
task_logger.info("Start refresh ical files")
schedules = OnCallSchedule.objects.all()
schedules = OnCallSchedule.objects.filter(organization__deleted_at__isnull=True)
for schedule in schedules:
refresh_ical_file.apply_async((schedule.pk,))
@ -30,7 +30,7 @@ def start_refresh_ical_final_schedules():
task_logger.info("Start refresh ical final schedules")
schedules = OnCallSchedule.objects.all()
schedules = OnCallSchedule.objects.filter(organization__deleted_at__isnull=True)
for schedule in schedules:
refresh_ical_final_schedule.apply_async((schedule.pk,))

View file

@ -1,9 +1,10 @@
import datetime
from unittest.mock import patch
import pytest
from apps.schedules.models import OnCallScheduleICal
from apps.schedules.tasks.refresh_ical_files import refresh_ical_file
from apps.schedules.models import OnCallScheduleICal, OnCallScheduleWeb
from apps.schedules.tasks.refresh_ical_files import refresh_ical_file, start_refresh_ical_files
@pytest.mark.django_db
@ -56,3 +57,25 @@ def test_refresh_ical_file_trigger_run(
assert mock_notify_empty.apply_async.called == run_task
assert mock_notify_gaps.apply_async.called == run_task
@pytest.mark.django_db
@patch("apps.slack.tasks.start_update_slack_user_group_for_schedules.apply_async")
def test_refresh_ical_files_filter_orgs(
mocked_start_update_slack_user_group_for_schedules,
make_organization,
make_schedule,
):
organization = make_organization()
deleted_organization = make_organization(deleted_at=datetime.datetime.now())
schedule_from_deleted_org = make_schedule(deleted_organization, schedule_class=OnCallScheduleWeb)
schedule = make_schedule(organization, schedule_class=OnCallScheduleWeb)
with patch("apps.schedules.tasks.refresh_ical_file.apply_async") as mocked_refresh_ical_file:
start_refresh_ical_files()
assert mocked_refresh_ical_file.called
called_args = mocked_refresh_ical_file.call_args_list
assert len(called_args) == 1
assert schedule.id in called_args[0].args[0]
assert schedule_from_deleted_org.id not in called_args[0].args[0]

View file

@ -30,12 +30,13 @@ export const verifyThatAlertGroupIsTriggered = async (
await goToOnCallPage(page, 'incidents');
// filter by integration
await selectDropdownValue({
const selectElement = await selectDropdownValue({
page,
selectType: 'grafanaSelect',
placeholderText: 'Search or filter results...',
value: 'Integration',
});
await selectElement.type(integrationName);
await selectValuePickerValue(page, integrationName, false);
/**

View file

@ -86,7 +86,7 @@ const textMatchSelector = (optionExactMatch: boolean, value: string): string =>
const chooseDropdownValue = async ({ page, value, optionExactMatch = true }: SelectDropdownValueArgs): Promise<void> =>
page.locator(`div[id^="react-select-"][id$="-listbox"] >> ${textMatchSelector(optionExactMatch, value)}`).click();
export const selectDropdownValue = async (args: SelectDropdownValueArgs): Promise<void> => {
export const selectDropdownValue = async (args: SelectDropdownValueArgs): Promise<Locator> => {
const selectElement = await openSelect(args);
/**
@ -97,6 +97,8 @@ export const selectDropdownValue = async (args: SelectDropdownValueArgs): Promis
await selectElement.type(args.value.slice(0, 5));
await chooseDropdownValue(args);
return selectElement;
};
export const generateRandomValue = (): string => randomUUID();