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

View file

@ -342,7 +342,10 @@ void main() {
);
expect(
await Unique.db.findById(testSession, deletedRow.id!),
await Unique.db.findFirstRow(
session,
where: (t) => t.id.equals(deletedRow.id) & t.includeHiddenRows,
),
isNotNull,
);
});
@ -362,11 +365,20 @@ void main() {
});
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 {
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!.name, startsWith(name));

View file

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

View file

@ -188,7 +188,7 @@ void main() {
});
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!.name, 'shared row');

View file

@ -248,7 +248,10 @@ void main() {
});
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!.name, person.name);
@ -466,9 +469,10 @@ void main() {
expect(foundVisibleRow, isNotNull);
expect(foundVisibleRow!.name, 'updated');
// Use the test session to find the deleted row, since it is not visible
// in the CRDT database.
final foundDeletedRow = await Unique.db.findById(testSession, deletedRow.id!);
final foundDeletedRow = await Unique.db.findFirstRow(
session,
where: (t) => t.id.equals(deletedRow.id) & t.includeHiddenRows,
);
expect(foundDeletedRow, isNotNull);
expect(foundDeletedRow!.name, startsWith(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 {
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!.name, startsWith(deletedRow.name));

View file

@ -57,7 +57,13 @@ void main() {
test('then the row is hidden by the tombstone.', () async {
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 {

View file

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

View file

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

View file

@ -277,7 +277,10 @@ void main() {
});
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(
session,
where: (t) =>