Screenshot tests (#130)
* #9 Add snapshot testing library * #9 Create script to boot test simulators * #9 Create the UI test plan * #9 Create shared schemes for test targets * #9 Disable split view for UI tests * #9 Fix fastlane dependencies * #9 Add snapshot testing to the application * #9 assert screenshots * #9 fix swipe gestures on iPad * #9 Fix accessing items in session verification screen * #9 Workaround for flaky unit test * #9 Specify scheme for alpha build * #9 Add reference screenshots * Update python script path and check assets for png check * Update script path * Use static timezone for simulator time * Fix build after SwiftFormat * Add changelog * Upload failed screenshots artifact * Always upload artifacts * Update boot simulator script * Update simulator overridden time * Install pytz before tests * Get time from Ruby script * Disable SwiftUI animation when running UI tests * Update screenshots after animation setting * Include reference images in the artifact * Update matching precision * Update image matching precision & revert artifact content * Include Xcode result in the artifact * Update test output directory * Disable gradient on splash screen for tests * Tap next button explicitly * Wait a bit before checking alert * Wait 1 second * Run SwiftFormat on project * Ignore temporary screenshots * Fix most of the PR remarks * Fix conflicts * Bump Python version to 3 * Update reference screenshots for authentication screens * Update SwiftFormat * Fix flakey session verification test. * Update scheme. Co-authored-by: Doug <douglase@element.io>
This commit is contained in:
@@ -15,3 +15,11 @@ Usage:
|
||||
```
|
||||
./localizer.py
|
||||
```
|
||||
|
||||
## Boot Test Simulator
|
||||
Boots a desired simulator and makes status bar overrides on that.
|
||||
|
||||
Usage:
|
||||
```
|
||||
./bootTestSimulator.py 'iPhone 13 Pro Max'
|
||||
```
|
||||
|
||||
@@ -43,7 +43,7 @@ struct TemplateScreen: View {
|
||||
.padding(.horizontal)
|
||||
.padding(.vertical)
|
||||
.readableFrame()
|
||||
.background(.regularMaterial)
|
||||
.background(Color.element.system)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ class TemplateScreenUITests: XCTestCase {
|
||||
XCTAssert(title.exists)
|
||||
|
||||
XCTAssertEqual(title.label, "Make this chat public?")
|
||||
|
||||
app.assertScreenshot(.simpleRegular)
|
||||
}
|
||||
|
||||
func testUpgradeScreen() {
|
||||
@@ -36,5 +38,7 @@ class TemplateScreenUITests: XCTestCase {
|
||||
XCTAssert(title.exists)
|
||||
|
||||
XCTAssertEqual(title.label, "Privacy warning")
|
||||
|
||||
app.assertScreenshot(.simpleUpgrade)
|
||||
}
|
||||
}
|
||||
|
||||
52
Tools/Scripts/bootTestSimulator.py
Executable file
52
Tools/Scripts/bootTestSimulator.py
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
from encodings import utf_8
|
||||
import os
|
||||
import subprocess
|
||||
import json
|
||||
import argparse
|
||||
from datetime import datetime
|
||||
|
||||
RUNTIME_PREFIX = 'com.apple.CoreSimulator.SimRuntime.'
|
||||
|
||||
def device_name(device):
|
||||
return device['name']
|
||||
def runtime_name(runtime):
|
||||
return runtime.replace(RUNTIME_PREFIX, '').replace('-', '.')
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--name', type=str, help='Simulator name (like \'iPhone 13 Pro Max\')', required=True)
|
||||
parser.add_argument('--version', type=str, default='iOS.15.5', help='OS version (defaults to \'iOS.15.5\')', required=False)
|
||||
|
||||
args = vars(parser.parse_args())
|
||||
|
||||
simulator_name = args['name']
|
||||
os_version = args['version'].replace('.', '-')
|
||||
|
||||
runtimes_map = subprocess.check_output("/usr/bin/xcrun simctl list --json devices available", shell=True)
|
||||
runtime = RUNTIME_PREFIX + os_version
|
||||
json_object = json.loads(runtimes_map)
|
||||
if runtime in json_object['devices']:
|
||||
devices = json_object['devices'][runtime]
|
||||
|
||||
device_found=False
|
||||
for device in devices:
|
||||
if device_name(device) == simulator_name:
|
||||
UDID=device['udid']
|
||||
print("Found device UDID: " + UDID)
|
||||
|
||||
dirname = os.path.dirname(os.path.abspath(__file__))
|
||||
overridden_time = datetime(2007, 1, 9, 9, 41, 0).astimezone().isoformat()
|
||||
print("Will override simulator with time: " + overridden_time)
|
||||
os.system("/usr/bin/xcrun simctl boot '" + UDID + "' > /dev/null 2>&1")
|
||||
os.system("/usr/bin/xcrun simctl status_bar '" + UDID + "' override --time '" + overridden_time + "' --dataNetwork 'wifi' --wifiMode 'active' --wifiBars 3 --cellularMode 'active' --cellularBars 4 --batteryState 'charged' --batteryLevel 100 > /dev/null 2>&1")
|
||||
print("Simulator booted and status bar overriden")
|
||||
device_found=True
|
||||
break
|
||||
|
||||
if device_found == False:
|
||||
print("Device could not be found. \n\nAvailable devices: " + ', '.join(map(device_name, devices)))
|
||||
exit(1)
|
||||
else:
|
||||
print("Runtime could not be found. \n\nAvailable runtimes: " + ', '.join(map(runtime_name, json_object['devices'].keys())))
|
||||
exit(1)
|
||||
Reference in New Issue
Block a user