Merge pull request #1213 from bpoulaindev/bugfix/delete_running_api

bugfix(#1210): prevent collection run mapping on deleted items
This commit is contained in:
Anoop M D 2023-12-20 00:28:44 +05:30 committed by GitHub
commit 4b76bf85f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,35 +31,39 @@ export default function RunnerResults({ collection }) {
}, [collection, setSelectedItem]); }, [collection, setSelectedItem]);
const collectionCopy = cloneDeep(collection); const collectionCopy = cloneDeep(collection);
const items = cloneDeep(get(collection, 'runnerResult.items', []));
const runnerInfo = get(collection, 'runnerResult.info', {}); const runnerInfo = get(collection, 'runnerResult.info', {});
each(items, (item) => { const items = cloneDeep(get(collection, 'runnerResult.items', []))
.map((item) => {
const info = findItemInCollection(collectionCopy, item.uid); const info = findItemInCollection(collectionCopy, item.uid);
if (!info) {
item.name = info.name; return null;
item.type = info.type; }
item.filename = info.filename; const newItem = {
item.pathname = info.pathname; ...item,
item.relativePath = getRelativePath(collection.pathname, info.pathname); name: info.name,
type: info.type,
if (item.status !== 'error') { filename: info.filename,
if (item.testResults) { pathname: info.pathname,
const failed = item.testResults.filter((result) => result.status === 'fail'); relativePath: getRelativePath(collection.pathname, info.pathname)
};
item.testStatus = failed.length ? 'fail' : 'pass'; if (newItem.status !== 'error') {
if (newItem.testResults) {
const failed = newItem.testResults.filter((result) => result.status === 'fail');
newItem.testStatus = failed.length ? 'fail' : 'pass';
} else { } else {
item.testStatus = 'pass'; newItem.testStatus = 'pass';
} }
if (item.assertionResults) { if (newItem.assertionResults) {
const failed = item.assertionResults.filter((result) => result.status === 'fail'); const failed = newItem.assertionResults.filter((result) => result.status === 'fail');
newItem.assertionStatus = failed.length ? 'fail' : 'pass';
item.assertionStatus = failed.length ? 'fail' : 'pass';
} else { } else {
item.assertionStatus = 'pass'; newItem.assertionStatus = 'pass';
} }
} }
}); return newItem;
})
.filter(Boolean);
const runCollection = () => { const runCollection = () => {
dispatch(runCollectionFolder(collection.uid, null, true)); dispatch(runCollectionFolder(collection.uid, null, true));
@ -168,8 +172,7 @@ export default function RunnerResults({ collection }) {
</li> </li>
)) ))
: null} : null}
{item.assertionResults {item.assertionResults?.map((result) => (
? item.assertionResults.map((result) => (
<li key={result.uid}> <li key={result.uid}>
{result.status === 'pass' ? ( {result.status === 'pass' ? (
<span className="test-success flex items-center"> <span className="test-success flex items-center">
@ -186,8 +189,7 @@ export default function RunnerResults({ collection }) {
</> </>
)} )}
</li> </li>
)) ))}
: null}
</ul> </ul>
</div> </div>
</div> </div>