Skip to content
Closed
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 @@ -348,7 +348,10 @@ public void orFilterGroupCombinationShouldNotReturnAgentThatIsNotTargetOfInject(
agent3Wrapper.get().getAsset().getId(),
agent3Wrapper.get().getExecutor().getType()));

assertThatJson(response).node("content").isEqualTo(mapper.writeValueAsString(expected));
assertThatJson(response)
.when(Option.IGNORING_ARRAY_ORDER)
.node("content")
.isEqualTo(mapper.writeValueAsString(expected));
}
}

Expand Down
4 changes: 1 addition & 3 deletions openaev-front/src/actions/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,7 @@ export const storeHelper = state => ({
getExerciseInjectExpectations: id => entities('injectexpectations', state).filter(
i => i.get('inject_expectation_exercise') === id,
),
getInjectExpectationsByAsset: (id, type) => entities('injectexpectations', state).filter(
i => (i.get('inject_expectation_asset') === id && i.get('inject_expectation_type') === type),
),

getInjectExpectationsMap: () => maps('injectexpectations', state),
// documents
getDocuments: () => entities('documents', state),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ export const fetchTargetResult = (injectId: string, targetId: string, targetType
return simpleCall(uri);
};

export const fetchTargetResultAssetWithAgents = (injectId: string, targetId: string, expectationType: string) => (dispatch: Dispatch) => {
export const fetchTargetResultAssetWithAgents = (injectId: string, targetId: string, expectationType: string) => {
const uri = `${ATOMIC_TESTING_URI}/${injectId}/target_results/${targetId}/asset_with_agents?expectationType=${expectationType}`;
return getReferential(schema.arrayOfInjectexpectations, uri)(dispatch);
return simpleCall(uri);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So now we completely bypass the store to always get fresh data from the backend, we probably don't want that. @guillaumejparis @corinnekrych thoughts?

};

export const createAtomicTesting = (data: AtomicTestingInput) => {
Expand Down
5 changes: 1 addition & 4 deletions openaev-front/src/actions/injects/inject-helper.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {
type Exercise,
type Inject,
type InjectExpectation, type InjectExpectationAgentOutput,
type InjectTarget,
type InjectExpectation,
type Scenario,
type Team,
} from '../../utils/api-types';
Expand All @@ -17,6 +16,4 @@ export interface InjectHelper {

getScenarioInjects: (scenarioId: Scenario['scenario_id']) => Inject[];
getTeamScenarioInjects: (teamId: Team['team_id']) => Inject[];

getInjectExpectationsByAsset: (targetId: InjectTarget['target_id'], expectationType: string) => InjectExpectationAgentOutput[];
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import { Paper, Typography } from '@mui/material';
import { useTheme } from '@mui/material/styles';
import { useState } from 'react';
import { useEffect, useState } from 'react';

import { fetchTargetResultAssetWithAgents } from '../../../../../actions/atomic_testings/atomic-testing-actions';
import { type InjectHelper } from '../../../../../actions/injects/inject-helper';
import ExpandableSection from '../../../../../components/common/ExpandableSection';
import { useFormatter } from '../../../../../components/i18n';
import ItemStatus from '../../../../../components/ItemStatus';
import Loader from '../../../../../components/Loader';
import { useHelper } from '../../../../../store';
import type {
InjectExpectationAgentOutput,
InjectResultOverviewOutput,
InjectTarget,
} from '../../../../../utils/api-types';
import { useAppDispatch } from '../../../../../utils/hooks';
import useDataLoader from '../../../../../utils/hooks/useDataLoader';
import { computeInjectExpectationLabel } from '../../../../../utils/statusUtils';
import type { InjectExpectationsStore } from '../../../common/injects/expectations/Expectation';
import InjectExpectationResultList from './InjectExpectationResultList';
Expand All @@ -27,18 +23,30 @@ interface Props {
}

const InjectExpectationAggregatedAgentsView = ({ inject, expectationType, target }: Props) => {
const dispatch = useAppDispatch();
const { t } = useFormatter();
const theme = useTheme();
const [loading, setLoading] = useState(false);
const [loading, setLoading] = useState(true);
const [injectExpectationsWithAgents, setInjectExpectationsWithAgents] = useState<InjectExpectationAgentOutput[]>([]);

useDataLoader(() => {
useEffect(() => {
let active = true;
setLoading(true);
dispatch(fetchTargetResultAssetWithAgents(inject.inject_id, target.target_id, expectationType)).finally(() => setLoading(false));
});

const { injectExpectationsWithAgents } = useHelper((helper: InjectHelper) =>
({ injectExpectationsWithAgents: helper.getInjectExpectationsByAsset(target.target_id, expectationType) }));
fetchTargetResultAssetWithAgents(inject.inject_id, target.target_id, expectationType)
.then((result: { data: InjectExpectationAgentOutput[] }) => {
if (active) {
setInjectExpectationsWithAgents(result.data ?? []);
}
})
.catch(() => {}) // error already notified by simpleCall
.finally(() => {
if (active) {
setLoading(false);
}
});
return () => {
active = false;
};
}, [inject.inject_id, target.target_id, expectationType]);

if (loading) {
return <Loader />;
Expand Down
Loading