Skip to content

Commit

Permalink
Merge branch 'master' into prepare-for-1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SounD120 committed Sep 28, 2020
2 parents e42773d + c6027ea commit e757cc8
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/extension/exponent/xdlInterface.ts
Expand Up @@ -113,7 +113,7 @@ export function startTunnels(projectRoot: string): Promise<void> {
export function getUrl(projectRoot: string, options?: XDLPackage.IUrlOptions): Promise<string> {
return getPackage()
.then((xdl) =>
xdl.Project.getUrlAsync(projectRoot, options));
xdl.UrlUtils.constructManifestUrlAsync(projectRoot, options));
}

export function stopAll(projectRoot: string): Promise<void> {
Expand Down
3 changes: 1 addition & 2 deletions src/extension/windows/windowsPlatform.ts
Expand Up @@ -45,9 +45,8 @@ export class WindowsPlatform extends GeneralMobilePlatform {

if (semver.gte(this.runOptions.reactNativeVersions.reactNativeWindowsVersion, "0.63.0")) {
this.runArguments.push("--logging");
} else {
if (enableDebug) {
this.runArguments.push("--proxy");
this.runArguments.push("--remote-debugging");
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/typings/exponent/xdl.d.ts
Expand Up @@ -67,6 +67,10 @@ declare module xdl {
setOptionsAsync(projectRoot: string, options?: IOptions): Promise<void>;
}

var UrlUtils: {
constructManifestUrlAsync(projectRoot: string, opts?: any, requestHostname?: string): Promise<string>;
}

var Versions: {
facebookReactNativeVersionsAsync(): Promise<string[]>;
facebookReactNativeVersionToExpoVersionAsync(facebookReactNativeVersion: string): Promise<string>;
Expand Down
1 change: 1 addition & 0 deletions test/smoke/docs/run-locally.md
Expand Up @@ -145,6 +145,7 @@ Tests requires several environment variables to be set up before starting:
|`IOS_VERSION`|13.0|(**Only for iOS tests**) Version of iOS on the simulated device|
|`CODE_VERSION`|`*`, `1.34.1`, `insiders`|Version of VS Code to download and run while running tests|
|`EXPO_XDL_VERSION` (optional)|`54.1.4`, `skip`|Version of @expo/xdl package to install to the extension directory. If set to "skip" then package installation will be skipped|
|`EXPO_SDK_MAJOR_VERSION` (optional)|`38`, `skip`|Version of `expo-sdk` for Expo applications. If set to "skip" then the latest `expo-sdk` version will be used|
|`RN_VERSION` (optional)|`0.60.0`, `skip`|Version of React Native application to debug while running tests. If set to "skip" then the latest version will be installed|
|`PURE_RN_VERSION` (optional)|`0.59.8`, `skip`|Version of React Native while running tests on pure RN app with Expo. If set to "skip" then the latest version will be installed|
|`PURE_EXPO_VERSION` (optional)|`34.0.2`, `skip`|Version of Expo while running tests on pure RN app with Expo. If set to "skip" then the latest version will be installed|
Expand Down
1 change: 1 addition & 0 deletions test/smoke/package/config.json
Expand Up @@ -5,6 +5,7 @@
"IOS_VERSION": "13.6",
"CODE_VERSION": "1.45.1",
"EXPO_XDL_VERSION": "57.9.31",
"EXPO_SDK_MAJOR_VERSION": "38",
"RN_VERSION": "0.63.2",
"PURE_RN_VERSION": "0.62.2",
"PURE_EXPO_VERSION": "38.0.9"
Expand Down
4 changes: 2 additions & 2 deletions test/smoke/package/src/helpers/appiumHelper.ts
Expand Up @@ -282,7 +282,7 @@ export class AppiumHelper {
private static async openExpoAppViaClipboardAndroid(client: AppiumClient, expoURL: string) {
// Expo application automatically detects Expo URLs in the clipboard
// So we are copying expoURL to system clipboard and click on the special "Open from Clipboard" UI element
const EXPLORE_ELEMENT = "//android.widget.Button[@content-desc='Projects, tab, 1 of 3']";
const EXPLORE_ELEMENT = "//android.widget.TextView[@text='Projects']";
await client
.waitForExist(EXPLORE_ELEMENT, 30 * 1000)
.click(EXPLORE_ELEMENT);
Expand All @@ -303,7 +303,7 @@ export class AppiumHelper {
private static async openExpoAppViaExpoXDLAndroidFunction(client: AppiumClient, projectFolder: string) {
console.log(`*** Opening Expo app via XDL.Android function`);
console.log(`*** Searching for the "Explore" button...`);
const EXPLORE_ELEMENT = "//android.widget.Button[@content-desc='Explore' or @content-desc='Explore, tab, 2 of 3']";
const EXPLORE_ELEMENT = "//android.widget.TextView[@text='Projects']";
await client
.waitForExist(EXPLORE_ELEMENT, 30 * 1000);

Expand Down
8 changes: 8 additions & 0 deletions test/smoke/package/src/helpers/configHelper.ts
Expand Up @@ -20,6 +20,7 @@ export interface TestEnvVariables {
IOS_VERSION?: string;
CODE_VERSION?: string;
EXPO_XDL_VERSION?: string;
EXPO_SDK_MAJOR_VERSION?: string;
RN_VERSION?: string;
PURE_RN_VERSION?: string;
PURE_EXPO_VERSION?: string;
Expand Down Expand Up @@ -51,6 +52,9 @@ export class TestConfigurator {
if (!variables.EXPO_XDL_VERSION) {
console.warn("Optional EXPO_XDL_VERSION variable is not set");
}
if (!variables.EXPO_SDK_MAJOR_VERSION) {
console.warn("Optional EXPO_SDK_MAJOR_VERSION variable is not set. Use latest.");
}
if (!variables.RN_VERSION) {
console.warn("Optional RN_VERSION variable is not set");
}
Expand Down Expand Up @@ -88,6 +92,9 @@ export class TestConfigurator {
if (variables.EXPO_XDL_VERSION === "skip") {
delete variables.EXPO_XDL_VERSION;
}
if (variables.EXPO_SDK_MAJOR_VERSION === "skip") {
delete variables.EXPO_SDK_MAJOR_VERSION;
}
if (variables.RN_VERSION === "skip" || process.env.NIGHTLY) {
delete variables.RN_VERSION;
}
Expand All @@ -111,6 +118,7 @@ export class TestConfigurator {
initLog += `IOS_VERSION = ${process.env.IOS_VERSION}\n`;
initLog += `CODE_VERSION = ${process.env.CODE_VERSION}\n`;
initLog += `EXPO_XDL_VERSION = ${process.env.EXPO_XDL_VERSION}\n`;
initLog += `EXPO_SDK_MAJOR_VERSION = ${process.env.EXPO_SDK_MAJOR_VERSION}\n`;
initLog += `RN_VERSION = ${process.env.RN_VERSION}\n`;
initLog += `PURE_RN_VERSION = ${process.env.PURE_RN_VERSION}\n`;
initLog += `PURE_EXPO_VERSION = ${process.env.PURE_EXPO_VERSION}\n`;
Expand Down
48 changes: 30 additions & 18 deletions test/smoke/package/src/helpers/setupEnvironmentHelper.ts
Expand Up @@ -20,7 +20,7 @@ export class SetupEnvironmentHelper {
public static expoBundleId = "host.exp.Exponent";
public static iOSExpoAppsCacheDir = `${os.homedir()}/.expo/ios-simulator-app-cache`;

public static prepareReactNativeApplication(workspaceFilePath: string, resourcesPath: string, workspacePath: string, appName: string, customEntryPointFolder: string, version?: string) {
public static prepareReactNativeApplication(workspaceFilePath: string, resourcesPath: string, workspacePath: string, appName: string, customEntryPointFolder: string, version?: string) {
let command = `react-native init ${appName}`;
if (version) {
command += ` --version ${version}`;
Expand Down Expand Up @@ -64,8 +64,9 @@ export class SetupEnvironmentHelper {
fs.copyFileSync(testButtonPath, path.join(workspacePath, "AppTestButton.js"));
}

public static prepareExpoApplication(workspaceFilePath: string, resourcesPath: string, workspacePath: string, appName: string) {
const command = `echo -ne '\\n' | expo init -t tabs --name ${appName} ${appName}`;
public static prepareExpoApplication(workspaceFilePath: string, resourcesPath: string, workspacePath: string, appName: string, expoSdkMajorVersion?: string) {
const useSpecificSdk = expoSdkMajorVersion ? `@sdk-${expoSdkMajorVersion}` : "";
const command = `echo -ne '\\n' | expo init -t tabs${useSpecificSdk} --name ${appName} ${appName}`;
console.log(`*** Creating Expo app via '${command}' in ${workspacePath}...`);
cp.execSync(command, { cwd: resourcesPath, stdio: "inherit" });

Expand Down Expand Up @@ -126,8 +127,10 @@ export class SetupEnvironmentHelper {
}
}

public static async getLatestSupportedRNVersionForExpo(): Promise<any> {
console.log("*** Getting latest React Native version supported by Expo...");
public static async getLatestSupportedRNVersionForExpo(expoSdkMajorVersion?: string): Promise<any> {
const printSpecifiedMajorVersion = expoSdkMajorVersion ? `sdk-${expoSdkMajorVersion}` : "";
const printIsLatest = printSpecifiedMajorVersion ? "" : "latest ";
console.log(`*** Getting latest React Native version supported by ${printIsLatest}Expo ${printSpecifiedMajorVersion}...`);
return new Promise((resolve, reject) => {
utilities.getContents("https://exp.host/--/api/v2/versions", null, null, function (error, versionsContent) {
if (error) {
Expand All @@ -136,20 +139,29 @@ export class SetupEnvironmentHelper {
try {
const content = JSON.parse(versionsContent);
if (content.sdkVersions) {
const maxSdkVersion = Object.keys(content.sdkVersions).sort((ver1, ver2) => {
if (semver.lt(ver1, ver2)) {
return 1;
} else if (semver.gt(ver1, ver2)) {
return -1;
}
return 0;
})[0];
if (content.sdkVersions[maxSdkVersion]) {
if (content.sdkVersions[maxSdkVersion].facebookReactNativeVersion) {
console.log(`*** Latest React Native version supported by Expo: ${content.sdkVersions[maxSdkVersion].facebookReactNativeVersion}`);
resolve(content.sdkVersions[maxSdkVersion].facebookReactNativeVersion as string);
}
let usesSdkVersion: string | undefined;
if (expoSdkMajorVersion) {
usesSdkVersion = Object.keys(content.sdkVersions).find((version) => semver.major(version) === parseInt(expoSdkMajorVersion));
if (!usesSdkVersion) {
console.log(`*** Сould not find the version of Expo sdk matching the specified version - ${printSpecifiedMajorVersion}`);
}
}
if (!usesSdkVersion) {
usesSdkVersion = Object.keys(content.sdkVersions).sort((ver1, ver2) => {
if (semver.lt(ver1, ver2)) {
return 1;
} else if (semver.gt(ver1, ver2)) {
return -1;
}
return 0;
})[0];
}
if (content.sdkVersions[usesSdkVersion]) {
if (content.sdkVersions[usesSdkVersion].facebookReactNativeVersion) {
console.log(`*** Latest React Native version supported by Expo ${printSpecifiedMajorVersion}: ${content.sdkVersions[usesSdkVersion].facebookReactNativeVersion}`);
resolve(content.sdkVersions[usesSdkVersion].facebookReactNativeVersion as string);
}
}
}
reject("Received object is incorrect");
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions test/smoke/package/src/main.ts
Expand Up @@ -170,8 +170,8 @@ async function setup(): Promise<void> {

SetupEnvironmentHelper.prepareReactNativeApplication(RNworkspaceFilePath, resourcesPath, RNworkspacePath, SmokeTestsConstants.RNAppName, "ReactNativeSample", process.env.RN_VERSION);
if (!testParams.RunBasicTests) {
SetupEnvironmentHelper.prepareExpoApplication(ExpoWorkspaceFilePath, resourcesPath, ExpoWorkspacePath, SmokeTestsConstants.ExpoAppName);
const PureRNVersionExpo = process.env.PURE_RN_VERSION || await SetupEnvironmentHelper.getLatestSupportedRNVersionForExpo();
SetupEnvironmentHelper.prepareExpoApplication(ExpoWorkspaceFilePath, resourcesPath, ExpoWorkspacePath, SmokeTestsConstants.ExpoAppName, process.env.EXPO_SDK_MAJOR_VERSION);
const PureRNVersionExpo = process.env.PURE_RN_VERSION || await SetupEnvironmentHelper.getLatestSupportedRNVersionForExpo(process.env.EXPO_SDK_MAJOR_VERSION);
SetupEnvironmentHelper.prepareReactNativeApplication(pureRNWorkspaceFilePath, resourcesPath, pureRNWorkspacePath, SmokeTestsConstants.pureRNExpoApp, "PureRNExpoSample", PureRNVersionExpo);
SetupEnvironmentHelper.addExpoDependencyToRNProject(pureRNWorkspacePath, process.env.PURE_EXPO_VERSION);
await SetupEnvironmentHelper.installExpoAppOnAndroid();
Expand Down

0 comments on commit e757cc8

Please sign in to comment.