Skip to content

Commit

Permalink
Reenable test execution (#27587)
Browse files Browse the repository at this point in the history
<!-- Thank you for submitting a Pull Request. If you're new to
contributing to AlAppExtensions please read our pull request guideline
below
* https://github.com/microsoft/ALAppExtensions/blob/main/CONTRIBUTING.md
-->
#### Summary <!-- Provide a general summary of your changes -->
Reenable tests by uninstalling apps that aren't supported in W1 before
we start running tests. This will ensure tests don't accidently trigger
e.g. event subscribers from apps that aren't supported in W1 anyway.
Right now we are building, publishing and testing apps on top of a W1
Base App even though some of them aren't supported in W1.

We'll continue to compile the apps. We just won't have them installed
when running tests. With this change, tests are working again:
https://github.com/microsoft/ALAppExtensions/actions/runs/11664233820

Another way we could solve this from AL-Go would could define anti
patterns for app/test folders. In that case we would have the following
in the AL-Go settings `testFolders: [ Apps/W1/*/app/,
!Apps/W1/INTaxEngine/app ] `

#### Work Item(s) <!-- Add the issue number here after the #. The issue
needs to be open and approved. Submitting PRs with no linked issues or
unapproved issues is highly discouraged. -->
Fixes
[AB#556300](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/556300)
  • Loading branch information
aholstrup1 authored Nov 13, 2024
1 parent 9a75182 commit e2a83ee
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 3 deletions.
26 changes: 25 additions & 1 deletion Build/BuildConfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
{
"MaxAllowedObsoleteVersion": "24"
"MaxAllowedObsoleteVersion": "24",
"AppsNotToBePublished": [
"AMC Banking 365 Fundamentals",
"AMC Banking 365 Fundamentals Test Automations",
"Automatic Account Codes",
"Automatic Account Codes Tests",
"Basic Experience",
"Basic Experience Tests",
"Dynamics GP History SmartLists",
"Dynamics GP Historical Data",
"Dynamics GP Historical Data Tests",
"Dynamics GP Intelligent Cloud",
"Dynamics GP Intelligent Cloud Tests",
"Image Analyzer",
"Image Analyzer Tests",
"Import of QuickBooks Payroll Files",
"Quickbooks Payroll File Import Tests",
"Send remittance advice by email Tests",
"AMC Banking 365 Fundamentals Test Automations",
"Tax Engine",
"Tax Engine Test",
"Transactions and Receipts Storage",
"WorldPay Payments Standard",
"WorldPay Payments Standard Tests"
]
}
44 changes: 44 additions & 0 deletions Build/Scripts/ImportTestDataInBcContainer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Param(
[Parameter(ParameterSetName="ALGo")]
[Hashtable]$parameters,
[Parameter(ParameterSetName="Manual")]
[string]$containerName
)

Import-Module "$PSScriptRoot\EnlistmentHelperFunctions.psm1"

function Get-NavDefaultCompanyName
{
return "CRONUS International Ltd."
}

if ($PSCmdlet.ParameterSetName -eq 'ALGo') {
$containerName = $parameters.ContainerName
}

# Unpublish apps that should not be published
$installedApps = Get-BcContainerAppInfo -containerName $parameters.ContainerName -tenantSpecificProperties -sort DependenciesLast
$appsToBeUnPublished = (Get-ConfigValue -ConfigType "BuildConfig" -Key "AppsNotToBePublished")
$installedApps | ForEach-Object {
if ($_.Name -in $appsToBeUnPublished) {
Write-Host "Unpublishing $($_.Name)"
Unpublish-BcContainerApp -containerName $parameters.ContainerName -name $_.Name -unInstall -doNotSaveData -doNotSaveSchema -force
}
}

# Import test data
try {
$repoVersion = Get-ConfigValue -ConfigType "AL-GO" -Key "RepoVersion"
$DemoDataType = "EXTENDED"

Write-Host "Initializing company"
Invoke-NavContainerCodeunit -Codeunitid 2 -containerName $containerName -CompanyName (Get-NavDefaultCompanyName)

Write-Host "Importing configuration package"
Invoke-NavContainerCodeunit -Codeunitid 8620 -containerName $containerName -CompanyName (Get-NavDefaultCompanyName) -MethodName "ImportAndApplyRapidStartPackage" -Argument "C:\ConfigurationPackages\NAV$($repoVersion).W1.ENU.$($DemoDataType).rapidstart"
} catch {
Write-Host "Error while importing configuration package"
Write-Host $_.Exception.Message
Write-Host $_.Exception.StackTrace
exit 1
}
10 changes: 9 additions & 1 deletion Build/Scripts/RunTestsInBcContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ if ($disabledTests)
$parameters["disabledTests"] = $disabledTests
}

Run-TestsInBcContainer @parameters

$installedApps = Get-BcContainerAppInfo -containerName $parameters.containerName | Select-Object -ExpandProperty AppId
$extensionId = $parameters.extensionId
if ($extensionId -in $installedApps) {
return Run-TestsInBcContainer @parameters
} else {
Write-Host "Extension $extensionId is not installed in container $containerName. Skipping tests."
return $true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Param(
[Hashtable]$parameters
)

$script = Join-Path $PSScriptRoot "../../../scripts/ImportTestDataInBcContainer.ps1" -Resolve
. $script -parameters $parameters
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"..\\..\\..\\Apps\\W1\\*\\*\\test",
"..\\..\\..\\Apps\\W1\\*\\*\\test library"
],
"doNotRunTests": true
"doNotRunTests": false
}

0 comments on commit e2a83ee

Please sign in to comment.