Skip to content

Commit

Permalink
tests: fix additional requests of global search on this test pages
Browse files Browse the repository at this point in the history
  • Loading branch information
dmijatovic committed Feb 3, 2025
1 parent ea895cd commit 9702aee
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
19 changes: 11 additions & 8 deletions frontend/__tests__/CookiesPage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2022 - 2023 Dusan Mijatovic (dv4all)
// SPDX-FileCopyrightText: 2022 - 2023 dv4all
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center)
// SPDX-FileCopyrightText: 2023 Netherlands eScience Center
// SPDX-FileCopyrightText: 2023 - 2025 Dusan Mijatovic (Netherlands eScience Center)
// SPDX-FileCopyrightText: 2023 - 2025 Netherlands eScience Center
//
// SPDX-License-Identifier: Apache-2.0

Expand All @@ -13,6 +13,9 @@ import CookiesPage from '../pages/cookies'
// use DEFAULT MOCK for login providers list
// required when AppHeader component is used
jest.mock('~/auth/api/useLoginProviders')
// MOCK global search
jest.mock('~/components/GlobalSearchAutocomplete/apiGlobalSearch')
jest.mock('~/components/GlobalSearchAutocomplete/useHasRemotes')


it('renders cookies page with title Cookies', async() => {
Expand All @@ -22,8 +25,8 @@ it('renders cookies page with title Cookies', async() => {
}
render(WrappedComponentWithProps(
CookiesPage, {
props
}))
props
}))
const heading = await screen.findByRole('heading',{
name: 'Cookies'
})
Expand All @@ -39,8 +42,8 @@ it('renders cookies page with anonymous statistics checkbox ON', async() => {
}
render(WrappedComponentWithProps(
CookiesPage, {
props
}))
props
}))

const heading = await screen.findByRole('heading',{
name: 'Tracking cookies'
Expand All @@ -61,8 +64,8 @@ it('renders cookies page with anonymous statistics checkbox OFF', async() => {
}
render(WrappedComponentWithProps(
CookiesPage, {
props
}))
props
}))

const checkbox = await screen.findByRole('checkbox', {
checked:false
Expand Down
6 changes: 5 additions & 1 deletion frontend/__tests__/OrganisationPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ import mockSoftware from '~/components/organisation/software/__mocks__/mockSoftw
import mockProjects from '~/components/organisation/projects/__mocks__/mockProjects.json'
import mockUnits from '~/components/organisation/units/__mocks__/mockUnits.json'
import {TabKey} from '~/components/organisation/tabs/OrganisationTabItems'
import {OrganisationForContext} from '~/components/organisation/context/OrganisationContext'

// MOCK user agreement call
jest.mock('~/components/user/settings/useUserAgreements')
// global search
jest.mock('~/components/GlobalSearchAutocomplete/apiGlobalSearch')
jest.mock('~/components/GlobalSearchAutocomplete/useHasRemotes')

// use DEFAULT MOCK for login providers list
// required when AppHeader component is used
jest.mock('~/auth/api/useLoginProviders')

const mockProps = {
organisation: mockOrganisation,
organisation: mockOrganisation as OrganisationForContext,
slug:['dutch-research-council'],
tab: 'software' as TabKey,
ror: mockRORIinfo as any,
Expand Down
8 changes: 5 additions & 3 deletions frontend/__tests__/ProjectEditPage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center)
// SPDX-FileCopyrightText: 2023 - 2025 Dusan Mijatovic (Netherlands eScience Center)
// SPDX-FileCopyrightText: 2023 - 2025 Netherlands eScience Center
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all)
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all) (dv4all)
// SPDX-FileCopyrightText: 2023 Netherlands eScience Center
// SPDX-FileCopyrightText: 2023 dv4all
//
// SPDX-License-Identifier: Apache-2.0
Expand All @@ -22,6 +22,9 @@ import mockProjectToEdit from '~/components/projects/edit/information/__mocks__/
jest.mock('~/auth/api/useLoginProviders')
// mock user agreement call
jest.mock('~/components/user/settings/useUserAgreements')
// global search
jest.mock('~/components/GlobalSearchAutocomplete/apiGlobalSearch')
jest.mock('~/components/GlobalSearchAutocomplete/useHasRemotes')

// MOCK isMaintainerOf
const mockIsMaintainer = jest.fn(props => Promise.resolve(false))
Expand All @@ -44,7 +47,6 @@ window.IntersectionObserver = jest.fn(() => ({
unobserve: mockUnobserve,
} as any))


const mockProps = {
// information page
pageIndex: 0,
Expand Down
7 changes: 5 additions & 2 deletions frontend/__tests__/SoftwareEditPage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-FileCopyrightText: 2023 - 2024 Dusan Mijatovic (Netherlands eScience Center)
// SPDX-FileCopyrightText: 2023 - 2024 Netherlands eScience Center
// SPDX-FileCopyrightText: 2023 - 2025 Dusan Mijatovic (Netherlands eScience Center)
// SPDX-FileCopyrightText: 2023 - 2025 Netherlands eScience Center
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all)
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all) (dv4all)
// SPDX-FileCopyrightText: 2023 dv4all
Expand All @@ -24,6 +24,9 @@ import {RsdSettingsState} from '~/config/rsdSettingsReducer'
jest.mock('~/auth/api/useLoginProviders')
// mock user agreement call
jest.mock('~/components/user/settings/useUserAgreements')
// MOCK global search
jest.mock('~/components/GlobalSearchAutocomplete/apiGlobalSearch')
jest.mock('~/components/GlobalSearchAutocomplete/useHasRemotes')

// MOCK isMaintainerOf
const mockIsMaintainer = jest.fn(props => Promise.resolve(false))
Expand Down
7 changes: 5 additions & 2 deletions frontend/__tests__/UserPages.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-FileCopyrightText: 2023 - 2024 Dusan Mijatovic (Netherlands eScience Center)
// SPDX-FileCopyrightText: 2023 - 2024 Netherlands eScience Center
// SPDX-FileCopyrightText: 2023 - 2025 Dusan Mijatovic (Netherlands eScience Center)
// SPDX-FileCopyrightText: 2023 - 2025 Netherlands eScience Center
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all)
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all) (dv4all)
// SPDX-FileCopyrightText: 2023 Ewan Cahen (Netherlands eScience Center) <[email protected]>
Expand Down Expand Up @@ -32,6 +32,9 @@ jest.mock('~/components/user/software/useUserSoftware')
jest.mock('~/components/user/organisations/useUserOrganisations')
// MOCK user communities list
jest.mock('~/components/user/communities/useUserCommunities')
// MOCK global search
jest.mock('~/components/GlobalSearchAutocomplete/apiGlobalSearch')
jest.mock('~/components/GlobalSearchAutocomplete/useHasRemotes')

// MOCKS
const mockProps = {
Expand Down

0 comments on commit 9702aee

Please sign in to comment.