Skip to content

Adding end to end tests for the guides and samples#351

Merged
nmetulev merged 34 commits intomainfrom
nm/sample-tests
Apr 20, 2026
Merged

Adding end to end tests for the guides and samples#351
nmetulev merged 34 commits intomainfrom
nm/sample-tests

Conversation

@nmetulev
Copy link
Copy Markdown
Member

@nmetulev nmetulev commented Mar 9, 2026

Description

Adds end-to-end Pester tests for all 8 guides and samples, running automatically on every PR. These tests exercise the core CLI workflows (winapp init, winapp run, winapp pack, winapp cert, winapp node create-addon, etc.) across all supported frameworks. This gives us regression coverage so that changes to the CLI — like modifying winapp init, package resolution, or the addon template — are validated against real-world workflows before merging. The three bug fixes in this PR were discovered directly by this test coverage.

Each sample has a self-contained test.Tests.ps1 that validates the guide workflow from scratch (Phase 1) and verifies the existing sample code still builds (Phase 2).

Test Coverage Matrix

Command cpp dotnet electron flutter rust tauri wpf packaging
winapp init
winapp restore
winapp run ⚠️
winapp pack
winapp sign
winapp cert generate
winapp cert info
winapp manifest generate
manifest add-alias
create-debug-identity
add-electron-debug-identity
node create-addon (C++)
node create-addon (C#)
Framework build
Sample freshness check

⚠️ Tests using --no-launch to ensure identity is properly set up even though the app will not launch using winapp run.

Infrastructure

  • New CI workflow .github/workflows/test-samples.yml with matrix strategy (8 parallel jobs)
  • Shared test helpers in samples/SampleTestHelpers.psm1
  • Runner script scripts/test-samples.ps1 for local execution
  • Minor guide doc fixes found during test authoring

Type of Change

  • 🧪 Tests
  • 🐛 Bug fix
  • 🔧 Config/build

Checklist

  • New tests added for new functionality (if applicable)
  • Tested locally on Windows
  • All CI checks passing

Notes

  • Windows App SDK Notification didn't appear for me when going through the notification add on guide.
  • Windows runners are slow to get picked up and since this PR introduces a lot of tests that need those runners which could be blocking and slow down the development loop.

nmetulev and others added 5 commits March 6, 2026 23:07
- Create SampleTestHelpers.psm1 shared PowerShell module with assertion,
  logging, CLI invocation, and MSIX packaging helpers
- Add self-contained test.ps1 for each sample: cpp-app, dotnet-app,
  electron, flutter-app, rust-app, tauri-app, wpf-app
- Add test-samples.yml GitHub Actions workflow with matrix strategy
  running 7 samples in parallel, triggered by Build and Package workflow
- Add scripts/test-samples.ps1 local orchestrator for running tests
  locally with pass/fail summary
- Update AGENTS.md with sample testing conventions and instructions

Each test validates: prerequisites -> build -> package MSIX -> verify output.
Tests run without elevation. electron-winml skipped (requires ML models).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rewrite all 7 sample test.ps1 scripts to follow a guide-first approach:
- Phase 1: From-scratch guide workflow in a temp directory (scaffold
  project, winapp init, build, cert generate, cert info, pack MSIX)
- Phase 2: Quick build of existing sample code to verify freshness

Add new packaging-cli guide test (samples/packaging-cli/test.ps1):
- Tests winapp manifest generate, cert generate, cert info, pack, sign
- Validates the docs/guides/packaging-cli.md workflow end-to-end

Update shared module with new helpers:
- New-TempTestDirectory / Remove-TempTestDirectory for temp dir lifecycle
- Assert-WinappInitOutput for verifying winapp init creates expected files
- Assert-CertInfo for verifying winapp cert info output

Add packaging-cli to CI workflow matrix (8 parallel jobs total).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix [switch]$Verbose conflict with PowerShell common parameter in all
  test scripts and orchestrator (use [CmdletBinding()] instead)
- Fix $PSScriptRoot in module functions pointing to wrong directory
  (pass -SampleDir $PSScriptRoot from callers)
- Fix Assert-WinappInitOutput defaults (switches default to $false)
- Remove -ExpectWinappYaml for .NET and --setup-sdks=none projects
  (.NET uses .csproj, Rust/Tauri with no SDKs skip winapp.yaml)
- Fix dotnet/wpf tests to explicitly call winapp pack after build
  (auto-packaging MSBuild targets are optional, not added by init)
- Find .exe output directory recursively (handles RID subdirectories)
- Fix winapp sign syntax: positional args, not --cert flag
- Simplify electron test to sample freshness check only (from-scratch
  Electron guide workflow is covered by E2E test in test-e2e-electron.ps1)
- Rename workflow and headings to 'Sample & Guide'
- Update CI matrix: packaging-cli needs Node.js, electron no longer
  needs .NET

Validated locally: packaging-cli, dotnet-app, rust-app, electron, wpf-app

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace 8 raw PowerShell test.ps1 files with Pester test.Tests.ps1 files
- Simplify SampleTestHelpers.psm1 from ~460 to ~180 lines (Pester handles assertions/reporting)
- Use BeforeDiscovery + BeforeAll dual-phase pattern for prerequisite skip logic
- Update orchestrator (scripts/test-samples.ps1) as thin Pester wrapper with comma-split support
- Update CI workflow for Invoke-Pester with JUnit XML test result reporting
- Update AGENTS.md with Pester conventions for sample tests
- Fix winapp cert info positional arg syntax in wpf-app test
- Resolve WinappPath to absolute in orchestrator before passing to containers

All 8 sample tests validated locally:
  packaging-cli: 10/10, electron: 7/7, dotnet-app: 15/15,
  rust-app: 15/15, wpf-app: 10/10, tauri-app: 17/17,
  cpp-app: 8 skipped (no cmake), flutter-app: 7 skipped (no flutter)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…l sample tests

- Replace all Invoke-Expression 'winapp ...' calls with Invoke-WinappCommand
  -Arguments in dotnet-app, packaging-cli, rust-app, and tauri-app tests.
  This ensures tests work in environments where winapp isn't on PATH by
  using the helper's fallback chain (npx -> dotnet run -> PATH).
- Fix flutter-app to use -Arguments named parameter consistently.
- Remove duplicate \ assignments in dotnet-app and rust-app.
- Update AGENTS.md to document Context-level -Skip as acceptable when
  BeforeAll has prerequisite-dependent setup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 9, 2026

Build Metrics Report

Binary Sizes

Artifact Baseline Current Delta
CLI (ARM64) 30.52 MB 30.52 MB 📈 +2.0 KB (+0.01%)
CLI (x64) 30.89 MB 30.89 MB 📈 +2.0 KB (+0.01%)
MSIX (ARM64) 12.89 MB 12.89 MB 📈 +3.0 KB (+0.02%)
MSIX (x64) 13.68 MB 13.67 MB 📉 -1.5 KB (-0.01%)
NPM Package 26.79 MB 26.79 MB 📉 -0.4 KB (-0.00%)
NuGet Package 26.87 MB 26.87 MB 📈 +0.7 KB (+0.00%)

Test Results

722 passed out of 722 tests in 381.2s (-140.6s vs. baseline)

Test Coverage

20.6% line coverage, 34.6% branch coverage · ✅ no change vs. baseline

CLI Startup Time

44ms median (x64, winapp --version) · ✅ no change vs. baseline


Updated 2026-04-17 20:24:10 UTC · commit e4c0329 · workflow run

nmetulev and others added 4 commits March 9, 2026 13:46
Migrate the full Electron guide workflow from scripts/test-e2e-electron.ps1
into samples/electron/test.Tests.ps1 as Phase 1, making electron consistent
with all other sample tests (Phase 1: from-scratch guide + Phase 2: sample
freshness check).

Changes:
- Rewrite electron test.Tests.ps1 with Phase 1 covering: Electron app
  creation, winapp init, C++/C# addon creation and build, debug identity,
  Electron packaging, certificate generation, and MSIX packaging.
- Remove e2e-test job from build-package.yml (now covered by test-samples.yml).
- Delete scripts/test-e2e-electron.ps1 (replaced by Pester test).
- Add .NET SDK setup for electron in test-samples.yml (needed for C# addon).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The workflow_run trigger only works for workflow files on the default
branch, so test-samples.yml won't trigger until merged. Adding
pull_request trigger lets sample tests run as proper PR checks.

For PR events, a build job produces the npm-package artifact first.
The test-sample jobs then download it, same as workflow_run/dispatch.
The build job is skipped for non-PR triggers since the artifact
comes from the Build and Package workflow instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 7, 2026 20:39

This comment was marked as outdated.

@nmetulev
Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 16, 2026

@copilot resolve the merge conflicts in this pull request

Resolved by merging latest main into this branch in commit 07d8819, and the branch is currently conflict-free.

@nmetulev
Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

Co-authored-by: nmetulev <711864+nmetulev@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 16, 2026

@copilot resolve the merge conflicts in this pull request

Resolved in 55e56a2. I merged latest main into this branch and completed the remaining conflict resolution; the branch is now conflict-free.

Jaylyn-Barbee and others added 3 commits April 16, 2026 14:47
…Package.appxmanifest

winapp init and manifest generate now output Package.appxmanifest instead of
appxmanifest.xml. Update all Phase 1 test assertions and --manifest arguments
to match the new filename. Phase 2 (existing sample) references are unchanged
since those samples still have appxmanifest.xml committed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nifest

The tauri test copies the existing sample (which has appxmanifest.xml) before
running winapp init. Since init with --use-defaults preserves existing manifests,
the file remains appxmanifest.xml rather than being regenerated as
Package.appxmanifest.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 29 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread samples/SampleTestHelpers.psm1 Outdated
Comment thread AGENTS.md Outdated
Comment thread .github/workflows/test-samples.yml Outdated
Comment thread samples/SampleTestHelpers.psm1 Outdated
nmetulev and others added 2 commits April 17, 2026 13:02
- Resolve-WinappCliPath: include artifacts\ in default candidates and pick newest .tgz by LastWriteTime
- Invoke-WinappCommand: prefer winapp on PATH over dotnet run against repo source so tests exercise the packaged CLI; opt back into dotnet via WINAPP_TEST_USE_DOTNET=1
- test-samples.yml: drop workflow_run trigger to avoid duplicate runs per PR; build job now also runs on workflow_dispatch so the workflow is self-contained; simplify artifact downloads
- AGENTS.md: fix local example to use .\artifacts\ where package-npm.ps1 emits the tarball

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nmetulev nmetulev enabled auto-merge (squash) April 20, 2026 16:18
@nmetulev nmetulev disabled auto-merge April 20, 2026 16:18
@nmetulev nmetulev merged commit 37a2acd into main Apr 20, 2026
21 checks passed
@nmetulev nmetulev deleted the nm/sample-tests branch April 20, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants