chore: add e2e test for refresh tokens cooldown period - skip e2e (#2860)
* chore: add e2e test for refresh tokens cooldown period * chore: fix refreshing session in e2e * chore: fix session refresh cooldown test * chore: fix e2e test * Add dropped response simulation test --------- Co-authored-by: moughxyz <mo@standardnotes.com>
This commit is contained in:
@@ -408,7 +408,12 @@ export class LegacyApiService
|
||||
}
|
||||
}
|
||||
|
||||
async refreshSession(): Promise<HttpResponse<SessionRenewalResponse>> {
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* This function should be replaced with @standardnotes/api's `HttpService::refreshSession` function.
|
||||
*/
|
||||
async deprecatedRefreshSessionOnlyUsedInE2eTests(): Promise<HttpResponse<SessionRenewalResponse>> {
|
||||
const preprocessingError = this.preprocessingError()
|
||||
if (preprocessingError) {
|
||||
return preprocessingError
|
||||
|
||||
@@ -874,7 +874,14 @@ export class SessionManager
|
||||
const willRefreshTokenExpireSoon = refreshTokenExpiration.getTime() - Date.now() < ThirtyMinutes
|
||||
|
||||
if (willAccessTokenExpireSoon || willRefreshTokenExpireSoon) {
|
||||
return this.httpService.refreshSession()
|
||||
const refreshSessionResultOrError = await this.httpService.refreshSession()
|
||||
if (refreshSessionResultOrError.isFailed()) {
|
||||
return false
|
||||
}
|
||||
|
||||
const refreshSessionResult = refreshSessionResultOrError.getValue()
|
||||
|
||||
return isErrorResponse(refreshSessionResult)
|
||||
}
|
||||
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user