[PR #7953] [MERGED] chore: add chat message order test #8232

Closed
opened 2026-03-23 23:23:13 +00:00 by mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/AppFlowy-IO/AppFlowy/pull/7953
Author: @appflowy
Created: 5/20/2025
Status: Merged
Merged: 5/20/2025
Merged by: @appflowy

Base: mainHead: add_chat_message_order_test


📝 Commits (2)

📊 Changes

4 files changed (+1047 additions, -46 deletions)

View changed files

frontend/rust-lib/event-integration-test/tests/sql_test/chat_message_ordering_test.rs (+621 -0)
📝 frontend/rust-lib/event-integration-test/tests/sql_test/chat_message_test.rs (+366 -22)
📝 frontend/rust-lib/event-integration-test/tests/sql_test/mod.rs (+1 -0)
📝 frontend/rust-lib/flowy-ai-pub/src/persistence/chat_message_sql.rs (+59 -24)

📄 Description

Feature Preview


PR Checklist

  • My code adheres to AppFlowy's Conventions
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

Summary by Sourcery

Enhance the chat message retrieval logic to consistently sort by timestamp and provide accurate pagination metadata, and add a suite of integration tests to verify default ordering, cursor behaviors, and edge cases.

Enhancements:

  • Derive Clone for ChatMessageTable and calculate total_count before pagination
  • Always order chat messages by created_at descending then message_id descending and streamline limit application
  • Improve has_more computation for all MessageCursor variants (Offset, AfterMessageId, BeforeMessageId, NextBack)

Tests:

  • Add chat_message_ordering_test.rs with integration tests verifying default ordering, secondary sort by ID on timestamp ties, pagination via Offset, AfterMessageId, BeforeMessageId and NextBack, consistency across cursor types, and edge cases

Chores:

  • Register new chat_message_ordering_test module in sql_test/mod.rs

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/AppFlowy-IO/AppFlowy/pull/7953 **Author:** [@appflowy](https://github.com/appflowy) **Created:** 5/20/2025 **Status:** ✅ Merged **Merged:** 5/20/2025 **Merged by:** [@appflowy](https://github.com/appflowy) **Base:** `main` ← **Head:** `add_chat_message_order_test` --- ### 📝 Commits (2) - [`ff91c6c`](https://github.com/AppFlowy-IO/AppFlowy/commit/ff91c6c92b403bb0281afa33bda15b7adfcf5f12) chore: add chat message order test - [`c203b26`](https://github.com/AppFlowy-IO/AppFlowy/commit/c203b266d778f16253037eba79f4cfc90120afd1) chore: clippy ### 📊 Changes **4 files changed** (+1047 additions, -46 deletions) <details> <summary>View changed files</summary> ➕ `frontend/rust-lib/event-integration-test/tests/sql_test/chat_message_ordering_test.rs` (+621 -0) 📝 `frontend/rust-lib/event-integration-test/tests/sql_test/chat_message_test.rs` (+366 -22) 📝 `frontend/rust-lib/event-integration-test/tests/sql_test/mod.rs` (+1 -0) 📝 `frontend/rust-lib/flowy-ai-pub/src/persistence/chat_message_sql.rs` (+59 -24) </details> ### 📄 Description <!--- Thank you for submitting a pull request to AppFlowy. The team will dedicate their best efforts to reviewing and approving your pull request. If you have any questions about the project or feedback for us, please join our [Discord](https://discord.gg/wdjWUXXhtw). --> <!--- If your pull request adds a new feature, please drag and drop a video into this section to showcase what you've done! If not, you may delete this section. --> ### Feature Preview <!--- List at least one issue here that this PR addresses. If it fixes the issue, please use the [fixes](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests) keyword to close the issue. For example: fixes https://github.com/AppFlowy-IO/AppFlowy/pull/2106 --> --- <!--- Before you mark this PR ready for review, run through this checklist! --> #### PR Checklist - [ ] My code adheres to [AppFlowy's Conventions](https://docs.appflowy.io/docs/documentation/software-contributions/conventions) - [ ] I've listed at least one issue that this PR fixes in the description above. - [ ] I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes. - [ ] All existing tests are passing. ## Summary by Sourcery Enhance the chat message retrieval logic to consistently sort by timestamp and provide accurate pagination metadata, and add a suite of integration tests to verify default ordering, cursor behaviors, and edge cases. Enhancements: - Derive Clone for ChatMessageTable and calculate total_count before pagination - Always order chat messages by created_at descending then message_id descending and streamline limit application - Improve has_more computation for all MessageCursor variants (Offset, AfterMessageId, BeforeMessageId, NextBack) Tests: - Add chat_message_ordering_test.rs with integration tests verifying default ordering, secondary sort by ID on timestamp ties, pagination via Offset, AfterMessageId, BeforeMessageId and NextBack, consistency across cursor types, and edge cases Chores: - Register new chat_message_ordering_test module in sql_test/mod.rs --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
mirror 2026-03-23 23:23:13 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#8232
No description provided.