Skip to content

Commit 79ab847

Browse files
committed
add initiative state enum
1 parent 9c117c4 commit 79ab847

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/models/Initiative.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { BaseModel, LogoProps } from "./common";
22

3+
export enum InitiativeState {
4+
DRAFT = "DRAFT",
5+
PLANNED = "PLANNED",
6+
ACTIVE = "ACTIVE",
7+
COMPLETED = "COMPLETED",
8+
CLOSED = "CLOSED",
9+
}
310
/**
411
* Initiative model interfaces
512
*/
@@ -13,7 +20,7 @@ export interface Initiative extends BaseModel {
1320
start_date?: string;
1421
end_date?: string;
1522
logo_props?: LogoProps;
16-
state: string; // StateChoices: DRAFT, etc.
23+
state?: InitiativeState;
1724
workspace: string;
1825
}
1926

tests/unit/initiative.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { PlaneClient } from "../../src/client/plane-client";
2-
import { Initiative, UpdateInitiative } from "../../src/models/Initiative";
2+
import { Initiative, InitiativeState, UpdateInitiative } from "../../src/models/Initiative";
33
import { InitiativeLabel } from "../../src/models/InitiativeLabel";
44
import { Project } from "../../src/models/Project";
55
import { Epic } from "../../src/models/Epic";
@@ -74,14 +74,14 @@ describeIf(!!(config.workspaceSlug && config.projectId), "Initiative API Tests",
7474
initiative = await client.initiatives.create(workspaceSlug, {
7575
name: randomizeName("Test Initiative"),
7676
description: "Test Initiative Description",
77-
state: "DRAFT",
77+
state: InitiativeState.ACTIVE,
7878
});
7979

8080
expect(initiative).toBeDefined();
8181
expect(initiative.id).toBeDefined();
8282
expect(initiative.name).toContain("Test Initiative");
8383
expect(initiative.description).toBe("Test Initiative Description");
84-
expect(initiative.state).toBe("DRAFT");
84+
expect(initiative.state).toBe(InitiativeState.ACTIVE);
8585
});
8686

8787
it("should retrieve an initiative", async () => {
@@ -90,19 +90,22 @@ describeIf(!!(config.workspaceSlug && config.projectId), "Initiative API Tests",
9090
expect(retrievedInitiative).toBeDefined();
9191
expect(retrievedInitiative.id).toBe(initiative.id);
9292
expect(retrievedInitiative.name).toBe(initiative.name);
93+
expect(retrievedInitiative.state).toBe(initiative.state);
9394
});
9495

9596
it("should update an initiative", async () => {
9697
const updateData: UpdateInitiative = {
9798
name: randomizeName("Updated Test Initiative"),
9899
description: "Updated Test Initiative Description",
100+
state: InitiativeState.PLANNED,
99101
};
100102

101103
const updatedInitiative = await client.initiatives.update(workspaceSlug, initiative.id, updateData);
102104

103105
expect(updatedInitiative).toBeDefined();
104106
expect(updatedInitiative.id).toBe(initiative.id);
105107
expect(updatedInitiative.name).toContain("Updated Test Initiative");
108+
expect(updatedInitiative.state).toBe(InitiativeState.PLANNED);
106109
});
107110

108111
it("should list initiatives", async () => {

0 commit comments

Comments
 (0)