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

Automatic e2e testing #29

Merged
merged 44 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d3771c0
Create pipeline to run e2e tests
martinkyjac Oct 18, 2024
3293c45
Merge latest XbK version
martinkyjac Oct 18, 2024
bcda54f
Change launch profile name
martinkyjac Oct 18, 2024
f5820f8
Add database backup ZIP
martinkyjac Oct 18, 2024
e9a3aa6
Enable pipeline to run in branch feat/automatic_E2E_testing
martinkyjac Oct 18, 2024
ee1786e
Add Utilities.psm1
martinkyjac Oct 18, 2024
2d2af30
Fix DB backup file name
martinkyjac Oct 18, 2024
ab85120
Add connection string to testing database
martinkyjac Oct 18, 2024
00ce5b3
Add updated DB backup file
martinkyjac Oct 21, 2024
324972f
Get CMSDBVersion after restore to check if version is correct.
martinkyjac Oct 21, 2024
d475eb8
Fix DB query to get XbK version
martinkyjac Oct 21, 2024
b4af31c
Add debuging commands for docker
martinkyjac Oct 21, 2024
26814db
Move backup back to database folder
martinkyjac Oct 21, 2024
4e6d299
Change DB backup file
martinkyjac Oct 21, 2024
560985e
Change database name
martinkyjac Oct 21, 2024
b3b9189
Fix backup file names and connection string
martinkyjac Oct 21, 2024
9fb7830
Try run kxp-update before CI restore
martinkyjac Oct 21, 2024
e317d89
Specify project name
martinkyjac Oct 21, 2024
e9a1d51
fix kxp-update run command
martinkyjac Oct 21, 2024
bda773b
Disable CI before kxp update
martinkyjac Oct 21, 2024
81ef6fa
Fix publish errors
martinkyjac Oct 21, 2024
146b3c9
Add sleep after start job command
martinkyjac Oct 22, 2024
15e1050
Change database backup and add .net health check services
martinkyjac Oct 22, 2024
78ab8d3
Remove debugging DB queries
martinkyjac Oct 22, 2024
b118b71
Enable central package floating versions and update Kentico NuGets to…
martinkyjac Oct 23, 2024
17afe6a
Update CI repository and upload new DB backup
martinkyjac Oct 23, 2024
c4fbb19
Regenerate whole CI repository + use API credentials from github secrets
martinkyjac Oct 23, 2024
0254986
Use latest hotfix only for dancinggoat livesite
martinkyjac Nov 18, 2024
1e6d1d6
Update DB backup
martinkyjac Nov 18, 2024
74fe7d5
Upgrade DB backup
martinkyjac Nov 18, 2024
ac6a483
E2E tests with associated ci.yml changes
andrejrblue Nov 18, 2024
fbe7f85
Update ci.yml
andrejrblue Nov 18, 2024
4955d78
Update ci.yml
andrejrblue Nov 18, 2024
f8af2b9
Update DB backup file with created product pages
martinkyjac Nov 21, 2024
d05405e
Add new license key to test pipeline
martinkyjac Nov 21, 2024
ae9c4ca
Resolve merge conflicts
martinkyjac Nov 21, 2024
8d623d5
Add currency formats to DB backup
martinkyjac Nov 21, 2024
c8e2b67
Locator fix
andrejrblue Nov 21, 2024
6bc0596
Merge branch 'feat/automatic_E2E_testing' of https://github.com/Kenti…
andrejrblue Nov 21, 2024
97d3c50
Get xbyk license from secrets
martinkyjac Nov 22, 2024
6defc9f
Create separate pipeline for E2E tests
martinkyjac Nov 25, 2024
86d8b58
Remove E2E tests from original pipeline
martinkyjac Nov 25, 2024
a77542b
Change line endings
martinkyjac Nov 25, 2024
e98af3f
Use const instead of var for scrollHeight
martinkyjac Nov 26, 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ jobs:
dotnet test `
--configuration Release `
--no-build `
--no-restore
--no-restore
179 changes: 179 additions & 0 deletions .github/workflows/e2etest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
name: "E2E: Build and Test"

on:
schedule:
- cron: '0 10 * * 5' # Runs every Friday at 10:00 UTC

jobs:
build_and_test:
name: Test E2E
runs-on: ubuntu-latest
defaults:
run:
shell: pwsh

env:
ASPNETCORE_ENVIRONMENT: CI
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: 1
PROJECT_NAME: DancingGoat
DB_NAME: XByK_DancingGoat_Shopify
ASPNETCORE_URLS: https://localhost:14065
STATUS_CHECK_URL: https://localhost:14065/status
CMSSHOPIFYCONFIG__ADMINAPIKEY: ${{ secrets.ADMIN_API_KEY }}
CMSSHOPIFYCONFIG__SHOPIFYURL: ${{ secrets.SHOPIFY_URL }}
CMSSHOPIFYCONFIG__STOREFRONTAPIKEY: ${{ secrets.STOREFRONT_API_KEY }}
CMSSHOPIFYCONFIG__STOREFRONTAPIVERSION: ${{ secrets.STOREFRONT_API_VERSION }}
CMSSHOPIFYCONFIG__STOREPASSWORD: ${{ secrets.SHOPIFY_STORE_PASSWORD }}
XPERIENCE_BY_KENTICO_LICENSE: ${{ secrets.XPERIENCE_BY_KENTICO_LICENSE }}

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Install NPM
run: |
cd test/Playwright
npm ci
npx playwright install --with-deps
cd ../..

- name: Install dependencies
run: |
dotnet restore `
--locked-mode

- name: Build Solution
run: |
dotnet build `
--configuration Release `
-p:XbyKVersion=*

- name: Get Database Backup Name
run: |
$latestBackup = Get-Content -Path "./database/backups.txt" -TotalCount 1
"DATABASE_BACKUP_FILENAME=$latestBackup" >> $env:GITHUB_ENV

- name: Extract Database Backup
run: |
Expand-Archive `
-Path "./database/${{ env.DATABASE_BACKUP_FILENAME }}.zip" `
-DestinationPath "./database"
- name: Install a SQL Server suite of tools (SQLEngine, SQLPackage)
uses: potatoqualitee/mssqlsuite@9a0136e208df60b8ecb62909f076bc34854fa55a # set as a commit hash for security - v1.7
with:
install: sqlpackage, sqlengine
sa-password: Pass@12345
version: 2022

- name: Restore Database .bak
run: |
docker exec sql mkdir /var/opt/mssql/backup
docker cp "./database/${{ env.DATABASE_BACKUP_FILENAME }}" sql:/var/opt/mssql/backup
sqlcmd `
-S localhost `
-d master `
-U "sa" `
-P "Pass@12345" `
-Q "RESTORE DATABASE [${{env.DB_NAME}}] FROM DISK='/var/opt/mssql/backup/${{ env.DATABASE_BACKUP_FILENAME }}' WITH MOVE 'XByK_DancingGoat_Shopify' TO '/var/opt/mssql/data/${{env.DB_NAME}}.mdf', MOVE 'XByK_DancingGoat_Shopify_log' TO '/var/opt/mssql/data/${{env.DB_NAME}}_log.ldf'"
if: endsWith(env.DATABASE_BACKUP_FILENAME, '.bak')

- name: Import license key to DB
run: |
sqlcmd `
-S localhost `
-d ${{env.DB_NAME}} `
-U "sa" `
-P "Pass@12345" `
-Q "UPDATE CMS_SettingsKey SET KeyValue='${{ env.XPERIENCE_BY_KENTICO_LICENSE }}' WHERE KeyName='CMSLicenseKey'"

- name: Restore CI Repository
working-directory: "./scripts"
run: |
./UpdateAndRestoreCI.ps1

- name: Publish Application
run: |
dotnet publish `
./examples/DancingGoat-Shopify `
-c Release `
-o ./publish `
--no-build `
--no-restore

- name: Install Azurite
id: azuright
uses: potatoqualitee/azuright@e56d2754eb15218d507961493bc83ca037216887 # set as a commit hash for security - v1.1

- name: Test Solution
run: |
dotnet test `
--configuration Release `
--no-build `
--no-restore

- name: Run Application and E2E Tests
run: |
# Run the ASP.NET Core app as a background job
cd ./publish
Start-Job -ScriptBlock { dotnet ./${{ env.PROJECT_NAME }}.dll } -Name ${{ env.PROJECT_NAME }}
Receive-Job -Name ${{ env.PROJECT_NAME }}
cd ../

# The ASP.NET Core app can take a few seconds to start, so we delay running tests
# until it is ready, and fail if we go over a maximum wait time
$limit = 10
$attempts = 0
$success = $false

while ($attempts -lt $limit -and -not $success) {
Start-Sleep -Seconds 1
try {
$response = Invoke-WebRequest -Uri ${{ env.STATUS_CHECK_URL }} -Method Get -SkipCertificateCheck
if ($response.StatusCode -eq 200) {
Write-Output "Application is ready."
$success = $true
}
}
catch {
Write-Output "Attempt $attempts - Application not ready yet."
}
$attempts++
}

if (-not $success) {
Write-Output "Application did not respond in time."
exit 1
}

# Sleep for finishing initialization
Start-Sleep -Seconds 10

# Run the E2E tests
cd test/Playwright
npx playwright test
cd ../..

# Stop the background ASP.NET Core application
Receive-Job -Name ${{ env.PROJECT_NAME }}
Stop-Job -Name ${{ env.PROJECT_NAME }}
Remove-Job -Name ${{ env.PROJECT_NAME }}

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: ./test/Playwright/playwright-report/
retention-days: 30
15 changes: 9 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageVersionOverrideEnabled>false</CentralPackageVersionOverrideEnabled>
<CentralPackageVersionOverrideEnabled>true</CentralPackageVersionOverrideEnabled>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
<CentralPackageFloatingVersionsEnabled>true</CentralPackageFloatingVersionsEnabled>
<LastAppliedHotfix>29.5.3</LastAppliedHotfix>
<XbyKVersion Condition="'$(XbyKVersion)' == ''">$(LastAppliedHotfix)</XbyKVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="GraphQL" Version="7.8.0" />
<PackageVersion Include="GraphQL.Client" Version="6.0.2" />
<PackageVersion Include="GraphQL.Client.Serializer.Newtonsoft" Version="6.0.2" />
<PackageVersion Include="Kentico.Xperience.Admin" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="29.5.3" />
<PackageVersion Include="kentico.xperience.azurestorage" Version="29.5.3" />
<PackageVersion Include="kentico.xperience.imageprocessing" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.Core" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.Admin" Version="$(LastAppliedHotfix)" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="$(LastAppliedHotfix)" />
<PackageVersion Include="kentico.xperience.azurestorage" Version="$(LastAppliedHotfix)" />
<PackageVersion Include="kentico.xperience.imageprocessing" Version="$(LastAppliedHotfix)" />
<PackageVersion Include="Kentico.Xperience.Core" Version="$(LastAppliedHotfix)" />
<PackageVersion Include="Moq.AutoMock" Version="3.5.0" />
<PackageVersion Include="ShopifySharp" Version="6.17.0" />
<PackageVersion Include="ShopifySharp.Extensions.DependencyInjection" Version="1.6.0" />
Expand Down
Binary file added database/XByK_DancingGoat_Shopify.bak.zip
Binary file not shown.
1 change: 1 addition & 0 deletions database/backups.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
XByK_DancingGoat_Shopify.bak
2 changes: 1 addition & 1 deletion examples/DancingGoat-Shopify/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"kentico.xperience.dbmanager": {
"version": "28.2.1",
"version": "29.5.3",
"commands": [
"kentico-xperience-dbmanager"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<cms.alternativeform>
<FormClassID>
<CodeName>Shopify.CurrencyFormat</CodeName>
<GUID>996f2159-f3fd-4ec1-99c6-c6d62fa12705</GUID>
<ObjectType>cms.class</ObjectType>
</FormClassID>
<FormDefinition>
<form>
<field column="CurrencyFormatID" guid="d29aad73-40e2-47b5-a315-d84f87354bb8" enabled="" />
<field column="CurrencyCode" enabled="true" guid="ceff5511-08b8-4072-8089-5ff7010b9248" visible="true">
<settings>
<controlname>Kentico.Administration.TextInput</controlname>
</settings>
<validationrulesdata>
<ValidationRuleConfiguration>
<ValidationRuleIdentifier>Kentico.Administration.RequiredValue</ValidationRuleIdentifier>
<RuleValues />
</ValidationRuleConfiguration>
</validationrulesdata>
<properties>
<explanationtextashtml>False</explanationtextashtml>
<fieldcaption>Currency code</fieldcaption>
<fielddescriptionashtml>False</fielddescriptionashtml>
</properties>
</field>
<field column="CurrencyPriceFormat" enabled="true" guid="3bf597d9-ce11-411b-8b5e-232b76ee26cc" visible="true">
<settings>
<controlname>Kentico.Administration.TextInput</controlname>
<WatermarkText>$0.00</WatermarkText>
</settings>
<properties>
<explanationtextashtml>False</explanationtextashtml>
<fieldcaption>Currency price format</fieldcaption>
<fielddescription>
<![CDATA[Currency format will be used in decimal.ToString method to convert the price value to string.]]>
</fielddescription>
<fielddescriptionashtml>False</fielddescriptionashtml>
</properties>
</field>
</form>
</FormDefinition>
<FormDisplayName>Shopify currency format form</FormDisplayName>
<FormGUID>fc4f83bf-6a68-4c18-8e1e-77763f6ea36f</FormGUID>
<FormIsCustom>True</FormIsCustom>
<FormName>ShopifyCurrencyFormatForm</FormName>
<?xml version="1.0" encoding="utf-8"?>
<cms.alternativeform>
<FormClassID>
<CodeName>Shopify.CurrencyFormat</CodeName>
<GUID>996f2159-f3fd-4ec1-99c6-c6d62fa12705</GUID>
<ObjectType>cms.class</ObjectType>
</FormClassID>
<FormDefinition>
<form>
<field column="CurrencyFormatID" guid="d29aad73-40e2-47b5-a315-d84f87354bb8" enabled="" />
<field column="CurrencyCode" enabled="true" guid="ceff5511-08b8-4072-8089-5ff7010b9248" visible="true">
<settings>
<controlname>Kentico.Administration.TextInput</controlname>
</settings>
<validationrulesdata>
<ValidationRuleConfiguration>
<ValidationRuleIdentifier>Kentico.Administration.RequiredValue</ValidationRuleIdentifier>
<RuleValues />
</ValidationRuleConfiguration>
</validationrulesdata>
<properties>
<explanationtextashtml>False</explanationtextashtml>
<fieldcaption>Currency code</fieldcaption>
<fielddescriptionashtml>False</fielddescriptionashtml>
</properties>
</field>
<field column="CurrencyPriceFormat" enabled="true" guid="3bf597d9-ce11-411b-8b5e-232b76ee26cc" visible="true">
<settings>
<controlname>Kentico.Administration.TextInput</controlname>
<WatermarkText>$0.00</WatermarkText>
</settings>
<properties>
<explanationtextashtml>False</explanationtextashtml>
<fieldcaption>Currency price format</fieldcaption>
<fielddescription>
<![CDATA[Currency format will be used in decimal.ToString method to convert the price value to string.]]>
</fielddescription>
<fielddescriptionashtml>False</fielddescriptionashtml>
</properties>
</field>
</form>
</FormDefinition>
<FormDisplayName>Shopify currency format form</FormDisplayName>
<FormGUID>fc4f83bf-6a68-4c18-8e1e-77763f6ea36f</FormGUID>
<FormIsCustom>True</FormIsCustom>
<FormName>ShopifyCurrencyFormatForm</FormName>
</cms.alternativeform>
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<cms.class>
<ClassCodeGenerationSettings>
<Data>
<CodeNameColumn>CurrencyCode</CodeNameColumn>
<DisplayNameColumn>CurrencyCode</DisplayNameColumn>
<ObjectType>Shopify.CurrencyFormat</ObjectType>
<UseGuidHashtable>False</UseGuidHashtable>
<UseIdHashtable>False</UseIdHashtable>
<UseNameHashtable>False</UseNameHashtable>
</Data>
</ClassCodeGenerationSettings>
<ClassDisplayName>Shopify currency format</ClassDisplayName>
<ClassFormDefinition>
<form>
<field column="CurrencyFormatID" columntype="integer" enabled="true" guid="d29aad73-40e2-47b5-a315-d84f87354bb8" isPK="true" />
<field column="CurrencyCode" columnprecision="0" columnsize="5" columntype="text" enabled="true" guid="ceff5511-08b8-4072-8089-5ff7010b9248" />
<field column="CurrencyPriceFormat" columnprecision="0" columnsize="200" columntype="text" enabled="true" guid="3bf597d9-ce11-411b-8b5e-232b76ee26cc" />
</form>
</ClassFormDefinition>
<ClassGUID>996f2159-f3fd-4ec1-99c6-c6d62fa12705</ClassGUID>
<ClassHasUnmanagedDbSchema>False</ClassHasUnmanagedDbSchema>
<ClassName>Shopify.CurrencyFormat</ClassName>
<ClassResourceID>
<CodeName>ShopifyStoreConfiguration</CodeName>
<GUID>3b34600d-ecb1-4048-bdf0-4ec6298ddd28</GUID>
<ObjectType>cms.resource</ObjectType>
</ClassResourceID>
<ClassTableName>Shopify_CurrencyFormat</ClassTableName>
<ClassType>Other</ClassType>
<?xml version="1.0" encoding="utf-8"?>
<cms.class>
<ClassCodeGenerationSettings>
<Data>
<CodeNameColumn>CurrencyCode</CodeNameColumn>
<DisplayNameColumn>CurrencyCode</DisplayNameColumn>
<ObjectType>Shopify.CurrencyFormat</ObjectType>
<UseGuidHashtable>False</UseGuidHashtable>
<UseIdHashtable>False</UseIdHashtable>
<UseNameHashtable>False</UseNameHashtable>
</Data>
</ClassCodeGenerationSettings>
<ClassDisplayName>Shopify currency format</ClassDisplayName>
<ClassFormDefinition>
<form>
<field column="CurrencyFormatID" columntype="integer" enabled="true" guid="d29aad73-40e2-47b5-a315-d84f87354bb8" isPK="true" />
<field column="CurrencyCode" columnprecision="0" columnsize="5" columntype="text" enabled="true" guid="ceff5511-08b8-4072-8089-5ff7010b9248" />
<field column="CurrencyPriceFormat" columnprecision="0" columnsize="200" columntype="text" enabled="true" guid="3bf597d9-ce11-411b-8b5e-232b76ee26cc" />
</form>
</ClassFormDefinition>
<ClassGUID>996f2159-f3fd-4ec1-99c6-c6d62fa12705</ClassGUID>
<ClassHasUnmanagedDbSchema>False</ClassHasUnmanagedDbSchema>
<ClassName>Shopify.CurrencyFormat</ClassName>
<ClassResourceID>
<CodeName>ShopifyStoreConfiguration</CodeName>
<GUID>3b34600d-ecb1-4048-bdf0-4ec6298ddd28</GUID>
<ObjectType>cms.resource</ObjectType>
</ClassResourceID>
<ClassTableName>Shopify_CurrencyFormat</ClassTableName>
<ClassType>Other</ClassType>
</cms.class>
Loading