diff --git a/TESTING.md b/TESTING.md index f06d98a..c2f13aa 100644 --- a/TESTING.md +++ b/TESTING.md @@ -19,6 +19,7 @@ The `tests/` IIS application assumes the repository layout keeps `tests/`, `publ | Create | `tests/component/web.config` | Mirrored config for nested component pages that load config-aware code | | Create | `tests/integration/web.config` | Mirrored config for nested integration pages that load config-aware code | | Create | `tests/sync-webconfigs.vbs` | Utility script to mirror `tests/web.config` into nested test folders | +| Create | `tests/run-tests.cmd` | Windows helper to sync configs and open the test runner URL | | Create | `tests/bootstrap.asp` | Shared test bootstrap and runtime reset helpers | | Create | `tests/PlainRunnerTheme.asp` | Local runner theme that removes CDN dependence from the test UI | | Create | `tests/support/HttpCaptureHelpers.asp` | Shared HTTP capture helpers for rendered-page assertions | @@ -33,6 +34,7 @@ The `tests/` IIS application assumes the repository layout keeps `tests/`, `publ | Create | `tests/integration/TestRoutes.asp` | Route-helper/config integration coverage | | Create | `tests/integration/TestConfigSettings.asp` | Nested config and fallback behavior coverage | | Create | `tests/integration/TestRenderedOutput.asp` | Production-page output assertions through safe HTTP capture | +| Create | `tests/integration/TestSharedLayout.asp` | Shared header/footer/layout assertions against rendered production pages | | Reference | `public/web.config` | Source of mirrored config keys for the test app | | Reference | `core/helpers.asp` | Helper functions and config-loading behavior under test | | Reference | `core/mvc.asp` | Dispatcher behavior used by the smoke test | @@ -49,6 +51,7 @@ The `tests/` IIS application assumes the repository layout keeps `tests/`, `publ 6. If you change `tests/web.config`, run `cscript //nologo tests\sync-webconfigs.vbs` to refresh the nested copies used by the unit, component, and integration pages. 7. If your production app is not served from the same host root as the `tests/` app, set `ProductionAppBaseUrl` in `tests/web.config` and re-run the sync script so rendered-output tests know where to send HTTP requests. Example: `http://localhost/` for a root site, or `http://localhost/MyClassicApp/` for a virtual-directory app. +8. To sync configs and open the suite in one step on Windows, run `tests\run-tests.cmd` with an optional runner URL argument. Example layout: @@ -84,12 +87,25 @@ http://localhost/tests-dev/run-all.asp aspunit renders a UI in runner mode and loads each registered page with `?task=test` behind the scenes. +On Windows you can also use: + +```bat +tests\run-tests.cmd +``` + +Or with an explicit runner URL: + +```bat +tests\run-tests.cmd http://localhost:8085/run-all.asp +``` + ## Adding a New Test Page 1. Choose the right folder: - `tests/unit/` for deterministic helper or registry tests - `tests/component/` for direct controller/object tests with controlled setup - - `tests/integration/` for narrow runtime smoke coverage, config behavior, or rendered-page capture +- `tests/integration/` for narrow runtime smoke coverage, config behavior, or rendered-page capture + - shared layout assertions belong here too, because they verify rendered production responses rather than isolated helper behavior 2. Create a new `.asp` file that: - includes `../aspunit/Lib/ASPUnit.asp` - includes `../bootstrap.asp` @@ -120,6 +136,7 @@ aspunit renders a UI in runner mode and loads each registered page with `?task=t - Helper, registry, component, and integration suites all execute. - Route-helper/config integration assertions execute from the same isolated IIS app. - Rendered-page capture assertions can verify production HTML and status codes without polluting aspunit JSON responses. +- Shared layout assertions can verify navbar, asset links, titles, and footer script presence across production-rendered pages. - Re-running the suite produces stable results. - The production site under `public/` still exposes no test runner pages or test routes. diff --git a/tests/integration/TestSharedLayout.asp b/tests/integration/TestSharedLayout.asp new file mode 100644 index 0000000..b5645b6 --- /dev/null +++ b/tests/integration/TestSharedLayout.asp @@ -0,0 +1,69 @@ + + + + +<% +Call ASPUnit.AddModule( _ + ASPUnit.CreateModule( _ + "Shared Layout Render Tests", _ + Array( _ + ASPUnit.CreateTest("HomePageIncludesSharedHeaderAssets"), _ + ASPUnit.CreateTest("HomePageUsesControllerTitleInLayout"), _ + ASPUnit.CreateTest("NotFoundPageStillIncludesSharedLayoutChrome") _ + ), _ + ASPUnit.CreateLifeCycle("SetupSharedLayout", "TeardownSharedLayout") _ + ) _ +) + +Call ASPUnit.Run() + +Sub SetupSharedLayout() + Call ResetTestRuntime() +End Sub + +Sub TeardownSharedLayout() + Call ResetTestRuntime() +End Sub + +Function HomePageIncludesSharedHeaderAssets() + Dim responseData + Dim body + + Set responseData = FetchPage("/") + body = responseData.Item("body") + + Call ASPUnit.Ok((responseData.Item("status") = 200 And _ + InStr(body, "navbar-brand rk-navbar-brand") > 0 And _ + InStr(body, "/css/site.css") > 0 And _ + InStr(body, "bootstrap.bundle.min.js") > 0), _ + "Home page should include shared header and footer assets from the layout") + + Set responseData = Nothing +End Function + +Function HomePageUsesControllerTitleInLayout() + Dim responseData + Set responseData = FetchPage("/") + + Call ASPUnit.Ok((InStr(LCase(responseData.Item("body")), "