Skip to content

Commit

Permalink
Merge branch 'main' into nativeLogs
Browse files Browse the repository at this point in the history
  • Loading branch information
larkox committed Dec 10, 2024
2 parents 9559257 + 63889c0 commit 19e18e9
Show file tree
Hide file tree
Showing 236 changed files with 5,883 additions and 3,030 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/e2e-detox-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ on:
description: "iPhone simulator name"
required: false
type: string
default: "iPhone 14"
default: "iPhone 15 Pro"
ios_device_os_name:
description: "iPhone simulator OS version"
required: false
type: string
default: "iOS 17.0"
default: "iOS 17.4"
low_bandwidth_mode:
description: "Enable low bandwidth mode"
required: false
Expand All @@ -66,8 +66,8 @@ env:
ADMIN_EMAIL: ${{ secrets.MM_MOBILE_E2E_ADMIN_EMAIL }}
ADMIN_USERNAME: ${{ secrets.MM_MOBILE_E2E_ADMIN_USERNAME }}
ADMIN_PASSWORD: ${{ secrets.MM_MOBILE_E2E_ADMIN_PASSWORD }}
# BRANCH: ${{ github.head_ref || github.ref_name }}
# COMMIT_HASH: ${{ github.sha }}
BRANCH: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}
COMMIT_HASH: ${{ github.sha }}
DEVICE_NAME: ${{ inputs.ios_device_name }}
DEVICE_OS_VERSION: ${{ inputs.ios_device_os_name }}
DETOX_AWS_S3_BUCKET: "mattermost-detox-report"
Expand Down Expand Up @@ -195,7 +195,6 @@ jobs:
DETOX_OS_VERSION: ${{ env.DEVICE_OS_VERSION }}
LOW_BANDWIDTH_MODE: ${{ inputs.low_bandwidth_mode }}


- name: reset network settings
if: ${{ inputs.low_bandwidth_mode || failure() }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mattermost Mobile v2

- **Minimum Server versions:** Current ESR version (9.5.0+)
- **Minimum Server versions:** Current ESR version (9.11.0+)
- **Supported iOS versions:** 13.4+
- **Supported Android versions:** 7.0+

Expand Down
11 changes: 8 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ android {
applicationId "com.mattermost.rnbeta"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 572
versionName "2.22.0"
versionCode 583
versionName "2.23.0"
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
Expand Down Expand Up @@ -186,6 +186,7 @@ repositories {
maven {
url 'https://maven.google.com'
}
maven { url 'https://jitpack.io' }
}

dependencies {
Expand All @@ -203,8 +204,11 @@ dependencies {
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "com.google.firebase:firebase-messaging:$firebaseVersion"

androidTestImplementation('com.wix:detox:+')
androidTestImplementation 'androidx.test:core:1.6.0'
androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestImplementation 'com.wix:detox:20.26.2'

implementation project(':reactnativenotifications')
implementation project(':watermelondb-jsi')

Expand All @@ -217,6 +221,7 @@ dependencies {

configurations.all {
resolutionStrategy {
force 'androidx.test:core:1.6.0'
eachDependency { DependencyResolveDetails details ->
if (details.requested.name == 'play-services-base') {
details.useTarget group: details.requested.group, name: details.requested.name, version: '18.2.0'
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ buildscript {
allprojects {
repositories {
maven {
url "$rootDir/../node_modules/detox/Detox-android"
url "$rootDir/../detox/node_modules/detox/Detox-android"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
org.gradle.jvmargs=-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
27 changes: 24 additions & 3 deletions app/actions/local/category.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from './category';

import type ServerDataOperator from '@database/operator/server_data_operator';
import type ChannelModel from '@typings/database/models/servers/channel';

describe('handleConvertedGMCategories', () => {
const serverUrl = 'baseHandler.test.com';
Expand Down Expand Up @@ -66,7 +67,7 @@ describe('handleConvertedGMCategories', () => {
};
await operator.handleCategoryChannels({categoryChannels: [dmCategoryChannel, customCategoryChannel], prepareRecordsOnly: false});

const {models, error} = await handleConvertedGMCategories(serverUrl, channelId, teamId1, true);
const {models, error} = await handleConvertedGMCategories(serverUrl, channelId, teamId1);
expect(error).toBeUndefined();
expect(models).toBeDefined();
expect(models!.length).toBe(3); // two for removing channel for a custom and a DM category, and one for adding it to default channels category
Expand All @@ -83,7 +84,7 @@ describe('handleConvertedGMCategories', () => {
});

it('error - database not prepared', async () => {
const {error} = await handleConvertedGMCategories(serverUrl, channelId, teamId1, true);
const {error} = await handleConvertedGMCategories('', channelId, teamId1, true);
expect(error).toBeDefined();
});
});
Expand Down Expand Up @@ -124,6 +125,11 @@ describe('category crud', () => {
expect(error2).toBeUndefined();
});

it('deleteCategory - handle database not found', async () => {
const {error} = await deleteCategory('', '');
expect(error).toBeDefined();
});

it('storeCategories', async () => {
const defaultCategory: CategoryWithChannels = {
id: 'default_category_id',
Expand All @@ -143,6 +149,11 @@ describe('category crud', () => {
expect(models!.length).toBe(3);
});

it('storeCategories - handle database not found', async () => {
const {error} = await storeCategories('', []);
expect(error).toBeDefined();
});

it('toggleCollapseCategory', async () => {
const defaultCategory: Category = {
id: 'default_category_id',
Expand All @@ -163,6 +174,11 @@ describe('category crud', () => {
expect(categoryResult2).toBeDefined();
expect(categoryResult2?.collapsed).toBe(defaultCategory.collapsed);
});

it('toggleCollapseCategory - handle database not found', async () => {
const {error} = await toggleCollapseCategory('', '');
expect(error).toBeDefined();
});
});

describe('addChannelToDefaultCategory', () => {
Expand Down Expand Up @@ -221,6 +237,11 @@ describe('addChannelToDefaultCategory', () => {
expect(dmError).toBeUndefined();
expect(dmModels).toBeDefined();
expect(dmModels!.length).toBe(1); // one for the dm channel

const {models: channelModels, error: channelModelError} = await addChannelToDefaultCategory(serverUrl, {teamId: teamId1, id: channelId} as ChannelModel);
expect(channelModelError).toBeUndefined();
expect(channelModels).toBeDefined();
expect(channelModels!.length).toBe(1); // one for the channel
});

it('error - no current user', async () => {
Expand All @@ -233,7 +254,7 @@ describe('addChannelToDefaultCategory', () => {
});

it('error - database not prepared', async () => {
const {error} = await addChannelToDefaultCategory(serverUrl, channel);
const {error} = await addChannelToDefaultCategory('', channel);
expect(error).toBeDefined();
});
});
18 changes: 13 additions & 5 deletions app/actions/local/draft.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('updateDraftFile', () => {
it('update draft file', async () => {
await operator.handleDraft({drafts: [{...draft, files: [{...fileInfo, localPath: 'path0'}]}], prepareRecordsOnly: false});

const {draft: draftModel, error} = await updateDraftFile(serverUrl, channelId, '', fileInfo, false);
const {draft: draftModel, error} = await updateDraftFile(serverUrl, channelId, '', fileInfo);
expect(error).toBeUndefined();
expect(draftModel).toBeDefined();
expect(draftModel?.files?.length).toBe(1);
Expand Down Expand Up @@ -101,7 +101,7 @@ describe('removeDraftFile', () => {
it('remove draft file', async () => {
await operator.handleDraft({drafts: [{...draft, files: [fileInfo]}], prepareRecordsOnly: false});

const {draft: draftModel, error} = await removeDraftFile(serverUrl, channelId, '', 'clientid', false);
const {draft: draftModel, error} = await removeDraftFile(serverUrl, channelId, '', 'clientid');
expect(error).toBeUndefined();
expect(draftModel).toBeDefined();
});
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('updateDraftMessage', () => {
it('update draft message', async () => {
await operator.handleDraft({drafts: [{...draft, files: [fileInfo]}], prepareRecordsOnly: false});

const result = await updateDraftMessage(serverUrl, channelId, '', 'newmessage', false) as {draft: DraftModel; error: unknown};
const result = await updateDraftMessage(serverUrl, channelId, '', 'newmessage') as {draft: DraftModel; error: unknown};
expect(result.error).toBeUndefined();
expect(result.draft).toBeDefined();
expect(result.draft.message).toBe('newmessage');
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('addFilesToDraft', () => {
it('add draft files', async () => {
await operator.handleDraft({drafts: [draft], prepareRecordsOnly: false});

const result = await addFilesToDraft(serverUrl, channelId, '', [fileInfo], false) as {draft: DraftModel; error: unknown};
const result = await addFilesToDraft(serverUrl, channelId, '', [fileInfo]) as {draft: DraftModel; error: unknown};
expect(result.error).toBeUndefined();
expect(result.draft).toBeDefined();
expect(result?.draft.files.length).toBe(1);
Expand All @@ -201,7 +201,15 @@ describe('removeDraft', () => {
it('remove draft', async () => {
await operator.handleDraft({drafts: [draft], prepareRecordsOnly: false});

const result = await removeDraft(serverUrl, channelId, '');
const result = await removeDraft(serverUrl, channelId);
expect(result.error).toBeUndefined();
expect(result.draft).toBeDefined();
});

it('remove draft with root id', async () => {
await operator.handleDraft({drafts: [{...draft, root_id: 'postid'}], prepareRecordsOnly: false});

const result = await removeDraft(serverUrl, channelId, 'postid');
expect(result.error).toBeUndefined();
expect(result.draft).toBeDefined();
});
Expand Down
22 changes: 21 additions & 1 deletion app/actions/local/file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import DatabaseManager from '@database/manager';
import {
updateLocalFile,
updateLocalFilePath,
getLocalFileInfo,
} from './file';

import type ServerDataOperator from '@database/operator/server_data_operator';
import type FileModel from '@typings/database/models/servers/file';

describe('updateLocalFiles', () => {
describe('files', () => {
let operator: ServerDataOperator;
const serverUrl = 'baseHandler.test.com';
const fileInfo: FileInfo = {
Expand Down Expand Up @@ -52,4 +53,23 @@ describe('updateLocalFiles', () => {
const {error} = await updateLocalFilePath(serverUrl, fileInfo.id as string, 'newpath');
expect(error).toBeUndefined();
});

it('updateLocalFilePath - no file', async () => {
const {error} = await updateLocalFilePath(serverUrl, fileInfo.id as string, 'newpath');
expect(error).toBeUndefined();
});

it('getLocalFileInfo - handle not found database', async () => {
const {error} = await getLocalFileInfo('foo', '');
expect(error).toBeTruthy();
});

it('getLocalFileInfo', async () => {
await operator.handleFiles({files: [fileInfo], prepareRecordsOnly: false});

const {file, error} = await getLocalFileInfo(serverUrl, fileInfo.id as string);
expect(error).toBeUndefined();
expect(file).toBeDefined();
expect(file!.id).toBe(fileInfo.id);
});
});
34 changes: 34 additions & 0 deletions app/actions/local/group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ describe('searchGroups', () => {
expect(models[0].id).toBe(group.id);
});

it('searchGroupsByName', async () => {
const groupModels = await operator.handleGroups({groups: [group], prepareRecordsOnly: false});
mockedRemoteGroups.fetchGroupsForAutocomplete.mockReturnValueOnce(Promise.resolve(groupModels));

const models = await searchGroupsByName(serverUrl, group.name);
expect(models).toBeDefined();
expect(models.length).toBe(1);
expect(models[0].id).toBe(group.id);
});

it('searchGroupsByNameInTeam - handle not found database', async () => {
const models = await searchGroupsByNameInTeam('foo', 'test', teamId);
expect(models).toBeDefined();
Expand All @@ -90,6 +100,18 @@ describe('searchGroups', () => {
expect(models[0].id).toBe(group.id);
});

it('searchGroupsByNameInTeam', async () => {
const groupModels = await operator.handleGroups({groups: [group], prepareRecordsOnly: false});
await operator.handleGroupTeamsForTeam({groups: [group], teamId, prepareRecordsOnly: false});

mockedRemoteGroups.fetchFilteredTeamGroups.mockReturnValueOnce(Promise.resolve(groupModels));

const models = await searchGroupsByNameInTeam(serverUrl, group.name, teamId);
expect(models).toBeDefined();
expect(models.length).toBe(1);
expect(models[0].id).toBe(group.id);
});

it('searchGroupsByNameInChannel - handle not found database', async () => {
const models = await searchGroupsByNameInChannel('foo', 'test', channelId);
expect(models).toBeDefined();
Expand All @@ -113,4 +135,16 @@ describe('searchGroups', () => {
expect(models.length).toBe(1);
expect(models[0].id).toBe(group.id);
});

it('searchGroupsByNameInChannel', async () => {
const groupModels = await operator.handleGroups({groups: [group], prepareRecordsOnly: false});
await operator.handleGroupChannelsForChannel({groups: [group], channelId, prepareRecordsOnly: false});

mockedRemoteGroups.fetchFilteredChannelGroups.mockReturnValueOnce(Promise.resolve(groupModels));

const models = await searchGroupsByNameInChannel(serverUrl, group.name, channelId);
expect(models).toBeDefined();
expect(models.length).toBe(1);
expect(models[0].id).toBe(group.id);
});
});
Loading

0 comments on commit 19e18e9

Please sign in to comment.