Skip to content

Commit

Permalink
Log execAsync environment
Browse files Browse the repository at this point in the history
  • Loading branch information
ospfranco committed Oct 19, 2023
1 parent 41a5078 commit 8dbd16a
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 91 deletions.
2 changes: 1 addition & 1 deletion metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const defaultConfig = getDefaultConfig(__dirname);
const isUsingMockAPI = process.env.E2E_TESTING === 'true';
if (isUsingMockAPI) {
// eslint-disable-next-line no-console
console.warn('⚠️ Using mock API');
console.log('⚠️ Using mock API');
}

/**
Expand Down
307 changes: 227 additions & 80 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.3.86-1",
"version": "1.3.84-1",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down Expand Up @@ -90,14 +90,15 @@
"@types/node": "^18.14.0",
"@ua/react-native-airship": "^15.2.6",
"awesome-phonenumber": "^5.4.0",
"babel-plugin-transform-remove-console": "^6.9.4",
"babel-polyfill": "^6.26.0",
"canvas-size": "^1.2.6",
"core-js": "^3.32.0",
"date-fns": "^2.30.0",
"date-fns-tz": "^2.0.0",
"dom-serializer": "^0.2.2",
"domhandler": "^4.3.0",
"expensify-common": "git+ssh://[email protected]/Expensify/expensify-common.git#bdbdf44825658500ba581d3e86237d7b8996cc2e",
"expensify-common": "git+ssh://[email protected]/Expensify/expensify-common.git#009c2ab79bf7ddeab0eea7a3a4c0d9cc4277c34b",
"fbjs": "^3.0.2",
"htmlparser2": "^7.2.0",
"idb-keyval": "^6.2.1",
Expand Down Expand Up @@ -184,6 +185,8 @@
"@babel/runtime": "^7.20.0",
"@electron/notarize": "^1.2.3",
"@jest/globals": "^29.5.0",
"@kie/act-js": "^2.0.1",
"@kie/mock-github": "^1.0.0",
"@octokit/core": "4.0.4",
"@octokit/plugin-paginate-rest": "3.1.0",
"@octokit/plugin-throttling": "4.1.0",
Expand Down Expand Up @@ -266,7 +269,7 @@
"react-native-performance-flipper-reporter": "^2.0.0",
"react-native-svg-transformer": "^1.0.0",
"react-test-renderer": "18.2.0",
"reassure": "^0.10.1",
"reassure": "^0.9.0",
"setimmediate": "^1.0.5",
"shellcheck": "^1.1.0",
"style-loader": "^2.0.0",
Expand Down
6 changes: 6 additions & 0 deletions src/libs/E2E/API.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import mockSigninUser from './apiMocks/signinUser';
import mockAuthenticatePusher from './apiMocks/authenticatePusher';
import mockOpenApp from './apiMocks/openApp';
import mockOpenReport from './apiMocks/openReport';
import mockSignInAttemptState from './apiMocks/signInAttemptState';

/**
* A dictionary which has the name of a API command as key, and a function which
Expand All @@ -22,10 +23,15 @@ const mocks = {
ReconnectApp: mockOpenApp,
OpenReport: mockOpenReport,
AuthenticatePusher: mockAuthenticatePusher,
SignInAttemptState: mockSignInAttemptState,
};

function mockCall(command, apiCommandParameters, tag) {
const mockResponse = mocks[command] && mocks[command](apiCommandParameters);
Log.warn('🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐');
Log.warn('🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐');
Log.warn(`Mock Call to ${command}`);
Log.warn('🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐🫐');
if (!mockResponse || !_.isArray(mockResponse.onyxData)) {
Log.warn(`[${tag}] for command ${command} is not mocked yet!`);
return;
Expand Down
1 change: 1 addition & 0 deletions src/libs/E2E/apiMocks/beginSignin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default ({email}) => ({
key: 'account',
value: {
validated: true,
hasEmailDeliveryFailure: false,
},
},
{
Expand Down
21 changes: 21 additions & 0 deletions src/libs/E2E/apiMocks/signInAttemptState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default ({email}) => ({
onyxData: [
{
onyxMethod: 'merge',
key: 'account',
value: {
isLoading: false,
loadingForm: null,
},
},
{
onyxMethod: 'merge',
key: 'credenttials',
value: {
validateCode: null,
},
},
],
jsonCode: 200,
requestID: '783e54ef4b38cff5-SJC',
});
1 change: 1 addition & 0 deletions src/libs/E2E/apiMocks/signinUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default ({email}) => ({
key: 'account',
value: {
requiresTwoFactorAuth: false,
hasEmailDeliveryFailure: false,
},
},
],
Expand Down
4 changes: 4 additions & 0 deletions src/pages/signin/SignInPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ function getRenderOptions({hasLogin, hasValidateCode, account, isPrimaryLogin, i
}

const shouldShowLoginForm = isClientTheLeader && !hasLogin && !hasValidateCode;
console.warn('🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏');
console.warn('🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏');
console.warn('🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏🍏');
const shouldShowEmailDeliveryFailurePage = hasLogin && hasEmailDeliveryFailure && !shouldShowChooseSSOOrMagicCode && !shouldInitiateSAMLLogin;
console.warn({shouldShowEmailDeliveryFailurePage, hasLogin, hasEmailDeliveryFailure});
const isUnvalidatedSecondaryLogin = hasLogin && !isPrimaryLogin && !account.validated && !hasEmailDeliveryFailure;
const shouldShowValidateCodeForm =
hasAccount && (hasLogin || hasValidateCode) && !isUnvalidatedSecondaryLogin && !hasEmailDeliveryFailure && !shouldShowChooseSSOOrMagicCode && !isSAMLRequired;
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/testRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const runTests = async () => {
const tempDir = `${config.OUTPUT_DIR}/temp`;
const tempBundlePath = `${tempDir}/index.android.bundle`;
await execAsync(`rm -rf ${tempDir} && mkdir ${tempDir}`);
await execAsync(`npx react-native bundle --platform android --dev false --entry-file ${config.ENTRY_FILE} --bundle-output ${tempBundlePath}`, {E2E_TESTING: true});
await execAsync(`npx react-native bundle --platform android --dev false --entry-file ${config.ENTRY_FILE} --bundle-output ${tempBundlePath}`, {E2E_TESTING: 'true'});
// Repackage the existing native app with the new bundle
const tempApkPath = `${tempDir}/app-release.apk`;
await execAsync(`./scripts/android-repackage-app-bundle-and-sign.sh ${appPath} ${tempBundlePath} ${tempApkPath}`);
Expand Down
17 changes: 11 additions & 6 deletions tests/e2e/utils/execAsync.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const {exec} = require('child_process');
const _ = require('underscore');
const Logger = require('./logger');

/**
Expand All @@ -11,18 +12,22 @@ const Logger = require('./logger');
module.exports = (command, env = {}) => {
let childProcess;
const promise = new Promise((resolve, reject) => {
Logger.log(`\nRunning command:`);
const finalEnv = {
...process.env,
...env,
};

if (_.keys(env).length !== 0) {
Logger.log(`environment variables:`, JSON.stringify(finalEnv, null, 2));
}

Logger.important(command);

childProcess = exec(
command,
{
encoding: 'utf8',
maxBuffer: 1024 * 1024 * 10, // Increase max buffer to 10MB, to avoid errors
env: {
...process.env,
...env,
},
env: finalEnv,
},
(error, stdout) => {
if (error) {
Expand Down

0 comments on commit 8dbd16a

Please sign in to comment.