Skip to content

Commit

Permalink
Merge branch 'main' into ts-migration/group3-tests
Browse files Browse the repository at this point in the history
# Conflicts:
#	tests/e2e/measure/math.ts
  • Loading branch information
ruben-rebelo committed Mar 4, 2024
2 parents 1825d3a + 4231ac9 commit 3f02374
Show file tree
Hide file tree
Showing 141 changed files with 2,299 additions and 990 deletions.
4 changes: 2 additions & 2 deletions .github/actions/composite/setupNode/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ runs:
desktop/package-lock.json
- id: cache-node-modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json', 'patches/**') }}

- id: cache-desktop-node-modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: desktop/node_modules
key: ${{ runner.os }}-desktop-node-modules-${{ hashFiles('desktop/package-lock.json', 'desktop/patches/**') }}
Expand Down
9 changes: 7 additions & 2 deletions .github/actions/javascript/bumpVersion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2657,12 +2657,17 @@ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`)

// Coercion.
// Extract anything that could conceivably be a part of a valid semver
createToken('COERCE', `${'(^|[^\\d])' +
createToken('COERCEPLAIN', `${'(^|[^\\d])' +
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`)
createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`)
createToken('COERCEFULL', src[t.COERCEPLAIN] +
`(?:${src[t.PRERELEASE]})?` +
`(?:${src[t.BUILD]})?` +
`(?:$|[^\\d])`)
createToken('COERCERTL', src[t.COERCE], true)
createToken('COERCERTLFULL', src[t.COERCEFULL], true)

// Tilde ranges.
// Meaning is "reasonably at or greater than"
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/checkE2ETestCode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check e2e test code builds correctly

on:
workflow_call:
pull_request:
types: [opened, synchronize]
paths:
- 'tests/e2e/**'
- 'src/libs/E2E/**'

jobs:
lint:
if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: ./.github/actions/composite/setupNode

- name: Verify e2e tests compile correctly
run: npm run e2e-test-runner-build
24 changes: 8 additions & 16 deletions .github/workflows/e2ePerformanceTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
type: string
required: true

concurrency:
group: "${{ github.ref }}-e2e"
cancel-in-progress: true

jobs:
buildBaseline:
runs-on: ubuntu-latest-xl
Expand Down Expand Up @@ -175,23 +179,11 @@ jobs:
- name: Rename delta APK
run: mv "${{steps.downloadDeltaAPK.outputs.download-path}}/app-e2edelta-release.apk" "${{steps.downloadDeltaAPK.outputs.download-path}}/app-e2edeltaRelease.apk"

- name: Copy e2e code into zip folder
run: cp -r tests/e2e zip
- name: Compile test runner to be executable in a nodeJS environment
run: npm run e2e-test-runner-build

# Note: we can't reuse the apps tsconfig, as it depends on modules that aren't available in the AWS Device Farm environment
- name: Write tsconfig.json to zip folder
run: |
echo '{
"compilerOptions": {
"target": "ESNext",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
}
}' > zip/tsconfig.json
- name: Copy e2e code into zip folder
run: cp tests/e2e/dist/index.js zip/testRunner.js

- name: Zip everything in the zip directory up
run: zip -qr App.zip ./zip
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ on:
branches-ignore: [staging, production]
paths: ['**.js', '**.ts', '**.tsx', '**.json', '**.mjs', '**.cjs', 'config/.editorconfig', '.watchmanconfig', '.imgbotconfig']

concurrency:
group: "${{ github.ref }}-lint"
cancel-in-progress: true

jobs:
lint:
name: Run ESLint
if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }}
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/platformDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ jobs:
bundler-cache: true

- name: Cache Pod dependencies
uses: actions/cache@v3
uses: actions/cache@v4
id: pods-cache
with:
path: ios/Pods
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
branches-ignore: [staging, production]
paths: ['**.js', '**.ts', '**.tsx', '**.sh', 'package.json', 'package-lock.json']

concurrency:
group: "${{ github.ref }}-jest"
cancel-in-progress: true

jobs:
jest:
if: ${{ github.actor != 'OSBotify' && github.actor != 'imgbot[bot]' || github.event_name == 'workflow_call' }}
Expand All @@ -31,7 +35,7 @@ jobs:

- name: Cache Jest cache
id: cache-jest-cache
uses: actions/cache@ac25611caef967612169ab7e95533cf932c32270
uses: actions/cache@v4
with:
path: .jest-cache
key: ${{ runner.os }}-jest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ jobs:
bundler-cache: true

- name: Cache Pod dependencies
uses: actions/cache@v3
uses: actions/cache@v4
id: pods-cache
with:
path: ios/Pods
Expand Down
44 changes: 33 additions & 11 deletions __mocks__/react-native.js → __mocks__/react-native.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,47 @@
// eslint-disable-next-line no-restricted-imports
import * as ReactNative from 'react-native';
import _ from 'underscore';
import type StartupTimer from '@libs/StartupTimer/types';

const {BootSplash} = ReactNative.NativeModules;

jest.doMock('react-native', () => {
let url = 'https://new.expensify.com/';
const getInitialURL = () => Promise.resolve(url);

let appState = 'active';
let appState: ReactNative.AppStateStatus = 'active';
let count = 0;
const changeListeners = {};
const changeListeners: Record<number, (state: ReactNative.AppStateStatus) => void> = {};

// Tests will run with the app in a typical small screen size by default. We do this since the react-native test renderer
// runs against index.native.js source and so anything that is testing a component reliant on withWindowDimensions()
// would be most commonly assumed to be on a mobile phone vs. a tablet or desktop style view. This behavior can be
// overridden by explicitly setting the dimensions inside a test via Dimensions.set()
let dimensions = {
let dimensions: Record<string, number> = {
width: 300,
height: 700,
scale: 1,
fontScale: 1,
};

return Object.setPrototypeOf(
type ReactNativeMock = typeof ReactNative & {
NativeModules: typeof ReactNative.NativeModules & {
BootSplash: {
getVisibilityStatus: typeof BootSplash.getVisibilityStatus;
hide: typeof BootSplash.hide;
logoSizeRatio: number;
navigationBarHeight: number;
};
StartupTimer: StartupTimer;
};
Linking: typeof ReactNative.Linking & {
setInitialURL: (newUrl: string) => void;
};
AppState: typeof ReactNative.AppState & {
emitCurrentTestState: (state: ReactNative.AppStateStatus) => void;
};
};

const reactNativeMock: ReactNativeMock = Object.setPrototypeOf(
{
NativeModules: {
...ReactNative.NativeModules,
Expand All @@ -36,7 +56,7 @@ jest.doMock('react-native', () => {
Linking: {
...ReactNative.Linking,
getInitialURL,
setInitialURL(newUrl) {
setInitialURL(newUrl: string) {
url = newUrl;
},
},
Expand All @@ -45,11 +65,11 @@ jest.doMock('react-native', () => {
get currentState() {
return appState;
},
emitCurrentTestState(state) {
emitCurrentTestState(state: ReactNative.AppStateStatus) {
appState = state;
_.each(changeListeners, (listener) => listener(appState));
Object.entries(changeListeners).forEach(([, listener]) => listener(appState));
},
addEventListener(type, listener) {
addEventListener(type: ReactNative.AppStateEvent, listener: (state: ReactNative.AppStateStatus) => void) {
if (type === 'change') {
const originalCount = count;
changeListeners[originalCount] = listener;
Expand All @@ -68,7 +88,7 @@ jest.doMock('react-native', () => {
...ReactNative.Dimensions,
addEventListener: jest.fn(),
get: () => dimensions,
set: (newDimensions) => {
set: (newDimensions: Record<string, number>) => {
dimensions = newDimensions;
},
},
Expand All @@ -78,9 +98,11 @@ jest.doMock('react-native', () => {
// so it seems easier to just run the callback immediately in tests.
InteractionManager: {
...ReactNative.InteractionManager,
runAfterInteractions: (callback) => callback(),
runAfterInteractions: (callback: () => void) => callback(),
},
},
ReactNative,
);

return reactNativeMock;
});
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001044600
versionName "1.4.46-0"
versionCode 1001044601
versionName "1.4.46-1"
}

flavorDimensions "default"
Expand Down
12 changes: 12 additions & 0 deletions assets/images/make-admin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions assets/images/remove-members.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Set Up the Card for your Company
title: Set Up the Expensify Visa® Commercial Card for your Company
description: Details on setting up the Expensify Card for your company as an admin
---
# Overview
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.4.46.0</string>
<string>1.4.46.1</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.4.46.0</string>
<string>1.4.46.1</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion ios/NotificationServiceExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<key>CFBundleShortVersionString</key>
<string>1.4.46</string>
<key>CFBundleVersion</key>
<string>1.4.46.0</string>
<string>1.4.46.1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
},
testEnvironment: 'jsdom',
setupFiles: ['<rootDir>/jest/setup.ts', './node_modules/@react-native-google-signin/google-signin/jest/build/setup.js'],
setupFilesAfterEnv: ['@testing-library/jest-native/extend-expect', '<rootDir>/jest/setupAfterEnv.ts', '<rootDir>/tests/perf-test/setupAfterEnv.js'],
setupFilesAfterEnv: ['<rootDir>/jest/setupAfterEnv.ts', '<rootDir>/tests/perf-test/setupAfterEnv.js'],
cacheDirectory: '<rootDir>/.jest-cache',
moduleNameMapper: {
'\\.(lottie)$': '<rootDir>/__mocks__/fileMock.ts',
Expand Down
3 changes: 3 additions & 0 deletions jest/setupAfterEnv.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
// This is required in order for jest to recognize custom matchers like toBeDisabled. This can be removed once testing-library/react-native version is bumped to v12.4 or later
import '@testing-library/jest-native/extend-expect';

jest.useRealTimers();
Loading

0 comments on commit 3f02374

Please sign in to comment.