-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add snackbar after creating an offer in CompleteProfileBlock (#2635)
* test conditional message & button * added snackbar after creating an offer in CompleteProfileBlock * added test for snackbar * test dispatch * added tests for CreateOrEditOffer * tests * fixed test * Fixed prettier * Removed unused onResponseError * Removed unused imports and variable * Fixed tests * Removed useless test * prettified AppSnackbar.tsx for more readability * extracted styles in AppSnackbar, optimized dispatch and fixed default values * prettified openAlert * fixed ts error & isHash --------- Co-authored-by: Vadym Pavlyk <[email protected]>
- Loading branch information
Showing
9 changed files
with
280 additions
and
25 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const styles = { | ||
alert: { | ||
color: 'basic.white' | ||
}, | ||
action: { | ||
p: '4px 8px 0 30px', | ||
cursor: 'pointer' | ||
}, | ||
secondMessage: { | ||
fontSize: '12px', | ||
fontWeight: '300' | ||
} | ||
} |
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
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
67 changes: 67 additions & 0 deletions
67
tests/unit/containers/layout/app-snackbar/AppSnackbarExtended.spec.jsx
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,67 @@ | ||
import { screen, fireEvent, waitFor } from '@testing-library/react' | ||
import { renderWithProviders } from '~tests/test-utils' | ||
import LoginDialog from '~/containers/guest-home-page/login-dialog/LoginDialog' | ||
import { TestSnackbar } from '~tests/test-utils' | ||
import { vi } from 'vitest' | ||
import { useAppSelector } from '~/hooks/use-redux' | ||
|
||
const preloadedState = { | ||
appMain: { loading: false, authLoading: false, userRole: '', error: '' } | ||
} | ||
const unwrap = vi.fn().mockRejectedValue({ data: { code: 'error' } }) | ||
const loginUser = vi.fn().mockReturnValue({ unwrap }) | ||
|
||
vi.mock('~/containers/guest-home-page/google-button/GoogleButton', () => ({ | ||
__esModule: true, | ||
default: function () { | ||
return <button>Google</button> | ||
} | ||
})) | ||
|
||
vi.mock('~/services/auth-service', async () => { | ||
return { | ||
__esModule: true, | ||
authService: { | ||
endpoint: { matchFulfilled: vi.fn(), matchPending: vi.fn() } | ||
}, | ||
useLoginMutation: () => [loginUser] | ||
} | ||
}) | ||
|
||
vi.mock('~/hooks/use-redux', async () => { | ||
const actual = await vi.importActual('~/hooks/use-redux') | ||
return { | ||
...actual, | ||
useAppSelector: vi.fn() | ||
} | ||
}) | ||
|
||
describe('snackbar with extended', () => { | ||
beforeEach(async () => { | ||
vi.mocked(useAppSelector).mockReturnValue({ | ||
isOpened: true, | ||
message: 'Test message; Additional info', | ||
duration: 3000, | ||
severity: 'info', | ||
isExtended: true, | ||
route: '/test-route' | ||
}) | ||
|
||
renderWithProviders( | ||
<TestSnackbar> | ||
<LoginDialog /> | ||
</TestSnackbar>, | ||
preloadedState | ||
) | ||
}) | ||
|
||
it('should render extended content when isExtended is true', async () => { | ||
const mainMessage = await screen.findByText('Test message') | ||
const additionalInfo = await screen.findByText('Additional info') | ||
const actionButton = await screen.findByText('offerPage.createOffer.seeAll') | ||
|
||
expect(mainMessage).toBeInTheDocument() | ||
expect(additionalInfo).toBeInTheDocument() | ||
expect(actionButton).toBeInTheDocument() | ||
}) | ||
}) |
Oops, something went wrong.