Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove the getIdentity prop from the profileSaga #569

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/modules/profile/sagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ import {
setProfileAvatarDescriptionRequest,
setProfileAvatarDescriptionSuccess
} from './actions'
import { getIdentityOrRedirect } from '../identity/sagas'
import { call } from 'redux-saga/effects'

let mockAuthIdentity: AuthIdentity | undefined = {} as AuthIdentity

const profileSagas = createProfileSaga({
getIdentity: () => mockAuthIdentity,
peerUrl: 'aURL'
})
const address = 'anAddress'
Expand Down Expand Up @@ -58,7 +59,8 @@ describe('when handling the action to set the profile avatar description', () =>
EntitiesOperator.prototype.deployEntityWithoutNewFiles
),
Promise.reject(new Error(errorMessage))
]
],
[call(getIdentityOrRedirect), mockAuthIdentity]
])
.put(setProfileAvatarDescriptionFailure(address, errorMessage))
.dispatch(setProfileAvatarDescriptionRequest(address, description))
Expand All @@ -83,6 +85,7 @@ describe('when handling the action to set the profile avatar description', () =>

return expectSaga(profileSagas)
.provide([
[call(getIdentityOrRedirect), mockAuthIdentity],
[
matchers.call.fn(PeerAPI.prototype.fetchProfile),
dynamicDeepParametersEquality(
Expand Down Expand Up @@ -166,6 +169,7 @@ describe('when handling the action to set the profile avatar alias', () => {
it('should dispatch an action to signal that the request failed', () => {
return expectSaga(profileSagas)
.provide([
[call(getIdentityOrRedirect), mockAuthIdentity],
[
matchers.call.fn(PeerAPI.prototype.fetchProfile),
Promise.resolve(profileFromLambda)
Expand Down Expand Up @@ -201,6 +205,7 @@ describe('when handling the action to set the profile avatar alias', () => {

return expectSaga(profileSagas)
.provide([
[call(getIdentityOrRedirect), mockAuthIdentity],
[
matchers.call.fn(PeerAPI.prototype.fetchProfile),
dynamicDeepParametersEquality(
Expand Down
5 changes: 2 additions & 3 deletions src/modules/profile/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Avatar } from '@dcl/schemas/dist/platform/profile'
import { EntityType } from '@dcl/schemas/dist/platform/entity'
import { PeerAPI } from '../../lib/peer'
import { EntitiesOperator } from '../../lib/entities'
import { getIdentityOrRedirect } from '../identity/sagas'
import {
ConnectWalletSuccessAction,
CONNECT_WALLET_SUCCESS,
Expand Down Expand Up @@ -31,13 +32,11 @@ import { Profile } from './types'
export const NO_IDENTITY_FOUND_ERROR_MESSAGE = 'No identity found'

type CreateProfileSagaOptions = {
getIdentity: () => AuthIdentity | undefined
peerUrl: string
peerWithNoGbCollectorUrl?: string
}

export function createProfileSaga({
getIdentity,
peerUrl,
peerWithNoGbCollectorUrl
}: CreateProfileSagaOptions) {
Expand Down Expand Up @@ -139,7 +138,7 @@ export function createProfileSaga({
const profileMetadata: Profile = {
avatars: [newAvatar, ...profileWithContentHashes.avatars.slice(1)]
}
const identity = getIdentity()
const identity: AuthIdentity | null = yield call(getIdentityOrRedirect)

if (identity) {
yield call(
Expand Down