---
title: "Discard an edited draft without persisting fields"
description: "Verify that Cancel abandons changes across text, selection, and toggle controls while reopening the record restores the last saved values."
canonical_url: "https://vostride.com/agent-library/forms-validation/cancel-edit-restores-saved.md"
md_url: "https://vostride.com/agent-library/forms-validation/cancel-edit-restores-saved.md"
content_kind: "recipe"
topic: "forms-validation"
---

# Discard an edited draft without persisting fields

Verify that Cancel abandons changes across text, selection, and toggle controls while reopening the record restores the last saved values.

## Risk

Local state can leak a canceled edit into the next editor session even when the backend is unchanged. Check both the read-only detail and a newly opened editor after discarding the draft.

## Fixtures

- A test profile has display name Cedar desk, timezone UTC, and a disabled weekly-summary toggle.
- The editor has an explicit Cancel action whose documented contract is to discard unsaved changes.
- A fixture inventory records the three initial values independently before the browser journey.

## Steps

1. Open the profile editor and verify the initial name, timezone, and summary-toggle state.
2. Change the name to Maple desk, choose a different timezone, and enable weekly summary without saving.
3. Choose Cancel and verify the read-only profile still displays Cedar desk and UTC with summary disabled.
4. Reopen the editor and verify all three original values are restored, with no abandoned draft visible.
5. Reload the page and inspect the profile again to verify that none of the canceled values persisted.

## Expected results

- The saved profile matches the initial fixture values after cancellation.
- A fresh editor session initializes from saved state rather than the discarded component state.
- Reloading confirms the unchanged detail was not merely a stale UI snapshot hiding a persisted mutation.

## False-pass traps

- Checking only the text field misses canceled select or toggle state leaking into the next edit.
- Using the browser back button instead of the product Cancel action exercises a different behavior.

## Cleanup

- Restore the original profile values through the fixture setup if an unexpected mutation occurred.

## Use with agent-qa

Adapt this test design to your application's acceptance criteria and configured target using the [recipe execution guide](/agent-library/software-factory/turn-a-recipe-into-an-agent-qa-test.md). External fixture setup and non-UI checks require your own supported hooks or test tooling. Validate the authored test, execute it, and inspect the completed evidence; this recipe is not a recorded test result.

## References

- [agent-qa test](/docs/agent-qa/configuration/test.md)
- [agent-qa first test](/docs/agent-qa/guides/first-test.md)
- [agent-qa web testing](/docs/agent-qa/guides/web-testing.md)

- [Forms and validation QA recipes](/agent-library/forms-validation.md)
- [Software factory QA library](/agent-library.md)
