Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0eac04d
First tests added
NeoCoderMatrix86 May 19, 2025
6ddb728
Update run_unit_tests.yml
NeoCoderMatrix86 May 19, 2025
6c86829
Rename action
NeoCoderMatrix86 May 19, 2025
fc5bf16
Update run_tests.yml
NeoCoderMatrix86 May 19, 2025
c991e21
Update run_tests.yml
NeoCoderMatrix86 May 19, 2025
d593352
Update run_tests.yml
NeoCoderMatrix86 May 19, 2025
dc38802
update to .net9
NeoCoderMatrix86 May 19, 2025
055b398
move to http
NeoCoderMatrix86 May 19, 2025
7512852
Update IndexTest.cs
NeoCoderMatrix86 May 19, 2025
9b5ac72
use trace in case of failed test
NeoCoderMatrix86 May 20, 2025
fe8ca4e
Update IndexTest.cs
NeoCoderMatrix86 May 20, 2025
07a0d06
Update IndexTest.cs
NeoCoderMatrix86 May 21, 2025
abfda40
Update IndexTest.cs
NeoCoderMatrix86 May 21, 2025
4f67a01
Update IndexTest.cs
NeoCoderMatrix86 May 21, 2025
090be6a
Update run_tests.yml
NeoCoderMatrix86 May 21, 2025
73d7960
Update run_tests.yml
NeoCoderMatrix86 May 21, 2025
edb4ff6
include test files
NeoCoderMatrix86 May 22, 2025
5585656
use samples
NeoCoderMatrix86 May 22, 2025
7bdd110
Update run_tests.yml
NeoCoderMatrix86 May 22, 2025
1f86623
Update run_tests.yml
NeoCoderMatrix86 May 22, 2025
efc4d6d
Update IndexTest.cs
NeoCoderMatrix86 May 22, 2025
490afc6
Merge branch '414-use-end-to-end-tests' of https://github.com/NeoCode…
NeoCoderMatrix86 May 22, 2025
804468f
Update run_tests.yml
NeoCoderMatrix86 May 22, 2025
6b79f96
Merge branch '414-use-end-to-end-tests' of https://github.com/NeoCode…
NeoCoderMatrix86 May 22, 2025
8723d0d
always write trace
NeoCoderMatrix86 May 22, 2025
92d146a
Update run_tests.yml
NeoCoderMatrix86 May 22, 2025
cd93592
Write traces only in case of error
NeoCoderMatrix86 May 22, 2025
0c42739
Update run_tests.yml
NeoCoderMatrix86 May 22, 2025
a87afd8
Update run_tests.yml
NeoCoderMatrix86 May 22, 2025
d7127fd
Update run_tests.yml
NeoCoderMatrix86 May 24, 2025
696e112
Update run_tests.yml
NeoCoderMatrix86 May 24, 2025
32b06a4
Update run_tests.yml
NeoCoderMatrix86 May 26, 2025
6ebdf3a
Update run_tests.yml
NeoCoderMatrix86 May 26, 2025
e8d88c5
Update run_tests.yml
NeoCoderMatrix86 May 26, 2025
090ea5e
Update IndexTest.cs
NeoCoderMatrix86 May 26, 2025
2b7cdbe
Update IndexTest.cs
NeoCoderMatrix86 May 26, 2025
7c077c2
Update AudioCuesheetEditor.End2EndTests.csproj
NeoCoderMatrix86 May 26, 2025
ef3e631
Update IndexTest.cs
NeoCoderMatrix86 May 26, 2025
cc50fd2
Update IndexTest.cs
NeoCoderMatrix86 May 26, 2025
d5c22d4
Try to generate with sample file
NeoCoderMatrix86 May 26, 2025
5258b70
Update IndexTest.cs
NeoCoderMatrix86 May 26, 2025
1164ea9
Fix tests
NeoCoderMatrix86 May 26, 2025
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
42 changes: 42 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Run tests

on:
pull_request:

jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2

- name: Set timestamp variable
id: timestamp
run: echo "datetime=$(date +'%Y-%m-%d_%H-%M-%S')" >> $GITHUB_OUTPUT

# version can be found here https://dotnet.microsoft.com/en-us/download/dotnet/9.0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

- name: Install wasm-tools
run: dotnet workload install wasm-tools

- name: Build & Install
run: dotnet build
- name: Ensure browsers are installed
run: pwsh AudioCuesheetEditor.End2EndTests/bin/Debug/net9.0/playwright.ps1 install --with-deps

- name: Start App
run: dotnet run --project AudioCuesheetEditor &

- name: Run tests
run: dotnet test

- name: Upload traces
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-traces-${{ steps.timestamp.outputs.datetime }}
path: AudioCuesheetEditor.End2EndTests/bin/Debug/net9.0/playwright-traces/
if-no-files-found: ignore
26 changes: 0 additions & 26 deletions .github/workflows/run_unit_tests.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableMSTestRunner>true</EnableMSTestRunner>
<OutputType>Exe</OutputType>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<!--
Displays error on console in addition to the log file. Note that this feature comes with a performance impact.
For more information, visit https://learn.microsoft.com/dotnet/core/testing/unit-testing-platform-integration-dotnet-test#show-failure-per-test
-->
<TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
<PackageReference Include="Microsoft.Playwright.MSTest" Version="1.52.0" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" Version="17.14.2" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="1.7.0" />
<PackageReference Include="MSTest" Version="3.9.0" />
</ItemGroup>

<ItemGroup>
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>

</Project>
44 changes: 44 additions & 0 deletions AudioCuesheetEditor.End2EndTests/Pages/AboutTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Microsoft.Playwright;
using Microsoft.Playwright.MSTest;

namespace AudioCuesheetEditor.End2EndTests.Pages
{
[TestClass]
public class AboutTest : PageTest
{
[TestInitialize]
public async Task TestInitialize()
{
await Context.Tracing.StartAsync(new()
{
Title = $"{TestContext.FullyQualifiedTestClassName}.{TestContext.TestName}",
Screenshots = true,
Snapshots = true,
Sources = true
});
}

[TestCleanup]
public async Task TestCleanup()
{
var failed = new[] { UnitTestOutcome.Failed, UnitTestOutcome.Error, UnitTestOutcome.Timeout, UnitTestOutcome.Aborted }.Contains(TestContext.CurrentTestOutcome);

await Context.Tracing.StopAsync(new()
{
Path = failed ? Path.Combine(
Environment.CurrentDirectory,
"playwright-traces",
$"{TestContext.FullyQualifiedTestClassName}.{TestContext.TestName}.zip"
) : null,
});
}

[TestMethod]
public async Task HasTitle()
{
await Page.GotoAsync("http://localhost:5132/about");
await Expect(Page).ToHaveTitleAsync("AudioCuesheetEditor");
await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "About AudioCuesheetEditor" })).ToBeVisibleAsync();
}
}
}
93 changes: 93 additions & 0 deletions AudioCuesheetEditor.End2EndTests/Pages/IndexTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using Microsoft.Playwright;
using Microsoft.Playwright.MSTest;
using System.Text.RegularExpressions;

namespace AudioCuesheetEditor.End2EndTests.Pages
{
[TestClass]
public class IndexTest : PageTest
{
[TestInitialize]
public async Task TestInitialize()
{
await Context.Tracing.StartAsync(new()
{
Title = $"{TestContext.FullyQualifiedTestClassName}.{TestContext.TestName}",
Screenshots = true,
Snapshots = true,
Sources = true
});
}

[TestCleanup]
public async Task TestCleanup()
{
var failed = new[] { UnitTestOutcome.Failed, UnitTestOutcome.Error, UnitTestOutcome.Timeout, UnitTestOutcome.Aborted }.Contains(TestContext.CurrentTestOutcome);

await Context.Tracing.StopAsync(new()
{
Path = failed ? Path.Combine(
Environment.CurrentDirectory,
"playwright-traces",
$"{TestContext.FullyQualifiedTestClassName}.{TestContext.TestName}.zip"
) : null,
});
}

[TestMethod]
public async Task HasTitle()
{
await Page.GotoAsync("http://localhost:5132/");
await Expect(Page).ToHaveTitleAsync("AudioCuesheetEditor");
await Expect(Page.GetByRole(AriaRole.Button, new() { Name = "AudioCuesheetEditor" })).ToBeVisibleAsync();
}

[TestMethod]
public async Task CheckSettings()
{
await Page.GotoAsync("http://localhost:5132/");
await Page.GetByRole(AriaRole.Toolbar).GetByRole(AriaRole.Button).Filter(new() { HasTextRegex = new Regex("^$") }).Nth(3).ClickAsync();
await Page.Locator("div").Filter(new() { HasTextRegex = new Regex("^Settings$") }).ClickAsync();
await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Settings" })).ToBeVisibleAsync();
}

[TestMethod]
public async Task Record()
{
await Page.GotoAsync("http://localhost:5132/");
await Page.GetByText("Record view").ClickAsync();
await Page.GetByRole(AriaRole.Button, new() { Name = "Start recording" }).ClickAsync();
await Page.GetByRole(AriaRole.Textbox, new() { Name = "Artist", Exact = true }).ClickAsync();
await Page.GetByRole(AriaRole.Textbox, new() { Name = "Artist", Exact = true }).FillAsync("Test Track 1 Artist");
await Page.GetByRole(AriaRole.Textbox, new() { Name = "Artist", Exact = true }).PressAsync("Tab");
await Page.GetByRole(AriaRole.Textbox, new() { Name = "Title", Exact = true }).FillAsync("Test Track 1 Title");
await Page.GetByRole(AriaRole.Textbox, new() { Name = "Title", Exact = true }).PressAsync("Tab");
await Page.GetByRole(AriaRole.Button, new() { Name = "Add track" }).ClickAsync();
await Page.GetByRole(AriaRole.Textbox, new() { Name = "Artist", Exact = true }).FillAsync("Test Track 2 Artist");
await Page.GetByRole(AriaRole.Textbox, new() { Name = "Artist", Exact = true }).PressAsync("Tab");
await Page.GetByRole(AriaRole.Textbox, new() { Name = "Title", Exact = true }).FillAsync("Test Track 2 Title");
await Page.GetByRole(AriaRole.Textbox, new() { Name = "Title", Exact = true }).PressAsync("Tab");
await Page.GetByRole(AriaRole.Button, new() { Name = "Add track" }).ClickAsync();
await Page.Locator(".mud-overlay").ClickAsync();
await Page.GetByRole(AriaRole.Button, new() { Name = "Stop recording" }).ClickAsync();
await Expect(Page.GetByRole(AriaRole.Cell, new() { Name = "Test Track 1 Artist Clear" })).ToBeVisibleAsync();
await Expect(Page.GetByRole(AriaRole.Cell, new() { Name = "Test Track 1 Title Clear" })).ToBeVisibleAsync();
await Expect(Page.GetByRole(AriaRole.Cell, new() { Name = "Test Track 2 Artist Clear" })).ToBeVisibleAsync();
await Expect(Page.GetByRole(AriaRole.Cell, new() { Name = "Test Track 2 Title Clear" })).ToBeVisibleAsync();
}

[TestMethod]
public async Task Import()
{
await Page.GotoAsync("http://localhost:5132/");
await Page.GetByText("Import view").ClickAsync();
await Page.GetByRole(AriaRole.Button, new() { Name = "Choose File" }).SetInputFilesAsync(new[] { "../../../../AudioCuesheetEditor/wwwroot/samples/Sample_Inputfile.txt" });
await Page.GetByRole(AriaRole.Button, new() { Name = "Complete" }).ClickAsync();
await Expect(Page.GetByRole(AriaRole.Cell, new() { Name = "Sample Artist 1 Clear" })).ToBeVisibleAsync();
await Expect(Page.GetByRole(AriaRole.Cell, new() { Name = ":20:13" }).Nth(1)).ToBeVisibleAsync();
await Expect(Page.GetByRole(AriaRole.Textbox, new() { Name = "Cuesheet artist" })).ToHaveValueAsync("CuesheetArtist");
await Page.GetByRole(AriaRole.Textbox, new() { Name = "Cuesheet title" }).ClickAsync();
await Expect(Page.GetByRole(AriaRole.Group).Filter(new() { HasText = "AudiofileAudiofile Search" }).Locator("input[type=\"file\"]")).ToBeEmptyAsync();
}
}
}
6 changes: 6 additions & 0 deletions AudioCuesheetEditor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AudioCuesheetEditor", "Audi
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AudioCuesheetEditor.Tests", "AudioCuesheetEditor.Tests\AudioCuesheetEditor.Tests.csproj", "{12CA5D1F-D758-4016-85D0-A045AC06CFE6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AudioCuesheetEditor.End2EndTests", "AudioCuesheetEditor.End2EndTests\AudioCuesheetEditor.End2EndTests.csproj", "{7297DF58-3F83-49E9-B714-B2BE29D08180}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +23,10 @@ Global
{12CA5D1F-D758-4016-85D0-A045AC06CFE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12CA5D1F-D758-4016-85D0-A045AC06CFE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12CA5D1F-D758-4016-85D0-A045AC06CFE6}.Release|Any CPU.Build.0 = Release|Any CPU
{7297DF58-3F83-49E9-B714-B2BE29D08180}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7297DF58-3F83-49E9-B714-B2BE29D08180}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7297DF58-3F83-49E9-B714-B2BE29D08180}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7297DF58-3F83-49E9-B714-B2BE29D08180}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down