Files
coder/site/e2e
Jake Howell 1c6b121610 fix(site): persist disabled template autostop settings (#30477)
> 🤖 This PR was modified by Coder Agents on behalf of Jake Howell.

In template settings → Schedule, setting Default autostop or Activity
bump to `0` appeared to save successfully, but omitted the field from
the PATCH request. The API preserves omitted values, leaving the
previous duration configured despite the UI saying zero disables it.

Send explicit zeros, including clearing a stale activity bump when
neither default nor user-customizable autostop is enabled. Preserve
nonzero conversions. Replace the affected story submission assertion
with real-form Vitest coverage while retaining its visual state.

<details>
<summary>Regression evidence and validation</summary>

- Four zero-value cases failed before the fix with `undefined` instead
of zero; the nonzero control passed. All five pass after the fix.
- Covers disabling either setting, disabling both, clearing a disabled
stale bump, and nonzero conversion.
- Extended the existing Playwright E2E test to save 48h autostop and 2h
activity bump, reload, disable both, and fetch the template from the
real API. With the old serialization, it fails because persisted values
remain 172800000ms and 7200000ms rather than zero. With the fix, the
test and both setup dependencies pass against a fresh local server.
Unrelated template settings are also checked for preservation.
- All nine schedule stories pass; browser verification confirms both
explicit zeros in serialized requests.
- `pnpm check`, `pnpm lint`, and `pnpm format` pass.
- Full unit file: 22 pass; three existing page-integration tests fail
locally as the page returns to a loading state during interaction. The
original API submission test also fails in isolation before the
production fix. New regressions render the real form without the
unrelated page-loading harness.
- Local stress fixtures and screenshots are excluded.

</details>
2026-10-07 23:30:01 +00:00
..
…

e2e

The structure of the end-to-end tests is optimized for speed and reliability. Not all tests require setting up a new PostgreSQL instance or using the Terraform provisioner. Deciding when to trade time for robustness rests with the developers; the framework's role is to facilitate this process.

Take a look at prior art in tests/ for inspiration. To run a test:

cd site
# Build the frontend assets. If you are actively changing
# the site to debug an issue, add `--watch`.
pnpm build
# Alternatively, build with debug info and source maps:
NODE_ENV=development pnpm vite build --mode=development
# Install the browsers to `~/.cache/ms-playwright`.
pnpm playwright:install
# Run E2E tests. You can see the configuration of the server
# in `playwright.config.ts`. This builds and runs `site/e2e/bin/coder`.
pnpm playwright:test
# Run a specific test (`-g` stands for grep. It accepts regex).
pnpm playwright:test -g '<your test here>'

Using nix

If this breaks, it is likely because the flake chromium version and playwright are no longer compatible. To fix this, update the flake to get the latest chromium version, and adjust the playwright version in the package.json.

You can see the playwright version here: https://search.nixos.org/packages?channel=unstable&show=playwright-driver&from=0&size=50&sort=relevance&type=packages&query=playwright-driver

# Optionally add '--command zsh' to choose your shell.
nix develop
cd site
pnpm install
pnpm build
pnpm playwright:test

To run the playwright debugger from VSCode, just launch VSCode from the nix environment and have the extension installed.

# Optionally add '--command zsh' to choose your shell.
nix develop
code .

Enterprise tests

Enterprise tests require a license key to run.

export CODER_E2E_LICENSE=<license key>

Debugging tests

To debug a test, it is more helpful to run it in ui mode.

pnpm playwright:test-ui