From 1125931f088aedcd25bb9998bd962de2d9c7fd78 Mon Sep 17 00:00:00 2001 From: Guilhem Lemouel Date: Tue, 27 Oct 2026 01:17:17 -0700 Subject: [PATCH] test: pin that a transfer keeps script lineage the fork has Co-Authored-By: Claude Opus 5.5 (1M context) --- .../tests/drafts.rs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/backend/windmill-api-integration-tests/tests/drafts.rs b/backend/windmill-api-integration-tests/tests/drafts.rs index 22fe851729..e3aa882d95 100644 --- a/backend/windmill-api-integration-tests/tests/drafts.rs +++ b/backend/windmill-api-integration-tests/tests/drafts.rs @@ -493,6 +493,43 @@ async fn test_transfer_drafts_to_fork(db: Pool) -> anyhow::Result<()> .await?; assert_eq!((parent_hash, base), (None, None)); + // A version the fork has keeps its lineage. Its hash has the high bit set, so the match also + // holds for a negative i64, which serializes as 16 hex digits. + sqlx::query( + "INSERT INTO script (workspace_id, hash, path, summary, description, content, created_by) + VALUES ($1, -1, 'u/test-user/lineage', '', '', 'l', 'test-user')", + ) + .bind(fork) + .execute(&db) + .await?; + let r = c + .post(save_url(port, "script", "u/test-user/lineage")) + .json(&json!({ "value": { "content": "l2", "parent_hash": "ffffffffffffffff" } })) + .send() + .await?; + assert_eq!(r.status(), 200, "{}", r.text().await?); + let r = c + .post(&transfer_url) + .json(&json!({ + "target_workspace": fork, + "items": [{ "kind": "script", "path": "u/test-user/lineage" }], + "replace_existing": true + })) + .send() + .await?; + assert_eq!(r.status(), 200, "{}", r.text().await?); + let (parent_hash, base): (Option, Option) = sqlx::query_as( + "SELECT value->>'parent_hash', base FROM draft + WHERE workspace_id = $1 AND path = 'u/test-user/lineage'", + ) + .bind(fork) + .fetch_one(&db) + .await?; + assert_eq!( + (parent_hash.as_deref(), base.as_deref()), + (Some("ffffffffffffffff"), Some("ffffffffffffffff")) + ); + // Only a fork of the source is a valid target. let r = c .post(format!(