Skip to content
This repository was archived by the owner on Feb 8, 2025. It is now read-only.

Commit 62302b7

Browse files
committed
fix broken tests
1 parent 78aafaf commit 62302b7

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed

assets/icon.png

-2 Bytes
Loading

src/api.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import axios from 'axios'
22
import _isEmpty from 'lodash/isEmpty'
33
import _map from 'lodash/map'
44
import createAuthRefreshInterceptor from 'axios-auth-refresh'
5+
6+
import { authActions } from './redux/actions/auth'
7+
import { store } from './redux/store'
58
import { getAccessToken, setAccessToken, getRefreshToken } from './utils'
69

710
const baseURL = 'https://api.swetrix.com'
@@ -20,13 +23,13 @@ const refreshAuthLogic = async (failedRequest) =>
2023
.then((tokenRefreshResponse) => {
2124
const { accessToken } = tokenRefreshResponse.data
2225
setAccessToken(accessToken)
23-
// eslint-disable-next-line
2426
failedRequest.response.config.headers.Authorization = `Bearer ${accessToken}`
27+
// eslint-disable-next-line
2528
return Promise.resolve()
2629
})
2730
.catch((error) => {
2831
store.dispatch(authActions.logout())
29-
return Promise.reject(error)
32+
throw error
3033
})
3134

3235
// Instantiate the interceptor
@@ -62,7 +65,7 @@ export const logoutApi = (refreshToken) =>
6265
})
6366
.then((response) => response.data)
6467
.catch((error) => {
65-
debug('%s', error)
68+
console.error('[API RESPONSE CATCH][logoutApi]', error)
6669
throw _isEmpty(error.response.data?.message)
6770
? error.response.data
6871
: error.response.data.message

src/redux/actions/auth/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { types } from './types'
21
import { getRefreshToken, removeAccessToken, removeRefreshToken } from '../../../utils'
32
import { logoutApi } from '../../../api'
3+
import { types } from './types'
44

55
export const authActions = {
66
// Synchronous

src/redux/sagas/auth/workers/signin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { login } from '../../../../api'
99

1010
export default function* singinWorker({ payload: { credentials, callback } }) {
1111
try {
12-
const { accessToken, refreshToken, user } = yield call(login, credentials) // eslint-disable-line
12+
const { accessToken, refreshToken, user } = yield call(login, credentials)
1313

1414
yield put(authActions.loginSuccess(user))
1515
yield call(setAccessToken, accessToken)

src/redux/sagas/ui/initialise.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { put, call } from 'redux-saga/effects'
22

3-
import { getAccessToken } from '../../../utils'
3+
import {
4+
getAccessToken, getRefreshToken,
5+
} from '../../../utils'
46
import UIActions from '../../actions/ui'
57

68
export default function* initialise() {

src/utils.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import browser from 'webextension-polyfill'
2-
import _isEmpty from 'lodash/isEmpty'
32

43
const TOKEN = 'access_token'
54
const REFRESH_TOKEN = 'refresh_token'
@@ -35,7 +34,7 @@ export const removeAccessToken = async () => {
3534
const STORE_REFRESH_TOKEN_FOR = 8467200
3635

3736
export const getRefreshToken = async () => {
38-
await browser.cookies.get({
37+
const result = await browser.cookies.get({
3938
name: REFRESH_TOKEN,
4039
url: 'https://swetrix.com',
4140
})
@@ -59,4 +58,4 @@ export const removeRefreshToken = async () => {
5958
name: REFRESH_TOKEN,
6059
url: 'https://swetrix.com',
6160
})
62-
}
61+
}

0 commit comments

Comments
 (0)