Skip to content
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
22 changes: 22 additions & 0 deletions web/src/__tests__/requests/lineage.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2018-2023 contributors to the Marquez project
// SPDX-License-Identifier: Apache-2.0

import { generateNodeId } from '../../helpers/nodes'
import * as requestUtils from '../../store/requests'
import { getLineage } from '../../store/requests/lineage'

describe('getLineage function', () => {
let spy: jest.SpyInstance<Promise<any>, [string, requestUtils.IParams, string]>
let testResult: Promise<any>

beforeEach(() => {
spy = jest.spyOn(requestUtils, 'genericFetchWrapper').mockImplementation(() => {})
testResult = getLineage('JOB', 'foo', 'bar', 0)
})

it('does not url-encode query params', () => {
const expectedNodeId = generateNodeId('JOB', 'foo', 'bar')
const actualParamString = spy.mock.lastCall[0].split('?')
expect(actualParamString.pop()!.split('&')).toContain(`nodeId=${expectedNodeId}`)
})
})
2 changes: 1 addition & 1 deletion web/src/store/requests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const genericErrorMessageConstructor = (functionName: string, error: APIE
throw `${functionName} responded with error code ${code}: ${message}. Here are the details: ${details}`
}

interface IParams {
export interface IParams {
method: HttpMethod
body?: string
}
Expand Down
8 changes: 3 additions & 5 deletions web/src/store/requests/lineage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ export const getLineage = async (
name: string,
depth: number
) => {
const params = new URLSearchParams({
nodeId: generateNodeId(nodeType, namespace, name),
depth: depth.toString()
})
const url = `${API_URL}/lineage/?${params.toString()}`
const nodeId = generateNodeId(nodeType, namespace, name)
// Node ID cannot be URL encoded
const url = `${API_URL}/lineage/?nodeId=${nodeId}&depth=${depth}`
return genericFetchWrapper(url, { method: 'GET' }, 'fetchLineage')
}