-
Notifications
You must be signed in to change notification settings - Fork 38
Add Unit Tests for Application and New CI Workflow for Vitest Coverage #1379
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
EnsiyehE
wants to merge
20
commits into
opencast:develop
Choose a base branch
from
EnsiyehE:my-feature-branch
base: develop
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 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ad88ef7
Add vitest coverage GitHub Action
EnsiyehE 58d52a8
Add Vitest coverage integration
EnsiyehE a988c4b
eslint errors solved
EnsiyehE f292571
changing the ci jobs
EnsiyehE 3ad5fca
edittextfilter action creator function redux tested -without the requ…
EnsiyehE fbd666e
polish the test files and check on syntaxes
EnsiyehE f3679ca
Merge remote-tracking branch 'origin/develop' into my-feature-branch
EnsiyehE 6e22ab2
fix the merge conflicts with the test cases
EnsiyehE d1921d7
fix error and warnings of the test inside the console
EnsiyehE 127a2a3
Fix the npm build error env key
EnsiyehE f57a03e
fix the archticture and the test cases
EnsiyehE 0153192
try to fix the eslint warnings
EnsiyehE 4b9bd94
es lint warnings
EnsiyehE fe227cd
Change the test cases errors
EnsiyehE bab71b7
Merge remote-tracking branch 'origin/develop' into my-feature-branch
EnsiyehE edd1cf4
resolving the conflicts
EnsiyehE 97b5ee4
remove the extra console
EnsiyehE 8511f29
test the workflow error
EnsiyehE eb3cd5f
fix the eslint warning for the building the project
EnsiyehE 4a8bb7b
try to fix the build error
EnsiyehE 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
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 |
|---|---|---|
| @@ -1,4 +1,12 @@ | ||
| import { FLUSH, PAUSE, PERSIST, PURGE, REGISTER, REHYDRATE, persistReducer } from "redux-persist"; | ||
| import { | ||
| FLUSH, | ||
| PAUSE, | ||
| PERSIST, | ||
| PURGE, | ||
| REGISTER, | ||
| REHYDRATE, | ||
| persistReducer, | ||
| } from "redux-persist"; | ||
| import storage from "redux-persist/lib/storage"; | ||
| import { UnknownAction, combineReducers } from "redux"; | ||
| import tableFilters from "./slices/tableFilterSlice"; | ||
|
|
@@ -35,61 +43,87 @@ import autoMergeLevel2 from "redux-persist/lib/stateReconciler/autoMergeLevel2"; | |
| */ | ||
|
|
||
| // Configuration for persisting states in store | ||
| const tableFilterProfilesPersistConfig = { key: "tableFilterProfiles", storage, whitelist: ["profiles"] }; | ||
| const tableFilterProfilesPersistConfig = { | ||
| key: "tableFilterProfiles", | ||
| storage, | ||
| whitelist: ["profiles"], | ||
| }; | ||
| const eventsPersistConfig = { key: "events", storage, whitelist: ["columns"] }; | ||
| const seriesPersistConfig = { key: "series", storage, whitelist: ["columns"] }; | ||
| const tablePersistConfig = { key: "table", storage, whitelist: ["pagination", "sortBy", "reverse"] }; | ||
| const recordingsPersistConfig = { key: "recordings", storage, whitelist: ["columns"] }; | ||
| const tablePersistConfig = { | ||
| key: "table", | ||
| storage, | ||
| whitelist: ["pagination", "sortBy", "reverse"], | ||
| }; | ||
| const recordingsPersistConfig = { | ||
| key: "recordings", | ||
| storage, | ||
| whitelist: ["columns"], | ||
| }; | ||
| const jobsPersistConfig = { key: "jobs", storage, whitelist: ["columns"] }; | ||
| const serversPersistConfig = { key: "servers", storage, whitelist: ["columns"] }; | ||
| const servicesPersistConfig = { key: "services", storage, whitelist: ["columns"] }; | ||
| const serversPersistConfig = { | ||
| key: "servers", | ||
| storage, | ||
| whitelist: ["columns"], | ||
| }; | ||
| const servicesPersistConfig = { | ||
| key: "services", | ||
| storage, | ||
| whitelist: ["columns"], | ||
| }; | ||
| const usersPersistConfig = { key: "users", storage, whitelist: ["columns"] }; | ||
| const groupsPersistConfig = { key: "groups", storage, whitelist: ["columns"] }; | ||
| const aclsPersistConfig = { key: "acls", storage, whitelist: ["columns"] }; | ||
| const themesPersistConfig = { key: "themes", storage, whitelist: ["columns"] }; | ||
|
|
||
| // form reducer and all other reducers used in this app | ||
| const reducers = combineReducers({ | ||
| tableFilters, | ||
| tableFilterProfiles: persistReducer(tableFilterProfilesPersistConfig, tableFilterProfiles), | ||
| events: persistReducer(eventsPersistConfig, events), | ||
| series: persistReducer(seriesPersistConfig, series), | ||
| table: persistReducer(tablePersistConfig, table), | ||
| recordings: persistReducer(recordingsPersistConfig, recordings), | ||
| jobs: persistReducer(jobsPersistConfig, jobs), | ||
| servers: persistReducer(serversPersistConfig, servers), | ||
| services: persistReducer(servicesPersistConfig, services), | ||
| users: persistReducer(usersPersistConfig, users), | ||
| groups: persistReducer(groupsPersistConfig, groups), | ||
| acls: persistReducer(aclsPersistConfig, acls), | ||
| themes: persistReducer(themesPersistConfig, themes), | ||
| health, | ||
| notifications, | ||
| workflows, | ||
| eventDetails, | ||
| themeDetails, | ||
| seriesDetails, | ||
| recordingDetails, | ||
| userDetails, | ||
| groupDetails, | ||
| aclDetails, | ||
| userInfo, | ||
| statistics, | ||
| tableFilters, | ||
| tableFilterProfiles: persistReducer( | ||
| tableFilterProfilesPersistConfig, | ||
| tableFilterProfiles, | ||
| ), | ||
| events: persistReducer(eventsPersistConfig, events), | ||
| series: persistReducer(seriesPersistConfig, series), | ||
| table: persistReducer(tablePersistConfig, table), | ||
| recordings: persistReducer(recordingsPersistConfig, recordings), | ||
| jobs: persistReducer(jobsPersistConfig, jobs), | ||
| servers: persistReducer(serversPersistConfig, servers), | ||
| services: persistReducer(servicesPersistConfig, services), | ||
| users: persistReducer(usersPersistConfig, users), | ||
| groups: persistReducer(groupsPersistConfig, groups), | ||
| acls: persistReducer(aclsPersistConfig, acls), | ||
| themes: persistReducer(themesPersistConfig, themes), | ||
| health, | ||
| notifications, | ||
| workflows, | ||
| eventDetails, | ||
| themeDetails, | ||
| seriesDetails, | ||
| recordingDetails, | ||
| userDetails, | ||
| groupDetails, | ||
| aclDetails, | ||
| userInfo, | ||
| statistics, | ||
| }); | ||
|
|
||
| // Configuration for persisting store | ||
| const persistConfig = { | ||
| key: "root", | ||
| storage, | ||
| stateReconciler: autoMergeLevel2, | ||
| whitelist: ["tableFilters"], | ||
| key: "root", | ||
| storage, | ||
| stateReconciler: autoMergeLevel2, | ||
| whitelist: ["tableFilters"], | ||
| }; | ||
|
|
||
| const persistedReducer = persistReducer<ReturnType<typeof reducers>>(persistConfig, reducers); | ||
| const persistedReducer = persistReducer<ReturnType<typeof reducers>>( | ||
| persistConfig, | ||
| reducers, | ||
| ); | ||
|
|
||
| const store = configureStore({ | ||
| reducer: persistedReducer, | ||
| middleware: getDefaultMiddleware => | ||
| middleware: (getDefaultMiddleware) => | ||
| getDefaultMiddleware({ | ||
| serializableCheck: { | ||
| ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER], | ||
|
|
@@ -110,6 +144,8 @@ export type AppThunk<ReturnType = void> = ThunkAction< | |
| RootState, | ||
| unknown, | ||
| UnknownAction | ||
| > | ||
| >; | ||
|
|
||
| export const rootReducer = reducers; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not directly export |
||
|
|
||
| export default store; | ||
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 |
|---|---|---|
| @@ -1,41 +1,29 @@ | ||
| import React from "react"; | ||
| import { Provider } from "react-redux"; | ||
| import { configureStore, combineReducers } from "@reduxjs/toolkit"; | ||
| import { render } from "@testing-library/react"; | ||
| import { BrowserRouter } from "react-router"; | ||
| import { combineReducers } from "redux"; | ||
|
|
||
| const userInfoReducer = ( | ||
| state = { | ||
| user: { name: "Test User" }, | ||
| roles: ["admin"], | ||
| org: { id: "org1", properties: {} }, | ||
| }, | ||
| ) => state; | ||
| // Stub reducers returning default state (no action handling needed for tests) | ||
| const userInfoReducer = () => ({ | ||
| user: { name: "Test User" }, | ||
| roles: ["admin"], | ||
| org: { id: "org1", properties: {} }, | ||
| }); | ||
|
|
||
| const eventsReducer = ( | ||
| state = { | ||
| uploadSourceOptions: [], | ||
| uploadAssetOptions: [], | ||
| isFetchingAssetUploadOptions: false, | ||
| metadata: { title: "event", flavor: "someFlavor", fields: [] }, | ||
| extendedMetadata: [], | ||
| total: 0, | ||
| }, | ||
| ) => state; | ||
| const eventsReducer = () => ({ | ||
| uploadSourceOptions: [], | ||
| uploadAssetOptions: [], | ||
| isFetchingAssetUploadOptions: false, | ||
| metadata: { title: "event", flavor: "someFlavor", fields: [] }, | ||
| extendedMetadata: [], | ||
| total: 0, | ||
| }); | ||
|
|
||
| const rootReducer = combineReducers({ | ||
| // Root reducer object with your test slices | ||
| export const rootReducer = { | ||
| userInfo: userInfoReducer, | ||
| events: eventsReducer, | ||
| }); | ||
| }; | ||
|
|
||
| export const combinedReducer = combineReducers(rootReducer); | ||
|
|
||
| export type TestRootState = ReturnType<typeof combinedReducer>; | ||
|
|
||
| export default function renderWithStore( | ||
| ui: React.ReactElement, | ||
| preloadedState = {}, | ||
| ) { | ||
| const store = configureStore({ reducer: rootReducer, preloadedState }); | ||
| return render( | ||
| <Provider store={store}> | ||
| <BrowserRouter>{ui}</BrowserRouter> | ||
| </Provider>, | ||
| ); | ||
| } | ||
| export default rootReducer; |
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
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.