UI: Only include upgrades with previous versions (#26870)

* only include upgrades with previous versions

* update tests

* fix prettier linting

* update counts test

* why are you failing??

* match key order of expected object to actual

* timezones -_-

* attempt to fix flaky openapi test again
This commit is contained in:
claire bontempo
2024-05-08 14:29:07 +01:00
committed by GitHub
parent 7880616c18
commit 7874f06ca3
6 changed files with 125 additions and 81 deletions

View File

@@ -35,14 +35,19 @@ export const filterVersionHistory = (
end: string
) => {
if (versionHistory) {
const notableUpgrades = ['1.9', '1.10', '1.17'];
const upgrades = versionHistory.reduce((array: ClientsVersionHistoryModel[], upgradeData) => {
const includesVersion = (v: string) =>
// only add first match, disregard subsequent patch releases of the same version
upgradeData.version.match(v) && !array.some((d: ClientsVersionHistoryModel) => d.version.match(v));
const isRelevantHistory = (v: string) => {
return (
upgradeData.version.match(v) &&
// only add if there is a previous version, otherwise this upgrade is the users' first version
upgradeData.previousVersion &&
// only add first match, disregard subsequent patch releases of the same version
!array.some((d: ClientsVersionHistoryModel) => d.version.match(v))
);
};
notableUpgrades.forEach((v) => {
if (includesVersion(v)) array.push(upgradeData);
['1.9', '1.10', '1.17'].forEach((v) => {
if (isRelevantHistory(v)) array.push(upgradeData);
});
return array;