Skip to content

Commit

Permalink
bug/FP-896: Fix add definition to list (#342)
Browse files Browse the repository at this point in the history
* fix add definition to list

* add system def list unit test

Co-authored-by: Owais Jamil <47395902+owaisj@users.noreply.github.com>
  • Loading branch information
2 people authored and wesleyboar committed Jan 7, 2022
1 parent 2d7926d commit 933860d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client/src/redux/reducers/datafiles.reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function systems(state = initialSystemState, action) {
...state,
definitions: {
...state.definitions,
list: addSystemDefinition(action.payload, state.definitions),
list: addSystemDefinition(action.payload, state.definitions.list),
error: false,
errorMessage: null,
loading: false
Expand All @@ -79,7 +79,7 @@ export function systems(state = initialSystemState, action) {
return {
...state,
definitions: {
...state.datafiles,
...state.definitions,
error: true,
errorMessage: action.payload,
loading: false
Expand Down
26 changes: 26 additions & 0 deletions client/src/redux/reducers/tests/datafiles.reducers.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {systems as datafilesReducer, initialSystemState } from "../datafiles.reducers";
import systemDefinitionFixture from '../../sagas/fixtures/systemDefinition.fixture';

describe("Datafiles Reducer", () => {
test("Load initial state", () => {
expect(datafilesReducer(initialSystemState, { type: undefined })).toEqual(
initialSystemState
);
});
test("Add system definition to state", () => {
const addSystemDefinitionAction = {
type: "FETCH_SYSTEM_DEFINITION_SUCCESS",
payload: systemDefinitionFixture
};
expect(datafilesReducer(initialSystemState, addSystemDefinitionAction)).toEqual({
...initialSystemState,
definitions: {
...initialSystemState.definitions,
list: [systemDefinitionFixture],
error: false,
errorMessage: null,
loading: false
}
});
});
});
43 changes: 43 additions & 0 deletions client/src/redux/sagas/fixtures/systemDefinition.fixture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const systemDefinitionFixture = {
owner: 'wma_prtl',
_links: {
owner: { href: 'https://portals-api.tacc.utexas.edu/profiles/v2/wma_prtl' },
metadata: {
href:
'https://portals-api.tacc.utexas.edu/meta/v2/data/?q=%7B%22associationIds%22%3A%221843722814843916777-242ac119-0001-006%22%7D'
},
roles: {
href:
'https://portals-api.tacc.utexas.edu/systems/v2/frontera.home.user/roles'
},
self: {
href: 'https://portals-api.tacc.utexas.edu/systems/v2/frontera.home.user'
}
},
available: true,
description: 'Home system for user: user',
storage: {
proxy: null,
protocol: 'SFTP',
mirror: false,
port: 22,
auth: { type: 'SSHKEYS' },
publicAppsDir: null,
host: 'frontera.tacc.utexas.edu',
rootDir: '/home1/12345/user',
homeDir: '/'
},
type: 'STORAGE',
uuid: '1843722814843916777-242ac119-0001-006',
revision: 2,
site: 'portal.dev',
default: false,
public: false,
globalDefault: false,
name: 'frontera.home.user',
id: 'frontera.home.user',
lastModified: '2020-08-11T14:37:39-05:00',
status: 'UP'
};

export default systemDefinitionFixture;

0 comments on commit 933860d

Please sign in to comment.