From 2b54f5c51ff9a26d4077037631ed39d62ed2b3fb Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Thu, 12 Jun 2025 09:11:18 +0200 Subject: Initial support for translation reviews --- server/tests/integration_test.rs | 98 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) (limited to 'server/tests/integration_test.rs') 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)); + } +} -- cgit v1.2.3-70-g09d2