test: Use includeHiddenRows on tests (#80)

This commit is contained in:
Marcelo Mendonça Soares 2026-06-21 10:12:39 -03:00 • committed by GitHub
commit 5a8f9c91a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 73 additions and 35 deletions

View file

@ -45,9 +45,8 @@ void main() {
test('then the row still exist on the person table.', () async { test('then the row still exist on the person table.', () async {
final row = await Person.db.findFirstRow( final row = await Person.db.findFirstRow(
// Use the test session to avoid the tombstone filter of the CRDT database. session,
testSession, where: (t) => t.id.equals(person.id) & t.includeHiddenRows,
where: (t) => t.id.equals(person.id),
); );
expect(row, isNotNull); expect(row, isNotNull);
expect(row!.name, person.name); expect(row!.name, person.name);
@ -192,7 +191,10 @@ void main() {
test( test(
'then the unique property of the row is updated to a conflict-free value.', 'then the unique property of the row is updated to a conflict-free value.',
() async { () async {
final row = await Unique.db.findById(testSession, unique.id!); final row = await Unique.db.findFirstRow(
session,
where: (t) => t.id.equals(unique.id) & t.includeHiddenRows,
);
expect(row, isNotNull); expect(row, isNotNull);
expect(row!.name, startsWith(unique.name)); expect(row!.name, startsWith(unique.name));
@ -224,7 +226,10 @@ void main() {
test( test(
'then the unique UUID property of the row is updated to a conflict-free value.', 'then the unique UUID property of the row is updated to a conflict-free value.',
() async { () async {
final row = await UniqueUuid.db.findById(testSession, uniqueUuid.id!); final row = await UniqueUuid.db.findFirstRow(
session,
where: (t) => t.id.equals(uniqueUuid.id) & t.includeHiddenRows,
);
expect(row, isNotNull); expect(row, isNotNull);
expect(row!.value, isNot(uniqueUuid.value)); expect(row!.value, isNot(uniqueUuid.value));
@ -279,7 +284,10 @@ void main() {
test( test(
'then the unique nullable UUID foreign key is set to null.', 'then the unique nullable UUID foreign key is set to null.',
() async { () async {
final row = await Address.db.findById(testSession, address.id!); final row = await Address.db.findFirstRow(
session,
where: (t) => t.id.equals(address.id) & t.includeHiddenRows,
);
expect(row, isNotNull); expect(row, isNotNull);
expect(row!.inhabitantId, isNull); expect(row!.inhabitantId, isNull);
@ -424,9 +432,8 @@ void main() {
test('then the organization row still exist on the organization table.', () async { test('then the organization row still exist on the organization table.', () async {
final row = await Organization.db.findFirstRow( final row = await Organization.db.findFirstRow(
// Use the test session to avoid the tombstone filter of the CRDT database. session,
testSession, where: (t) => t.id.equals(organization.id) & t.includeHiddenRows,
where: (t) => t.id.equals(organization.id),
); );
expect(row, isNotNull); expect(row, isNotNull);
expect(row!.name, organization.name); expect(row!.name, organization.name);
@ -597,7 +604,7 @@ void main() {
test('then the company row is updated to the default town.', () async { test('then the company row is updated to the default town.', () async {
final updatedCompany = await Company.db.findFirstRow( final updatedCompany = await Company.db.findFirstRow(
testSession, session,
where: (t) => t.id.equals(company.id), where: (t) => t.id.equals(company.id),
); );

View file

@ -342,7 +342,10 @@ void main() {
); );
expect( expect(
await Unique.db.findById(testSession, deletedRow.id!), await Unique.db.findFirstRow(
session,
where: (t) => t.id.equals(deletedRow.id) & t.includeHiddenRows,
),
isNotNull, isNotNull,
); );
}); });
@ -362,11 +365,20 @@ void main() {
}); });
test('then the deleted row is still soft-deleted.', () async { test('then the deleted row is still soft-deleted.', () async {
expect(await Unique.db.findById(testSession, deletedRow.id!), isNotNull); expect(
await Unique.db.findFirstRow(
session,
where: (t) => t.id.equals(deletedRow.id) & t.includeHiddenRows,
),
isNotNull,
);
}); });
test('then the soft-deleted row has another conflict-free name.', () async { test('then the soft-deleted row has another conflict-free name.', () async {
final row = await Unique.db.findById(testSession, deletedRow.id!); final row = await Unique.db.findFirstRow(
session,
where: (t) => t.id.equals(deletedRow.id) & t.includeHiddenRows,
);
expect(row, isNotNull); expect(row, isNotNull);
expect(row!.name, startsWith(name)); expect(row!.name, startsWith(name));

View file

@ -86,8 +86,8 @@ void main() {
() async { () async {
expect( expect(
await Person.db.count( await Person.db.count(
testSession, session,
where: (t) => t.scopeId.equals(purgedScope.id), where: (t) => t.scopeId.equals(purgedScope.id) & t.includeHiddenRows,
), ),
greaterThan(0), greaterThan(0),
); );
@ -134,17 +134,17 @@ void main() {
'then the scope-owned domain rows are physically removed.', 'then the scope-owned domain rows are physically removed.',
() async { () async {
expect( expect(
await Person.db.findById(testSession, purgedKeptPerson.id!), await Person.db.findById(session, purgedKeptPerson.id!),
isNull, isNull,
); );
expect( expect(
await Person.db.findById(testSession, purgedDeletedPerson.id!), await Person.db.findById(session, purgedDeletedPerson.id!),
isNull, isNull,
); );
expect( expect(
await Person.db.count( await Person.db.count(
testSession, session,
where: (t) => t.scopeId.equals(purgedScope.id), where: (t) => t.scopeId.equals(purgedScope.id) & t.includeHiddenRows,
), ),
0, 0,
); );
@ -187,7 +187,7 @@ void main() {
'then the surviving scope keeps its domain rows and metadata.', 'then the surviving scope keeps its domain rows and metadata.',
() async { () async {
expect( expect(
await Person.db.findById(testSession, survivingPerson.id!), await Person.db.findById(session, survivingPerson.id!),
isNotNull, isNotNull,
); );
expect( expect(

View file

@ -188,7 +188,7 @@ void main() {
}); });
test('then the owner row is not overwritten.', () async { test('then the owner row is not overwritten.', () async {
final row = await Person.db.findById(testSession, rowId); final row = await Person.db.findById(session, rowId);
expect(row, isNotNull); expect(row, isNotNull);
expect(row!.name, 'shared row'); expect(row!.name, 'shared row');

View file

@ -248,7 +248,10 @@ void main() {
}); });
test('then the deleted row keeps its original value.', () async { test('then the deleted row keeps its original value.', () async {
final row = await Person.db.findById(testSession, person.id!); final row = await Person.db.findFirstRow(
session,
where: (t) => t.id.equals(person.id) & t.includeHiddenRows,
);
expect(row, isNotNull); expect(row, isNotNull);
expect(row!.name, person.name); expect(row!.name, person.name);
@ -466,9 +469,10 @@ void main() {
expect(foundVisibleRow, isNotNull); expect(foundVisibleRow, isNotNull);
expect(foundVisibleRow!.name, 'updated'); expect(foundVisibleRow!.name, 'updated');
// Use the test session to find the deleted row, since it is not visible final foundDeletedRow = await Unique.db.findFirstRow(
// in the CRDT database. session,
final foundDeletedRow = await Unique.db.findById(testSession, deletedRow.id!); where: (t) => t.id.equals(deletedRow.id) & t.includeHiddenRows,
);
expect(foundDeletedRow, isNotNull); expect(foundDeletedRow, isNotNull);
expect(foundDeletedRow!.name, startsWith(deletedRow.name)); expect(foundDeletedRow!.name, startsWith(deletedRow.name));
expect(foundDeletedRow.name, isNot(deletedRow.name)); expect(foundDeletedRow.name, isNot(deletedRow.name));
@ -494,7 +498,10 @@ void main() {
}); });
test('then the soft-deleted row has another conflict-free name.', () async { test('then the soft-deleted row has another conflict-free name.', () async {
final row = await Unique.db.findById(testSession, deletedRow.id!); final row = await Unique.db.findFirstRow(
session,
where: (t) => t.id.equals(deletedRow.id) & t.includeHiddenRows,
);
expect(row, isNotNull); expect(row, isNotNull);
expect(row!.name, startsWith(deletedRow.name)); expect(row!.name, startsWith(deletedRow.name));

View file

@ -57,7 +57,13 @@ void main() {
test('then the row is hidden by the tombstone.', () async { test('then the row is hidden by the tombstone.', () async {
expect(await Person.db.findById(session, person.id!), isNull); expect(await Person.db.findById(session, person.id!), isNull);
expect(await Person.db.findById(testSession, person.id!), isNotNull); expect(
await Person.db.findFirstRow(
session,
where: (t) => t.id.equals(person.id) & t.includeHiddenRows,
),
isNotNull,
);
}); });
test('then the tombstone is recorded as deleted.', () async { test('then the tombstone is recorded as deleted.', () async {

View file

@ -1739,7 +1739,10 @@ void main() {
'then the child is hidden so no visible orphan remains.', 'then the child is hidden so no visible orphan remains.',
() async { () async {
final visibleChild = await Address.db.findById(session, child.id!); final visibleChild = await Address.db.findById(session, child.id!);
final hiddenChild = await Address.db.findById(testSession, child.id!); final hiddenChild = await Address.db.findFirstRow(
session,
where: (t) => t.id.equals(child.id) & t.includeHiddenRows,
);
final crdtRow = await CrdtDataRow.db.findFirstRow( final crdtRow = await CrdtDataRow.db.findFirstRow(
session, session,
where: (t) => t.uuidRowId.equals(child.id), where: (t) => t.uuidRowId.equals(child.id),
@ -1816,9 +1819,9 @@ void main() {
session, session,
child.id!, child.id!,
); );
final hiddenChild = await Organization.db.findById( final hiddenChild = await Organization.db.findFirstRow(
testSession, session,
child.id!, where: (t) => t.id.equals(child.id) & t.includeHiddenRows,
); );
final crdtRow = await CrdtDataRow.db.findFirstRow( final crdtRow = await CrdtDataRow.db.findFirstRow(
session, session,

View file

@ -575,9 +575,9 @@ void main() {
test( test(
'then the hidden row keeps its released unique value.', 'then the hidden row keeps its released unique value.',
() async { () async {
final hiddenRow = await Unique.db.findById( final hiddenRow = await Unique.db.findFirstRow(
testSession, session,
deletedRow.id!, where: (t) => t.id.equals(deletedRow.id) & t.includeHiddenRows,
); );
expect(hiddenRow, isNotNull); expect(hiddenRow, isNotNull);

View file

@ -277,7 +277,10 @@ void main() {
}); });
test('then the field value is merged into the hidden row.', () async { test('then the field value is merged into the hidden row.', () async {
final hiddenRow = await Person.db.findById(testSession, person.id!); final hiddenRow = await Person.db.findFirstRow(
session,
where: (t) => t.id.equals(person.id) & t.includeHiddenRows,
);
final field = await CrdtDataField.db.findFirstRow( final field = await CrdtDataField.db.findFirstRow(
session, session,
where: (t) => where: (t) =>