Skip to content
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

Refactor AppSource Gallery tests to use test library #610

Merged
merged 65 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
87bdee7
Fixes and create json utilities codeunit
blrobl Feb 12, 2024
aa7cbb3
Coduenit for language and market functionality
blrobl Feb 12, 2024
a12ff70
Use Pascal casing
blrobl Feb 12, 2024
a06c3cd
code review
blrobl Feb 12, 2024
6649ee7
Move Open App Source action to page lvl
blrobl Feb 13, 2024
e09791b
fix
blrobl Feb 13, 2024
e41630c
Several minor fixes
blrobl Feb 13, 2024
ef956da
Merge branch 'main' of https://github.com/microsoft/BCApps into priva…
SBalslev Feb 14, 2024
27a6274
Catch if princingTypes does not exist
SBalslev Feb 14, 2024
2e1dbe8
Do nto show publisher type by default.
SBalslev Feb 14, 2024
39fb63a
Clean unused vars
SBalslev Feb 14, 2024
f59ccaa
Rename file to match object name
SBalslev Feb 14, 2024
cf3beef
Remove unused variables, make rating count visible and reorganize col…
SBalslev Feb 14, 2024
ef99fff
Update test to reflect rename of method
SBalslev Feb 14, 2024
4d0dc92
Rename field caption
SBalslev Feb 14, 2024
82160fc
Rename parameter to avoid name conflict
SBalslev Feb 14, 2024
e3ff597
fix
blrobl Feb 14, 2024
e81e95e
set focus on the top of the page by findset
SBalslev Feb 14, 2024
ec57367
Ensure dependency is interface after refactoring.
SBalslev Feb 14, 2024
e842a1b
Eula
blrobl Feb 14, 2024
04dd108
Merge branch 'private/brobledodiaz/appsource-gallery-fixes' of https:…
blrobl Feb 14, 2024
eec267a
Update test after refactoring
SBalslev Feb 14, 2024
0688d6a
Merge branch 'private/brobledodiaz/appsource-gallery-fixes' of https:…
SBalslev Feb 14, 2024
2e2bb39
Update casing
SBalslev Feb 14, 2024
4904f33
fix
blrobl Feb 14, 2024
e100abb
Merge branch 'private/brobledodiaz/appsource-gallery-fixes' of https:…
blrobl Feb 14, 2024
448157b
Update to use UriBuilder.AddODataQueryParameter
SBalslev Feb 15, 2024
2f38ac5
Merge branch 'private/brobledodiaz/appsource-gallery-fixes' of https:…
SBalslev Feb 15, 2024
beccc2d
Simplify can install
SBalslev Feb 15, 2024
97e50cb
Move "AppSource Market Locale Helper" to manager codeunit
blrobl Feb 15, 2024
79fd00b
Merge branch 'private/brobledodiaz/appsource-gallery-fixes' of https:…
blrobl Feb 15, 2024
54fb8a7
presever filters and fix error on loading products
blrobl Feb 15, 2024
4feb2af
sort on name
blrobl Feb 15, 2024
d1bdf69
code review
blrobl Feb 15, 2024
78acc41
fix implicit with error
blrobl Feb 15, 2024
54ebee2
Fix codecop
blrobl Feb 15, 2024
163305d
0 index array should stop at L-1
SBalslev Feb 15, 2024
fbc920d
typos
blrobl Feb 16, 2024
7d191a7
Merge branch 'private/brobledodiaz/appsource-gallery-fixes' of https:…
blrobl Feb 16, 2024
5188c6c
Add scope
SBalslev Feb 16, 2024
fe81efd
fix keyvault access
blrobl Feb 16, 2024
ad944e6
Merge branch 'private/brobledodiaz/appsource-gallery-fixes' of https:…
blrobl Feb 16, 2024
99d1f53
clean
blrobl Feb 16, 2024
6885bce
delete redundant methods
blrobl Feb 16, 2024
7e0a566
codecop
blrobl Feb 16, 2024
d06127f
fix AA0005
blrobl Feb 19, 2024
259bb82
use dependencies SetCommonHeaders
blrobl Feb 19, 2024
bd1231c
do not call SetCommonHeaders in tests
blrobl Feb 19, 2024
94e85ea
check if saas
blrobl Feb 19, 2024
81201ad
clean
blrobl Feb 19, 2024
9e85e26
refactor tests
blrobl Feb 20, 2024
79b7151
fix accesibility
blrobl Feb 21, 2024
2c2dbff
minor changes
blrobl Feb 21, 2024
b14cc5e
Merge branch 'main' of https://github.com/microsoft/BCApps into priva…
blrobl Feb 21, 2024
e1c7e7f
fix bad merge
blrobl Feb 21, 2024
67df75b
fix compiler diagnostics
blrobl Feb 21, 2024
d4d7f9a
add restclient dependency
blrobl Feb 21, 2024
dd889f1
Add user settings library
blrobl Feb 21, 2024
94983aa
detatch dependency provider
blrobl Feb 21, 2024
61a8625
use unique codeunit id
blrobl Feb 21, 2024
fd173e2
code review
blrobl Feb 22, 2024
6dea2f4
tests
blrobl Feb 26, 2024
547527b
merge main
blrobl Feb 26, 2024
cb64f2b
refactor faulty test
blrobl Feb 26, 2024
a0fdb73
Reset filters and records between tests
blrobl Feb 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions src/System Application/App/AppSource Gallery/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,19 @@
}
],
"internalsVisibleTo": [
{
"name": "AppSource Product Gallery Test",
"id": "c1830429-77f6-4469-837a-7bfd4705ff41",
"publisher": "Microsoft"
}
],
"screenshots": [

],
"platform": "24.0.0.0",
"idRanges": [
{
"from": 2515,
"to": 2517
}
],
"target": "OnPrem"
{
"id": "ba17b564-d600-44d5-be0b-ca7ff7ac28fc",
"name": "AppSource Gallery Test Library",
"publisher": "Microsoft"
}
],
"screenshots": [],
"platform": "24.0.0.0",
"idRanges": [
{
"from": 2515,
"to": 2518
}
],
"target": "OnPrem"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace System.Apps.AppSource;

/// <summary>
/// Library for managing AppSource product retrival and usage.
/// Library for managing AppSource product retrieval and usage.
/// </summary>
codeunit 2516 "AppSource Json Utilities"
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ using System.Environment.Configuration;
using System.Globalization;
using System.Azure.Identity;
using System.Utilities;
using System.Environment;
using System.Azure.KeyVault;
using System.RestClient;

/// <summary>
/// Library for managing AppSource product retrival and usage.
/// Library for managing AppSource product retrieval and usage.
/// </summary>
codeunit 2515 "AppSource Product Manager" implements "AppSource Product Manager Dependencies"
codeunit 2515 "AppSource Product Manager"
{
Access = Internal;
InherentEntitlements = X;
Expand All @@ -39,66 +38,6 @@ codeunit 2515 "AppSource Product Manager" implements "AppSource Product Manager
UnsupportedLanguageNotificationLbl: Label 'Language %1 is not supported by AppSource. Defaulting to "en". Change the language in the user profile to use another language.', Comment = '%1=Language ID, such as en';
UnsupportedMarketNotificationLbl: Label 'Market %1 is not supported by AppSource. Defaulting to "us". Change the region in the user profile to use another market.', Comment = '%1=Market ID, such as "us"';

#region Dependency Interface implementation
procedure GetCountryLetterCode(): Code[2]
var
AzureAdTenant: Codeunit "Azure AD Tenant";
begin
exit(AzureAdTenant.GetCountryLetterCode());
end;

procedure GetPreferredLanguage(): Text
var
AzureAdTenant: Codeunit "Azure AD Tenant";
begin
exit(AzureAdTenant.GetPreferredLanguage());
end;

procedure GetApplicationFamily(): Text
var
EnvironmentInformation: Codeunit "Environment Information";
begin
exit(EnvironmentInformation.GetApplicationFamily());
end;

procedure IsSaas(): boolean
var
EnvironmentInformation: Codeunit "Environment Information";
begin
exit(EnvironmentInformation.IsSaas());
end;

procedure GetFormatRegionOrDefault(FormatRegion: Text[80]): Text
var
Language: Codeunit Language;
begin
exit(Language.GetFormatRegionOrDefault(FormatRegion));
end;

procedure GetAsJSon(var RestClient: Codeunit "Rest Client"; RequestUri: Text): JsonToken
begin
exit(RestClient.GetAsJSon(RequestUri));
end;

procedure GetUserSettings(UserSecurityId: Guid; var TempUserSettingsRecord: record "User Settings" temporary)
var
UserSettings: Codeunit "User Settings";
begin
UserSettings.GetUserSettings(Database.UserSecurityID(), TempUserSettingsRecord);
end;

procedure ShouldSetCommonHeaders(): Boolean
begin
exit(true);
end;

#endregion
procedure SetDependencies(SpecificDependencies: Interface "AppSource Product Manager Dependencies")
begin
AppSourceProductManagerDependencies := SpecificDependencies;
IsDependenciesInterfaceSet := true;
end;

#region Product helpers
/// <summary>
/// Opens Microsoft AppSource web page for the region is specified in the UserSessionSettings or 'en-us' by default.
Expand Down Expand Up @@ -494,9 +433,14 @@ codeunit 2515 "AppSource Product Manager" implements "AppSource Product Manager

local procedure SetDefaultDependencyImplementation()
var
AppSourceProductManager: Codeunit "AppSource Product Manager";
AppSrcProductDepsProvider: Codeunit "AppSrc Product Deps. Provider";
begin
SetDependencies(AppSrcProductDepsProvider);
end;

internal procedure SetDependencies(AppSourceProductManagerDependencyProvider: Interface "AppSource Product Manager Dependencies")
begin
SetDependencies(AppSourceProductManager);
AppSourceProductManagerDependencies := AppSourceProductManagerDependencyProvider;
IsDependenciesInterfaceSet := true;
end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace System.Apps.AppSource;

using System.Environment.Configuration;
using System.Globalization;
using System.Azure.Identity;
using System.Environment;
using System.RestClient;

/// <summary>
/// Provides the dependencies used by the AppSource Gallery module.
/// </summary>
codeunit 2518 "AppSrc Product Deps. Provider" implements "AppSource Product Manager Dependencies"
{
Access = Internal;
InherentEntitlements = X;
InherentPermissions = X;

procedure GetCountryLetterCode(): Code[2]
var
AzureAdTenant: Codeunit "Azure AD Tenant";
begin
exit(AzureAdTenant.GetCountryLetterCode());
end;

procedure GetPreferredLanguage(): Text
var
AzureAdTenant: Codeunit "Azure AD Tenant";
begin
exit(AzureAdTenant.GetPreferredLanguage());
end;

procedure GetApplicationFamily(): Text
var
EnvironmentInformation: Codeunit "Environment Information";
begin
exit(EnvironmentInformation.GetApplicationFamily());
end;

procedure IsSaas(): boolean
var
EnvironmentInformation: Codeunit "Environment Information";
begin
exit(EnvironmentInformation.IsSaas());
end;

procedure GetFormatRegionOrDefault(FormatRegion: Text[80]): Text
var
Language: Codeunit Language;
begin
exit(Language.GetFormatRegionOrDefault(FormatRegion));
end;

procedure GetAsJSon(var RestClient: Codeunit "Rest Client"; RequestUri: Text): JsonToken
begin
exit(RestClient.GetAsJSon(RequestUri));
end;

procedure GetUserSettings(UserSecurityId: Guid; var TempUserSettingsRecord: record "User Settings" temporary)
var
UserSettings: Codeunit "User Settings";
begin
UserSettings.GetUserSettings(Database.UserSecurityID(), TempUserSettingsRecord);
end;

procedure ShouldSetCommonHeaders(): Boolean
begin
exit(true);
end;
}
48 changes: 48 additions & 0 deletions src/System Application/Test Library/AppSource Gallery/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"id": "ba17b564-d600-44d5-be0b-ca7ff7ac28fc",
"name": "AppSource Gallery Test Library",
"publisher": "Microsoft",
"brief": "Test objects for the AppSource Gallery module.",
"description": "Test objects for the AppSource Gallery module.",
"version": "25.0.0.0",
"privacyStatement": "https://go.microsoft.com/fwlink/?LinkId=724009",
"EULA": "https://go.microsoft.com/fwlink/?linkid=2009120",
"help": "",
"url": "https://go.microsoft.com/fwlink/?LinkId=724011",
"logo": "",
"dependencies": [
{
"id": "79952567-63d7-4586-8b47-ba13a11a8a18",
"name": "AppSource Product Gallery",
"publisher": "Microsoft",
"version": "25.0.0.0"
},
{
"id": "812b339d-a9db-4a6e-84e4-fe35cbef0c44",
"name": "Rest Client",
"publisher": "Microsoft",
"version": "25.0.0.0"
},
{
"id": "7b9b59f5-a68d-4271-b11a-0d3b9c0938dd",
"name": "User Settings",
"publisher": "Microsoft",
"version": "25.0.0.0"
}
],
"screenshots": [

],
"idRanges": [
{
"from": 132910,
"to": 132910
},
{
"from": 132913,
"to": 132913
}
],
"platform": "24.0.0.0",
"target": "OnPrem"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace System.TestLibraries.Apps.AppSource;

using System.Environment.Configuration;
using System.RestClient;
using System.Apps.AppSource;

/// <summary>
/// Library for providing mock dependencies for the AppSource product manager.
/// </summary>
codeunit 132913 "AppSource Mock Deps. Provider" implements "AppSource Product Manager Dependencies"
{
InherentEntitlements = X;
InherentPermissions = X;

var
FormatRegionStore: Text[80];
CountryLetterCode: Code[2];
PreferredLanguage: Text;
LanguageID: Variant;
IsInSaas: Boolean;
JsonRequests: JsonArray;
ApplicationFamily: Text;

// Dependency to Azure AD Tenant
procedure GetCountryLetterCode(): Code[2]
begin
exit(CountryLetterCode)
end;

procedure SetCountryLetterCode(InputCountryLetterCode: Code[2])
begin
CountryLetterCode := InputCountryLetterCode;
end;

procedure GetPreferredLanguage(): Text
begin
exit(PreferredLanguage);
end;

procedure SetPreferredLanguage(InputPreferredLanguage: Text)
begin
PreferredLanguage := InputPreferredLanguage;
end;

// Dependency to Environment Information
procedure GetApplicationFamily(): Text
begin
exit(ApplicationFamily);
end;

procedure SetApplicationFamily(InputApplicationFamily: Text)
begin
ApplicationFamily := InputApplicationFamily;
end;

procedure IsSaas(): Boolean
begin
exit(IsInSaas);
end;

procedure SetIsSaas(InputIsSaas: Boolean)
begin
IsInSaas := InputIsSaas;
end;

// Dependency to Language
procedure GetFormatRegionOrDefault(InputFormatRegion: Text[80]): Text
begin
if (InputFormatRegion <> '') then
exit(InputFormatRegion);
exit(FormatRegionStore);
end;

procedure SetFormatRegionStore(InputFormatRegion: Text[80])
begin
FormatRegionStore := InputFormatRegion;
end;

// Rest client override
procedure GetAsJSon(var RestClient: Codeunit "Rest Client"; RequestUri: Text): JsonToken
var
Json: JsonToken;
begin
JsonRequests.Get(0, Json);
JsonRequests.RemoveAt(0);
exit(Json);
end;

procedure SetJSon(JsonText: Text)
var
Json: JsonToken;
begin
Json.ReadFrom(JsonText);
JsonRequests.Add(Json);
end;

procedure ShouldSetCommonHeaders(): Boolean
begin
exit(false);
end;

// Dependency to User Settings
procedure GetUserSettings(UserSecurityID: Guid; var TempUserSettingsRecord: Record "User Settings" temporary)
begin
TempUserSettingsRecord.Init();
TempUserSettingsRecord."User Security ID" := UserSecurityID;
TempUserSettingsRecord."Language ID" := LanguageID;
end;

procedure SetUserSettings(InputLanguageId: Variant)
begin
LanguageID := InputLanguageId;
end;
}
Loading
Loading