-
Notifications
You must be signed in to change notification settings - Fork 56
feat: filter device allocation by deviceType and osVersion constraint expressions #269
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
Merged
Merged
Changes from all commits
Commits
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
| import { buildFilters } from './driver.js'; | ||
|
|
||
| test('deviceType criteria becomes a type EQUALS filter', () => { | ||
| const filters = buildFilters({ platform: 'ios', deviceType: 'real' }); | ||
|
|
||
| expect(filters).toContainEqual({ attribute: 'type', operator: 'EQUALS', value: 'real' }); | ||
| }); | ||
|
|
||
| test('a bare osVersion becomes inclusive-lower and exclusive-upper version filters', () => { | ||
| const filters = buildFilters({ platform: 'ios', osVersion: '17' }); | ||
|
|
||
| expect(filters).toContainEqual({ attribute: 'version', operator: 'GREATER_THAN_OR_EQUALS', value: '17' }); | ||
| expect(filters).toContainEqual({ attribute: 'version', operator: 'LESS_THAN', value: '18' }); | ||
| }); | ||
|
|
||
| test('comparator osVersion expressions map onto the matching fleet operators', () => { | ||
| expect(buildFilters({ platform: 'android', osVersion: '>16' })).toContainEqual( | ||
| { attribute: 'version', operator: 'GREATER_THAN', value: '16' }, | ||
| ); | ||
| expect(buildFilters({ platform: 'android', osVersion: '<=16' })).toContainEqual( | ||
| { attribute: 'version', operator: 'LESS_THAN_OR_EQUALS', value: '16' }, | ||
| ); | ||
| }); | ||
|
|
||
| test('an invalid osVersion expression throws before reaching the fleet API', () => { | ||
| expect(() => buildFilters({ platform: 'ios', osVersion: 'latest' })).toThrow(); | ||
| }); |
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 |
|---|---|---|
|
|
@@ -25,6 +25,10 @@ export interface MobilewrightUseOptions { | |
| deviceId?: string; | ||
| /** Regex to match device name. */ | ||
| deviceName?: RegExp; | ||
| /** Restrict to simulators, emulators, or real devices. */ | ||
| deviceType?: 'simulator' | 'emulator' | 'real'; | ||
| /** OS version constraint, e.g. "17" (any 17.x), "26.0" (exactly 26.0) or ">=17 <19". */ | ||
| osVersion?: string; | ||
|
Comment on lines
+28
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Correct the
📍 Affects 1 file
🤖 Prompt for AI Agents |
||
| /** App bundle ID for this project. */ | ||
| bundleId?: string; | ||
| /** App paths (APK/IPA) to install for this project. Overrides top-level installApps. */ | ||
|
|
@@ -79,6 +83,10 @@ export interface MobilewrightConfig { | |
| deviceId?: string; | ||
| /** Regex to match device name (e.g. /iPhone 17/). */ | ||
| deviceName?: RegExp; | ||
| /** Restrict to simulators, emulators, or real devices. */ | ||
| deviceType?: 'simulator' | 'emulator' | 'real'; | ||
| /** OS version constraint, e.g. "17" (any 17.x), "26.0" (exactly 26.0) or ">=17 <19". */ | ||
| osVersion?: string; | ||
| /** Default app bundle ID. */ | ||
| bundleId?: string; | ||
| /** App paths (APK/IPA) to install on the device before launching. */ | ||
|
|
||
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
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,3 +1,5 @@ | ||
| export type * from './types.js'; | ||
| export type * from './driver.js'; | ||
| export { NoDeviceAvailableError } from './driver.js'; | ||
| export { parseOsVersion, osVersionSatisfies } from './os-version.js'; | ||
| export type { OsVersionBound, OsVersionRange } from './os-version.js'; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Clarify the bare
26.0semantics.“Exactly 26.0” conflicts with “26.0.1 matches.” The bare-version behavior is an inclusive lower bound with an exclusive next-version upper bound, as shown by
packages/driver-mobilenext/src/build-filters.test.ts:10-15. Change this entry to “Any 26.0.x release (>=26.0,<26.1)” or equivalent.🤖 Prompt for AI Agents