Skip to content

Commit e061559

Browse files
committed
TMP
1 parent 1bb8032 commit e061559

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

canaries/integration_test/main_test.dart

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ void main() {
6363
final authSession = await Amplify.Auth.fetchAuthSession();
6464
expect(authSession.isSignedIn, isTrue);
6565

66-
// Clear DataStore to prevent sync conflicts with direct API calls
66+
// Stop DataStore sync engine to prevent race conditions with direct API calls.
67+
// DataStore.clear() only clears local data but keeps the sync engine running,
68+
// which can cause version conflicts when the sync engine picks up items created
69+
// via direct API and updates their _version field.
70+
await Amplify.DataStore.stop();
6771
await Amplify.DataStore.clear();
6872

6973
// === STORAGE: Download guest data ===
@@ -109,25 +113,17 @@ void main() {
109113
final queriedTodo = queryResponse.data!;
110114

111115
// === API: Delete Todo (cleanup) ===
112-
// Use deleteById to avoid ConflictUnhandled errors caused by _version mismatch
113-
// when DataStore sync may have modified the item's version in the background.
114-
// Note: Cleanup failures are logged but do not fail the test, as the primary
115-
// test assertions have already passed. DataStore sync can race with direct API
116-
// calls, causing version conflicts that are expected in this test scenario.
117116
final deleteMutation = ModelMutations.deleteById(
118117
Todo.classType,
119118
queriedTodo.modelIdentifier,
120119
);
121120
final deleteResponse =
122121
await Amplify.API.mutate(request: deleteMutation).response;
123-
if (deleteResponse.hasErrors) {
124-
// Log only error types (safe enums like "Unauthorized", "ConflictUnhandled")
125-
// Do NOT log error messages or field values which may contain sensitive data
126-
final errorTypes = deleteResponse.errors
127-
?.map((e) => e.errorType ?? 'Unknown')
128-
.join(', ');
129-
AWSLogger().warn('[Cleanup] Delete mutation failed with ${deleteResponse.errors?.length ?? 0} error(s). Types: $errorTypes. This is expected if DataStore sync modified the item version.');
130-
}
122+
expect(deleteResponse.hasErrors, isFalse);
123+
124+
// === DATASTORE: Start sync and test ===
125+
// Restart DataStore for DataStore-specific tests after API tests are complete
126+
await Amplify.DataStore.start();
131127

132128
// === DATASTORE: Save and observe ===
133129
final dsTodo = Todo(name: 'canary-ds-test', owner: username);

0 commit comments

Comments
 (0)