LifeMate — Personal, Family & Learning Companion
test(backend): isolate feedback unit from concurrent assessment fixtures
davoodmehraban89 committed
Oct 15, 2026 at 09:40 UTC
a2256929440ff348744e35ee7116211c49a32d31
1 file changed
+9
-2
backend/tests/learning_feedback.test.js
+9
-2
@@ -154,8 +154,15 @@ describe('learning feedback authenticated real HTTP and synthetic PostgreSQL', {
154
155
test('real submission stores only chosen text and an existing draft unit can be referenced', async () => {
156
const user = await actor();
157
- const units = await pool.query('select id from learning_unit order by id limit 1');
158
- assert.equal(units.rowCount, 1, 'Library fixture must import a public catalogue unit');
157
+ // The assessment suite creates ephemeral units concurrently. Selecting any
158
+ // global minimum UUID may bind this feedback row to another suite's unit and
159
+ // make that suite's fixture teardown fail with a foreign-key violation.
160
+ // Use the deterministic checked public-catalogue row imported by CI.
161
+ const units = await pool.query(`select u.id from learning_unit u
162
+ join textbook_catalog t on t.id=u.textbook_id
163
+ where t.book_code='101' and t.source_url='http://www.chap.sch.ir/books/14142'
164
+ order by u.order_index,u.id limit 1`);
165
+ assert.equal(units.rowCount, 1, 'Seeded primary catalogue unit must exist');
166
const body = submission({ unitId: units.rows[0].id, category: 'unclear', summary: '<b>SYNTHETIC-CHOSEN-FEEDBACK</b>' });
167
const created = await post(user, body);
168
assert.equal(created.status, 201);