mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-12 00:41:32 +00:00
fix(ui): authenticate pipeline status api call (#21257)
* fix(ui): authenticate pipeline status api call * fix tests
This commit is contained in:
parent
764b1702b4
commit
7a73598a93
@ -24,6 +24,16 @@ jest.mock('../../rest/ingestionPipelineAPI', () => ({
|
||||
getAirflowStatus: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('../../hooks/useApplicationStore', () => {
|
||||
return {
|
||||
useApplicationStore: jest.fn().mockImplementation(() => ({
|
||||
currentUser: {
|
||||
id: '123',
|
||||
},
|
||||
})),
|
||||
};
|
||||
});
|
||||
|
||||
// Mock component to test the context
|
||||
const TestComponent = () => {
|
||||
const {
|
||||
|
||||
@ -21,6 +21,7 @@ import React, {
|
||||
useState,
|
||||
} from 'react';
|
||||
import { PipelineServiceClientResponse } from '../../generated/entity/services/ingestionPipelines/pipelineServiceClientResponse';
|
||||
import { useApplicationStore } from '../../hooks/useApplicationStore';
|
||||
import { getAirflowStatus } from '../../rest/ingestionPipelineAPI';
|
||||
import { AirflowStatusContextType } from './AirflowStatusProvider.interface';
|
||||
|
||||
@ -40,8 +41,12 @@ const AirflowStatusProvider = ({ children }: Props) => {
|
||||
useState<PipelineServiceClientResponse['reason']>();
|
||||
const [platform, setPlatform] =
|
||||
useState<PipelineServiceClientResponse['platform']>('unknown');
|
||||
const { currentUser } = useApplicationStore();
|
||||
|
||||
const fetchAirflowStatus = useCallback(async () => {
|
||||
if (!currentUser?.id) {
|
||||
return;
|
||||
}
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const response = await getAirflowStatus();
|
||||
@ -54,11 +59,11 @@ const AirflowStatusProvider = ({ children }: Props) => {
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}, []);
|
||||
}, [currentUser?.id]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchAirflowStatus();
|
||||
}, []);
|
||||
}, [fetchAirflowStatus]);
|
||||
|
||||
const value: AirflowStatusContextType = useMemo(
|
||||
() => ({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user