Skip to content

Commit 5816a3f

Browse files
committed
Fix: add in expected cursor/scroll updates after an autosave delay.
1 parent 19d6373 commit 5816a3f

File tree

1 file changed

+33
-3
lines changed
  • server/tests/overall_core

1 file changed

+33
-3
lines changed

server/tests/overall_core/mod.rs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,28 @@ async fn test_server_core(
357357

358358
// Focus it.
359359
doc_block_contents.click().await.unwrap();
360-
sleep(Duration::from_millis(100)).await;
360+
// The click produces an updated cursor/scroll location after an autosave delay.
361+
let mut client_id = INITIAL_CLIENT_MESSAGE_ID;
362+
assert_eq!(
363+
codechat_server.get_message_timeout(TIMEOUT).await.unwrap(),
364+
EditorMessage {
365+
id: client_id,
366+
message: EditorMessageContents::Update(UpdateMessageContents {
367+
file_path: path_str.clone(),
368+
contents: None,
369+
cursor_position: Some(1),
370+
scroll_position: Some(1.0)
371+
})
372+
}
373+
);
374+
361375
// Refind it, since it's now switched with a TinyMCE editor.
362376
let tinymce_contents = driver_ref.find(By::Id("TinyMCE-inst")).await.unwrap();
363377
// Make an edit.
364378
tinymce_contents.send_keys("foo").await.unwrap();
365379

366380
// Verify the updated text.
367-
let mut client_id = INITIAL_CLIENT_MESSAGE_ID;
381+
client_id += MESSAGE_ID_INCREMENT;
368382
// Update the version from the value provided by the client, which varies randomly.
369383
let msg = codechat_server.get_message_timeout(TIMEOUT).await.unwrap();
370384
let client_version = get_version(&msg);
@@ -1150,6 +1164,8 @@ async fn test_client_updates_core(
11501164
}
11511165
);
11521166
codechat_server.send_result(client_id, None).await.unwrap();
1167+
client_id += MESSAGE_ID_INCREMENT;
1168+
11531169
// The Server sends the Client a wrapped version of the text; the Client replies with a Result(Ok).
11541170
assert_eq!(
11551171
codechat_server.get_message_timeout(TIMEOUT).await.unwrap(),
@@ -1182,13 +1198,27 @@ async fn test_client_updates_core(
11821198
.send_keys("4" + Key::Enter)
11831199
.await
11841200
.unwrap();
1201+
// The cursor movement produces a cursor/scroll position update after an autosave delay.
1202+
assert_eq!(
1203+
codechat_server.get_message_timeout(TIMEOUT).await.unwrap(),
1204+
EditorMessage {
1205+
id: client_id,
1206+
message: EditorMessageContents::Update(UpdateMessageContents {
1207+
file_path: path_str.clone(),
1208+
contents: None,
1209+
cursor_position: Some(4),
1210+
scroll_position: Some(1.0)
1211+
})
1212+
}
1213+
);
1214+
client_id += MESSAGE_ID_INCREMENT;
1215+
11851216
// Add an indented comment.
11861217
code_line.send_keys(Key::Home + "# ").await.unwrap();
11871218
// This should edit the (new) third line of the file after word wrap: `def
11881219
// foo():`.
11891220
let msg = codechat_server.get_message_timeout(TIMEOUT).await.unwrap();
11901221
let new_client_version = get_version(&msg);
1191-
client_id += MESSAGE_ID_INCREMENT;
11921222
assert_eq!(
11931223
msg,
11941224
EditorMessage {

0 commit comments

Comments
 (0)