test(sync): audit browser recovery paths

This commit is contained in:
slhx agent
2026-07-13 22:46:03 +02:00
parent d2ae025e13
commit 98b00920b9
5 changed files with 70 additions and 31 deletions
+19 -7
View File
@@ -675,7 +675,7 @@ async fn kanban_command_export_delete_and_reset_are_recoverable() -> WebDriverRe
let first_export = export_commands(&driver).await?.json().clone();
assert_eq!(first_export["schemaVersion"], 1);
assert_eq!(first_export["commands"].as_array().map(Vec::len), Some(1));
assert_eq!(first_export["commands"][0]["schemaVersion"], 1);
assert_eq!(first_export["commands"][0]["schemaVersion"], 2);
assert_eq!(first_export["commands"][0]["kind"], "reorder_card");
assert_eq!(first_export["commands"][0]["cardId"], "1");
let mut exported_keys = first_export["commands"][0]
@@ -688,6 +688,7 @@ async fn kanban_command_export_delete_and_reset_are_recoverable() -> WebDriverRe
assert_eq!(
exported_keys,
[
"accountPartition",
"actor",
"cardId",
"causal",
@@ -695,8 +696,10 @@ async fn kanban_command_export_delete_and_reset_are_recoverable() -> WebDriverRe
"id",
"key",
"kind",
"queuedAt",
"schemaVersion",
"session",
"targetColumn",
]
);
let first_actor = first_export["commands"][0]["actor"]
@@ -1205,7 +1208,7 @@ async fn kanban_replay_is_bounded_and_within_budget() -> WebDriverResult<()> {
assert_eq!(within_bound["order"], "2|1");
assert_eq!(within_bound["limit"], REPLAY_LIMIT.to_string());
assert_eq!(within_bound["budget"], REPLAY_BUDGET_MS);
assert_eq!(within_bound["over"], false);
assert_eq!(within_bound["over"], false, "{within_bound}");
assert!(
within_bound["elapsed"].as_f64().is_some_and(|elapsed| elapsed <= REPLAY_BUDGET_MS),
"replay exceeded budget: {within_bound}"
@@ -1884,12 +1887,15 @@ async fn store_replay_commands(driver: &WebDriver, first: u64, last: u64) -> Web
for (let causal = first; causal <= last; causal += 1) {
commands.add({
id: `replay:${causal}`,
schemaVersion: 1,
schemaVersion: 2,
accountPartition: 'demo:demo',
actor: 'replay',
session: 'replay',
causal,
queuedAt: Date.now(),
kind: 'reorder_card',
cardId: '1',
targetColumn: 'done',
eventKind: 'click',
key: null,
});
@@ -1922,12 +1928,15 @@ async fn store_malformed_command(driver: &WebDriver) -> WebDriverResult<()> {
const tx = open.result.transaction('commands', 'readwrite');
tx.objectStore('commands').add({
id: 'corrupt:1',
schemaVersion: 1,
schemaVersion: 2,
accountPartition: 'demo:demo',
actor: 'corrupt',
session: 'corrupt',
causal: 1,
queuedAt: Date.now(),
kind: 'reorder_card',
cardId: '',
targetColumn: 'done',
eventKind: 'click',
key: null,
});
@@ -1967,19 +1976,22 @@ async fn occupy_next_command_id(driver: &WebDriver) -> WebDriverResult<()> {
const next = causal + 1;
commands.add({
id: `${actor}:${next}`,
schemaVersion: 1,
schemaVersion: 2,
accountPartition: 'demo:demo',
actor,
session: 'fault-injection',
causal: next,
queuedAt: Date.now(),
kind: 'reorder_card',
cardId: 'fault-injection',
targetColumn: 'done',
eventKind: 'click',
key: null,
});
};
const actorRequest = meta.get('actor');
const actorRequest = meta.get('actor:demo:demo');
actorRequest.onsuccess = () => { actor = actorRequest.result; addCollision(); };
const causalRequest = meta.get('causal');
const causalRequest = meta.get('causal:demo:demo');
causalRequest.onsuccess = () => { causal = causalRequest.result; addCollision(); };
tx.oncomplete = () => done({ id: `${actor}:${causal + 1}` });
tx.onabort = () => done({ error: tx.error && tx.error.name });