Skip to content
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

bug/FP-896: Fix add definition to list #342

Merged
merged 4 commits into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;