From d643932baa620a49bf1a48229653dba7ec72f200 Mon Sep 17 00:00:00 2001 From: kravchenkodhealth <106426895+kravchenkodhealth@users.noreply.github.com> Date: Wed, 18 Jan 2023 19:22:38 +0200 Subject: [PATCH 1/2] [@dhealthdapps/frontend] fix(screens): restore setInterval authentication for mobile From 220361fba16d6998f8d6cfbaade3e682539bf2c4 Mon Sep 17 00:00:00 2001 From: kravchenkodhealth <106426895+kravchenkodhealth@users.noreply.github.com> Date: Tue, 24 Jan 2023 12:39:39 +0200 Subject: [PATCH 2/2] [@dhealthdapps/frontend] fix(tests): add tests for frontend --- .../src/views/LoginScreen/LoginScreen.ts | 1 + .../tests/unit/views/LoginScreen.spec.ts | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/runtime/dapp-frontend-vue/src/views/LoginScreen/LoginScreen.ts b/runtime/dapp-frontend-vue/src/views/LoginScreen/LoginScreen.ts index ca481ca1..5e1065d1 100644 --- a/runtime/dapp-frontend-vue/src/views/LoginScreen/LoginScreen.ts +++ b/runtime/dapp-frontend-vue/src/views/LoginScreen/LoginScreen.ts @@ -331,6 +331,7 @@ export default class LoginScreen extends MetaView { */ public get getMobileOS() { const ua = navigator.userAgent; + if (/android/i.test(ua)) { return "Android"; } else if ( diff --git a/runtime/dapp-frontend-vue/tests/unit/views/LoginScreen.spec.ts b/runtime/dapp-frontend-vue/tests/unit/views/LoginScreen.spec.ts index d2b0af6c..c73b635a 100644 --- a/runtime/dapp-frontend-vue/tests/unit/views/LoginScreen.spec.ts +++ b/runtime/dapp-frontend-vue/tests/unit/views/LoginScreen.spec.ts @@ -104,4 +104,40 @@ describe("LoginScreen -->", () => { // expect(widget.find(".qr-code").exists()).to.be.true; expect(widget.vm.createLoginQRCode()).to.be.not.null; }); + + it("should not call call login setInterval if device not mobile", () => { + expect(widget.vm.mobileFetchTimer).to.be.undefined; + }); + + it("should call call login setInterval if device is mobile", () => { + const mobileOptions = { + localVue, + stubs: ["router-link"], + mocks: { + getImageUrl, + $route: { params: {} }, + $router: { + push: jest.fn(), + }, + $t: jest.fn(), + $store: { + dispatch: jest.fn(), + commit: jest.fn(), + getters: { + "auth/isAuthenticated": true, + "auth/getChallenge": "rwrwer", + "auth/getAuthRegistry": "fake-registry", + "auth/getRefCode": undefined, + }, + }, + computed: { + getMobileOS() { + return "iOS"; + }, + }, + }, + }; + + expect(widget.vm.getMobileOs).to.be.not.null; + }); });