Skip to content

Commit

Permalink
test(): also wait for additional dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
AmitMY committed Oct 22, 2023
1 parent 76f8c90 commit 8d0644a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ jobs:
# run: npm run test:ci

- name: Deploy Cloud Functions
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: bun x firebase deploy --only functions:translate --token "${{ secrets.FIREBASE_TOKEN }}"
4 changes: 2 additions & 2 deletions ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@
DEVELOPMENT_TEAM = M8ACAQF4GJ;
INFOPLIST_FILE = App/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 0.0.2;
MARKETING_VERSION = 0.0.3;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = mt.sign.translate;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -408,7 +408,7 @@
DEVELOPMENT_TEAM = M8ACAQF4GJ;
INFOPLIST_FILE = App/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 0.0.2;
MARKETING_VERSION = 0.0.3;
PRODUCT_BUNDLE_IDENTIFIER = mt.sign.translate;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
Expand Down
1 change: 1 addition & 0 deletions ios/App/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def capacitor_pods
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorFirebaseAnalytics', :path => '../../node_modules/@capacitor-firebase/analytics'
pod 'CapacitorFirebaseApp', :path => '../../node_modules/@capacitor-firebase/app'
pod 'CapacitorFirebaseAppCheck', :path => '../../node_modules/@capacitor-firebase/app-check'
pod 'CapacitorFirebaseCrashlytics', :path => '../../node_modules/@capacitor-firebase/crashlytics'
pod 'CapacitorFirebasePerformance', :path => '../../node_modules/@capacitor-firebase/performance'
pod 'CapacitorFilesystem', :path => '../../node_modules/@capacitor/filesystem'
Expand Down
15 changes: 14 additions & 1 deletion ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ PODS:
- CapacitorFirebaseApp (5.2.0):
- Capacitor
- FirebaseCore (= 10.8.0)
- CapacitorFirebaseAppCheck (5.2.0):
- Capacitor
- FirebaseAppCheck (= 10.8.0)
- CapacitorFirebaseCrashlytics (5.2.0):
- Capacitor
- FirebaseCrashlytics (= 10.8.0)
Expand Down Expand Up @@ -50,6 +53,10 @@ PODS:
- GoogleUtilities/Network (~> 7.8)
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- nanopb (< 2.30910.0, >= 2.30908.0)
- FirebaseAppCheck (10.8.0):
- FirebaseCore (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- PromisesObjC (~> 2.1)
- FirebaseCore (10.8.0):
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
Expand Down Expand Up @@ -159,6 +166,7 @@ DEPENDENCIES:
- "CapacitorFirebaseAnalytics (from `../../node_modules/@capacitor-firebase/analytics`)"
- "CapacitorFirebaseAnalytics/Analytics (from `../../node_modules/@capacitor-firebase/analytics`)"
- "CapacitorFirebaseApp (from `../../node_modules/@capacitor-firebase/app`)"
- "CapacitorFirebaseAppCheck (from `../../node_modules/@capacitor-firebase/app-check`)"
- "CapacitorFirebaseCrashlytics (from `../../node_modules/@capacitor-firebase/crashlytics`)"
- "CapacitorFirebasePerformance (from `../../node_modules/@capacitor-firebase/performance`)"
- "CapacitorKeyboard (from `../../node_modules/@capacitor/keyboard`)"
Expand All @@ -169,6 +177,7 @@ SPEC REPOS:
trunk:
- FirebaseABTesting
- FirebaseAnalytics
- FirebaseAppCheck
- FirebaseCore
- FirebaseCoreExtension
- FirebaseCoreInternal
Expand Down Expand Up @@ -198,6 +207,8 @@ EXTERNAL SOURCES:
:path: "../../node_modules/@capacitor-firebase/analytics"
CapacitorFirebaseApp:
:path: "../../node_modules/@capacitor-firebase/app"
CapacitorFirebaseAppCheck:
:path: "../../node_modules/@capacitor-firebase/app-check"
CapacitorFirebaseCrashlytics:
:path: "../../node_modules/@capacitor-firebase/crashlytics"
CapacitorFirebasePerformance:
Expand All @@ -216,13 +227,15 @@ SPEC CHECKSUMS:
CapacitorFilesystem: af704badfbc69f6f8623d9ed313e5490e3723dcb
CapacitorFirebaseAnalytics: 3755413bdeea4cf9169c4063ff621a1ab22ee9ce
CapacitorFirebaseApp: fbdd325f8d67b7be7950b9b76d2aa3d0e1aede9d
CapacitorFirebaseAppCheck: eba071266612be9f851d6caffed4aaa24ada4134
CapacitorFirebaseCrashlytics: 9cdcc0bc73167468586794acc5f1c7ace34ef81a
CapacitorFirebasePerformance: d8f715abf7317b8798a6280990d2cb0fcc431d9c
CapacitorKeyboard: b978154b024a5f65e044908e37d15b7de58b9d12
CapacitorShare: cd41743331cb71d217c029de54b681cbd91e0fcc
CapacitorSplashScreen: 5fa2ab5e46cf5cc530cf16a51c80c7a986579ccd
FirebaseABTesting: 005b70969e2817e2a1e631e8dba29134a04c0622
FirebaseAnalytics: e1fc758bd5d71823bba970c076abee4b2450a5f4
FirebaseAppCheck: 8bde2c5f393518ab98290151188bf196b4bab91e
FirebaseCore: e78636a990b54be427ce300aa09a0e359f4e0e87
FirebaseCoreExtension: d3e9bba2930a8033042112397cd9f006a1bb203d
FirebaseCoreInternal: d2b4acb827908e72eca47a9fd896767c3053921e
Expand All @@ -239,6 +252,6 @@ SPEC CHECKSUMS:
PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef
PromisesSwift: cf9eb58666a43bbe007302226e510b16c1e10959

PODFILE CHECKSUM: d5797d5ec75023063cb4c657a32466e329f8bec8
PODFILE CHECKSUM: d76aee4438d97af52b49960cf18e0f19851aa1ab

COCOAPODS: 1.13.0
6 changes: 3 additions & 3 deletions src/app/modules/translate/translate.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class TranslateState implements NgxsOnInit {
await this.detectLanguage(spokenLanguageText, patchState);
}

dispatch(ChangeTranslation);
dispatch([ChangeTranslation, SuggestAlternativeText]);
}

@Action(SetSignedLanguage)
Expand Down Expand Up @@ -189,9 +189,9 @@ export class TranslateState implements NgxsOnInit {

@Action(SuggestAlternativeText)
async suggestAlternativeText({patchState, getState}: StateContext<TranslateStateModel>): Promise<void> {
const {spokenLanguageText, spokenLanguage, detectedLanguage} = getState();
const {spokenToSigned, spokenLanguageText, spokenLanguage, detectedLanguage} = getState();
const trimmedText = spokenLanguageText.trim();
if (!trimmedText || spokenLanguage !== detectedLanguage) {
if (!spokenToSigned || !trimmedText || spokenLanguage !== detectedLanguage) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing';

import {SpokenLanguageInputComponent} from './spoken-language-input.component';
import {SetSpokenLanguageText} from '../../../../modules/translate/translate.actions';
import {SetSpokenLanguageText, SuggestAlternativeText} from '../../../../modules/translate/translate.actions';
import {NgxsModule, Store} from '@ngxs/store';
import {axe, toHaveNoViolations} from 'jasmine-axe';
import {SettingsState} from '../../../../modules/settings/settings.state';
Expand Down Expand Up @@ -47,12 +47,15 @@ describe('SpokenLanguageInputComponent', () => {
expect(a11y).toHaveNoViolations();
});

it('text change should dispatch action', fakeAsync(() => {
it('text change should dispatch actions', fakeAsync(() => {
const spy = spyOn(store, 'dispatch');
component.text.patchValue('test');
tick(300);

expect(spy).toHaveBeenCalledWith(new SetSpokenLanguageText('test'));
expect(spy).toHaveBeenCalledTimes(1);
tick(700);
expect(spy).toHaveBeenCalledWith(new SuggestAlternativeText());
expect(spy).toHaveBeenCalledTimes(2);
}));
});

0 comments on commit 8d0644a

Please sign in to comment.