-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(tests): Add credentials table test #408
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Judging from your mock on line 94, it seems the NotificationChannel.messages
subscription is invoked three times in StoreJmxCredentials
. For my own understanding, could you explain why this happens? I thought there would be only two invocations (one for a stored notification and the other for a deleted notification) once the render is complete and the useEffect
calls are triggered.
Check on that latest commit please - the |
8d7037c
to
f6a8d35
Compare
I rebased my last commit and removed the extra dependencies - it turns out that you don't need dynamic importing for |
fcbfa0d
to
34a3303
Compare
Fix import filename Fix import ordering Remove uneeded deps
34a3303
to
e95d9bb
Compare
@jan-law ready to merge? |
yes, ready to merge |
Related #403
Adds unit tests for the Stored JMX Credentials Table and some refactoring to allow Jest access to the table components via imports and component labels.
You'll notice that the enums in StoreJmxCredentials were changed to "'TargetCredentialsStored' as NotificationCategory.TargetCredentialsStored".This is a workaround due to the fact that Jest doesn't support exported const enums when testing (link to issue)Nevermind, fixed the
messageKeys
import by adding...jest.requireActual('@app/Shared/Services/NotificationChannel.service'),
to the mockedNotificationChannel
service.To make the tests easier to read, I also split up the 'Delete credentials' test case into two tests, ie
'removes the correct table entry when a deletion notification is received'
and'makes a delete request when deleting one credential'
. The first test receives a mocked notification before asserting that the table state was updated, and the second test clicks the Add/Delete button before asserting that the API calls were made. (The equivalent API call assertion for adding stored credentials isn't tested here because the call is made inAuthModal
.)