A green success message answers one question: did the action report a failure? It does not tell you whether your update selected the intended record.
For a small service-request app, use two requests from the same fictional customer. Give them different saved IDs. If the update is accidentally filtered by customer name, the second record makes the mistake visible.
| Fixture ID | Customer | Starting status |
|---|---|---|
request_101 |
Alex Example | New |
request_102 |
Alex Example | New |
Reproduce the selection bug without a database
Save this as two-record-check.mjs and run node two-record-check.mjs. It uses only Node's built-in assertion module. The IDs are in-memory fixture values; use the actual saved IDs when testing a database.
import assert from 'node:assert/strict';
const before = [
{ id: 'request_101', customer: 'Alex Example', status: 'New' },
{ id: 'request_102', customer: 'Alex Example', status: 'New' },
];
const updateStatus = (rows, matches) =>
rows.map((row) =>
matches(row) ? { ...row, status: 'In progress' } : { ...row }
);
// The customer is not a unique request identifier.
const wrong = updateStatus(before, (row) => row.customer === 'Alex Example');
assert.deepEqual(wrong.map((row) => row.status), ['In progress', 'In progress']);
// Select exactly one request using its stable ID.
const right = updateStatus(before, (row) => row.id === 'request_101');
assert.equal(right[0].status, 'In progress');
assert.deepEqual(right[1], before[1]);
assert.deepEqual(right.map((row) => row.id), before.map((row) => row.id));
// A predicate can complete normally while changing nothing.
const missing = updateStatus(before, (row) => row.id === 'missing');
assert.deepEqual(missing, before);
// The fixture itself remains unchanged for the next test.
assert.deepEqual(before.map((row) => row.status), ['New', 'New']);
console.log('Passed: wrong selector, exact-ID selector, no match, unchanged fixture.');
The first assertion demonstrates the wrong outcome: both requests change. The next three assertions describe the intended update. The no-match example also finishes normally, although it changes no record.
This is a deterministic test of a selection predicate. It does not exercise a network request, database policy or published app.
Make the database response observable
With an already configured, appropriately authenticated Supabase JavaScript client, an update can look like this. Assume a practice table named service_requests, a unique id column, and an actual selected ID of the same type returned by the client:
const { data, error } = await supabase
.from('service_requests')
.update({ status: 'In progress' })
.eq('id', selectedRequestId)
.select('id, status');
if (error) throw error;
if (!data || data.length !== 1 ||
data[0].id !== selectedRequestId ||
data[0].status !== 'In progress') {
throw new Error('Expected one returned request with the intended ID and status');
}
Supabase's update reference explains that updated rows are not returned by default; chain .select() to request them. An error-free response with no returned matching row is not evidence of the intended change.
The check above happens after the update. Throwing an error there does not roll back a write that already happened. For this small test, stop other writers, keep the baseline, and read both practice records again from the data source. Verify the intended status and the complete set of business fields you expected to leave unchanged.
Do not use a missing response as a reason to broaden the filter or remove a policy. Supabase's RLS guide describes the policies needed for permitted operations, including a corresponding SELECT policy for updates. A filter chooses a record within the access rules; it does not establish authorization.
Apply the check to a visual builder
In AppStruct's Supabase Database Request, configure Insert, Select and Update as separate actions. First inspect the inserted records to obtain their actual saved IDs. For a bounded initial Update test, use an equality filter on the identifier column with one literal saved ID and map only the status change.
Select that record again, then select the second request and compare the saved values. After that passes, test the dynamic path separately: select the second card in the interface and inspect which ID reaches the update action. A working fixed-ID exercise does not establish that a selected-card binding works in the published build.
This same test design is useful with another builder or an HTTP API. Keep the action names and response mappings specific to the tool you are actually testing.
Keep a short evidence log
Record these observations in a private practice log:
- Both actual saved IDs and the starting fields.
- The selected ID and requested status.
- The update result and a fresh read of both records.
- Which user session performed the operation.
- The app URL and build you tested.
- The result after closing and reopening the detail screen.
Repeat allowed and denied operations with the test accounts agreed by the backend owner. In an isolated, non-concurrent fixture, the intended request should change and the other should retain its baseline values. In a shared system, include concurrent writes and their expected handling as a separate test.
The AppStruct/Supabase walkthrough and runnable test provides this .mjs file and a 16-case practice log. No signup is required for either download; every worksheet case starts as Not checked.
Disclosure: This article was generated with AI assistance for the AppStruct publishing account. The Node fixture above was executed locally; the Supabase API pattern was checked against the official references. No live Supabase connection or customer deployment was tested for this article.
Top comments (0)