public NotificationBannerModel(NotificationForBannerModel notification, bool showPadlock = false, bool showLink = false) { NotificationId = notification.NotificationId.ToString(); SortByDate = notification.NotificationDate ?? notification.CreationDate; TbService = notification.TbService; TbServiceCode = notification.TbServiceCode; TbServicePHECCode = notification.TbServicePHECCode; LocationPHECCode = notification.LocationPHECCode; CaseManager = notification.CaseManager; CaseManagerIsActive = notification.CaseManagerIsActive; CaseManagerId = notification.CaseManagerId; NhsNumber = notification.NhsNumber; DateOfBirth = notification.DateOfBirth; CountryOfBirth = notification.CountryOfBirth; Postcode = notification.Postcode; Name = notification.Name; Sex = notification.Sex; NotificationStatus = notification.NotificationStatus; NotificationStatusString = notification.NotificationStatus.GetDisplayName(); NotificationDate = notification.NotificationDate.ConvertToString(); DrugResistance = notification.DrugResistance; TreatmentOutcome = CalculateOutcome(notification.TreatmentEvents, notification.IsPostMortemWithCorrectEvents); PreviousTbServiceCodes = notification.PreviousTbServiceCodes; PreviousPhecCodes = notification.PreviousPhecCodes; LinkedNotificationTbServiceCodes = notification.LinkedNotificationTbServiceCodes; LinkedNotificationPhecCodes = notification.LinkedNotificationPhecCodes; Source = NtbsSource; ShowLink = showLink; ShowPadlock = showPadlock; RedirectPath = RouteHelper.GetNotificationPath(notification.NotificationId, NotificationSubPaths.Overview); }
// Access level is treated as a bool for either able to view or not. This differs from the standard PermissionLevel // implemented across the codebase due to there being no visual difference between full edit permissions // and readonly permissions on notification banner models public NotificationBannerModel(Notification notification, bool showPadlock = false, bool showLink = false) { NotificationId = notification.NotificationId.ToString(); SortByDate = notification.NotificationDate ?? notification.CreationDate; TbService = notification.HospitalDetails.TBServiceName; TbServiceCode = notification.HospitalDetails.TBServiceCode; TbServicePHECCode = notification.HospitalDetails.TBService?.PHECCode; LocationPHECCode = notification.PatientDetails.PostcodeLookup?.LocalAuthority?.LocalAuthorityToPHEC?.PHECCode; CaseManager = notification.HospitalDetails.CaseManagerName; CaseManagerIsActive = notification.HospitalDetails.CaseManager?.IsActive; CaseManagerId = notification.HospitalDetails.CaseManagerId; NhsNumber = notification.PatientDetails.FormattedNhsNumber; DateOfBirth = notification.PatientDetails.FormattedDob; CountryOfBirth = notification.PatientDetails.CountryName; Postcode = notification.PatientDetails.FormattedNoAbodeOrPostcodeString; Name = notification.PatientDetails.FullName; Sex = notification.PatientDetails.SexLabel; NotificationStatus = notification.NotificationStatus; NotificationStatusString = notification.NotificationStatus.GetDisplayName(); NotificationDate = notification.FormattedNotificationDate; DrugResistance = notification.DrugResistanceProfile.DrugResistanceProfileString; TreatmentOutcome = CalculateOutcome(notification.TreatmentEvents, notification.IsPostMortemAndHasCorrectEvents); PreviousTbServiceCodes = notification.PreviousTbServices.Select(service => service.TbServiceCode); PreviousPhecCodes = notification.PreviousTbServices.Select(service => service.PhecCode); LinkedNotificationPhecCodes = notification.Group?.Notifications.Select(no => no.HospitalDetails.TBService.PHECCode); LinkedNotificationTbServiceCodes = notification.Group?.Notifications.Select(no => no.HospitalDetails.TBServiceCode); Source = NtbsSource; ShowLink = showLink; ShowPadlock = showPadlock; RedirectPath = RouteHelper.GetNotificationPath(notification.NotificationId, NotificationSubPaths.Overview); }
public async Task AcceptTransferAlert_SuccessfullyChangesTbServiceCaseManagerAndHospitalOfNotificationAndDismissesAlert() { // Arrange const int id = Utilities.NOTIFIED_ID_WITH_NOTIFICATION_DATE; var url = GetCurrentPathForId(id); var initialDocument = await GetDocumentForUrlAsync(url); Assert.Equal(" ", initialDocument.QuerySelector("#banner-tb-service").TextContent); var formData = new Dictionary <string, string> { ["AcceptTransfer"] = "true", ["TargetCaseManagerUsername"] = Utilities.CASEMANAGER_ABINGDON_EMAIL, ["TargetHospitalId"] = Utilities.HOSPITAL_ABINGDON_COMMUNITY_HOSPITAL_ID }; // Act var result = await Client.SendPostFormWithData(initialDocument, formData, url); var resultDocument = await GetDocumentAsync(result); // Assert Assert.NotNull(resultDocument.QuerySelector("#return-to-notification")); var overviewUrl = RouteHelper.GetNotificationPath(id, NotificationSubPaths.Overview); var overviewPage = await GetDocumentForUrlAsync(overviewUrl); Assert.Contains("Abingdon Community Hospital", overviewPage.QuerySelector("#banner-tb-service").TextContent); Assert.Contains("TestCase TestManager", overviewPage.QuerySelector("#banner-case-manager").TextContent); Assert.Contains("ABINGDON COMMUNITY HOSPITAL", overviewPage.QuerySelector("#overview-hospital-name").TextContent); Assert.Null(overviewPage.QuerySelector("#alert-20003")); }
private async Task <Dictionary <string, string> > GenerateDuplicateNhsNumberNotificationUrlsAsync(string nhsNumber, NotificationGroup group) { // If NhsNumber is empty or does not pass validation - return null // Potential duplication of validation here so that both Server and Dynamic/JS routes to warnings // can use the same method. if (string.IsNullOrEmpty(nhsNumber) || !string.IsNullOrEmpty( ValidationService.GetPropertyValidationResult <PatientDetails>("NhsNumber", nhsNumber, false).Content)) { return(null); } var ntbsNhsNumberMatchesTask = NotificationRepository.GetNotificationIdsByNhsNumberAsync(nhsNumber); var legacyNhsNumberMatchesTask = _migrationRepository.GetLegacyNotificationNhsNumberMatches(nhsNumber); var ntbsNhsNumberMatches = await ntbsNhsNumberMatchesTask; var legacyNhsNumberMatches = await legacyNhsNumberMatchesTask; var idsInGroup = group?.Notifications?.Select(n => n.NotificationId) ?? new List <int>(); var filteredNtbsIdDictionary = ntbsNhsNumberMatches .Except(idsInGroup) .Where(n => n != NotificationId) .ToDictionary( id => id.ToString(), id => RouteHelper.GetNotificationPath(id, NotificationSubPaths.Overview)); var legacyIdDictionary = legacyNhsNumberMatches.ToDictionary( match => $"{match.Source}: {match.OldNotificationId}", match => RouteHelper.GetLegacyNotificationPath(match.OldNotificationId)); return(filteredNtbsIdDictionary.Concat(legacyIdDictionary).ToDictionary(x => x.Key, x => x.Value)); }
public async Task OnPostNhsNumberDuplicates_ReturnsExpectedResponseForGroupedDuplicateNhsNumber() { // Arrange const int id = Utilities.PATIENT_GROUPED_NOTIFIED_NOTIFICATION_1_SHARED_NHS_NUMBER_1; const string nhsNumber = Utilities.NHS_NUMBER_SHARED_1; var initialPage = await Client.GetAsync(GetCurrentPathForId(id)); var initialDocument = await GetDocumentAsync(initialPage); var request = new NhsNumberValidationModel { NotificationId = id, NhsNumber = nhsNumber }; const int expectedWarningNotificationId = Utilities.PATIENT_NOTIFIED_NOTIFICATION_SHARED_NHS_NUMBER_1; var expectedWarningUrl = RouteHelper.GetNotificationPath(expectedWarningNotificationId, NotificationSubPaths.Overview); // Act var response = await Client.SendVerificationPostAsync( initialPage, initialDocument, GetHandlerPath(null, "NhsNumberDuplicates", Utilities.NOTIFIED_ID), request); // Assert var result = await response.Content.ReadAsStringAsync(); Assert.Contains($"\"{expectedWarningNotificationId}\":\"{expectedWarningUrl}\"", result); }
public async Task AcceptTransferAlert_CreatesTransferInAndOutTreatmentEventsForNotification() { // Arrange const int id = Utilities.NOTIFICATION_WITH_TRANSFER_REQUEST_TO_ACCEPT; var treatmentEventsUrl = RouteHelper.GetNotificationPath(id, NotificationSubPaths.EditTreatmentEvents); var initialTreatmentEventsPage = await GetDocumentForUrlAsync(treatmentEventsUrl); Assert.Null(initialTreatmentEventsPage.QuerySelector("#treatment-events")); var url = GetCurrentPathForId(id); var initialDocument = await GetDocumentForUrlAsync(url); var formData = new Dictionary <string, string> { ["AcceptTransfer"] = "true" }; // Act await Client.SendPostFormWithData(initialDocument, formData, url); var reloadedTreatmentEventsPage = await GetDocumentForUrlAsync(treatmentEventsUrl); // Assert var reloadedTreatmentEventsTable = reloadedTreatmentEventsPage.QuerySelector("#treatment-events"); Assert.Contains("Transfer in", reloadedTreatmentEventsTable.InnerHtml); Assert.Contains("Transfer out", reloadedTreatmentEventsTable.InnerHtml); }
public async Task DeclineTransferAlert_CreatesNewTransferRejectionAlert() { // Arrange const int id = Utilities.NOTIFIED_ID_WITH_TRANSFER_REQUEST_TO_REJECT; var overviewUrl = RouteHelper.GetNotificationPath(id, NotificationSubPaths.Overview); var overviewPage = await GetDocumentForUrlAsync(overviewUrl); Assert.NotNull(overviewPage.QuerySelector("#alert-20004")); var url = GetCurrentPathForId(id); var initialDocument = await GetDocumentForUrlAsync(url); var formData = new Dictionary <string, string> { ["AcceptTransfer"] = "false", ["DeclineTransferReason"] = "nah" }; // Act await Client.SendPostFormWithData(initialDocument, formData, url); // Assert var reloadedOverviewUrl = RouteHelper.GetNotificationPath(id, NotificationSubPaths.Overview); var reloadedOverviewPage = await GetDocumentForUrlAsync(reloadedOverviewUrl); var alertsContainer = reloadedOverviewPage.QuerySelector(".overview-alerts-container"); Assert.Null(alertsContainer.QuerySelector("#alert-20004")); Assert.Contains("Transfer request rejected", alertsContainer.InnerHtml); }
// Access level is treated as a bool for either able to edit or not. This differs from the standard PermissionLevel // implemented across the codebase due to there being no visual difference between no permission level and readonly // permission on notification banner models public NotificationBannerModel(Notification notification, bool showPadlock = false, bool showLink = false) { NotificationId = notification.NotificationId.ToString(); SortByDate = notification.NotificationDate ?? notification.CreationDate; TbService = notification.HospitalDetails.TBServiceName; TbServiceCode = notification.HospitalDetails.TBServiceCode; TbServicePHECCode = notification.HospitalDetails.TBService?.PHECCode; LocationPHECCode = notification.PatientDetails.PostcodeLookup?.LocalAuthority?.LocalAuthorityToPHEC?.PHECCode; CaseManager = notification.HospitalDetails.CaseManagerName; CaseManagerUsername = notification.HospitalDetails.CaseManagerUsername; NhsNumber = notification.PatientDetails.FormattedNhsNumber; DateOfBirth = notification.PatientDetails.FormattedDob; CountryOfBirth = notification.PatientDetails.CountryName; Postcode = notification.PatientDetails.FormattedNoAbodeOrPostcodeString; Name = notification.PatientDetails.FullName; Sex = notification.PatientDetails.SexLabel; NotificationStatus = notification.NotificationStatus; NotificationStatusString = notification.NotificationStatus.GetDisplayName(); NotificationDate = notification.FormattedNotificationDate; DrugResistance = notification.DrugResistanceProfile.DrugResistanceProfileString; TreatmentOutcome = CalculateOutcome(notification); Source = "ntbs"; ShowLink = showLink; ShowPadlock = showPadlock; RedirectPath = RouteHelper.GetNotificationPath(notification.NotificationId, NotificationSubPaths.Overview); }
public async Task AcceptTransferAlert_CreatesTransferWithDateFromFormInsteadOfDateFromAlert() { // Arrange const int id = Utilities.NOTIFIED_WITH_ACTIVE_HOSPITAL; var treatmentEventsUrl = RouteHelper.GetNotificationPath(id, NotificationSubPaths.EditTreatmentEvents); var initialTreatmentEventsPage = await GetDocumentForUrlAsync(treatmentEventsUrl); Assert.Null(initialTreatmentEventsPage.QuerySelector("#treatment-events")); var url = GetCurrentPathForId(id); var initialDocument = await GetDocumentForUrlAsync(url); var formData = new Dictionary <string, string> { ["TransferRequest.AcceptTransfer"] = "true", ["FormattedTransferDate.Day"] = "3", ["FormattedTransferDate.Month"] = "12", ["FormattedTransferDate.Year"] = "2021", ["TransferRequest.TargetCaseManagerId"] = Utilities.CASEMANAGER_ABINGDON_ID.ToString(), ["TransferRequest.TargetHospitalId"] = Utilities.HOSPITAL_ABINGDON_COMMUNITY_HOSPITAL_ID }; // Act await Client.SendPostFormWithData(initialDocument, formData, url); var reloadedTreatmentEventsPage = await GetDocumentForUrlAsync(treatmentEventsUrl); // Assert var reloadedTreatmentEventsTable = reloadedTreatmentEventsPage.QuerySelector("#treatment-events"); Assert.Contains("Transfer in", reloadedTreatmentEventsTable.InnerHtml); Assert.Contains("03 Dec 2021", reloadedTreatmentEventsTable.TextContent); Assert.Contains("Transfer out", reloadedTreatmentEventsTable.InnerHtml); }
public async Task LastEditPage_HasNoSaveButton_ForDraftNonMDRRecord() { // Arrange const int id = Utilities.DRAFT_NOTIFICATION_WITH_DRAFT_ALERT; var lastEditPageUrl = RouteHelper.GetNotificationPath(id, NotificationSubPaths.EditTreatmentEvents); // Act var lastEditPage = await GetDocumentForUrlAsync(lastEditPageUrl); // Assert Assert.Null(lastEditPage.GetElementById("save-button")); }
public async Task Get_ReturnsEditPageWithAlert_IfDraftHasDraftAlert() { // Arrange const int id = Utilities.DRAFT_NOTIFICATION_WITH_DRAFT_ALERT; var patientEditPageUrl = RouteHelper.GetNotificationPath(id, NotificationSubPaths.EditPatientDetails); // Act var patientEditPage = await GetDocumentForUrlAsync(patientEditPageUrl); // Assert Assert.NotNull(patientEditPage.GetElementById("draft-alert-details")); }
public async Task EditTreatmentEventsPage_DoesNotContain_SaveButton() { // Arrange const int id = Utilities.NOTIFIED_ID; var editTreatmentEventsPageUrl = RouteHelper.GetNotificationPath(id, NotificationSubPaths.EditTreatmentEvents); // Act var editTreatmentEventsPage = await GetDocumentForUrlAsync(editTreatmentEventsPageUrl); var button = editTreatmentEventsPage.GetElementById("save-button"); // Assert Assert.Null(button); }
public async Task Get_ReturnsRedirectToOverview_ForReadOnlyUser() { // Arrange const int id = Utilities.DRAFT_NOTIFICATION_WITH_DRAFT_ALERT; using (var client = Factory.WithUserAuth(TestUser.ReadOnlyUser) .CreateClientWithoutRedirects()) { // Act var response = await client.GetAsync(RouteHelper.GetNotificationPath(id, NotificationSubPaths.EditPatientDetails)); // Assert response.AssertRedirectTo($"/Notifications/{id}"); } }
public async Task EditTreatmentEventsPage_HasContinueButton_WhenDraftRecordIsMDR() { // Arrange const int id = Utilities.DRAFT_ID; var lastEditPageUrl = RouteHelper.GetNotificationPath(id, NotificationSubPaths.EditTreatmentEvents); // Act var lastEditPage = await GetDocumentForUrlAsync(lastEditPageUrl); var button = lastEditPage.GetElementById("save-button"); // Assert Assert.NotNull(button); Assert.Equal("Continue", button.TextContent.Trim()); }
public async Task EditMDRDetailsPage_ContainsSaveButton() { // Arrange const int id = Utilities.MDR_DETAILS_EXIST; var editMDRDetailsPageUrl = RouteHelper.GetNotificationPath(id, NotificationSubPaths.EditMDRDetails); // Act var editMDRDetailsPage = await GetDocumentForUrlAsync(editMDRDetailsPageUrl); var button = editMDRDetailsPage.GetElementById("save-button"); // Assert Assert.NotNull(button); Assert.Equal("Save", button.TextContent.Trim()); }
public async Task AddPage_WhenModelValid_RedirectsToCollectionViewAndSavesChanges() { // Arrange const int id = Utilities.NOTIFICATION_ID_WITH_MBOVIS_ANIMAL_ENTITIES; var url = GetPathForId(NotificationSubPaths.AddMBovisAnimalExposure, id); var document = await GetDocumentForUrlAsync(url); // Act var formData = new Dictionary <string, string> { ["MBovisAnimalExposure.YearOfExposure"] = "2010", ["MBovisAnimalExposure.CountryId"] = "3", ["MBovisAnimalExposure.AnimalType"] = ((int)AnimalType.Pet).ToString(), ["MBovisAnimalExposure.Animal"] = "Badger", ["MBovisAnimalExposure.AnimalTbStatus"] = ((int)AnimalTbStatus.SuspectedTb).ToString(), ["MBovisAnimalExposure.ExposureDuration"] = "12", ["MBovisAnimalExposure.OtherDetails"] = "Some other testing details" }; var result = await Client.SendPostFormWithData(document, formData, url); // Assert result.AssertRedirectTo( RouteHelper.GetNotificationPath(id, NotificationSubPaths.EditMBovisAnimalExposures)); // Find the edit page for the newly added animal exposure event. We don't know what ID the database // will give this event, so we can't generate the URL. Instead, we take it from the event's edit link var animalExposuresDocument = await GetDocumentForUrlAsync(GetRedirectLocation(result)); var newAnimalExposureUrl = animalExposuresDocument.QuerySelectorAll(".notification-edit-link") .First() .Attributes .GetNamedItem("href") .Value; var newAnimalExposureDocument = await GetDocumentForUrlAsync(newAnimalExposureUrl); newAnimalExposureDocument.AssertInputTextValue("MBovisAnimalExposure_YearOfExposure", "2010"); newAnimalExposureDocument.AssertInputSelectValue("MBovisAnimalExposure_AnimalType", ((int)AnimalType.Pet).ToString()); newAnimalExposureDocument.AssertInputSelectValue("MBovisAnimalExposure_CountryId", "3"); newAnimalExposureDocument.AssertInputTextValue("MBovisAnimalExposure_Animal", "Badger"); newAnimalExposureDocument.AssertInputSelectValue("MBovisAnimalExposure_AnimalTbStatus", ((int)AnimalTbStatus.SuspectedTb).ToString()); newAnimalExposureDocument.AssertInputTextValue("MBovisAnimalExposure_ExposureDuration", "12"); newAnimalExposureDocument.AssertTextAreaValue("MBovisAnimalExposure_OtherDetails", "Some other testing details"); }
public async Task AddPage_WhenModelValid_RedirectsToCollectionViewAndSavesChanges() { // Arrange const int id = Utilities.NOTIFICATION_ID_WITH_MBOVIS_MILK_ENTITIES; var url = GetPathForId(NotificationSubPaths.AddMBovisUnpasteurisedMilkConsumption, id); var document = await GetDocumentForUrlAsync(url); // Act var formData = new Dictionary <string, string> { ["MBovisUnpasteurisedMilkConsumption.YearOfConsumption"] = "2010", ["MBovisUnpasteurisedMilkConsumption.CountryId"] = "3", ["MBovisUnpasteurisedMilkConsumption.MilkProductType"] = ((int)MilkProductType.Milk).ToString(), ["MBovisUnpasteurisedMilkConsumption.ConsumptionFrequency"] = ((int)ConsumptionFrequency.Occasionally).ToString(), ["MBovisUnpasteurisedMilkConsumption.OtherDetails"] = "Some other testing details" }; var result = await Client.SendPostFormWithData(document, formData, url); // Assert result.AssertRedirectTo( RouteHelper.GetNotificationPath(id, NotificationSubPaths.EditMBovisUnpasteurisedMilkConsumptions)); // Find the edit page for the newly added milk exposure event. We don't know what ID the database // will give this event, so we can't generate the URL. Instead, we take it from the event's edit link var milkExposureDocument = await GetDocumentForUrlAsync(GetRedirectLocation(result)); var milkExposureUrl = milkExposureDocument.QuerySelectorAll(".notification-edit-link") .First() .Attributes .GetNamedItem("href") .Value; var newMilkExposureDocument = await GetDocumentForUrlAsync(milkExposureUrl); newMilkExposureDocument.AssertInputTextValue("MBovisUnpasteurisedMilkConsumption_YearOfConsumption", "2010"); newMilkExposureDocument.AssertInputSelectValue("MBovisUnpasteurisedMilkConsumption_CountryId", "3"); newMilkExposureDocument.AssertInputSelectValue("MBovisUnpasteurisedMilkConsumption_MilkProductType", ((int)MilkProductType.Milk).ToString()); newMilkExposureDocument.AssertInputSelectValue("MBovisUnpasteurisedMilkConsumption_ConsumptionFrequency", ((int)ConsumptionFrequency.Occasionally).ToString()); newMilkExposureDocument.AssertTextAreaValue("MBovisUnpasteurisedMilkConsumption_OtherDetails", "Some other testing details"); }
public async Task AddPage_WhenModelValid_RedirectsToCollectionViewAndSavesChanges() { // Arrange const int id = Utilities.NOTIFICATION_ID_WITH_MBOVIS_OTHER_CASE_ENTITIES; var url = GetPathForId(NotificationSubPaths.AddMBovisExposureToKnownCase, id); var document = await GetDocumentForUrlAsync(url); // Act var formData = new Dictionary <string, string> { ["MBovisExposureToKnownCase.YearOfExposure"] = "2010", ["MBovisExposureToKnownCase.ExposureSetting"] = ((int)ExposureSetting.Pub).ToString(), ["MBovisExposureToKnownCase.NotifiedToPheStatus"] = ((int)Status.Yes).ToString(), ["MBovisExposureToKnownCase.ExposureNotificationId"] = $"{Utilities.NOTIFIED_ID}", ["MBovisExposureToKnownCase.OtherDetails"] = "Some other testing details" }; var result = await Client.SendPostFormWithData(document, formData, url); // Assert result.AssertRedirectTo( RouteHelper.GetNotificationPath(id, NotificationSubPaths.EditMBovisExposureToKnownCases)); // Find the edit page for the newly added known case exposure event. We don't know what ID the database // will give this event, so we can't generate the URL. Instead, we take it from the event's edit link var knownCasesExposureDocument = await GetDocumentForUrlAsync(GetRedirectLocation(result)); var knownCasesExposureUrl = knownCasesExposureDocument.QuerySelectorAll(".notification-edit-link") .First() .Attributes .GetNamedItem("href") .Value; var newKnownCaseExposureDocument = await GetDocumentForUrlAsync(knownCasesExposureUrl); newKnownCaseExposureDocument.AssertInputTextValue("MBovisExposureToKnownCase_YearOfExposure", "2010"); newKnownCaseExposureDocument.AssertInputSelectValue("MBovisExposureToKnownCase_ExposureSetting", ((int)ExposureSetting.Pub).ToString()); newKnownCaseExposureDocument.AssertInputRadioValue("notified-yes", true); newKnownCaseExposureDocument.AssertInputTextValue("MBovisExposureToKnownCase_ExposureNotificationId", $"{Utilities.NOTIFIED_ID}"); newKnownCaseExposureDocument.AssertTextAreaValue("MBovisExposureToKnownCase_OtherDetails", "Some other testing details"); }
public async Task DuplicateNhsNumber_ShowsWarningsWithExpectedIds(int pageNotificationId, List <int> expectedWarningNotificationIds) { // Arrange var url = GetCurrentPathForId(pageNotificationId); // Act var initialDocument = await GetDocumentForUrlAsync(url); // Assert Assert.False(initialDocument.GetElementById("nhs-number-warning").ClassList.Contains("hidden")); var linksContainer = initialDocument.GetElementById("nhs-number-links"); Assert.Equal(expectedWarningNotificationIds.Count, linksContainer.ChildElementCount); foreach (var notificationId in expectedWarningNotificationIds) { var warningUrl = RouteHelper.GetNotificationPath(notificationId, NotificationSubPaths.Overview); Assert.Equal($"#{notificationId}", linksContainer.QuerySelector($"a[href='{warningUrl}']").TextContent); } }
public async Task DismissRejectedTransferAlert_DismissesAlertOnOverviewPage() { // Arrange const int id = Utilities.NOTIFIED_ID; var overviewUrl = RouteHelper.GetNotificationPath(id, NotificationSubPaths.Overview); var initialOverviewPage = await GetDocumentForUrlAsync(overviewUrl); Assert.NotNull(initialOverviewPage.QuerySelector("#alert-20005")); var url = GetCurrentPathForId(id); var initialDocument = await GetDocumentForUrlAsync(url); // Act await Client.SendPostFormWithData(initialDocument, null, url); // Assert var resultOverviewPage = await GetDocumentForUrlAsync(overviewUrl); Assert.Null(resultOverviewPage.QuerySelector("#alert-20005")); }
public async Task AddPage_WhenModelValid_RedirectsToCollectionView() { // Arrange const int id = Utilities.NOTIFICATION_ID_WITH_MBOVIS_OTHER_CASE_ENTITIES; var url = GetPathForId(NotificationSubPaths.AddMBovisExposureToKnownCase, id); var document = await GetDocumentForUrlAsync(url); // Act var formData = new Dictionary <string, string> { ["MBovisExposureToKnownCase.YearOfExposure"] = "2000", ["MBovisExposureToKnownCase.ExposureSetting"] = ((int)ExposureSetting.Household).ToString(), ["MBovisExposureToKnownCase.ExposureNotificationId"] = $"{Utilities.NOTIFIED_ID}" }; var result = await Client.SendPostFormWithData(document, formData, url); // Assert result.AssertRedirectTo( RouteHelper.GetNotificationPath(id, NotificationSubPaths.EditMBovisExposureToKnownCases)); }
public async Task AddPage_WhenModelValid_RedirectsToCollectionView() { // Arrange const int id = Utilities.NOTIFICATION_ID_WITH_MBOVIS_OCCUPATION_ENTITIES; var url = GetPathForId(NotificationSubPaths.AddMBovisOccupationExposure, id); var document = await GetDocumentForUrlAsync(url); // Act var formData = new Dictionary <string, string> { ["MBovisOccupationExposure.YearOfExposure"] = "2000", ["MBovisOccupationExposure.CountryId"] = "1", ["MBovisOccupationExposure.OccupationSetting"] = ((int)OccupationSetting.Farm).ToString(), ["MBovisOccupationExposure.OccupationDuration"] = "1" }; var result = await Client.SendPostFormWithData(document, formData, url); // Assert result.AssertRedirectTo( RouteHelper.GetNotificationPath(id, NotificationSubPaths.EditMBovisOccupationExposures)); }
public async Task OnGetNhsNumberDuplicates_ReturnsExpectedResponseForGroupedDuplicateNhsNumber() { // Arrange const int id = Utilities.PATIENT_GROUPED_NOTIFIED_NOTIFICATION_SHARED_NHS_NUMBER; const string nhsNumber = Utilities.NHS_NUMBER_SHARED; var formData = new Dictionary <string, string> { ["notificationId"] = id.ToString(), ["nhsNumber"] = nhsNumber }; const int expectedWarningNotificationId = Utilities.PATIENT_NOTIFIED_NOTIFICATION_SHARED_NHS_NUMBER; var expectedWarningUrl = RouteHelper.GetNotificationPath(expectedWarningNotificationId, NotificationSubPaths.Overview); // Act var response = await Client.GetAsync(GetHandlerPath(formData, "NhsNumberDuplicates", id)); // Assert var result = await response.Content.ReadAsStringAsync(); Assert.Contains($"\"{expectedWarningNotificationId}\":\"{expectedWarningUrl}\"", result); }
public async Task AddPage_WhenModelValid_RedirectsToCollectionView() { // Arrange const int id = Utilities.NOTIFICATION_ID_WITH_MBOVIS_MILK_ENTITIES; var url = GetPathForId(NotificationSubPaths.AddMBovisUnpasteurisedMilkConsumption, id); var document = await GetDocumentForUrlAsync(url); // Act var formData = new Dictionary <string, string> { ["MBovisUnpasteurisedMilkConsumption.YearOfConsumption"] = "2000", ["MBovisUnpasteurisedMilkConsumption.CountryId"] = "1", ["MBovisUnpasteurisedMilkConsumption.MilkProductType"] = ((int)MilkProductType.Cheese).ToString(), ["MBovisUnpasteurisedMilkConsumption.ConsumptionFrequency"] = ((int)ConsumptionFrequency.Occasionally).ToString() }; var result = await Client.SendPostFormWithData(document, formData, url); // Assert result.AssertRedirectTo( RouteHelper.GetNotificationPath(id, NotificationSubPaths.EditMBovisUnpasteurisedMilkConsumptions)); }
private async Task <Dictionary <string, string> > GenerateDuplicateNhsNumberNotificationUrlsAsync(string nhsNumber, NotificationGroup group) { // If NhsNumber is empty or does not pass validation - return null // Potential duplication of validation here so that both Server and Dynamic/JS routes to warnings // can use the same method. if (string.IsNullOrEmpty(nhsNumber) || !string.IsNullOrEmpty( ValidationService.GetPropertyValidationResult <PatientDetails>("NhsNumber", nhsNumber, false).Content)) { return(null); } var notificationIds = await NotificationRepository.GetNotificationIdsByNhsNumberAsync(nhsNumber); var idsInGroup = group?.Notifications?.Select(n => n.NotificationId) ?? new List <int>(); var filteredIds = notificationIds .Except(idsInGroup) .Where(n => n != NotificationId) .ToDictionary( id => id.ToString(), id => RouteHelper.GetNotificationPath(id, NotificationSubPaths.Overview)); return(filteredIds); }
public async Task AddPage_WhenModelValid_RedirectsToCollectionView() { // Arrange const int id = Utilities.NOTIFICATION_ID_WITH_MBOVIS_ANIMAL_ENTITIES; var url = GetPathForId(NotificationSubPaths.AddMBovisAnimalExposure, id); var document = await GetDocumentForUrlAsync(url); // Act var formData = new Dictionary <string, string> { ["MBovisAnimalExposure.YearOfExposure"] = "2010", ["MBovisAnimalExposure.CountryId"] = "1", ["MBovisAnimalExposure.AnimalType"] = ((int)AnimalType.WildAnimal).ToString(), ["MBovisAnimalExposure.Animal"] = "Badger", ["MBovisAnimalExposure.AnimalTbStatus"] = ((int)AnimalTbStatus.ConfirmedTb).ToString(), ["MBovisAnimalExposure.ExposureDuration"] = "1", }; var result = await Client.SendPostFormWithData(document, formData, url); // Assert result.AssertRedirectTo( RouteHelper.GetNotificationPath(id, NotificationSubPaths.EditMBovisAnimalExposures)); }
protected string GetPathForId(string subPath, int id, Dictionary <string, string> queryDictionary = null) { return(RouteHelper.GetNotificationPath(id, subPath, queryDictionary)); }