fix(server): blob gc (#15280)

#### PR Dependency Tree


* **PR #15280** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved workspace document discovery so documents in trashed pages
are correctly included when loading workspace content.
* Fixed dragging collections into Favorites, including reordering
collections within Favorites.
* **Tests**
* Added coverage for document projection behavior and collection
drag-and-drop interactions.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
DarkSky
2026-07-19 16:49:41 +08:00
committed by GitHub
parent 9122cfd108
commit 81df4751a3
2 changed files with 43 additions and 5 deletions
@@ -102,7 +102,7 @@ async fn load_workspace_doc_ids(pool: &PgPool, workspace_id: &str) -> RuntimeRes
let Some(root) = load_current_doc(pool, workspace_id, workspace_id).await? else {
return Ok(Vec::new());
};
let ids = doc_loader::get_doc_ids_from_binary(root.blob, false)
let ids = doc_loader::get_doc_ids_from_binary(root.blob, true)
.map_err(|err| RuntimeError::invalid_state(format!("Doc blob refs root doc parse failed: {err}")))?;
let mut ids = ids;
ids.sort();
@@ -229,7 +229,7 @@ mod tests {
use super::*;
#[test]
fn doc_blob_refs_extracts_image_refs() {
fn doc_blob_refs_projection_semantics() {
let doc_id = "doc-blob-ref-test".to_string();
let blob =
doc_loader::build_full_doc("Doc", "![Alt](blob://image-blob-key)", &doc_id).expect("doc fixture should build");
@@ -247,6 +247,30 @@ mod tests {
.iter()
.any(|reference| { reference.blob_key == "image-blob-key" && reference.flavour == "affine:image" })
);
let root = Doc::default();
let mut meta = root.get_or_create_map("meta").expect("root meta should build");
let mut pages = root.create_array().expect("root pages should build");
let mut active = root.create_map().expect("active doc meta should build");
active
.insert("id".to_string(), "active-doc")
.expect("active doc id should insert");
pages.push(active).expect("active doc should insert");
let mut trashed = root.create_map().expect("trashed doc meta should build");
trashed
.insert("id".to_string(), "trashed-doc")
.expect("trashed doc id should insert");
trashed
.insert("trash".to_string(), true)
.expect("trash flag should insert");
pages.push(trashed).expect("trashed doc should insert");
meta
.insert("pages".to_string(), pages)
.expect("root pages should insert");
let root = root.encode_update_v1().expect("root doc should encode");
let ids = doc_loader::get_doc_ids_from_binary(root, true).expect("root doc ids should parse");
assert_eq!(ids, vec!["active-doc", "trashed-doc"]);
}
}
+17 -3
View File
@@ -30,7 +30,11 @@ const dragToFavourites = async (
const favourites = page.getByTestId(
'navigation-panel-favorite-category-divider'
);
await dragTo(page, dragItem, favourites);
if (type === 'collection') {
await dragItem.dragTo(favourites);
} else {
await dragTo(page, dragItem, favourites);
}
const item = page
.getByTestId(`navigation-panel-favorites`)
.locator(`[data-testid="navigation-panel-${type}-${id}"]`);
@@ -168,7 +172,12 @@ test('drag a collection to favourites', async ({ page }) => {
await page.waitForTimeout(500);
const collection = await createCollection(page, 'test collection');
const collectionId = getCurrentCollectionIdFromUrl(page);
await dragToFavourites(page, collection, collectionId, 'collection');
await dragToFavourites(
page,
collection.locator('[data-affine-draggable]'),
collectionId,
'collection'
);
});
test('items in favourites can be reordered by dragging', async ({ page }) => {
@@ -183,7 +192,12 @@ test('items in favourites can be reordered by dragging', async ({ page }) => {
{
const collection = await createCollection(page, 'test collection');
const collectionId = getCurrentCollectionIdFromUrl(page);
await dragToFavourites(page, collection, collectionId, 'collection');
await dragToFavourites(
page,
collection.locator('[data-affine-draggable]'),
collectionId,
'collection'
);
}
// assert the order of the items in favourites