-
Notifications
You must be signed in to change notification settings - Fork 90
Add @testing-library/react and component tests #465
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
Open
Raghunandhan8818
wants to merge
18
commits into
mattermost:master
Choose a base branch
from
Raghunandhan8818:435-team-sidebar-ts-migration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3a28f7a
migrate team sidebar component to typescript
Raghunandhan8818 7b3775b
added tests to the team_sidebar components
Raghunandhan8818 9d0099e
fixed lint issues
Raghunandhan8818 d7dacd5
moved rtl to devdependencies, added snapshot tests to team_sidebar
Raghunandhan8818 8c95b3b
removed mocking in team_sidebar.test, added @reduxjs/toolkit in devde…
Raghunandhan8818 1ae80bd
gitlabURL and username added in the team_sidebar.test
Raghunandhan8818 bb5571c
changed gitlabURL in team_sidebar.test and updated the snapshots
Raghunandhan8818 e4c1763
downgrade @redux/toolkit and excluded 'node_modules'from type-checkin…
Raghunandhan8818 f051d2e
Fix. conflicts in package.json
Raghunandhan8818 eaaebb2
Merge branch 'master' of github.com:mattermost/mattermost-plugin-gitl…
Kshitij-Katiyar 95f6058
fixed missing dependency
Kshitij-Katiyar a8938c3
added missing redux offline package
Kshitij-Katiyar de1b4e6
Merge branch 'master' into 435-team-sidebar-ts-migration
mattermost-build d3ebdea
Merge branch 'master' of github.com:mattermost/mattermost-plugin-gitl…
Kshitij-Katiyar 5ed5f2e
fixed lint issues
Kshitij-Katiyar d0d4463
Merge branch 'master' of github.com:mattermost/mattermost-plugin-gitl…
Kshitij-Katiyar 3b0d8d9
updated jest version
Kshitij-Katiyar b0200c8
Empty commit
Kshitij-Katiyar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
116 changes: 116 additions & 0 deletions
116
webapp/src/components/team_sidebar/__snapshots__/team_sidebar.test.tsx.snap
This file contains hidden or 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,116 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`TeamSidebar should render when show is false 1`] = `<div />`; | ||
|
|
||
| exports[`TeamSidebar should render when show is true 1`] = ` | ||
| <div> | ||
| <div> | ||
| <a | ||
| href="https://gitlab.com/gitlab-org" | ||
| rel="noopener noreferrer" | ||
| style="color: rgba(51, 51, 51, 0.6); display: block; margin-bottom: 10px; width: 100%;" | ||
| target="_blank" | ||
| > | ||
| <i | ||
| class="fa fa-gitlab fa-lg" | ||
| /> | ||
| </a> | ||
| <a | ||
| style="color: rgba(51, 51, 51, 0.6); display: block; margin-bottom: 10px; width: 100%;" | ||
| > | ||
| <svg | ||
| height="13" | ||
| viewBox="0 0 16 16" | ||
| width="13" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| > | ||
| <path | ||
| clip-rule="evenodd" | ||
| d="M10.34 1.22a.75.75 0 0 0-1.06 0L7.53 2.97 7 3.5l.53.53 1.75 1.75a.75.75 0 1 0 1.06-1.06l-.47-.47h.63c.69 0 1.25.56 1.25 1.25v4.614a2.501 2.501 0 1 0 1.5 0V5.5a2.75 2.75 0 0 0-2.75-2.75h-.63l.47-.47a.75.75 0 0 0 0-1.06ZM13.5 12.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm-9 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm1.5 0a2.5 2.5 0 1 1-3.25-2.386V5.886a2.501 2.501 0 1 1 1.5 0v4.228A2.501 2.501 0 0 1 6 12.5Zm-1.5-9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z" | ||
| fill="rgba(51,51,51,0.6)" | ||
| fill-rule="evenodd" | ||
| /> | ||
| </svg> | ||
| <span | ||
| style="margin-left: 2px;" | ||
| > | ||
| 0 | ||
| </span> | ||
| </a> | ||
| <a | ||
| style="color: rgba(51, 51, 51, 0.6); display: block; margin-bottom: 10px; width: 100%;" | ||
| > | ||
| <svg | ||
| height="13" | ||
| viewBox="0 0 16 16" | ||
| width="13" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| > | ||
| <path | ||
| clip-rule="evenodd" | ||
| d="M9 2.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm1.45-.5a2.5 2.5 0 0 0-4.9 0H3a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V3a1 1 0 0 0-1-1h-2.55ZM8 5H5.5V3.5h-2v11h9v-11h-2V5H8ZM5 7.75A.75.75 0 0 1 5.75 7h4.5a.75.75 0 0 1 0 1.5h-4.5A.75.75 0 0 1 5 7.75Zm.75 1.75a.75.75 0 0 0 0 1.5h4.5a.75.75 0 0 0 0-1.5h-4.5Z" | ||
| fill="rgba(51,51,51,0.6)" | ||
| fill-rule="evenodd" | ||
| /> | ||
| </svg> | ||
| <span | ||
| style="margin-left: 2px;" | ||
| > | ||
| 0 | ||
| </span> | ||
| </a> | ||
| <a | ||
| style="color: rgba(51, 51, 51, 0.6); display: block; margin-bottom: 10px; width: 100%;" | ||
| > | ||
| <svg | ||
| height="13" | ||
| viewBox="0 0 16 16" | ||
| width="13" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| > | ||
| <path | ||
| clip-rule="evenodd" | ||
| d="M3 2.5h6a.5.5 0 0 1 .5.5v10a.5.5 0 0 1-.5.5H3a.5.5 0 0 1-.5-.5V3a.5.5 0 0 1 .5-.5ZM1 3a2 2 0 0 1 2-2h6a2 2 0 0 1 1.97 1.658l2.913 1.516a1.75 1.75 0 0 1 .744 2.36l-3.878 7.45a.753.753 0 0 1-.098.145c-.36.526-.965.871-1.651.871H3a2 2 0 0 1-2-2V3Zm10 7.254 2.297-4.413a.25.25 0 0 0-.106-.337L11 4.364v5.89Z" | ||
| fill="rgba(51,51,51,0.6)" | ||
| fill-rule="evenodd" | ||
| /> | ||
| </svg> | ||
| <span | ||
| style="margin-left: 2px;" | ||
| > | ||
| 0 | ||
| </span> | ||
| </a> | ||
| <a | ||
| style="color: rgba(51, 51, 51, 0.6); display: block; margin-bottom: 10px; width: 100%;" | ||
| > | ||
| <svg | ||
| height="13" | ||
| viewBox="0 0 16 16" | ||
| width="13" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| > | ||
| <path | ||
| clip-rule="evenodd" | ||
| d="M3 13.5a.5.5 0 0 1-.5-.5V3a.5.5 0 0 1 .5-.5h9.25a.75.75 0 0 0 0-1.5H3a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V9.75a.75.75 0 0 0-1.5 0V13a.5.5 0 0 1-.5.5H3Zm12.78-8.82a.75.75 0 0 0-1.06-1.06L9.162 9.177 7.289 7.241a.75.75 0 1 0-1.078 1.043l2.403 2.484a.75.75 0 0 0 1.07.01L15.78 4.68Z" | ||
| fill="rgba(51,51,51,0.6)" | ||
| fill-rule="evenodd" | ||
| /> | ||
| </svg> | ||
| <span | ||
| style="margin-left: 2px;" | ||
| > | ||
| 0 | ||
| </span> | ||
| </a> | ||
| <a | ||
| href="#" | ||
| style="color: rgba(51, 51, 51, 0.6); display: block; margin-bottom: 10px; width: 100%;" | ||
| > | ||
| <i | ||
| class="fa fa-refresh fa-spin" | ||
| /> | ||
| </a> | ||
| </div> | ||
| </div> | ||
| `; |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,80 @@ | ||
| // Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved. | ||
| // See LICENSE.txt for license information. | ||
|
|
||
| import React from 'react'; | ||
|
|
||
| import {describe, expect, test} from '@jest/globals'; | ||
| import {render} from '@testing-library/react'; | ||
| import {configureStore, createSlice} from '@reduxjs/toolkit'; | ||
|
|
||
| import {Provider} from 'react-redux'; | ||
|
|
||
| import TeamSidebar from './team_sidebar'; | ||
|
|
||
| const mockTheme = { | ||
| sidebarBg: '#ffffff', | ||
| sidebarText: '#333333', | ||
| sidebarUnreadText: '#ff0000', | ||
| sidebarTextHoverBg: '#eeeeee', | ||
| sidebarTextActiveBorder: '#007bff', | ||
| sidebarTextActiveColor: '#007bff', | ||
| sidebarHeaderBg: '#f8f9fa', | ||
| sidebarHeaderTextColor: '#495057', | ||
| onlineIndicator: '#28a745', | ||
| awayIndicator: '#ffc107', | ||
| dndIndicator: '#dc3545', | ||
| mentionBg: '#ffeb3b', | ||
| mentionBj: '#ffeb3b', | ||
| mentionColor: '#333333', | ||
| centerChannelBg: '#f8f9fa', | ||
| centerChannelColor: '#333333', | ||
| newMessageSeparator: '#007bff', | ||
| linkColor: '#007bff', | ||
| buttonBg: '#007bff', | ||
| buttonColor: '#ffffff', | ||
| errorTextColor: '#dc3545', | ||
| mentionHighlightBg: '#ffeb3b', | ||
| mentionHighlightLink: '#007bff', | ||
| codeTheme: 'solarized-dark', | ||
| }; | ||
|
|
||
| const mockSlice = createSlice({ | ||
| name: 'mock-reducer', | ||
| initialState: { | ||
| 'plugins-com.github.manland.mattermost-plugin-gitlab': { | ||
| connected: true, | ||
| username: 'mattermost', | ||
| clientId: '', | ||
| lhsData: { | ||
| reviews: [], | ||
| yourAssignedPrs: [], | ||
| yourAssignedIssues: [], | ||
| todos: [], | ||
| }, | ||
| gitlabURL: 'https://gitlab.com/gitlab-org', | ||
| organization: '', | ||
| rhsPluginAction: () => true, | ||
| }, | ||
| entities: {general: {config: {}}}, | ||
| }, | ||
| reducers: {}, | ||
| }); | ||
|
|
||
| const mockStore = configureStore({ | ||
| reducer: mockSlice.reducer, | ||
| }); | ||
|
|
||
| describe('TeamSidebar', () => { | ||
| test.each([true, false])('should render when show is %s', (show) => { | ||
| const {container} = render( | ||
| <Provider store={mockStore}> | ||
| <TeamSidebar | ||
| show={show} | ||
| theme={mockTheme} | ||
| /> | ||
| </Provider>, | ||
| ); | ||
|
|
||
| expect(container).toMatchSnapshot(); | ||
| }); | ||
| }); |
This file contains hidden or 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,28 @@ | ||
| // Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved. | ||
| // See LICENSE.txt for license information. | ||
|
|
||
| import React, {FC} from 'react'; | ||
|
|
||
| import {Theme} from 'mattermost-redux/types/preferences'; | ||
|
|
||
| import SidebarButtons from '../sidebar_buttons'; | ||
|
|
||
| interface TeamSidebarProps { | ||
| show: boolean; | ||
| theme: Theme; | ||
| } | ||
|
|
||
| const TeamSidebar: FC<TeamSidebarProps> = ({show, theme}: TeamSidebarProps) => { | ||
| if (!show) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <SidebarButtons | ||
| theme={theme} | ||
| isTeamSidebar={true} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| export default TeamSidebar; |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| ], | ||
| "exclude": [ | ||
| "dist", | ||
| "!node_modules/@types" | ||
| "!node_modules/@types", | ||
| "node_modules" | ||
| ] | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.