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

fix: handle null LiteralMap in RemoteLiteralMapViewer #117

Merged
merged 1 commit into from
Nov 11, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ describe('RelaunchExecutionForm', () => {
task = createMockTask('MyTask');
executionData = {
inputs: { url: 'http://somePath', bytes: long(1000) },
outputs: {}
outputs: {},
fullInputs: null,
fullOutputs: null
};

mockGetWorkflow = jest.fn().mockResolvedValue(workflow);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ const nodeRetryAttempts = {

const apiContext = mockAPIContextValue({
getExecution: () => Promise.resolve(workflowExecution),
getNodeExecutionData: () => Promise.resolve({ inputs: {}, outputs: {} }),
getNodeExecutionData: () =>
Promise.resolve({
inputs: {},
outputs: {},
fullInputs: null,
fullOutputs: null
}),
listTaskExecutions: nodeExecutionId => {
const length = nodeRetryAttempts[nodeExecutionId.nodeId] || 1;
const entities = Array.from({ length }, (_, retryAttempt) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ const generateMocks = (variables: Record<string, Variable>) => {

const mockExecutionData: ExecutionData = {
inputs: { url: 'inputsUrl', bytes: Long.fromNumber(1000) },
outputs: { url: 'outputsUrl', bytes: Long.fromNumber(1000) }
outputs: { url: 'outputsUrl', bytes: Long.fromNumber(1000) },
fullInputs: null,
fullOutputs: null
};

const mockExecutionInputs: LiteralMap = Object.keys(
Expand Down
4 changes: 2 additions & 2 deletions src/components/Literals/RemoteLiteralMapViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const BlobTooLarge: React.FC<{ url: string }> = ({ url }) => (
*/
export const RemoteLiteralMapViewer: React.FC<{
blob: UrlBlob;
map?: LiteralMap;
map: LiteralMap | null;
}> = ({ blob, map }) => {
if (!blob.url || !blob.bytes) {
return (
Expand All @@ -38,7 +38,7 @@ export const RemoteLiteralMapViewer: React.FC<{
);
}

if (map !== undefined) {
if (map != null) {
return <LiteralMapViewer map={map} />;
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/Literals/test/RemoteLiteralMapViewer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('RemoteLiteralMapViewer', () => {
};

const { getAllByText } = render(
<RemoteLiteralMapViewer map={undefined} blob={blob} />
<RemoteLiteralMapViewer map={null} blob={blob} />
);

const items = getAllByText('No data is available.');
Expand All @@ -45,7 +45,7 @@ describe('RemoteLiteralMapViewer', () => {
expect(items.length).toBe(1);
});

it('fetches blob if map is undefined', () => {
it('fetches blob if map is null', () => {
const map: LiteralMap = {
literals: {
input1: {}
Expand All @@ -65,7 +65,7 @@ describe('RemoteLiteralMapViewer', () => {
};

const { getAllByText } = render(
<RemoteLiteralMapViewer map={undefined} blob={blob} />
<RemoteLiteralMapViewer map={null} blob={blob} />
);

const items = getAllByText('input1:');
Expand Down
4 changes: 3 additions & 1 deletion src/models/Execution/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ export const getExecution = (

const emptyExecutionData: ExecutionData = {
inputs: {},
outputs: {}
outputs: {},
fullInputs: null,
fullOutputs: null
};
/** Fetches data URLs for an `Execution` record */
export const getExecutionData = (
Expand Down
4 changes: 2 additions & 2 deletions src/models/Execution/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ export interface TaskExecutionClosure extends Admin.ITaskExecutionClosure {
export interface ExecutionData {
inputs: UrlBlob;
outputs: UrlBlob;
fullInputs?: LiteralMap;
fullOutputs?: LiteralMap;
fullInputs: LiteralMap | null;
fullOutputs: LiteralMap | null;
}