FREEFirst project with us? Your landing page design is on the house.See the offer

Chapter 6 of 6

Testing and governance

Libraries decay without rules. What to test on each section, how a new one gets added, how to change a section without breaking live pages, and who owns what.

6 min readUpdated 2026-11-07
All chaptersChapter 6 of 6
  1. 01Why sections, not pages
  2. 02Planning the library
  3. 03Sanity schemas for sections
  4. 04Studio for marketers
  5. 05AI page building with guardrails
  6. 06Testing and governance

The short answer

Test each section at its limits, on one page that shows every variant. Add new sections through one short request process. Change live sections carefully, because saved content does not update itself when the schema changes. Retire sections in stages. Name one owner, and review the library on a regular rhythm.

The aim is a boring library: one that still makes sense to a new team member a year from now.

What to test on every section

Test the extremes. Average content rarely breaks anything. Run this for each variant.

TestWhat to tryPass when
Longest contentText at the validation limit, in your longest real wordsNo overflow or broken layout at phone width
Shortest contentOnly required fields filledNo gaps or empty wrappers
Item countsThe fewest and most items a list allowsGrid still looks intended
ImagesTall, wide and small images, odd hotspotsCrops are fine, and no layout shift
NeighboursNext to each other section, dark next to darkSpacing holds
ScreensPhone to wide desktopNo sideways scroll
Keyboard and screen readerTab through it, check heading orderEverything can be reached, and headings make sense
No JavaScript, reduced motionTurn each offContent can still be read
SpeedLighthouse on a page with the sectionMeets your budget

Build a kitchen sink page

Make one private page that holds every section in every variant, at both the longest and shortest content. Mark it noindex and leave it out of your sitemap. It becomes your test bench, and a living catalogue for editors.

Use it for:

  • Screenshot tests. Compare before and after on each code change, so you see what really moved.
  • Reviews. A designer can check the whole library in one scroll.
  • Onboarding. A new editor can see what exists.
  • AI checks. Compare what the AI built with what a section should look like.

Keep this page's content in code or in a seed file, if you can, so a stray edit cannot hide a bug.

Automatic checks

Run these in your CI on each pull request that touches sections, so problems stop before they reach an editor.

  • Schema check: sanity schemas validate.
  • Type check: TypeGen, then your type checker.
  • Content check: sanity documents validate against a copy of your dataset, to find saved content that no longer fits.
  • Build: every section type has a component.
  • Pages: crawl the built site for errors, broken links and sideways scroll.
  • Screenshots of the kitchen sink page.
  • Speed and page weight budgets.

You do not need all of these on day one. Start with the build and the schema check, then add the rest as the library grows.

How a new section gets added

When adding is too easy, the library bloats. When it is too hard, people work around it. A short written request is enough.

  1. Request. Which page needs it? What job does it do? Which existing section came closest, and why does it fall short?
  2. Owner decides. One of four answers: use an existing section, add a variant, add a section, or make a one-off.
  3. Design. Every screen size, every variant, the longest content.
  4. Build. Schema, component, preview image, usage note, kitchen sink entry.
  5. Test. The table above, then watch an editor try it.
  6. Announce. Tell editors, and add it to the AI's library guide. If the AI's guide is not updated, it will not know the section exists, or when to use it.

Decision rule Add a section when at least two planned pages need it, or one page needs it and it earns real money. Otherwise, build a one-off page and look again if the need comes back. Writing down why you said no saves the same debate later.

Change sections without breaking pages

Sanity's migration docs are clear: changing a schema will not change or delete content already in your dataset. Old documents stay as they are, so they may no longer match. So sort every change by how risky it is.

ChangeRiskHow to handle it
New optional fieldLowShip it, and make sure the component copes when it is empty
Tighter length limitMediumCheck saved content first. Long text will start failing validation
Remove a variantMediumMove pages off it first, then remove
Rename a fieldHighAdd the new one, migrate content, ship the code, then remove the old one
Rename a section typeHighAvoid it if you can. Plan and test a migration on a copy first

For high-risk changes, use the migration tool. sanity migrations create makes a script, and sanity migrations run <id> runs it. The docs say it always runs as a dry run unless you add --no-dry-run, so you can read the patches first. They also say to back up first with sanity datasets export. Do not keep two sections called hero and heroV2 for long. Parallel versions are fine during a move, but they should have an end date.

Retire sections in stages

Removing a section from of does not remove it from saved pages. So go in order:

  1. Find it. Use GROQ to list the pages that still use the section.
  2. Warn. Add a warning in the Studio, and tell editors and the AI's guide to stop using it. Sanity also has a deprecated property for document types and fields. Try it on your section fields, and check how it behaves there before relying on it.
  3. Move. Replace it on each page, by hand or with a migration.
  4. Remove. Take it out of of, then delete the schema, the component and its preview image. Only do this when your search returns no pages.

Who owns what

Write this down once, and put names in it. Titles are only examples.

JobWhoHow often
Decide on section requestsLibrary ownerAs they come in
Design and variant rulesDesignerPer change
Schemas, components, checksDeveloperPer change
Fact documents: prices, quotes, clientsMarketing leadWhen facts change
AI skills and recipesLibrary owner, with marketingEach new section
Usage reviewLibrary ownerEvery few months

In the usage review, count how often each section is used with a GROQ query, ask editors what they avoided, and read a few AI drafts. Merge or retire what nobody uses.

Done when A new person can find out what exists, how to request a section and who decides, without asking anyone.

If you want this built for you, an Astro and Sanity site starts at $2,000 and includes a section library, as our pricing page shows. Adding a library to an existing Sanity site gets a fixed quote after a 20 minute call. See section library.

Takeaways

What to remember from chapter 6.

  • Test at the extremes, on one page that shows every section and variant.
  • One short request process, and one owner who can say no.
  • Schema changes do not touch saved content, so sort changes by risk and migrate.
  • Retire in stages. Search first, and remove last.
  • Put names on the jobs, and review usage every few months.

Keep a copy

Take the whole guide
as a PDF.

It all stays free to read here. If you want a copy for your team, leave your email and the download link shows up right away.

Nothing gets emailed to you, the link appears on this page. We do not send marketing email unless you ask. Privacy policy

Your turn

Let's kook
what you krave.

Hi Kookies, I need a built on . I'd love to launch . Reach me at
or book a callSent. We reply within one working day.