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

Implement the capability to change the language between tests #873

Merged
merged 38 commits into from
Sep 29, 2018
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
797a3dd
pipe language through to xcrun launch
Jul 20, 2018
bdff879
Revert "pipe language through to xcrun launch"
Jul 20, 2018
d5dae80
pipe the thing through for real this time
Jul 20, 2018
30afc5f
pass the other arg
Aug 2, 2018
d7e8292
Merge branch 'master' into locale
Aug 2, 2018
4dd1215
remove console.logs
Aug 2, 2018
9e00b94
pass language prop to android
Aug 3, 2018
9fb206f
remove a newline
Aug 3, 2018
92e7a42
fix unit tests
Aug 3, 2018
b160757
add a unit test
Aug 3, 2018
1529795
Merge branch 'master' into locale
Sep 9, 2018
697e6bb
re-apply changes and fix unit tests
Sep 9, 2018
19f73da
add a locale option
Sep 9, 2018
12a7a60
update unit test
Sep 9, 2018
8b6f74f
100% test coverage
Sep 9, 2018
9de21e5
temp rename unneeded test files
Sep 9, 2018
c11308d
temp use iphone 6
Sep 9, 2018
9ee6c55
install and link react-native-device-info
Sep 9, 2018
fe31f84
add boilerplate for a language screen
Sep 9, 2018
9cfd763
render current country and locale in test app
Sep 9, 2018
1de2f1e
add e2e test
Sep 9, 2018
8c648b5
add language UI to language screen
Sep 9, 2018
ab62a22
update e2e
Sep 9, 2018
55e256d
Revert "install and link react-native-device-info"
Sep 9, 2018
667475c
e2e test is passing
Sep 9, 2018
3f6bb30
clean up language screen
Sep 9, 2018
971fb09
temp switch emulator
Sep 9, 2018
6b1b446
add language support to test app for android
Sep 9, 2018
50b4d3e
Revert "add language support to test app for android"
Sep 9, 2018
d5d4955
add android support to language screen
Sep 9, 2018
df7967f
update android API
Sep 9, 2018
3768a34
Revert "temp switch emulator"
Sep 9, 2018
85a2ccd
Revert "temp use iphone 6"
Sep 9, 2018
168e42e
Revert "temp rename unneeded test files"
Sep 9, 2018
4691118
uncomment some tests
Sep 9, 2018
f7f8e2f
comment out the not cross-plat test
Sep 9, 2018
28c87f0
Merge branch 'master' into locale-sync-2
Sep 28, 2018
7c7596d
update docs
Sep 28, 2018
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
2 changes: 1 addition & 1 deletion detox/src/devices/AndroidDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class AndroidDriver extends DeviceDriverBase {
}
}

async launch(deviceId, bundleId, launchArgs) {
async launch(deviceId, bundleId, launchArgs, language) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a locale option as well.

const args = [];
_.forEach(launchArgs, (value, key) => {
args.push(`${key} ${value}`);
Expand Down
10 changes: 6 additions & 4 deletions detox/src/devices/AppleSimUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ class AppleSimUtils {
}
}

async launch(udid, bundleId, launchArgs) {
async launch(udid, bundleId, launchArgs, language) {
const frameworkPath = await environment.getFrameworkPath();
const logsInfo = new LogsInfo(udid);
const args = this._joinLaunchArgs(launchArgs);

const result = await this._launchMagically(frameworkPath, logsInfo, udid, bundleId, args);
const result = await this._launchMagically(frameworkPath, logsInfo, udid, bundleId, args, language);
return this._parseLaunchId(result);
}

Expand Down Expand Up @@ -243,17 +243,19 @@ class AppleSimUtils {
return _.map(launchArgs, (v, k) => `${k} ${v}`).join(' ').trim();
}

async _launchMagically(frameworkPath, logsInfo, udid, bundleId, args) {
async _launchMagically(frameworkPath, logsInfo, udid, bundleId, args, language) {
const statusLogs = {
trying: `Launching ${bundleId}...`,
successful: `${bundleId} launched. The stdout and stderr logs were recreated, you can watch them with:\n` +
` tail -F ${logsInfo.absJoined}`
};

const languageArgs = !!language ? `-AppleLanguages "(${language})" -AppleLocale ${language} ` : '';

const launchBin = `/bin/cat /dev/null >${logsInfo.absStdout} 2>${logsInfo.absStderr} && ` +
`SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="${frameworkPath}/Detox" ` +
`/usr/bin/xcrun simctl launch --stdout=${logsInfo.simStdout} --stderr=${logsInfo.simStderr} ` +
`${udid} ${bundleId} --args ${args}`;
`${udid} ${bundleId} ${languageArgs}--args ${args}`;;

return await exec.execWithRetriesAndLogs(launchBin, undefined, statusLogs, 1);
}
Expand Down
2 changes: 1 addition & 1 deletion detox/src/devices/Device.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class Device {
bundleId: _bundleId,
});

const processId = await this.deviceDriver.launch(this._deviceId, _bundleId, this._prepareLaunchArgs(baseLaunchArgs));
const processId = await this.deviceDriver.launch(this._deviceId, _bundleId, this._prepareLaunchArgs(baseLaunchArgs), params.language);
this._processes[_bundleId] = processId;

await this.deviceDriver.waitUntilReady();
Expand Down
28 changes: 20 additions & 8 deletions detox/src/devices/Device.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,19 @@ describe('Device', () => {

expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId,
device._bundleId,
{"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"});
{"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined);
});

it('launchApp({language}) should launch app with a specific language', async () => {
device = validDevice();

const language = 'es-MX';

await device.launchApp({language});

expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId,
device._bundleId,
{"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, language);
});

it('launchApp() should emit \'launchApp\' event for async listeners and wait for them', async () => {
Expand Down Expand Up @@ -163,7 +175,7 @@ describe('Device', () => {
expect(device.deviceDriver.terminate).toHaveBeenCalled();
expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId,
device._bundleId,
{"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"});
{"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined);
});

it(`relaunchApp({newInstance: false}) should not terminate the app before launch`, async () => {
Expand Down Expand Up @@ -200,7 +212,7 @@ describe('Device', () => {
expect(device.deviceDriver.installApp).toHaveBeenCalled();
expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId,
device._bundleId,
{"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"});
{"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined);
});

it(`relaunchApp() without delete when reuse is enabled should not uninstall and install`, async () => {
Expand All @@ -214,7 +226,7 @@ describe('Device', () => {
expect(device.deviceDriver.installApp).not.toHaveBeenCalled();
expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId,
device._bundleId,
{"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"});
{"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test"}, undefined);
});

it(`relaunchApp() with url should send the url as a param in launchParams`, async () => {
Expand All @@ -223,7 +235,7 @@ describe('Device', () => {

expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId,
device._bundleId,
{"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxURLOverride": "scheme://some.url"});
{"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxURLOverride": "scheme://some.url"}, undefined);
});

it(`relaunchApp() with url should send the url as a param in launchParams`, async () => {
Expand All @@ -235,7 +247,7 @@ describe('Device', () => {
{
"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxURLOverride": "scheme://some.url", "-detoxSourceAppOverride":
"sourceAppBundleId"
});
}, undefined);
});

it(`relaunchApp() with userNofitication should send the userNotification as a param in launchParams`, async () => {
Expand All @@ -247,7 +259,7 @@ describe('Device', () => {

expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId,
device._bundleId,
{"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxUserNotificationDataURL": "url"});
{"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-detoxUserNotificationDataURL": "url"}, undefined);
});

it(`relaunchApp() with url and userNofitication should throw`, async () => {
Expand Down Expand Up @@ -275,7 +287,7 @@ describe('Device', () => {

expect(device.deviceDriver.launch).toHaveBeenCalledWith(device._deviceId,
device._bundleId,
{"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-arg1": "1", "-arg2": 2});
{"-detoxServer": "ws://localhost:8099", "-detoxSessionId": "test", "-arg1": "1", "-arg2": 2}, undefined);
});

it(`sendToHome() should pass to device driver`, async () => {
Expand Down
4 changes: 2 additions & 2 deletions detox/src/devices/SimulatorDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ class SimulatorDriver extends IosDriver {
await this._applesimutils.uninstall(deviceId, bundleId);
}

async launch(deviceId, bundleId, launchArgs) {
return await this._applesimutils.launch(deviceId, bundleId, launchArgs);
async launch(deviceId, bundleId, launchArgs, language) {
return await this._applesimutils.launch(deviceId, bundleId, launchArgs, language);
}

async terminate(deviceId, bundleId) {
Expand Down