-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better external auth integration, restore + site button, tests! (#223)
See PR for details
- Loading branch information
Showing
73 changed files
with
2,183 additions
and
628 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.2.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.