Skip to content
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

test: Update "reduce..." tests #2524

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 36 additions & 36 deletions test/functional/desired.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,36 @@ function checkFeatureInEnv(envArg) {
return !!feature;
}

function amendCapabilities(baseCaps, ...newCaps) {
export function amendCapabilities(baseCaps, ...newCaps) {
return node.deepFreeze({
alwaysMatch: _.cloneDeep(Object.assign({}, baseCaps.alwaysMatch, ...newCaps)),
firstMatch: [{}],
});
}

function extractCapabilityValue(caps, capName) {
export function extractCapabilityValue(caps, capName) {
return caps?.alwaysMatch?.[capName];
}

const PLATFORM_VERSION = process.env.PLATFORM_VERSION || '11.3';
const IS_ABOVE_IOS13 = util.compareVersions(PLATFORM_VERSION, '>=', '13.0');
const DEVICE_NAME = process.env.DEVICE_NAME || (IS_ABOVE_IOS13 ? 'iPhone 8' : 'iPhone 6');
const DEVICE_NAME_FOR_TOUCH_ID = process.env.DEVICE_NAME_FOR_TOUCH_ID || 'iPhone 8';
const DEVICE_NAME_FOR_SAFARI_IPAD = process.env.DEVICE_NAME_FOR_SAFARI_IPAD || 'iPad Simulator';
export const PLATFORM_VERSION = process.env.PLATFORM_VERSION || '17.4';
export const DEVICE_NAME = process.env.DEVICE_NAME || 'iPhone 15';
const DEVICE_NAME_FOR_TOUCH_ID = process.env.DEVICE_NAME_FOR_TOUCH_ID || 'iPhone 15';
export const DEVICE_NAME_FOR_SAFARI_IPAD = process.env.DEVICE_NAME_FOR_SAFARI_IPAD || 'iPad Simulator';
const LAUNCH_WITH_IDB = checkFeatureInEnv('LAUNCH_WITH_IDB');
const SHOW_XCODE_LOG = checkFeatureInEnv('SHOW_XCODE_LOG');
const APPS = {
uiCatalogApp: path.resolve(
__dirname,
'..',
'assets',
`${IS_ABOVE_IOS13 ? 'UIKitCatalog' : 'UICatalog'}-iphonesimulator.app`,
'UIKitCatalog-iphonesimulator.app',
), // https://github.com/appium/ios-uicatalog
iosTestApp: path.resolve(__dirname, '..', 'assets', 'TestApp-iphonesimulator.app'), // https://github.com/appium/ios-test-app
biometricApp: path.resolve(__dirname, '..', 'assets', 'biometric.app'), // https://github.com/mwakizaka/LocalAuthentication
};

const initTimeout = 60 * 1000 * (process.env.CI ? 16 : 4);
const GENERIC_CAPS = node.deepFreeze({
export const GENERIC_CAPS = node.deepFreeze({
alwaysMatch: {
platformName: 'iOS',
'appium:platformVersion': PLATFORM_VERSION,
Expand All @@ -58,66 +57,67 @@ const GENERIC_CAPS = node.deepFreeze({
'appium:useNewWDA': true,
'appium:webviewConnectTimeout': 30000,
'appium:simulatorStartupTimeout': initTimeout,
'appium:forceAppLaunch': true,
},
firstMatch: [{}],
});

const UICATALOG_CAPS = amendCapabilities(GENERIC_CAPS, {
/**
*
* @param {string} minVersion
* @returns {boolean}
*/
export function isIosVersionAtLeast(minVersion) {
return util.compareVersions(PLATFORM_VERSION, '>=', minVersion);
}

/**
*
* @param {string} minVersion
* @returns {boolean}
*/
export function isIosVersionBelow(maxVersion) {
return util.compareVersions(PLATFORM_VERSION, '<', maxVersion);
}

export const UICATALOG_CAPS = amendCapabilities(GENERIC_CAPS, {
'appium:app': APPS.uiCatalogApp,
});

const UICATALOG_SIM_CAPS = amendCapabilities(GENERIC_CAPS, {
export const UICATALOG_SIM_CAPS = amendCapabilities(GENERIC_CAPS, {
'appium:app': APPS.uiCatalogApp,
'appium:noReset': false,
}); // do not want to have no reset on the tests that use this

const SETTINGS_CAPS = amendCapabilities(GENERIC_CAPS, {
export const SETTINGS_CAPS = amendCapabilities(GENERIC_CAPS, {
'appium:bundleId': 'com.apple.Preferences',
});

const SAFARI_CAPS = amendCapabilities(GENERIC_CAPS, {
export const SAFARI_CAPS = amendCapabilities(GENERIC_CAPS, {
browserName: 'Safari',
'appium:nativeWebTap': false,
});

const TESTAPP_CAPS = amendCapabilities(GENERIC_CAPS, {
export const TESTAPP_CAPS = amendCapabilities(GENERIC_CAPS, {
'appium:app': APPS.iosTestApp,
});

const MULTIPLE_APPS = amendCapabilities(GENERIC_CAPS, {
export const MULTIPLE_APPS = amendCapabilities(GENERIC_CAPS, {
'appium:app': APPS.uiCatalogApp,
'appium:otherApps': APPS.iosTestApp,
});

const TOUCHIDAPP_CAPS = amendCapabilities(GENERIC_CAPS, {
export const TOUCHIDAPP_CAPS = amendCapabilities(GENERIC_CAPS, {
'appium:app': APPS.biometricApp,
'appium:deviceName': DEVICE_NAME_FOR_TOUCH_ID,
});

const FACEIDAPP_CAPS = amendCapabilities(GENERIC_CAPS, {
export const FACEIDAPP_CAPS = amendCapabilities(GENERIC_CAPS, {
'appium:app': APPS.biometricApp,
});

const TVOS_CAPS = amendCapabilities(GENERIC_CAPS, {
export const TVOS_CAPS = amendCapabilities(GENERIC_CAPS, {
platformName: 'tvOS',
'appium:bundleId': 'com.apple.TVSettings',
'appium:deviceName': 'Apple TV',
});

export {
UICATALOG_CAPS,
UICATALOG_SIM_CAPS,
SAFARI_CAPS,
TESTAPP_CAPS,
PLATFORM_VERSION,
TOUCHIDAPP_CAPS,
FACEIDAPP_CAPS,
DEVICE_NAME,
DEVICE_NAME_FOR_SAFARI_IPAD,
SETTINGS_CAPS,
TVOS_CAPS,
MULTIPLE_APPS,
GENERIC_CAPS,
amendCapabilities,
extractCapabilityValue,
};
26 changes: 6 additions & 20 deletions test/functional/device/accessibility-e2e-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,16 @@ describe('Accessibility', function () {
});

async function showAccessibilityTab(driver) {
let hasGeneralTab = false;
try {
// iOS 13 has Accessibility outside the General tab
await driver
.$(`${PREDICATE_SEARCH}:type == 'XCUIElementTypeCell' AND name == 'Accessibility'`)
.click();
} catch {
await driver
.$(`${PREDICATE_SEARCH}:type == 'XCUIElementTypeCell' AND name == 'General'`)
.click();
await driver
.$(`${PREDICATE_SEARCH}:type == 'XCUIElementTypeCell' AND name == 'Accessibility'`)
.click();
hasGeneralTab = true;
}
return hasGeneralTab;
await driver
.$(`${PREDICATE_SEARCH}:name == 'Accessibility'`)
.click();
}

describe('ReduceMotion', function () {
async function getReduceMotion(driver) {
const hasGeneralTab = await showAccessibilityTab(driver);
const motionCellName = hasGeneralTab ? 'Reduce Motion' : 'Motion';
await showAccessibilityTab(driver);
await driver
.$(`${PREDICATE_SEARCH}:type == 'XCUIElementTypeCell' AND name == '${motionCellName}'`)
.$(`${PREDICATE_SEARCH}:type == 'XCUIElementTypeCell' AND name IN {'Reduce Motion', 'Motion'}`)
.click();
return await driver
.$(`${PREDICATE_SEARCH}:type == 'XCUIElementTypeSwitch' AND name == 'Reduce Motion'`)
Expand All @@ -90,7 +76,7 @@ describe('Accessibility', function () {
await showAccessibilityTab(driver);
await driver
.$(
`${PREDICATE_SEARCH}:type == 'XCUIElementTypeCell' AND name == '${'Display & Text Size'}'`,
`${PREDICATE_SEARCH}:name == 'Display & Text Size'`,
)
.click();
return await driver
Expand Down
Loading