From a97b2f43cadce7949e9b6b316cb30383c1022e86 Mon Sep 17 00:00:00 2001 From: Mihajlo Date: Fri, 29 Apr 2022 12:40:38 +0200 Subject: [PATCH] chore: sasjs login fix --- sasjs-tests/src/Login.tsx | 2 +- sasjs-tests/src/testSuites/Basic.ts | 67 ++++++++++++++--------------- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/sasjs-tests/src/Login.tsx b/sasjs-tests/src/Login.tsx index a72b458..2e69fb8 100644 --- a/sasjs-tests/src/Login.tsx +++ b/sasjs-tests/src/Login.tsx @@ -11,7 +11,7 @@ const Login = (): ReactElement<{}> => { const handleSubmit = useCallback( (e) => { e.preventDefault() - appContext.adapter.logIn(username, password).then((res) => { + appContext.adapter.logIn(username, password, 'clientID1').then((res) => { appContext.setIsLoggedIn(res.isLoggedIn) }) }, diff --git a/sasjs-tests/src/testSuites/Basic.ts b/sasjs-tests/src/testSuites/Basic.ts index b19e39d..16c8d42 100644 --- a/sasjs-tests/src/testSuites/Basic.ts +++ b/sasjs-tests/src/testSuites/Basic.ts @@ -33,41 +33,40 @@ export const basicTests = ( ): TestSuite => ({ name: 'Basic Tests', tests: [ - // LOGIN TESTS DISABLED UNTIL SASJS SERVER MODE NOT FIXED - // { - // title: 'Log in', - // description: 'Should log the user in', - // test: async () => { - // return adapter.logIn(userName, password) - // }, - // assertion: (response: any) => - // response && response.isLoggedIn && response.userName === userName - // }, - // { - // title: 'Fetch username for already logged in user', - // description: 'Should log the user in', - // test: async () => { - // await adapter.logIn(userName, password) + { + title: 'Log in', + description: 'Should log the user in', + test: async () => { + return adapter.logIn(userName, password, 'clientID1') + }, + assertion: (response: any) => + response && response.isLoggedIn && response.userName === userName + }, + { + title: 'Fetch username for already logged in user', + description: 'Should log the user in', + test: async () => { + await adapter.logIn(userName, password, 'clientID1') - // const newAdapterIns = new SASjs(adapter.getSasjsConfig()) + const newAdapterIns = new SASjs(adapter.getSasjsConfig()) - // return await newAdapterIns.checkSession() - // }, - // assertion: (response: any) => - // response?.isLoggedIn && response?.userName === userName - // }, - // { - // title: 'Multiple Log in attempts', - // description: - // 'Should fail on first attempt and should log the user in on second attempt', - // test: async () => { - // await adapter.logOut() - // await adapter.logIn('invalid', 'invalid') - // return await adapter.logIn(userName, password) - // }, - // assertion: (response: any) => - // response && response.isLoggedIn && response.userName === userName - // }, + return await newAdapterIns.checkSession() + }, + assertion: (response: any) => + response?.isLoggedIn && response?.userName === userName + }, + { + title: 'Multiple Log in attempts', + description: + 'Should fail on first attempt and should log the user in on second attempt', + test: async () => { + await adapter.logOut() + await adapter.logIn('invalid', 'invalid', 'clientID1') + return await adapter.logIn(userName, password, 'clientID1') + }, + assertion: (response: any) => + response && response.isLoggedIn && response.userName === userName + }, { title: 'Trigger login callback', description: @@ -80,7 +79,7 @@ export const basicTests = ( stringData, undefined, async () => { - await adapter.logIn(userName, password) + await adapter.logIn(userName, password, 'clientID1') } ) },