|
1 | 1 | import { browser, expect } from '@wdio/globals'; |
2 | | -import path from "path"; |
| 2 | +import path from 'path'; |
3 | 3 |
|
4 | 4 | async function performLogin(userName = 'admin', password = '1234') { |
5 | 5 | await browser.takeScreenshot(); |
@@ -288,84 +288,98 @@ describe('My Login application', () => { |
288 | 288 | .getText(); |
289 | 289 | expect(dropped).toEqual('The box is dropped'); |
290 | 290 | }); |
291 | | - |
292 | | - //TODO: Wbview is not inspectable on iOS demo app, need to fix it. |
293 | | - itForAndroidOnly('should switch to webview context and validate the page title', async () => { |
294 | | - await performLogin(); |
295 | | - await openScreen('Web View'); |
296 | | - await switchToWebview(); |
297 | | - |
298 | | - await browser.waitUntil( |
299 | | - async () => (await browser.getTitle()) === 'Hacker News', |
300 | | - { |
301 | | - timeout: 10000, |
302 | | - timeoutMsg: 'Expected Hacker News title not found', |
303 | | - }, |
304 | | - ); |
305 | 291 |
|
306 | | - const title = await browser.getTitle(); |
307 | | - expect(title).toEqual( |
308 | | - 'Hacker News', |
309 | | - 'Webview title did not match expected', |
310 | | - ); |
311 | | - }); |
| 292 | + //TODO: Wbview is not inspectable on iOS demo app, need to fix it. |
| 293 | + itForAndroidOnly( |
| 294 | + 'should switch to webview context and validate the page title', |
| 295 | + async () => { |
| 296 | + await performLogin(); |
| 297 | + await openScreen('Web View'); |
| 298 | + await switchToWebview(); |
| 299 | + |
| 300 | + await browser.waitUntil( |
| 301 | + async () => (await browser.getTitle()) === 'Hacker News', |
| 302 | + { |
| 303 | + timeout: 10000, |
| 304 | + timeoutMsg: 'Expected Hacker News title not found', |
| 305 | + }, |
| 306 | + ); |
| 307 | + |
| 308 | + const title = await browser.getTitle(); |
| 309 | + expect(title).toEqual( |
| 310 | + 'Hacker News', |
| 311 | + 'Webview title did not match expected', |
| 312 | + ); |
| 313 | + }, |
| 314 | + ); |
312 | 315 |
|
313 | | - itForAndroidOnly('should execute native commands correctly while in Webview context', async () => { |
314 | | - await performLogin(); |
315 | | - await openScreen('Web View'); |
316 | | - await switchToWebview(); |
| 316 | + itForAndroidOnly( |
| 317 | + 'should execute native commands correctly while in Webview context', |
| 318 | + async () => { |
| 319 | + await performLogin(); |
| 320 | + await openScreen('Web View'); |
| 321 | + await switchToWebview(); |
317 | 322 |
|
318 | | - // Verify no-proxy native commands still operate while in webview context |
319 | | - const currentContext = await browser.getContext(); |
320 | | - expect(currentContext).toContain('WEBVIEW'); |
| 323 | + // Verify no-proxy native commands still operate while in webview context |
| 324 | + const currentContext = await browser.getContext(); |
| 325 | + expect(currentContext).toContain('WEBVIEW'); |
321 | 326 |
|
322 | | - const contexts = await browser.getContexts(); |
323 | | - expect(Array.isArray(contexts)).toBe(true); |
324 | | - expect(contexts.length).toBeGreaterThan(0); |
| 327 | + const contexts = await browser.getContexts(); |
| 328 | + expect(Array.isArray(contexts)).toBe(true); |
| 329 | + expect(contexts.length).toBeGreaterThan(0); |
325 | 330 |
|
326 | | - const windowHandle = await browser.getWindowHandle(); |
327 | | - expect(typeof windowHandle).toBe('string'); |
| 331 | + const windowHandle = await browser.getWindowHandle(); |
| 332 | + expect(typeof windowHandle).toBe('string'); |
328 | 333 |
|
329 | | - const pageSource = await browser.getPageSource(); |
330 | | - expect(typeof pageSource).toBe('string'); |
331 | | - }); |
| 334 | + const pageSource = await browser.getPageSource(); |
| 335 | + expect(typeof pageSource).toBe('string'); |
| 336 | + }, |
| 337 | + ); |
332 | 338 |
|
333 | | - itForAndroidOnly('should switch back and forth between native and Webview contexts', async () => { |
334 | | - await performLogin(); |
335 | | - await openScreen('Web View'); |
| 339 | + itForAndroidOnly( |
| 340 | + 'should switch back and forth between native and Webview contexts', |
| 341 | + async () => { |
| 342 | + await performLogin(); |
| 343 | + await openScreen('Web View'); |
336 | 344 |
|
337 | | - await switchToWebview(); |
338 | | - expect(await browser.getContext()).toContain('WEBVIEW'); |
| 345 | + await switchToWebview(); |
| 346 | + expect(await browser.getContext()).toContain('WEBVIEW'); |
339 | 347 |
|
340 | | - await browser.switchContext('NATIVE_APP'); |
341 | | - expect(await browser.getContext()).toBe('NATIVE_APP'); |
| 348 | + await browser.switchContext('NATIVE_APP'); |
| 349 | + expect(await browser.getContext()).toBe('NATIVE_APP'); |
342 | 350 |
|
343 | | - await switchToWebview(); |
344 | | - expect(await browser.getContext()).toContain('WEBVIEW'); |
345 | | - }); |
| 351 | + await switchToWebview(); |
| 352 | + expect(await browser.getContext()).toContain('WEBVIEW'); |
| 353 | + }, |
| 354 | + ); |
346 | 355 | }); |
347 | 356 |
|
348 | | -describe('Image mocking', async() => { |
| 357 | +describe('Image mocking', async () => { |
349 | 358 | afterEach(async () => { |
350 | 359 | await handleAppManagement(); |
351 | 360 | }); |
352 | 361 |
|
353 | | - it('Inject Image', async() => { |
| 362 | + it('Inject Image', async () => { |
354 | 363 | const firstImageToMock = path.resolve('test/qr.png'); |
355 | 364 | const secondImageToMock = path.resolve('test/SecondImage.png'); |
356 | 365 | await performLogin(); |
357 | 366 | await openScreen('Image Picker'); |
358 | | - const firstInjectedImage = await browser.flutterInjectImage(firstImageToMock); |
| 367 | + const firstInjectedImage = |
| 368 | + await browser.flutterInjectImage(firstImageToMock); |
359 | 369 | await browser.flutterByValueKey$('capture_image').click(); |
360 | 370 | await browser.flutterByText$('PICK').click(); |
361 | 371 | expect(await browser.flutterByText$('Success!').isDisplayed()).toBe(true); |
362 | 372 | await browser.flutterInjectImage(secondImageToMock); |
363 | 373 | await browser.flutterByValueKey$('capture_image').click(); |
364 | 374 | await browser.flutterByText$('PICK').click(); |
365 | | - expect(await browser.flutterByText$('SecondInjectedImage').isDisplayed()).toBe(true); |
366 | | - await browser.flutterActivateInjectedImage({ imageId: firstInjectedImage }); |
| 375 | + expect( |
| 376 | + await browser.flutterByText$('SecondInjectedImage').isDisplayed(), |
| 377 | + ).toBe(true); |
| 378 | + await browser.flutterActivateInjectedImage({ |
| 379 | + imageId: firstInjectedImage, |
| 380 | + }); |
367 | 381 | await browser.flutterByValueKey$('capture_image').click(); |
368 | 382 | await browser.flutterByText$('PICK').click(); |
369 | 383 | expect(await browser.flutterByText$('Success!').isDisplayed()).toBe(true); |
370 | | - }) |
371 | | -}) |
| 384 | + }); |
| 385 | +}); |
0 commit comments