From e0eb0f41fe41b8a7cdc79a269d221d9ae08a7153 Mon Sep 17 00:00:00 2001 From: Woraphot Chokratanasombat Date: Thu, 29 Feb 2024 23:41:56 +0700 Subject: [PATCH] [Example@test] Change: Add import detox, beforeAll, remove waitFor --- example/e2e/testCases/batchTest.spec.js | 10 +++++++--- example/e2e/testCases/cropTest.spec.js | 12 +++++++---- example/e2e/testCases/optimizeTest.spec.js | 8 ++++++-- .../e2e/testCases/overlayImageTest.spec.js | 10 +++++++--- example/e2e/testCases/printTextTest.spec.js | 10 +++++++--- example/e2e/testCases/sanityTest.spec.js | 6 +++++- .../project.pbxproj | 20 +++++++++---------- 7 files changed, 50 insertions(+), 26 deletions(-) diff --git a/example/e2e/testCases/batchTest.spec.js b/example/e2e/testCases/batchTest.spec.js index 8175e4f7..af21dc4c 100755 --- a/example/e2e/testCases/batchTest.spec.js +++ b/example/e2e/testCases/batchTest.spec.js @@ -1,10 +1,14 @@ -/* global device, element, by */ +import { by, device, element, expect } from 'detox'; describe('batch', () => { + beforeAll(async () => { + await device.launchApp({ newInstance: true }); + }); + it('should load images after batch', async () => { await expect(element(by.id('example-exampleBatch'))).toExist(); - await waitFor(element(by.id('batchResult'))).toExist().withTimeout(2000); - await waitFor(element(by.id('batchResultPng'))).toExist().withTimeout(2000); + await expect(element(by.id('batchResult'))).toExist(); + await expect(element(by.id('batchResultPng'))).toExist(); }); }); diff --git a/example/e2e/testCases/cropTest.spec.js b/example/e2e/testCases/cropTest.spec.js index 569d8f42..6644c3c6 100755 --- a/example/e2e/testCases/cropTest.spec.js +++ b/example/e2e/testCases/cropTest.spec.js @@ -1,11 +1,15 @@ -/* global device, element, by */ +import { by, device, element, expect } from 'detox'; describe('crop', () => { + beforeAll(async () => { + await device.launchApp({ newInstance: true }); + }); + it('should load images after crop', async () => { await expect(element(by.id('example-exampleCrop'))).toExist(); - await waitFor(element(by.id('cropResult'))).toExist().withTimeout(2000); - await waitFor(element(by.id('cropResizeResult'))).toExist().withTimeout(2000); - await waitFor(element(by.id('cropPngResult'))).toExist().withTimeout(2000); + await expect(element(by.id('cropResult'))).toExist(); + await expect(element(by.id('cropResizeResult'))).toExist(); + await expect(element(by.id('cropPngResult'))).toExist(); }); }); diff --git a/example/e2e/testCases/optimizeTest.spec.js b/example/e2e/testCases/optimizeTest.spec.js index 419ef3f3..5c924b98 100755 --- a/example/e2e/testCases/optimizeTest.spec.js +++ b/example/e2e/testCases/optimizeTest.spec.js @@ -1,9 +1,13 @@ -/* global device, element, by */ +import { by, device, element, expect } from 'detox'; describe('optimize', () => { + beforeAll(async () => { + await device.launchApp({ newInstance: true }); + }); + it('should load images after optimize', async () => { await expect(element(by.id('example-exampleOptimize'))).toExist(); - await waitFor(element(by.id('optimizeResult'))).toExist().withTimeout(2000); + await expect(element(by.id('optimizeResult'))).toExist(); }); }); diff --git a/example/e2e/testCases/overlayImageTest.spec.js b/example/e2e/testCases/overlayImageTest.spec.js index 9c1ce5a7..5b9ffe20 100755 --- a/example/e2e/testCases/overlayImageTest.spec.js +++ b/example/e2e/testCases/overlayImageTest.spec.js @@ -1,10 +1,14 @@ -/* global device, element, by */ +import { by, device, element, expect } from 'detox'; describe('overlayImage', () => { + beforeAll(async () => { + await device.launchApp({ newInstance: true }); + }); + it('should load images after overlay image', async () => { await expect(element(by.id('example-exampleOverlayImage'))).toExist(); - await waitFor(element(by.id('overlayImageResult'))).toExist().withTimeout(2000); - await waitFor(element(by.id('overlayImagePngResult'))).toExist().withTimeout(2000); + await expect(element(by.id('overlayImageResult'))).toExist(); + await expect(element(by.id('overlayImagePngResult'))).toExist(); }); }); diff --git a/example/e2e/testCases/printTextTest.spec.js b/example/e2e/testCases/printTextTest.spec.js index 71067e19..fcc75c34 100755 --- a/example/e2e/testCases/printTextTest.spec.js +++ b/example/e2e/testCases/printTextTest.spec.js @@ -1,10 +1,14 @@ -/* global device, element, by */ +import { by, device, element, expect } from 'detox'; describe('printText', () => { + beforeAll(async () => { + await device.launchApp({ newInstance: true }); + }); + it('should load images after printText', async () => { await expect(element(by.id('example-examplePrintText'))).toExist(); - await waitFor(element(by.id('printTextResult'))).toExist().withTimeout(2000); - await waitFor(element(by.id('printTextPngResult'))).toExist().withTimeout(2000); + await expect(element(by.id('printTextResult'))).toExist(); + await expect(element(by.id('printTextPngResult'))).toExist(); }); }); diff --git a/example/e2e/testCases/sanityTest.spec.js b/example/e2e/testCases/sanityTest.spec.js index 8848feba..a1aa8b4d 100755 --- a/example/e2e/testCases/sanityTest.spec.js +++ b/example/e2e/testCases/sanityTest.spec.js @@ -1,6 +1,10 @@ -/* global device, element, by */ +import { by, device, element, expect } from 'detox'; describe('PhotoManipulator', () => { + beforeAll(async () => { + await device.launchApp({ newInstance: true }); + }); + it('should load example app with no errors and show all the examples by default', async () => { await expect(element(by.id('examplesTitle'))).toExist(); await expect(element(by.id('example-originalImage'))).toExist(); diff --git a/example/ios/PhotoManipulatorExample.xcodeproj/project.pbxproj b/example/ios/PhotoManipulatorExample.xcodeproj/project.pbxproj index aa183795..7e553fd9 100644 --- a/example/ios/PhotoManipulatorExample.xcodeproj/project.pbxproj +++ b/example/ios/PhotoManipulatorExample.xcodeproj/project.pbxproj @@ -37,6 +37,7 @@ 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = PhotoManipulatorExample/Images.xcassets; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = PhotoManipulatorExample/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = PhotoManipulatorExample/main.m; sourceTree = ""; }; + 14E71C5D3FBB4DBEB463C029 /* Girassol-Regular.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = undefined; includeInIndex = 0; lastKnownFileType = unknown; name = "Girassol-Regular.ttf"; path = "../assets/fonts/Girassol-Regular.ttf"; sourceTree = ""; }; 19F6CBCC0A4E27FBF8BF4A61 /* libPods-PhotoManipulatorExample-PhotoManipulatorExampleTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-PhotoManipulatorExample-PhotoManipulatorExampleTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 3B4392A12AC88292D35C810B /* Pods-PhotoManipulatorExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PhotoManipulatorExample.debug.xcconfig"; path = "Target Support Files/Pods-PhotoManipulatorExample/Pods-PhotoManipulatorExample.debug.xcconfig"; sourceTree = ""; }; 5709B34CF0A7D63546082F79 /* Pods-PhotoManipulatorExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PhotoManipulatorExample.release.xcconfig"; path = "Target Support Files/Pods-PhotoManipulatorExample/Pods-PhotoManipulatorExample.release.xcconfig"; sourceTree = ""; }; @@ -45,7 +46,6 @@ 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = PhotoManipulatorExample/LaunchScreen.storyboard; sourceTree = ""; }; 89C6BE57DB24E9ADA2F236DE /* Pods-PhotoManipulatorExample-PhotoManipulatorExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PhotoManipulatorExample-PhotoManipulatorExampleTests.release.xcconfig"; path = "Target Support Files/Pods-PhotoManipulatorExample-PhotoManipulatorExampleTests/Pods-PhotoManipulatorExample-PhotoManipulatorExampleTests.release.xcconfig"; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; - 14E71C5D3FBB4DBEB463C029 /* Girassol-Regular.ttf */ = {isa = PBXFileReference; name = "Girassol-Regular.ttf"; path = "../assets/fonts/Girassol-Regular.ttf"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -108,6 +108,15 @@ name = Frameworks; sourceTree = ""; }; + 7008CECC701B4C89BCBF6080 /* Resources */ = { + isa = PBXGroup; + children = ( + 14E71C5D3FBB4DBEB463C029 /* Girassol-Regular.ttf */, + ); + name = Resources; + path = ""; + sourceTree = ""; + }; 832341AE1AAA6A7D00B99B32 /* Libraries */ = { isa = PBXGroup; children = ( @@ -151,15 +160,6 @@ path = Pods; sourceTree = ""; }; - 7008CECC701B4C89BCBF6080 /* Resources */ = { - isa = "PBXGroup"; - children = ( - 14E71C5D3FBB4DBEB463C029 /* Girassol-Regular.ttf */, - ); - name = Resources; - sourceTree = ""; - path = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */