-
Notifications
You must be signed in to change notification settings - Fork 4
iOS media handling changes #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Miki-Session
wants to merge
17
commits into
main
Choose a base branch
from
feat/qa-1265/ios-changes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,708
−1,991
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4ebc3ce
feat: add and use new InteractionPoints
Miki-Session a23a2ac
feat: clear ios simulator before booting
Miki-Session 3bf29aa
feat: changes to ios media handling
Miki-Session 97b4dc7
chore: clean up comments
Miki-Session f5f1cee
fix: remove simulator clearing before starting iOS tests
Miki-Session da9d533
feat: add appium/opencv
Miki-Session 71bf5a6
feat: add matchAndTap util
Miki-Session 6858b73
chore: remove date-based locators
Miki-Session 19414f8
Merge branch 'main' into feat/qa-1265/ios-changes
Miki-Session 8b787bb
fix: add matchAndTapImage to DeviceWrapper
Miki-Session 33abc9d
Merge branch 'main' into feat/qa-1265/ios-changes
Miki-Session bb21433
feat: add utility to copy files to iOS simulator's Downloads folder
Miki-Session 08101df
refactor: use matchAndTapImage instead of date-based ax ids
Miki-Session 6c51d73
refactor: streamline image sharing logic and remove unused variables
Miki-Session 9a126f0
chore: linting
Miki-Session 2d6b69a
fix: remove confidence property from matchAndTap center
Miki-Session a9d3659
Merge branch 'main' into feat/qa-1265/ios-changes
Miki-Session File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export const testImage = 'test_image.jpg'; | ||
export const testFile = 'test_file.pdf'; | ||
export const testVideo = 'test_video.mp4'; | ||
export const testVideoThumbnail = 'test_video_thumbnail.png'; | ||
export const profilePicture = 'profile_picture.jpg'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import { execSync } from 'child_process'; | ||
import { DeviceWrapper } from '../../../types/DeviceWrapper'; | ||
|
||
const TARGET_GROUP_ID = 'group.com.apple.FileProvider.LocalStorage'; | ||
const MEDIA_ROOT = path.join('run', 'test', 'specs', 'media'); | ||
|
||
/** | ||
* Utility for copying a file from the local 'media' directory to the current iOS simulator's | ||
* "Downloads" folder (inside the Files app group container) on disk, if not already present. | ||
* | ||
* Motivation: 'xcrun simctl addmedia' does not support PDFs, and downloading files in tests is unreliable. | ||
*/ | ||
|
||
/** | ||
* Gets the group container path for the Files app on the simulator. | ||
* Inspired by https://medium.com/@liwp.stephen/solution-how-to-get-files-in-files-app-in-ios-simulator-de1e9c9dc6fe | ||
*/ | ||
function getFilesAppGroupContainerPath(udid: string): string { | ||
const listAppsOutput = execSync(`xcrun simctl listapps ${udid}`, { encoding: 'utf8' }); | ||
const groupContainerRegex = (groupId: string) => new RegExp(`"${groupId}" = "file://([^"]+)"`); | ||
const match = listAppsOutput.match(groupContainerRegex(TARGET_GROUP_ID)); | ||
if (!match?.[1]) { | ||
throw new Error(`Group container for "${TARGET_GROUP_ID}" not found.`); | ||
} | ||
return match[1]; | ||
} | ||
|
||
/** | ||
* Gets the full destination path for the file in the simulator's Downloads folder. | ||
*/ | ||
function getSimulatorDownloadsPath( | ||
groupContainerPath: string, | ||
filename: string | ||
): { downloadsPath: string; destinationPath: string } { | ||
const downloadsPath = path.join(groupContainerPath, 'File Provider Storage', 'Downloads'); | ||
const destinationPath = path.join(downloadsPath, filename); | ||
return { downloadsPath, destinationPath }; | ||
} | ||
|
||
/** | ||
* Copies a file from the 'media' directory to the simulator's "Downloads" folder on disk if not already present. | ||
*/ | ||
export function copyFileToSimulator(device: DeviceWrapper, fileName: string): void { | ||
const sourcePath = path.join(MEDIA_ROOT, fileName); | ||
|
||
const groupContainerPath = getFilesAppGroupContainerPath(device.udid); | ||
const { downloadsPath, destinationPath } = getSimulatorDownloadsPath( | ||
groupContainerPath, | ||
fileName | ||
); | ||
|
||
if (fs.existsSync(destinationPath)) { | ||
console.log(`File already exists in simulator: ${destinationPath}`); | ||
return; | ||
} | ||
if (!fs.existsSync(sourcePath)) { | ||
throw new Error(`Source file does not exist: ${sourcePath}`); | ||
} | ||
fs.mkdirSync(downloadsPath, { recursive: true }); | ||
fs.copyFileSync(sourcePath, destinationPath); | ||
console.log(`Copied ${fileName} to simulator Downloads at: ${downloadsPath}`); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.