import { Application } from "../../automation" ; import { vscodeManager } from "./main" ; import * as assert from "assert" ; import { sleep } from "./helpers/utilities" ; import { SmokeTestsConstants } from "./helpers/smokeTestsConstants" ; import { SmokeTestLogger } from "./helpers/smokeTestLogger" ; import TestProject from "./helpers/testProject" ; import AutomationHelper from "./helpers/AutomationHelper" ; const startPackagerCommand = "Start Packager" ; const packagerStartedCheck = "Запуск упаковщика" ; export function startLocalizationTests ( project ) { describe ( "Localization test" , ( ) => { let app ; let automationHelper ; async function initApp ( workspaceOrFolder , sessionName ? , locale ? ) { app = await vscodeManager . runVSCode ( workspaceOrFolder , sessionName , locale ) ; automationHelper = new AutomationHelper ( app ) ; return app ; } afterEach ( async ( ) => { SmokeTestLogger . info ( "Dispose all ..." ) ; if ( app ) { SmokeTestLogger . info ( "Stopping React Native packager ..." ) ; await automationHelper . runCommandWithRetry ( SmokeTestsConstants . stopPackagerCommand ) ; await sleep ( 3000 ) ; await app . stop ( ) ; } } ) ; it ( "Test localization" , async function ( ) { try { app = await initApp ( project . workspaceDirectory , "LocalizationTest" , "ru" ) ; SmokeTestLogger . info ( "Localization test: Starting packager" ) ; await automationHelper . runCommandWithRetry ( startPackagerCommand ) ; await sleep ( 10 * 1000 ) ; SmokeTestLogger . info ( `Localization test: Search for '${ packagerStartedCheck }' string output` ) ; const found = vscodeManager . findStringInLogs ( packagerStartedCheck , SmokeTestsConstants . ReactNativeLogFileName ) ; if ( found ) { SmokeTestLogger . success ( `Localization test: Output found` ) ; } else { assert . fail ( "Localized RU string is not found in log file" ) ; } } catch ( e ) { SmokeTestLogger . error ( "Localization test failed: " + e ) ; return this . skip ( ) ; } } ) ; } ) ; }