1+ import { test , expect } from '@playwright/test'
12import { remote } from 'webdriverio'
23import { HomeScreen } from '../../src/mobile/screens'
34
5+ const isMobile = process . env . MOBILE === 'true'
6+
47const capabilities = {
58 platformName : 'Android' ,
69 'appium:automationName' : 'UiAutomator2' ,
@@ -11,39 +14,29 @@ const capabilities = {
1114 'appium:noReset' : true ,
1215}
1316
14- const wdioConfig = {
15- hostname : '127.0.0.1' ,
16- port : 4723 ,
17- logLevel : 'silent' as const ,
18- capabilities,
19- }
20-
21- describe ( '@mobile @smoke Android Settings App' , ( ) => {
22- let driver : Awaited < ReturnType < typeof remote > >
23- let homeScreen : HomeScreen
24-
25- before ( async ( ) => {
26- driver = await remote ( wdioConfig )
27- homeScreen = new HomeScreen ( driver )
28- } )
29-
30- after ( async ( ) => {
31- if ( driver ) await driver . deleteSession ( )
32- } )
33-
34- it ( 'should launch Settings app successfully' , async ( ) => {
35- const isLoaded = await homeScreen . isAppLoaded ( )
36- if ( ! isLoaded ) throw new Error ( 'App did not load' )
37- } )
38-
39- it ( 'should be on the correct package' , async ( ) => {
40- const pkg = await homeScreen . getCurrentPackage ( )
41- if ( pkg !== 'com.android.settings' ) throw new Error ( 'Wrong package: ' + pkg )
42- } )
43-
44- it ( 'should get current activity' , async ( ) => {
45- const activity = await homeScreen . getCurrentActivity ( )
46- if ( ! activity ) throw new Error ( 'No activity found' )
47- console . log ( 'Current activity:' , activity )
17+ test . describe ( '@mobile @smoke Android Settings App' , ( ) => {
18+ test . skip ( ! isMobile , 'Skipping mobile tests - set MOBILE=true to run' )
19+
20+ test ( 'should launch Settings app and validate package' , async ( ) => {
21+ const driver = await remote ( {
22+ hostname : '127.0.0.1' ,
23+ port : 4723 ,
24+ logLevel : 'silent' ,
25+ capabilities,
26+ } )
27+
28+ try {
29+ const screen = new HomeScreen ( driver )
30+ const isLoaded = await screen . isAppLoaded ( )
31+ expect ( isLoaded ) . toBeTruthy ( )
32+
33+ const pkg = await screen . getCurrentPackage ( )
34+ expect ( pkg ) . toBe ( 'com.android.settings' )
35+
36+ const activity = await screen . getCurrentActivity ( )
37+ expect ( activity ) . toBeTruthy ( )
38+ } finally {
39+ await driver . deleteSession ( )
40+ }
4841 } )
4942} )
0 commit comments