Skip to content

Commit

Permalink
Add generic sample tests and test generation. (#823)
Browse files Browse the repository at this point in the history
  • Loading branch information
skrustev authored Jan 13, 2025
1 parent 09980df commit 008d0e4
Show file tree
Hide file tree
Showing 24 changed files with 1,153 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@

/browser/Tests

/browser/IgBlazorSamples.Test/Generated/**

# misc
.DS_Store
.env.local
Expand Down
7 changes: 7 additions & 0 deletions azure-pipelines/NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="local-packages" value="../Dependencies/Blazor_NuGet" />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
4 changes: 2 additions & 2 deletions azure-pipelines/templates/build-steps-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ steps:
customCommand: ci

- task: CmdLine@2
displayName: 'npx gulp copySamplesTo${{ parameters.projectToBuild }}'
displayName: 'npx gulp copySamplesTo${{ parameters.projectToBuild }}CI'
inputs:
script: 'npx gulp copySamplesTo${{ parameters.projectToBuild }}'
script: 'npx gulp copySamplesTo${{ parameters.projectToBuild }}CI'
workingDirectory: '$(Build.SourcesDirectory)\browser\IgBlazorSamples.Gulp'
failOnStderr: true

Expand Down
18 changes: 18 additions & 0 deletions browser/.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<NUnit>
<NumberOfTestWorkers>7</NumberOfTestWorkers>
</NUnit>
<Playwright>
<BrowserName>chromium</BrowserName>
<ExpectTimeout>5000</ExpectTimeout>
<LaunchOptions>
<!--<Headless>false</Headless>-->
</LaunchOptions>
</Playwright>
<TestRunParameters>
<Parameter name="defaultTimeout" value="40000" />
<Parameter name="useInMemoryClient" value="true" />
<Parameter name="testUrl" value="http://localhost:4200" />
</TestRunParameters>
</RunSettings>
18 changes: 18 additions & 0 deletions browser/IgBlazorSamples.Gulp/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,21 @@ exports.updateIG = updateIG = gulp.series(
sb.updateIG,
);

// Copy samples task used only for local run of the Samples Browser Server.
exports.copySamplesToServer = copySamplesToServer = gulp.series(
// sb.updateVersion,
sb.getSamples,
sb.copySamplesToServer,
);

// Copy samples task used on host agents. Samples Browser Server from there has added '/blazor-samples' to the base url.
exports.copySamplesToServerCI = copySamplesToServerCI = gulp.series(
// sb.updateVersion,
sb.getSamples,
sb.copySamplesToServerCI,
);

// Copy samples task used only for local run of the SB Client.
exports.copySamplesToClient = copySamplesToClient = gulp.series(
// sb.updateVersion,
sb.getSamples,
Expand All @@ -81,6 +90,15 @@ exports.copySamplesToClient = copySamplesToClient = gulp.series(
);
exports.updateBrowser = updateBrowser = copySamplesToClient;

// Copy samples task used on host agents. Samples Browser Client from there has added '/blazor-samples' to the base url.
exports.copySamplesToClientCI = copySamplesToClientCI = gulp.series(
// sb.updateVersion,
sb.getSamples,
sb.copySamplesToClientCI,
sb.updateCodeViewer,
sb.updateReadme,
);

exports.cleanupSampleBrowsers = cleanupSampleBrowsers = gulp.series(
sb.cleanupSampleBrowsers,
);
Expand Down
19 changes: 15 additions & 4 deletions browser/IgBlazorSamples.Gulp/tasks/gulp-samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ function copySamplePages(cb, outputPath) {
cb();
}

function copySampleScripts(cb, outputPath, indexName) {
function copySampleScripts(cb, outputPath, indexName, isLocalBuild) {
var insertScriptFiles = [];

log('deleting scripts in: ' + outputPath + '/wwwroot/sb/*.js');
Expand Down Expand Up @@ -467,7 +467,6 @@ function copySampleScripts(cb, outputPath, indexName) {

// indexLines = indexLines.filter((v, i, a) => a.indexOf(v) === i);

var isLocalBuild = __dirname.indexOf('Agent') < 0;
for (let i = 0; i < indexLines.length; i++) {
if (indexLines[i].indexOf('<base href') > 0) {
if (isLocalBuild) {
Expand Down Expand Up @@ -495,19 +494,31 @@ function copySampleScripts(cb, outputPath, indexName) {
// '../../browser/IgBlazorSamples.Server/wwwroot'
function copySamplesToServer(cb) {
cleanupSampleBrowser( "../../browser/IgBlazorSamples.Server");
copySampleScripts(cb, "../../browser/IgBlazorSamples.Server", "/Pages/_Host.cshtml");
copySampleScripts(cb, "../../browser/IgBlazorSamples.Server", "/Pages/_Host.cshtml", true);
copySamplePages(cb, "../../browser/IgBlazorSamples.Server");
} exports.copySamplesToServer = copySamplesToServer;

function copySamplesToServerCI(cb) {
cleanupSampleBrowser( "../../browser/IgBlazorSamples.Server");
copySampleScripts(cb, "../../browser/IgBlazorSamples.Server", "/Pages/_Host.cshtml", false);
copySamplePages(cb, "../../browser/IgBlazorSamples.Server");
} exports.copySamplesToServerCI = copySamplesToServerCI;

// '../../browser/IgBlazorSamples.Client/Pages'
// '../../browser/IgBlazorSamples.Client/Services'
// '../../browser/IgBlazorSamples.Client/wwwroot'
function copySamplesToClient(cb) {
cleanupSampleBrowser( "../../browser/IgBlazorSamples.Client");
copySampleScripts(cb, "../../browser/IgBlazorSamples.Client", "/wwwroot/index.html");
copySampleScripts(cb, "../../browser/IgBlazorSamples.Client", "/wwwroot/index.html", true);
copySamplePages(cb, "../../browser/IgBlazorSamples.Client");
} exports.copySamplesToClient = copySamplesToClient;

function copySamplesToClientCI(cb) {
cleanupSampleBrowser( "../../browser/IgBlazorSamples.Client");
copySampleScripts(cb, "../../browser/IgBlazorSamples.Client", "/wwwroot/index.html", false);
copySamplePages(cb, "../../browser/IgBlazorSamples.Client");
} exports.copySamplesToClientCI = copySamplesToClientCI;

function updateReadme(cb) {

var changeFilesCount = 0;
Expand Down
54 changes: 54 additions & 0 deletions browser/IgBlazorSamples.Test.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32210.238
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IgBlazorSamples.Client", "IgBlazorSamples.Client\IgBlazorSamples.Client.csproj", "{8D8DE753-4CD1-4B21-9C9F-2E40AE5EED1B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IgBlazorSamples.Shared", "IgBlazorSamples.Shared\IgBlazorSamples.Shared.csproj", "{FBA48919-F510-4D99-A3F6-6743A9C304D2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IgBlazorSamples.Core", "IgBlazorSamples.Core\IgBlazorSamples.Core.csproj", "{B64DD2DE-32F6-4CF8-B9F5-7F0E29796460}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F85EE908-E593-4D66-A46D-2193EF3C98C2}"
ProjectSection(SolutionItems) = preProject
.runsettings = .runsettings
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IgBlazorSamples.TestServer", "IgBlazorSamples.TestServer\IgBlazorSamples.TestServer.csproj", "{3E6A34E9-442D-4CC0-BE26-0C872B51FF55}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IgBlazorSamples.Test", "IgBlazorSamples.Test\IgBlazorSamples.Test.csproj", "{EFFA7E4D-7130-40AE-9E8B-6110FCB099AF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8D8DE753-4CD1-4B21-9C9F-2E40AE5EED1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D8DE753-4CD1-4B21-9C9F-2E40AE5EED1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D8DE753-4CD1-4B21-9C9F-2E40AE5EED1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D8DE753-4CD1-4B21-9C9F-2E40AE5EED1B}.Release|Any CPU.Build.0 = Release|Any CPU
{FBA48919-F510-4D99-A3F6-6743A9C304D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FBA48919-F510-4D99-A3F6-6743A9C304D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FBA48919-F510-4D99-A3F6-6743A9C304D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FBA48919-F510-4D99-A3F6-6743A9C304D2}.Release|Any CPU.Build.0 = Release|Any CPU
{B64DD2DE-32F6-4CF8-B9F5-7F0E29796460}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B64DD2DE-32F6-4CF8-B9F5-7F0E29796460}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B64DD2DE-32F6-4CF8-B9F5-7F0E29796460}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B64DD2DE-32F6-4CF8-B9F5-7F0E29796460}.Release|Any CPU.Build.0 = Release|Any CPU
{3E6A34E9-442D-4CC0-BE26-0C872B51FF55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E6A34E9-442D-4CC0-BE26-0C872B51FF55}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E6A34E9-442D-4CC0-BE26-0C872B51FF55}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E6A34E9-442D-4CC0-BE26-0C872B51FF55}.Release|Any CPU.Build.0 = Release|Any CPU
{EFFA7E4D-7130-40AE-9E8B-6110FCB099AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EFFA7E4D-7130-40AE-9E8B-6110FCB099AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFFA7E4D-7130-40AE-9E8B-6110FCB099AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFFA7E4D-7130-40AE-9E8B-6110FCB099AF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2B229BA4-53C2-4C4E-8A25-BA19866A265A}
EndGlobalSection
EndGlobal
Loading

0 comments on commit 008d0e4

Please sign in to comment.