-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c10aef6
commit c4b7bcd
Showing
8 changed files
with
188 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
frontend/src/__tests__/components/Onboarding/TopBarPopover.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import {render, screen} from '@testing-library/react'; | ||
import {describe, test, expect} from 'vitest'; | ||
import React, {useState} from 'react'; | ||
import {ThemeProvider} from '@mui/system'; | ||
import Theme from 'util/Theme'; | ||
import TopBarPopover from 'components/OnboardingComponents/TopBarPopover'; | ||
import {Provider} from 'react-redux'; | ||
import {Store} from '../../../store'; | ||
|
||
type TopBarPopoverTestProps = { | ||
allToursCompletedProp?: boolean; | ||
}; | ||
|
||
const TopBarPopoverTest: React.FC<TopBarPopoverTestProps> = ({allToursCompletedProp = false}) => { | ||
const [anchorEl] = useState<HTMLElement | null>(document.createElement('div')); | ||
const [open, setOpen] = useState(true); | ||
|
||
const onClose = () => setOpen(false); | ||
const allToursCompleted = allToursCompletedProp; | ||
const completedTours = allToursCompleted ? 5 : 2; | ||
const totalTours = 5; | ||
|
||
return ( | ||
<ThemeProvider theme={Theme}> | ||
<Provider store={Store}> | ||
<TopBarPopover | ||
anchorEl={anchorEl} | ||
open={open} | ||
onClose={onClose} | ||
allToursCompleted={allToursCompleted} | ||
completedTours={completedTours} | ||
totalTours={totalTours} | ||
/> | ||
</Provider> | ||
</ThemeProvider> | ||
); | ||
}; | ||
describe('TopBarPopover', () => { | ||
test('renders the popover with the correct content', () => { | ||
render(<TopBarPopoverTest />); | ||
|
||
expect(screen.getByTestId('popover-testid')).toBeInTheDocument(); | ||
expect(screen.getByText('getStarted')).toBeInTheDocument(); | ||
expect(screen.getByText('getStartedContent')).toBeInTheDocument(); | ||
|
||
const progressBar = screen.getByRole('progressbar'); | ||
expect(progressBar).toHaveAttribute('aria-valuenow', '40'); // two out of five tours completed is 40% | ||
expect(screen.getByText('40% completed')).toBeInTheDocument(); | ||
}); | ||
|
||
test('displays the correct content when all tours are completed', () => { | ||
render(<TopBarPopoverTest allToursCompletedProp={true} />); | ||
|
||
expect(screen.getByText('completedTours')).toBeInTheDocument(); | ||
expect(screen.getByText('completedToursContent')).toBeInTheDocument(); | ||
}); | ||
}); |
34 changes: 0 additions & 34 deletions
34
frontend/src/__tests__/components/Onboarding/TourChips.test.tsx
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
frontend/src/__tests__/components/Onboarding/WelcomeDialog.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR) | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import {render, fireEvent, screen} from '@testing-library/react'; | ||
import {describe, test, expect} from 'vitest'; | ||
import {Store} from '../../../store'; | ||
import {I18nextProvider} from 'react-i18next'; | ||
import i18n from '../../../util/i18nForTests'; | ||
import {Provider} from 'react-redux'; | ||
import React, {Suspense} from 'react'; | ||
import WelcomeDialog from '../../../components/OnboardingComponents/WelcomeDialog'; | ||
import {ThemeProvider} from '@mui/system'; | ||
import Theme from 'util/Theme'; | ||
|
||
describe('WelcomeDialog', () => { | ||
const renderComponent = () => { | ||
render( | ||
<ThemeProvider theme={Theme}> | ||
<Provider store={Store}> | ||
<I18nextProvider i18n={i18n}> | ||
<Suspense> | ||
<WelcomeDialog /> | ||
</Suspense> | ||
</I18nextProvider> | ||
</Provider> | ||
</ThemeProvider> | ||
); | ||
}; | ||
|
||
test('renders correctly when the user is a first time user', () => { | ||
renderComponent(); | ||
expect(screen.getByLabelText('welcome-modal')).toBeInTheDocument(); | ||
}); | ||
|
||
test('goes to the next slide when forward arrow is clicked', () => { | ||
renderComponent(); | ||
const arrowForwardButton = screen.getByTestId('arrow-forward-button'); | ||
fireEvent.click(arrowForwardButton); | ||
|
||
expect(screen.getByText('welcomeModalSlides.slide2.title')).toBeInTheDocument(); | ||
}); | ||
|
||
test('goes to the previous slide when back arrow is clicked', () => { | ||
renderComponent(); | ||
fireEvent.click(screen.getByTestId('arrow-forward-button')); | ||
fireEvent.click(screen.getByTestId('arrow-backward-button')); | ||
|
||
expect(screen.getByText('welcomeModalSlides.slide1.title')).toBeInTheDocument(); | ||
}); | ||
|
||
test('does not render if close button is clicked', () => { | ||
renderComponent(); | ||
fireEvent.click(screen.getByTestId('CloseIcon')); | ||
expect(screen.queryByLabelText('welcome-modal')).not.toBeInTheDocument(); | ||
}); | ||
}); |
68 changes: 0 additions & 68 deletions
68
frontend/src/__tests__/components/Onboarding/WelcomeModal.test.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.