Skip to content

Commit

Permalink
Better external auth integration, restore + site button, tests! (#223)
Browse files Browse the repository at this point in the history
See PR for details
  • Loading branch information
pmusaraj authored Oct 30, 2024
1 parent e37dc22 commit 1ca7f99
Show file tree
Hide file tree
Showing 73 changed files with 2,183 additions and 628 deletions.
87 changes: 87 additions & 0 deletions .detoxrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/** @type {Detox.DetoxConfig} */
module.exports = {
testRunner: {
args: {
$0: 'jest',
config: 'e2e/jest.config.js',
},
jest: {
setupTimeout: 120000,
},
},
apps: {
'ios.debug': {
type: 'ios.app',
binaryPath:
'ios/build/Build/Products/Debug-iphonesimulator/Discourse.app',
build:
'xcodebuild -workspace ios/Discourse.xcworkspace -scheme Discourse -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build',
},
'ios.release': {
type: 'ios.app',
binaryPath:
'ios/build/Build/Products/Release-iphonesimulator/Discourse.app',
build:
'xcodebuild -workspace ios/Discourse.xcworkspace -scheme Discourse -configuration Release -sdk iphonesimulator -derivedDataPath ios/build',
},
'android.debug': {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
build:
'cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
reversePorts: [8081],
},
'android.release': {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk',
build:
'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
},
},
devices: {
simulator: {
type: 'ios.simulator',
device: {
type: 'iPhone 15',
},
},
attached: {
type: 'android.attached',
device: {
adbName: '.*',
},
},
emulator: {
type: 'android.emulator',
device: {
avdName: 'Pixel_3a_API_30_x86',
},
},
},
configurations: {
'ios.sim.debug': {
device: 'simulator',
app: 'ios.debug',
},
'ios.sim.release': {
device: 'simulator',
app: 'ios.release',
},
'android.att.debug': {
device: 'attached',
app: 'android.debug',
},
'android.att.release': {
device: 'attached',
app: 'android.release',
},
'android.emu.debug': {
device: 'emulator',
app: 'android.debug',
},
'android.emu.release': {
device: 'emulator',
app: 'android.release',
},
},
};
74 changes: 74 additions & 0 deletions .github/workflows/ios-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: ios-tests

on:
push:
branches:
- main
pull_request:

jobs:
ios-tests:
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version-file: .node-version

- name: Install Yarn dependencies
run: yarn --frozen-lockfile --prefer-offline

- name: Install macOS dependencies
run: |
brew tap wix/brew
brew install applesimutils
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Cache CocoaPods
id: cache-cocoapods
uses: actions/cache@v3
with:
path: ios/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Install CocoaPods
if: steps.cache-cocoapods.outputs.cache-hit != 'true'
run: cd ios ; pod install ; cd -

- name: Detox rebuild framework cache
run: yarn detox rebuild-framework-cache

- name: Cache Detox build
id: cache-detox-build
uses: actions/cache@v3
with:
path: ios/build
key: ${{ runner.os }}-detox-build
restore-keys: |
${{ runner.os }}-detox-build
- name: Detox build
run: yarn detox build --configuration ios.sim.release

- name: Detox test
run: yarn detox test --configuration ios.sim.release --cleanup --headless --record-logs all

- name: Upload artifacts
if: failure()
uses: actions/upload-artifact@v3
with:
name: detox-artifacts
path: artifacts
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.1
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled true
versionCode 213
versionCode 222
versionName MYAPP_VERSION
}

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 31
compileSdkVersion 33
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions e2e/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
rootDir: '..',
testMatch: ['<rootDir>/e2e/**/*.test.js'],
testTimeout: 120000,
maxWorkers: 1,
globalSetup: 'detox/runners/jest/globalSetup',
globalTeardown: 'detox/runners/jest/globalTeardown',
reporters: ['detox/runners/jest/reporter'],
testEnvironment: 'detox/runners/jest/testEnvironment',
verbose: true,
};
69 changes: 69 additions & 0 deletions e2e/onboarding.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* eslint-disable no-undef */
import i18n from 'i18n-js';

describe.each([['en'], ['fr']])(`Onboarding (locale: %s)`, locale => {
beforeAll(async () => {
i18n.translations = {
en: require('../js/locale/en.json'),
fr: require('../js/locale/fr.json'),
};

i18n.locale = locale;
i18n.fallbacks = true;

await device.launchApp({
newInstance: true,
languageAndLocale: {
language: locale,
locale,
},
permissions: {notifications: 'YES'},
});
});

beforeEach(async () => {
await device.reloadReactNative();
});

it('should have onboarding screen', async () => {
await expect(element(by.text(i18n.t('add_first_site')))).toBeVisible();
await expect(element(by.text(i18n.t('no_sites_yet')))).toBeVisible();
await element(by.text(i18n.t('add_first_site'))).tap();
await expect(
element(by.text(i18n.t('term_placeholder_single_site'))),
).toBeVisible();
await element(by.text(i18n.t('back'))).tap();
await expect(element(by.text(i18n.t('no_sites_yet')))).toBeVisible();
});

it('should show the Discover screen', async () => {
await element(by.text(i18n.t('discover'))).tap();
await expect(element(by.text(i18n.t('discover_all')))).toBeVisible();
});

it('should show the Notifications screen', async () => {
await element(by.text(i18n.t('notifications'))).tap();
await expect(element(by.text(i18n.t('replies')))).toBeVisible();
await element(by.text(i18n.t('home'))).tap();
await expect(element(by.text(i18n.t('no_sites_yet')))).toBeVisible();
});

it('should allow adding and removing a site to the Home list', async () => {
await expect(element(by.text(i18n.t('no_sites_yet')))).toBeVisible();
await element(by.text(i18n.t('add_first_site'))).tap();
await element(by.id('search-add-input')).typeText('meta.discourse.org');
await element(by.id('search-add-input')).tapReturnKey();

await element(by.id('add-site-icon')).tap();
await expect(element(by.text(i18n.t('home')))).toBeVisible();
await expect(element(by.text('Discourse Meta'))).toBeVisible();
await expect(element(by.text(i18n.t('connect')))).toBeVisible();
await expect(element(by.text(i18n.t('no_sites_yet')))).not.toBeVisible();

// cleanup added Home site row
await element(by.text('Discourse Meta')).swipe('left', 'fast', 0.5);
await element(by.id('site-row-delete')).tap();

await expect(element(by.text('Discourse Meta'))).not.toBeVisible();
});
});
2 changes: 1 addition & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fastlane_require "base64"
fastlane_require "fileutils"
fastlane_require "json"

IOS_APP_VERSION = "2.0.5"
IOS_APP_VERSION = "2.0.6"
ANDROID_APP_VERSION = "2.0.5" # run `fastlane bootstrap` after editing this
PROJECT_NAME = "Discourse"
IOS_TEAM_ID = "6T3LU73T8S"
Expand Down
4 changes: 2 additions & 2 deletions ios/Discourse.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 530;
CURRENT_PROJECT_VERSION = 540;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 6T3LU73T8S;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 6T3LU73T8S;
Expand Down Expand Up @@ -526,7 +526,7 @@
CODE_SIGN_ENTITLEMENTS = Discourse/Discourse.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 530;
CURRENT_PROJECT_VERSION = 540;
DEVELOPMENT_TEAM = 6T3LU73T8S;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 6T3LU73T8S;
ENABLE_BITCODE = NO;
Expand Down
Loading

0 comments on commit 1ca7f99

Please sign in to comment.