diff --git a/src/core/project.js b/src/core/project.js index 6619aea..ca62dbb 100644 --- a/src/core/project.js +++ b/src/core/project.js @@ -88,8 +88,8 @@ export function encodeProjectId(id: ProjectId): string { } const upgradeFrom051 = (p: ProjectV051): ProjectV052 => ({ - ...p, discord: null, + ...p, }); export type ProjectV051 = {| @@ -103,8 +103,8 @@ export type ProjectV051 = {| const upgradeFrom050 = (p: ProjectV050) => upgradeFrom051({ - ...p, timelineCredParams: {}, + ...p, }); export type ProjectV050 = {| @@ -117,8 +117,8 @@ export type ProjectV050 = {| const upgradeFrom040 = (p: ProjectV040) => upgradeFrom050({ - ...p, initiatives: null, + ...p, }); export type ProjectV040 = {| diff --git a/src/core/project.test.js b/src/core/project.test.js index 7515c1d..6a35865 100644 --- a/src/core/project.test.js +++ b/src/core/project.test.js @@ -15,7 +15,7 @@ import { import {makeRepoId} from "../plugins/github/repoId"; import {toCompat} from "../util/compat"; -import type {ProjectV050, ProjectV051} from "./project"; +import type {ProjectV050, ProjectV051, ProjectV052} from "./project"; describe("core/project", () => { const foobar = deepFreeze(makeRepoId("foo", "bar")); @@ -173,7 +173,7 @@ describe("core/project", () => { it("should upgrade from 0.5.1 formatting", () => { // Given const body: ProjectV051 = { - id: "example-050", + id: "example-051", repoIds: [foobar, foozod], discourseServer: {serverUrl: "https://example.com"}, identities: [], @@ -196,6 +196,33 @@ describe("core/project", () => { }: Project) ); }); + + it("should upgrade from 0.5.0 formatting without overwriting fields", () => { + // Given + const body: ProjectV052 = { + id: "example-051", + repoIds: [foobar, foozod], + discourseServer: {serverUrl: "https://example.com"}, + identities: [], + initiatives: null, + timelineCredParams: {alpha: 0.2, intervalDecay: 0.5}, + discord: {guildId: "1234", reactionWeights: {}}, + }; + const compat = toCompat( + {type: "sourcecred/project", version: "0.5.0"}, + body + ); + + // When + const project = projectFromJSON(compat); + + // Then + expect(project).toEqual( + ({ + ...body, + }: Project) + ); + }); describe("encodeProjectId", () => { it("is a base64-url encoded id", () => { const project = {id: "foo bar", repoIds: []};