diff --git a/app/lib/services/connect.ts b/app/lib/services/connect.ts index b04f75f8f..4d4110b52 100644 --- a/app/lib/services/connect.ts +++ b/app/lib/services/connect.ts @@ -45,16 +45,15 @@ function connect({ server, logoutOnError = false }: { server: string; logoutOnEr if (sdk.current?.client?.host === server) { return resolve(); } + + // Check for running requests and abort them before connecting to the server + abort(); + disconnect(); database.setActiveDB(server); store.dispatch(connectRequest()); - // It's not called anywhere else - // if (this.connectTimeout) { - // clearTimeout(this.connectTimeout); - // } - if (connectingListener) { connectingListener.then(stopListener); } @@ -374,7 +373,6 @@ function abort() { if (sdk.current) { return sdk.current.abort(); } - return new AbortController(); } function checkAndReopen() { diff --git a/app/sagas/selectServer.js b/app/sagas/selectServer.js index cc01354c3..a989ca03b 100644 --- a/app/sagas/selectServer.js +++ b/app/sagas/selectServer.js @@ -108,9 +108,6 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch const basicAuth = UserPreferences.getString(`${BASIC_AUTH_KEY}-${server}`); setBasicAuth(basicAuth); - // Check for running requests and abort them before connecting to the server - Services.abort(); - if (user) { yield put(clearSettings()); yield put(setUser(user)); diff --git a/e2e/helpers/app.js b/e2e/helpers/app.js index 343cdbee1..96fe34fd6 100644 --- a/e2e/helpers/app.js +++ b/e2e/helpers/app.js @@ -40,7 +40,6 @@ async function navigateToLogin(server) { await waitFor(element(by.id('login-view'))) .toExist() .withTimeout(2000); - await expect(element(by.id('login-view'))).toExist(); } async function navigateToRegister(server) { @@ -195,6 +194,9 @@ const checkServer = async server => { .toBeVisible() .withTimeout(10000); await element(by.id('sidebar-close-drawer')).tap(); + await waitFor(element(by.id('sidebar-close-drawer'))) + .not.toBeVisible() + .withTimeout(10000); }; function runCommand(command) { diff --git a/e2e/tests/onboarding/05-login.spec.js b/e2e/tests/onboarding/05-login.spec.js index 32628afb6..88623d905 100644 --- a/e2e/tests/onboarding/05-login.spec.js +++ b/e2e/tests/onboarding/05-login.spec.js @@ -1,4 +1,4 @@ -const { navigateToLogin, tapBack, platformTypes } = require('../../helpers/app'); +const { navigateToLogin, tapBack, platformTypes, navigateToWorkspace, login } = require('../../helpers/app'); const data = require('../../data'); describe('Login screen', () => { @@ -74,5 +74,13 @@ describe('Login screen', () => { .toBeVisible() .withTimeout(60000); }); + + it('should connect, go back, connect to the same server and login', async () => { + await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true, delete: true }); + await navigateToWorkspace(); + await tapBack(); + await navigateToLogin(); + await login(data.users.regular.username, data.users.regular.password); + }); }); });