summaryrefslogtreecommitdiff
path: root/server/tests/integration_test.rs
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-06-12 09:11:18 +0200
committerJoel Klinghed <the_jk@spawned.biz>2025-06-19 00:19:37 +0200
commit2b54f5c51ff9a26d4077037631ed39d62ed2b3fb (patch)
tree8544278dba24645a063472a3005a3021879a4bf1 /server/tests/integration_test.rs
parentbaa7c85ff3db2366d67ac875fca48ad6dcabf212 (diff)
Initial support for translation reviews
Diffstat (limited to 'server/tests/integration_test.rs')
-rw-r--r--server/tests/integration_test.rs98
1 files changed, 98 insertions, 0 deletions
diff --git a/server/tests/integration_test.rs b/server/tests/integration_test.rs
index 200657e..6becf61 100644
--- a/server/tests/integration_test.rs
+++ b/server/tests/integration_test.rs
@@ -1,9 +1,12 @@
+use pretty_assertions::assert_eq;
use std::path::PathBuf;
use std::thread::sleep;
use std::time::Duration;
use test_context::test_context;
use tokio::fs;
+use eyeballs_api::api_model;
+
mod common;
const TESTKEY1: &str = "-----BEGIN OPENSSH PRIVATE KEY-----
@@ -128,3 +131,98 @@ async fn test_sanity(ctx: &mut common::DockerComposeContext) {
sleep(Duration::from_millis(500));
}
}
+
+#[test_context(common::DockerComposeContext)]
+#[tokio::test]
+async fn test_translation_review_create(ctx: &mut common::DockerComposeContext) {
+ let mut client1 = common::create_client().expect("client1");
+ common::login(ctx, &mut client1, "user01", "password1")
+ .await
+ .expect("user01 login");
+
+ common::user_key_add(ctx, &mut client1, "ssh-rsa", TESTKEY1_PUB)
+ .await
+ .expect("user01 key add");
+ ctx.setup_ssh_key("client1", TESTKEY1)
+ .await
+ .expect("user01 ssh_config setup");
+
+ let remote_git = String::from(ctx.remote_git());
+ let remote_git_key = PathBuf::from(ctx.remote_git_key());
+ common::create_project(ctx, &mut client1, "fake", &remote_git, &remote_git_key)
+ .await
+ .expect("create fake project");
+
+ let review = common::create_translation_review(ctx, &mut client1, "fake")
+ .await
+ .expect("create translation review");
+
+ for _ in 0..5 {
+ let strings = common::list_translation_strings(ctx, &mut client1, review.id)
+ .await
+ .expect("list strings");
+ if strings.strings.len() > 0 {
+ assert_eq!(
+ strings.strings,
+ vec![
+ api_model::LocalizationString {
+ id: "EXTRA_STRING".to_string(),
+ file: "extra.grdp".to_string(),
+ description: "Some description".to_string(),
+ meaning: "".to_string(),
+ source: "Extra string, gray".to_string(),
+ placeholders: vec![],
+ placeholder_offset: vec![],
+ translations: vec![
+ api_model::TranslationString {
+ language: "en-gb".to_string(),
+ translation: "Extra string, grey".to_string(),
+ placeholder_offset: vec![],
+ state: api_model::TranslationState::Unchanged,
+ comment: "".to_string(),
+ reviewer: None,
+ },
+ api_model::TranslationString {
+ language: "sv".to_string(),
+ translation: "Extra sträng, grå".to_string(),
+ placeholder_offset: vec![],
+ state: api_model::TranslationState::Unchanged,
+ comment: "".to_string(),
+ reviewer: None,
+ }
+ ],
+ },
+ api_model::LocalizationString {
+ id: "MAIN_STRING".to_string(),
+ file: "strings.grd".to_string(),
+ description: "Description".to_string(),
+ meaning: "".to_string(),
+ source: "Main test string".to_string(),
+ placeholders: vec![],
+ placeholder_offset: vec![],
+ translations: vec![
+ api_model::TranslationString {
+ language: "en-gb".to_string(),
+ translation: "Main test string".to_string(),
+ placeholder_offset: vec![],
+ state: api_model::TranslationState::Unchanged,
+ comment: "".to_string(),
+ reviewer: None,
+ },
+ api_model::TranslationString {
+ language: "sv".to_string(),
+ translation: "Primära teststrängen".to_string(),
+ placeholder_offset: vec![],
+ state: api_model::TranslationState::Unchanged,
+ comment: "".to_string(),
+ reviewer: None,
+ }
+ ],
+ },
+ ]
+ );
+ break;
+ }
+ sleep(Duration::from_millis(500));
+ }
+}