import { screen , fireEvent } from '@testing-library/react' ; import { autorun , title , Scenario , Given , When , And , Then , Step , StepFunction , examples , } from '../../lib/step' ; import { Login } from '../../steps/Login' ; const SetupBrandConfig = ( props , context ) => { const { phone } = context ; phone . brand . setDynamicConfig ( { ... phone . brand . brandConfig , callWithJupiter : { link : 'http://localhost/' , protocol : 'mock://' , name : { __i18n__ : true , translations : { 'en-US' : 'en-US App Name' , 'fr-FR' : 'fr-FR App Name' , fr : 'fr-FR App Name' , en : 'en-US App Name' , } , } , } , } ) ; } ; const SetLocale = async ( props , context ) => { await context . phone . locale . setLocale ( props . locale ) ; } ; const NavigateTo = ( { path } , { phone } ) => { phone . routerInteraction . push ( path ) ; } ; const ExpandDropdown = ( { testId } ) => { fireEvent . click ( screen . getByTestId ( testId ) ) ; } ; const CheckDropdown = async ( { appName , } ) => { expect ( screen . getByText ( appName ) ) . toBeInTheDocument ( ) ; } ; @ autorun ( test ) @ title ( 'Jupiter App Name I18n Support' ) export class CallingSettingJupiterI18nSupport extends Step { run ( ) { return ( < Scenario desc = "Jupiter App Name I18n Support" > < Given desc = "Create phone instance and login" action = { Login } / > < Given desc = "brandConfig with callWithJupiter with i18n support" action = { ( ) => < SetupBrandConfig />}/ > < When desc = "App navigate to calling setting page" action = { ( ) => < NavigateTo path = "/settings/calling" / > } /> < And desc = "App expand calling setting dropdown selection" action = { ( ) => < ExpandDropdown testId = "callingSetting" / > } /> < And desc = "App locale is set to 'en-US'" action = { ( ) => < SetLocale locale = "en-US" / > } /> < Then desc = "Check jupiter app name" action = { ( ) => < CheckDropdown appName = "en-US App Name" / > } /> < When desc = "App locale is set to 'fr-FR'" action = { ( ) => < SetLocale locale = "fr-FR" / > } /> < Then desc = "Check jupiter app name" action = { ( ) => < CheckDropdown appName = "fr-FR App Name" / > } /> < When desc = "App locale is set to 'fr'" action = { ( ) => < SetLocale locale = "fr" / > } /> < Then desc = "Check jupiter app name" action = { ( ) => < CheckDropdown appName = "fr-FR App Name" / > } /> < When desc = "App locale is set to 'fr-CA'" action = { ( ) => < SetLocale locale = "fr-CA" / > } /> < Then desc = "Check jupiter app name" action = { ( ) => < CheckDropdown appName = "fr-FR App Name" / > } /> < /Scenario>); } }