How we test an estate agency CRM before every release

Asadullah7 min read

The short answer

Testing a SaaS CRM before release works best as a series of gates that each catch a different kind of failure: automated tests against real databases, static and security scans, a staging environment running the identical build, a separate step for database migrations, and a promotion that refuses to run unless staging is green and serving the exact commit. Propily applies those gates to both the API and the web app, then adds checks by hand wherever money, compliance records or outbound messages are involved.

What the automated test suites cover

The backend suite is pytest, with more than 1,300 test files across two trees (counted on the staging branch when this was written). More than half are unit tests that stub the outside world. A second group runs against a real Postgres database in a throwaway schema, because advisory locks, rollbacks and unique constraints are the point of those tests. Much of the finance and tenancy suites work this way, and a fake bank stands in for the real one. A third group covers security: one agency cannot reach another's documents, leads or deals by guessing an id, and webhooks must refuse unsigned payloads.

The frontend runs Jest in a jsdom browser environment with Testing Library, across more than 900 test files. They render a screen and assert what a user would see. A bank connection that has not synced for 30 hours must show an out-of-date banner, for example. API clients are tested separately from the screens, and finance, portals and the dashboard have the densest coverage.

Checks that run before anything deploys

Both repositories run their pipeline when a commit lands on staging or main, and a deploy only starts from a green run. On the backend that means linting, a check that the migration history has exactly one head, the tests, a Docker image build with a start-up smoke test, an image vulnerability scan that fails on any fixable critical finding, secret scanning of the new commits, a dependency audit, and static analysis that fails on new findings. Scheduled weekly scans look for new vulnerabilities in what is already deployed.

On the frontend it is ESLint, a TypeScript type check, the Jest suite, secret scanning, a dependency audit, Semgrep, an image build and a Trivy scan, then a check that the image reports the commit it was built from.

We do not run the full pipeline on every pull request. A pull request run plus the merge run was a large share of our CI usage, so the gate sits on the merge to staging and on the deploy instead. Pull requests get human review, and a narrow job runs the assistant and MCP tests when those areas change. A staging push runs the fast suite. The slow database-backed finance and tenancy suites run on every push to main, which gates the production deploy, and nightly against staging.

A staging environment that runs the same build

Staging used to build its own images from source on its server, so it ran different bytes from production and 'verified on staging' meant less than it sounded. Now staging deploys the exact image CI built, and production re-tags that same image. The shape matches production: nginx, the API, workers, the scheduler and Redis on one host. The differences are written down rather than hidden. Staging has its own database, stores files on local disk where production uses S3, and sits behind its own login.

Risky features ship dark. The second version of the tenant portal is gated by a backend flag and a frontend build flag, and the order is fixed: backend with the flag off, frontend with it off, backend on, then frontend on, because the frontend must never run ahead of the backend. A staging build can show the new interface while the production build keeps it off.

How migrations and releases move from staging to production

Migrations are handled by hand on purpose. Deploys never run Alembic. A manual workflow applies a named revision inside the running container, defaults to a dry run, and prints the revisions it would run before it runs them. The deploy pipeline has its own guard, sketched below: it works out the head revisions from the migration files, compares them with what the production database reports, and stops if the database is behind.

Promotion is manual too. Someone starts the promote workflow on staging and types the word PROMOTE. It refuses unless the tip of staging has a green CI run, a green staging deploy, and a live staging site reporting that exact commit. It moves main forward as a fast-forward only, never a merge commit, and its summary lists any migrations the release adds. Production then deploys, checks the public health endpoint, rolls back to the previously recorded build if it never turns healthy, and finally confirms the live commit.

revs, downs = set(), set()
for path in glob("alembic/versions/*.py"):
    rev, down = read_revision_ids(path)
    revs.add(rev)
    downs.update(down)

heads = revs - downs   # a head is a revision nothing descends from
# more than one head means two branches added migrations in parallel;
# the deploy compares these heads with the database's current revision

What we check by hand

Automation cannot decide whether a figure is right for an agency, so some checks stay human. These are the ones our runbooks write down.

  • Money. A change to anything that touches rent or payouts runs on staging first, with balances and every transaction compared against the bank's own statement. A rule that changes what a joint tenant sees on a statement needs sign-off from finance, not only a passing test.
  • Migrations. Read the dry run's list of revisions before applying, and snapshot the production database first when the chain is large.
  • Messaging. Before starting workers on a restored database, look for scheduled or recurring emails nobody at Propily created, because workers send whatever is due to real contacts. We never run workers locally against a database that holds real contacts.
  • Compliance and privacy. Confirm that uploaded evidence is scanned for malware, and that the CDN serves private prefixes only to signed requests, because the application cannot see the CDN's configuration.

The failures we test for, and what we changed

Many of our checks target one specific way a release can go wrong.

  • Code ahead of its migration. A deploy that ships queries for columns the database does not have yet fails every request that touches them. Migrations now go first, and the deploy guard refuses to proceed if the database is behind.
  • A deploy that reports success on an unreachable site. The pipeline now checks from outside, through the public edge, and rolls back automatically.
  • Money counted twice. Bank sync has four ways to count a payment twice: a reconnect re-imports history, a pending line stays beside its booked twin, one agency's error rolls back everyone's sync, and two syncs race. Each is a regression test against real Postgres.
  • A queue nobody listens to. A task sent to a queue with no consumer is accepted and then waits forever. WhatsApp has its own worker, so a client's message does not wait behind scheduled work, and a test derives the expected queue list from the code, so a new queue without a consumer fails the build.
  • Mock money booked as rent. Test-mode and mock-payment switches are forced off in production unless an explicit override is set, and the override is logged as critical.

Questions to ask a vendor about release testing

Ask how a vendor tests the parts that touch money, what a release is allowed to skip, who applies database changes and how a bad deploy is reversed. Our letting agent software page shows the lettings and finance features these checks protect.

Questions people ask

What should a QA process for a SaaS CRM include?

Automated tests that hit a real database for anything involving money, static and security scans, a staging environment running the same build as production, a controlled path for database migrations, and a few written manual checks for risky changes.

Why test a CRM on staging before production?

Staging catches what unit tests cannot: configuration, infrastructure and data-shape differences. It only helps if staging runs the same image as production, which is why we deploy the exact build to both.

Why are database migrations a separate step from deploys?

If code ships before its migration, every query on the changed table can fail. Applying the migration first, with a dry run, and having the deploy refuse to proceed on a database that is behind, removes that failure.

Do you run every test on every pull request?

No. The full pipeline runs on merges to staging and main, and the slowest database-backed suites run on main and nightly. Pull requests get human review and a narrow job for the assistant and MCP code.

Who answers your phones tonight?Book a demo
Testing a SaaS CRM before release: our QA process | Propily