diff --git a/src/Apps/W1/EDocumentConnectors/Continia/App/src/Onboarding/ContiniaOnboardingGuide.Page.al b/src/Apps/W1/EDocumentConnectors/Continia/App/src/Onboarding/ContiniaOnboardingGuide.Page.al index 4ce1aa9001..ebb8fe336a 100644 --- a/src/Apps/W1/EDocumentConnectors/Continia/App/src/Onboarding/ContiniaOnboardingGuide.Page.al +++ b/src/Apps/W1/EDocumentConnectors/Continia/App/src/Onboarding/ContiniaOnboardingGuide.Page.al @@ -1014,7 +1014,7 @@ page 6393 "Continia Onboarding Guide" OnboardingHelper.GetCurrentActivatedProfiles(TempParticipation, TempActivatedProfiles); CurrPage.SelectProfilesPeppol.Page.ClearProfileSelections(); - CurrPage.SelectProfilesPeppol.Page.SetCurrentNetwork(TempParticipation.Network); + CurrPage.SelectProfilesPeppol.Page.SetCurrentParticipation(TempParticipation); CurrPage.SelectProfilesPeppol.Page.SetProfileSelection(TempActivatedProfiles); end; @@ -1069,7 +1069,7 @@ page 6393 "Continia Onboarding Guide" TempActivatedProfiles.DeleteAll(); GetSelectedNetworksProfiles(TempActivatedProfiles); - CurrPage.SelectProfilesPeppol.Page.SetCurrentNetwork(TempParticipation.Network); + CurrPage.SelectProfilesPeppol.Page.SetCurrentParticipation(TempParticipation); CurrPage.SelectProfilesPeppol.Page.ClearProfileSelections(); CurrPage.SelectProfilesPeppol.Page.SetProfileSelection(TempActivatedProfiles); end; diff --git a/src/Apps/W1/EDocumentConnectors/Continia/App/src/Onboarding/ContiniaProfileSelection.Page.al b/src/Apps/W1/EDocumentConnectors/Continia/App/src/Onboarding/ContiniaProfileSelection.Page.al index 07a5e44ac3..f368891e04 100644 --- a/src/Apps/W1/EDocumentConnectors/Continia/App/src/Onboarding/ContiniaProfileSelection.Page.al +++ b/src/Apps/W1/EDocumentConnectors/Continia/App/src/Onboarding/ContiniaProfileSelection.Page.al @@ -32,7 +32,7 @@ page 6394 "Continia Profile Selection" NetworkProfileList: Page "Continia Network Profile List"; begin NetworkProfile.FilterGroup(2); - NetworkProfile.SetRange(Network, CurrentNetwork); + NetworkProfile.SetRange(Network, CurrentParticipation.Network); NetworkProfile.FilterGroup(0); NetworkProfileList.LookupMode(true); @@ -46,6 +46,9 @@ page 6394 "Continia Profile Selection" NetworkProfileList.SetRecord(NetworkProfile); if NetworkProfileList.RunModal() = Action::LookupOK then begin NetworkProfileList.GetRecord(NetworkProfile); + Rec.Network := CurrentParticipation.Network; + Rec."Identifier Type Id" := CurrentParticipation."Identifier Type Id"; + Rec."Identifier Value" := CurrentParticipation."Identifier Value"; Rec."Network Profile Id" := NetworkProfile.Id; ProfileName := NetworkProfile.Description; Text := NetworkProfile.Description; @@ -143,12 +146,12 @@ page 6394 "Continia Profile Selection" ActivatedNetworkProfiles := Original; end; - internal procedure SetCurrentNetwork(NewCurrentNetwork: Enum "Continia E-Delivery Network") + internal procedure SetCurrentParticipation(ContiniaParticipation: Record "Continia Participation") begin - CurrentNetwork := NewCurrentNetwork; + CurrentParticipation := ContiniaParticipation; end; var - CurrentNetwork: Enum "Continia E-Delivery Network"; + CurrentParticipation: Record "Continia Participation"; } diff --git a/src/Apps/W1/EDocumentConnectors/Continia/Test/src/ContiniaMockHttpHandler.Codeunit.al b/src/Apps/W1/EDocumentConnectors/Continia/Test/src/ContiniaMockHttpHandler.Codeunit.al index ac5cf5e9d7..71d8d753d9 100644 --- a/src/Apps/W1/EDocumentConnectors/Continia/Test/src/ContiniaMockHttpHandler.Codeunit.al +++ b/src/Apps/W1/EDocumentConnectors/Continia/Test/src/ContiniaMockHttpHandler.Codeunit.al @@ -148,9 +148,12 @@ codeunit 148201 "Continia Mock Http Handler" local procedure GetResponse(var Request: TestHttpRequestMessage; DictionaryKey: Text) HttpResponseMessage: TestHttpResponseMessage var + NoMockResponseFoundErr: Label 'No mock response found for request: %1 %2', Comment = '%1 = Method, %2 = Request Path'; Headers: Dictionary of [Text, Text]; HeaderName: Text; begin + if not ResponseStatusCodes.ContainsKey(DictionaryKey) then + Error(NoMockResponseFoundErr, Format(Request.RequestType), Request.Path); HttpResponseMessage.HttpStatusCode := ResponseStatusCodes.Get(DictionaryKey); HttpResponseMessage.Content().WriteFrom(ReplaceContentPlaceholders(ResponseContents.Get(DictionaryKey), Request.Path)); diff --git a/src/Apps/W1/EDocumentConnectors/Continia/Test/src/ContiniaRegIntegrTests.Codeunit.al b/src/Apps/W1/EDocumentConnectors/Continia/Test/src/ContiniaRegIntegrTests.Codeunit.al index 24a5f99713..85b1ca9481 100644 --- a/src/Apps/W1/EDocumentConnectors/Continia/Test/src/ContiniaRegIntegrTests.Codeunit.al +++ b/src/Apps/W1/EDocumentConnectors/Continia/Test/src/ContiniaRegIntegrTests.Codeunit.al @@ -978,6 +978,232 @@ codeunit 148204 "Continia Reg. Integr. Tests" EDocServicePage.Close(); end; + /// + /// Scenario: This test case focuses on the advanced setup step of the onboarding wizard for the Nemhandel network. + /// It ensures that the advanced setup page is displayed correctly when registering for the Nemhandel network and that + /// correct data is passed to the integration procedures. + /// + [Test] + [HandlerFunctions('HttpClientHandler,HandleNemhandelProfileSelection')] + procedure Registration_Nemhandel_AdvancedSetup() + var + EDocServicePage: TestPage "E-Document Service"; + ExtConnectionSetup: TestPage "Continia Ext. Connection Setup"; + OnboardingGuide: TestPage "Continia Onboarding Guide"; + Participations: TestPage "Continia Participations"; + NetworkProfileList: TestPage "Continia Network Profile List"; + begin + Initialize(); + + // [Given] Filled Company Information + CompanyInformation."Country/Region Code" := 'DK'; + CompanyInformation."VAT Registration No." := '123456789'; + CompanyInformation.Modify(true); + + LibraryPermission.SetTeamMember(); + LibraryPermission.AddPermissionSet('E-Doc. Core - Edit'); + + // [When] Open eDocument Service + EDocServicePage.OpenView(); + EDocServicePage.GoToRecord(EDocumentService); + + // [When] Open Setup Service Integration + ExtConnectionSetup.Trap(); + EDocServicePage.SetupServiceIntegration.Invoke(); + + // [Then] Validate No Of Participations is 0 + Assert.AreEqual('0', ExtConnectionSetup.NoOfParticipations.Value, IncorrectValueErr); + + // [When] Click on Register New Participation and on CDN Onboarding Click Next + OnboardingGuide.Trap(); + ExtConnectionSetup.RegisterNewParticipation.Invoke(); + OnboardingGuide.ActionNext.Invoke(); + Commit(); + + // [When] Fill Creadentials and press Next + OnboardingGuide.PartnerUserName.SetValue('PartnerUserName@contoso.com'); + OnboardingGuide.PartnerPassword.SetValue('PartnerPassword'); + ContiniaMockHttpHandler.ClearHandler(); + ContiniaMockHttpHandler.AddResponse( + HttpRequestType::Post, + ContiniaApiUrlMgt.PartnerAccessTokenUrl(), + 200, + GetMockResponseContent('PartnerZoneLogin200.txt') + ); + ContiniaMockHttpHandler.AddResponse( + HttpRequestType::Post, + ContiniaApiUrlMgt.ClientEnvironmentInitializeUrl(), + 200, + GetMockResponseContent('InitializeClient200.txt') + ); + ContiniaMockHttpHandler.AddResponse( + HttpRequestType::Post, + ContiniaApiUrlMgt.PartnerZoneUrl(), + 200, + GetMockResponseContent('PartnerZoneConnect200.txt') + ); + ContiniaMockHttpHandler.AddResponse( + HttpRequestType::Get, + ContiniaApiUrlMgt.NetworkIdentifiersUrl(Enum::"Continia E-Delivery Network"::Peppol, 1, 100), + 200, + GetMockResponseContent('PeppolNetworkIdTypes200.txt') + ); + ContiniaMockHttpHandler.AddResponse( + HttpRequestType::Get, + ContiniaApiUrlMgt.NetworkIdentifiersUrl(Enum::"Continia E-Delivery Network"::Nemhandel, 1, 100), + 200, + GetMockResponseContent('NemhandelNetworkIdTypes200.txt') + ); + ContiniaMockHttpHandler.AddResponse( + HttpRequestType::Get, + ContiniaApiUrlMgt.NetworkProfilesUrl(Enum::"Continia E-Delivery Network"::Peppol, 1, 100), + 200, + GetMockResponseContent('PeppolNetworkProfiles200.txt') + ); + ContiniaMockHttpHandler.AddResponse( + HttpRequestType::Get, + ContiniaApiUrlMgt.NetworkProfilesUrl(Enum::"Continia E-Delivery Network"::Nemhandel, 1, 100), + 200, + GetMockResponseContent('NemhandelNetworkProfiles200.txt') + ); + + OnboardingGuide.ActionNext.Invoke(); + Commit(); + + // [When] fill mandatory information and click Next + OnboardingGuide."Signatory Name".SetValue('Signatory Name'); + OnboardingGuide."Signatory Email".SetValue('signatory@email.address'); + OnboardingGuide.LicenseTerms.SetValue(true); + OnboardingGuide.ActionNext.Invoke(); + Commit(); + + // [When] fill mandatory information + OnboardingGuide.CompanyContactName.SetValue('Company Contact Name'); + OnboardingGuide.CompanyContactVAT.SetValue('123456789'); + OnboardingGuide.CompanyContactAddress.SetValue('CompanyContact Address'); + OnboardingGuide.CompanyContactPostCode.SetValue('111222'); + OnboardingGuide.CompanyContactCounty.SetValue('Company Contact County'); + OnboardingGuide.CompanyContactCountryRegion.SetValue(CompanyInformation."Country/Region Code"); + OnboardingGuide.CompanyContactPersonName.SetValue('Contact Name'); + OnboardingGuide.CompanyContactPersonEmail.SetValue('contact@email.address'); + OnboardingGuide.CompanyContactPersonPhoneNo.SetValue('999888777'); + // [When] click Next + OnboardingGuide.ActionNext.Invoke(); + Commit(); + + // [When] Select Nemhandel network + OnboardingGuide.Network.SetValue('Nemhandel'); + + // [Then] Validate Identifier Type and Company Identifier Value are set correctly + Assert.AreEqual('DK:CVR', OnboardingGuide.IdentifierTypeDesc.Value, 'Identifier Type should be set to CRV for Nemhandel network'); + Assert.AreEqual(CompanyInformation."VAT Registration No.", OnboardingGuide.CompanyIdentifierValue.Value, 'Company Identifier Value should be set to VAT number from Company'); + + // [When] click Next + OnboardingGuide.ActionNext.Invoke(); + + Commit(); + + // [Then] Document Types selection step opens + Assert.AreEqual(false, OnboardingGuide.Network.Visible(), 'Participation Network registration details should not be visible'); + Assert.AreEqual(true, OnboardingGuide.SendInvoiceCreditMemo.Visible(), 'Document Types selection should be visible'); + + // [When] Select Document Types and Expect Participation registered externally and click Next + OnboardingGuide.SendInvoiceCreditMemo.SetValue(true); + // [When] click Advanced Setup + OnboardingGuide.ActionAdvancedSetup.Invoke(); + Commit(); + + // [Then] Advanced Setup step opens + Assert.AreEqual(false, OnboardingGuide.SendInvoiceCreditMemo.Visible(), 'Document Types selection should not be visible'); + Assert.AreEqual(true, OnboardingGuide.SelectProfilesPeppol."Profile Name".Visible(), 'Advanced Setup should be visible'); + + // [When] assign E-Document Service Code on each record + OnboardingGuide.SelectProfilesPeppol.First(); + repeat + if OnboardingGuide.SelectProfilesPeppol."Profile Name".Value <> '' then + OnboardingGuide.SelectProfilesPeppol."E-Document Service Code".SetValue(EDocumentService.Code); + until not OnboardingGuide.SelectProfilesPeppol.Next(); + + // [When] Add additional profile in advanced setup + OnboardingGuide.SelectProfilesPeppol.Last(); + OnboardingGuide.SelectProfilesPeppol.Next(); + OnboardingGuide.SelectProfilesPeppol."Profile Name".Lookup(); + + // [Then] Network Profile List opens with Nemhandel filter applied + // HandleNemhandelProfileSelection() + + // [When] Participation is not registered externally and click Next + ContiniaMockHttpHandler.ClearHandler(); + ContiniaMockHttpHandler.AddResponse( + HttpRequestType::Get, + ContiniaApiUrlMgt.ParticipationLookupUrl( + Enum::"Continia E-Delivery Network"::Nemhandel, + CopyStr(OnboardingGuide.IdentifierTypeDesc.Value, 1, 4), + CopyStr(OnboardingGuide.CompanyIdentifierValue.Value, 1, 50)), + 200, + GetMockResponseContent('ParticipationLookup200.txt')); + OnboardingGuide.ActionNext.Invoke(); + + // [Then] Last step opens + Assert.AreEqual(false, OnboardingGuide.SelectProfilesPeppol."Profile Name".Visible(), 'Advanced Setup should not be visible'); + Assert.AreEqual(false, OnboardingGuide.ActionNext.Enabled(), 'Next must be disabled'); + Assert.AreEqual(true, OnboardingGuide.ActionFinish.Enabled(), 'Finish must be enabled'); + + // [When] click Finish + ContiniaMockHttpHandler.ClearHandler(); + ContiniaMockHttpHandler.AddResponse( + HttpRequestType::Post, + ContiniaApiUrlMgt.UpdateSubscriptionUrl(), + 200, + GetMockResponseContent('UpdateSubscription200.txt')); + ContiniaMockHttpHandler.AddResponse( + HttpRequestType::Post, + ContiniaApiUrlMgt.GetAcceptCompanyLicenseUrl(), + 200, + GetMockResponseContent('AcceptCompanyLicense200.txt')); + ContiniaMockHttpHandler.AddResponse( + HttpRequestType::Post, + ContiniaApiUrlMgt.ParticipationUrl(Enum::"Continia E-Delivery Network"::Nemhandel), + 200, + GetMockResponseContent('Participation200-Draft.txt')); + ContiniaMockHttpHandler.AddResponse( + HttpRequestType::Post, + ContiniaApiUrlMgt.ParticipationProfilesUrl(Enum::"Continia E-Delivery Network"::Nemhandel, ConnectorLibrary.ParticipationId(true)), + 200, + GetMockResponseContent('ParticipationProfile200-randomId.txt')); + ContiniaMockHttpHandler.AddResponse( + HttpRequestType::Patch, + ContiniaApiUrlMgt.SingleParticipationUrl(Enum::"Continia E-Delivery Network"::Nemhandel, ConnectorLibrary.ParticipationId(true)), + 200, + GetMockResponseContent('Participation200-InProcess.txt')); + ContiniaMockHttpHandler.AddResponse( + HttpRequestType::Get, + ContiniaApiUrlMgt.SingleParticipationUrl(Enum::"Continia E-Delivery Network"::Nemhandel, ConnectorLibrary.ParticipationId(true)), + 200, + GetMockResponseContent('Participation200-InProcess.txt')); + ContiniaMockHttpHandler.AddResponse( + HttpRequestType::Get, + ContiniaApiUrlMgt.ParticipationProfilesUrl(Enum::"Continia E-Delivery Network"::Nemhandel, ConnectorLibrary.ParticipationId(true), 1, 100), + 200, + GetMockResponseContent('ParticipationProfile200-randomId.txt')); + OnboardingGuide.ActionFinish.Invoke(); + Commit(); + + // [Then] Participation is created in pending state + Assert.AreEqual('1', ExtConnectionSetup.NoOfParticipations.Value, IncorrectValueErr); + Participations.Trap(); + ExtConnectionSetup.NoOfParticipations.Drilldown(); + Participations.First(); + Assert.AreEqual(Format(ConnectorLibrary.ParticipationId(true)).ToLower(), Participations.Id.Value, IncorrectValueErr); + Assert.AreEqual(Format(Enum::"Continia Registration Status"::InProcess), Participations.RegistrationStatus.Value, IncorrectValueErr); + + // [Then] Activated network profiles created + ValidateActivatedNetworkProfiles(); + + ExtConnectionSetup.Close(); + EDocServicePage.Close(); + end; + local procedure TestActivatedNetworkProfiles(Participation: Record "Continia Participation"; NetworkProfileIds: List of [Guid]; Disabled: Boolean) var ActivatedNetProf: Record "Continia Activated Net. Prof."; @@ -1070,6 +1296,15 @@ codeunit 148204 "Continia Reg. Integr. Tests" Response := ContiniaMockHttpHandler.GetResponse(Request); end; + [ModalPageHandler] + procedure HandleNemhandelProfileSelection(var NetworkProfileList: TestPage "Continia Network Profile List") + begin + Assert.AreEqual(Enum::"Continia E-Delivery Network"::Nemhandel.AsInteger().ToText(), NetworkProfileList.Filter.GetFilter(NetworkProfileList.Filter.Network), 'Network filter should be set to Nemhandel'); + NetworkProfileList.Filter.SetFilter(NetworkProfileList.Filter."Process Identifier", 'Procurement-BilSim-1.0'); + NetworkProfileList.First(); + NetworkProfileList.OK().Invoke(); + end; + var CompanyInformation: Record "Company Information"; Customer: Record Customer;