Skip to content

Commit

Permalink
fix: Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Nov 20, 2023
1 parent 6e9cfd6 commit 378ef51
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fireEvent, waitFor } from '@testing-library/react'
import { fireEvent } from '@testing-library/react'
import { t } from 'decentraland-dapps/dist/modules/translation/utils'
import { getAnalytics } from 'decentraland-dapps/dist/modules/analytics/utils'
import { renderWithProviders } from '../../../utils/test'
Expand Down Expand Up @@ -74,7 +74,7 @@ describe('when the share on twitter button is clicked', () => {

it('should open a new page with a twitter message', async () => {
jest.spyOn(window, 'open').mockImplementation(() => null)
const dclUrl = 'https://market.decentraland.zone'
const dclUrl = 'https://decentraland.zone/marketplace'
const locationsUrl =
'/lists/aListId?assetType=item&section=lists&vendor=decentraland&page=1&sortBy=newest'
const twitterURL = `https://twitter.com/intent/tweet?text=${encodeURIComponent(
Expand Down
7 changes: 5 additions & 2 deletions webapp/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import './modules/analytics/sentry'

import { ScrollToTop } from './components/ScrollToTop'
import * as locales from './modules/translation/locales'
import { initStore, history } from './modules/store'
import { initStore, createHistory } from './modules/store'
import { Routes } from './components/Routes'
import * as modals from './components/Modals'
import { config } from './config'
Expand All @@ -26,9 +26,12 @@ import './index.css'
// It is ideal to do this as soon as possible to avoid any availability issues.
SingleSignOn.init(config.get('SSO_URL'))

const history = createHistory()
const store = initStore(history)

async function main() {
const component = (
<Provider store={initStore()}>
<Provider store={store}>
<TranslationProvider locales={Object.keys(locales)}>
<WalletProvider>
<ConnectedRouter history={history}>
Expand Down
15 changes: 9 additions & 6 deletions webapp/src/modules/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ import { ARCHIVE_BID, UNARCHIVE_BID } from './bid/actions'
import { SET_IS_TRYING_ON } from './ui/preview/actions'
import { getCurrentIdentity } from './identity/selectors'
import { AuthIdentity } from 'decentraland-crypto-fetch'
import { createMemoryHistory, createBrowserHistory, History } from 'history'

export const history = require('history').createBrowserHistory({
basename: config.get('BASE_NAME') ?? undefined
})
export const createHistory = () =>
createBrowserHistory({
basename: config.get('BASE_NAME') ?? undefined
})

export function initStore() {
export function initStore(history: History) {
const anyWindow = window as any

const isDev = config.is(Env.DEVELOPMENT)
Expand Down Expand Up @@ -91,7 +93,8 @@ export function initStore() {
}

export function initTestStore(preloadedState = {}) {
const rootReducer = storageReducerWrapper(createRootReducer(history))
const testHistory = createMemoryHistory({ initialEntries: ['/marketplace'] })
const rootReducer = storageReducerWrapper(createRootReducer(testHistory))
const sagasMiddleware = createSagasMiddleware()
const transactionMiddleware = createTransactionMiddleware()
const { storageMiddleware, loadStorageMiddleware } = createStorageMiddleware({
Expand All @@ -106,7 +109,7 @@ export function initTestStore(preloadedState = {}) {

const middleware = applyMiddleware(
sagasMiddleware,
routerMiddleware(history),
routerMiddleware(testHistory),
transactionMiddleware,
storageMiddleware
)
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/utils/tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function renderWithProviders(
translation: { data: locales, locale: 'en' }
})

const history = createMemoryHistory()
const history = createMemoryHistory({ initialEntries: ['/marketplace'] })

function AppProviders({ children }: { children: JSX.Element }) {
return (
Expand Down

0 comments on commit 378ef51

Please sign in to comment.