Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Oct 27, 2023
1 parent 9095685 commit e26716d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/pages/apps/custom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const CustomSafeApps: NextPage = () => {
return (
<>
<Head>
<title>{'Custom Safe Apps'}</title>
<title>{'Safe{Wallet} – Custom Safe Apps'}</title>
</Head>

<SafeAppsSDKLink />
Expand Down
5 changes: 3 additions & 2 deletions src/pages/apps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const SafeApps: NextPage = () => {
const { remoteSafeApps, remoteSafeAppsLoading, pinnedSafeApps, pinnedSafeAppIds, togglePin } = useSafeApps()
const { filteredApps, query, setQuery, setSelectedCategories, setOptimizedWithBatchFilter, selectedCategories } =
useSafeAppsFilters(remoteSafeApps)
const isFiltered = !!query || selectedCategories.length > 0

const nonPinnedApps = useMemo(
() => remoteSafeApps.filter((app) => !pinnedSafeAppIds.has(app.id)),
Expand Down Expand Up @@ -51,7 +52,7 @@ const SafeApps: NextPage = () => {
/>

{/* Pinned apps */}
{!query && (
{!isFiltered && pinnedSafeApps.length > 0 && (
<SafeAppList
title="My pinned apps"
safeAppsList={pinnedSafeApps}
Expand All @@ -63,7 +64,7 @@ const SafeApps: NextPage = () => {
{/* All apps */}
<SafeAppList
title="All apps"
safeAppsList={query ? filteredApps : nonPinnedApps}
safeAppsList={isFiltered ? filteredApps : nonPinnedApps}
safeAppsListLoading={remoteSafeAppsLoading}
bookmarkedSafeAppsId={pinnedSafeAppIds}
onBookmarkSafeApp={togglePin}
Expand Down
34 changes: 17 additions & 17 deletions src/tests/pages/apps.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
within,
} from '../test-utils'
import AppsPage from '@/pages/apps'
import BookmarkedSafeAppsPage from '@/pages/apps/bookmarked'
import CustomSafeAppsPage from '@/pages/apps/custom'
import * as safeAppsService from '@/services/safe-apps/manifest'
import { LS_NAMESPACE } from '@/config/constants'
Expand Down Expand Up @@ -150,9 +149,9 @@ describe('AppsPage', () => {

window.localStorage.setItem(`${LS_NAMESPACE}safeApps`, JSON.stringify(mockedBookmarkedSafeApps))

render(<BookmarkedSafeAppsPage />, {
render(<AppsPage />, {
routerProps: {
pathname: '/apps/bookmarked',
pathname: '/apps',
query: {
safe: 'matic:0x0000000000000000000000000000000000000000',
},
Expand All @@ -161,10 +160,11 @@ describe('AppsPage', () => {

// show Bookmarked Safe Apps only
await waitFor(() => {
expect(screen.queryByText('Compound', { selector: 'h5' })).toBeInTheDocument()
expect(screen.queryByText('Transaction Builder', { selector: 'h5' })).toBeInTheDocument()
expect(screen.queryByText('ENS App', { selector: 'h5' })).not.toBeInTheDocument()
expect(screen.queryByText('Synthetix', { selector: 'h5' })).not.toBeInTheDocument()
expect(screen.queryByText('My pinned apps (2)')).toBeInTheDocument()
expect(screen.queryByLabelText('Unpin Compound')).toBeInTheDocument()
expect(screen.queryByLabelText('Unpin Transaction Builder')).toBeInTheDocument()
expect(screen.queryByLabelText('Unpin ENS App')).not.toBeInTheDocument()
expect(screen.queryByLabelText('Unpin Synthetix')).not.toBeInTheDocument()
})
})

Expand All @@ -176,28 +176,28 @@ describe('AppsPage', () => {

window.localStorage.setItem(`${LS_NAMESPACE}safeApps`, JSON.stringify(mockedBookmarkedSafeApps))

render(<BookmarkedSafeAppsPage />, {
render(<AppsPage />, {
routerProps: {
pathname: '/apps/bookmarked',
pathname: '/apps',
query: {
safe: 'matic:0x0000000000000000000000000000000000000000',
},
},
})

// show Bookmarked Safe Apps only
// show Bookmarked Safe Apps
await waitFor(() => {
expect(screen.queryByText('Compound', { selector: 'h5' })).toBeInTheDocument()
expect(screen.queryByText('Transaction Builder', { selector: 'h5' })).toBeInTheDocument()
expect(screen.queryByLabelText('Unpin Compound')).toBeInTheDocument()
expect(screen.queryByLabelText('Unpin Transaction Builder')).toBeInTheDocument()
})

// unpin Transaction Builder Safe App
fireEvent.click(screen.getByLabelText('Unpin Transaction Builder'))

// show Bookmarked Safe Apps only
// show Bookmarked Safe Apps
await waitFor(() => {
expect(screen.queryByText('Compound', { selector: 'h5' })).toBeInTheDocument()
expect(screen.queryByText('Transaction Builder', { selector: 'h5' })).not.toBeInTheDocument()
expect(screen.queryByLabelText('Unpin Compound')).toBeInTheDocument()
expect(screen.queryByLabelText('Unpin Transaction Builder')).not.toBeInTheDocument()
})
})

Expand All @@ -209,9 +209,9 @@ describe('AppsPage', () => {

window.localStorage.setItem(`${LS_NAMESPACE}safeApps`, JSON.stringify(mockedBookmarkedSafeApps))

render(<BookmarkedSafeAppsPage />, {
render(<AppsPage />, {
routerProps: {
pathname: '/apps/bookmarked',
pathname: '/apps',
query: {
safe: 'matic:0x0000000000000000000000000000000000000000',
},
Expand Down

0 comments on commit e26716d

Please sign in to comment.