Skip to content
Draft
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
21 changes: 20 additions & 1 deletion src/api/Pages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BaseResource } from "./BaseResource";
import { Configuration } from "../Configuration";
import { Page, CreatePage } from "../models/Page";
import { Page, CreatePage, ListPagesParams } from "../models/Page";
import { PaginatedResponse } from "../models/common";

/**
* Pages API resource
Expand Down Expand Up @@ -56,4 +57,22 @@ export class Pages extends BaseResource {
async retrieveProjectPage(workspaceSlug: string, projectId: string, pageId: string): Promise<Page> {
return this.getProjectPage(workspaceSlug, projectId, pageId);
}

/**
* List workspace pages with optional filtering
*/
async listWorkspacePages(workspaceSlug: string, params?: ListPagesParams): Promise<PaginatedResponse<Page>> {
return this.get<PaginatedResponse<Page>>(`/workspaces/${workspaceSlug}/pages/`, params);
}

/**
* List project pages with optional filtering
*/
async listProjectPages(
workspaceSlug: string,
projectId: string,
params?: ListPagesParams
): Promise<PaginatedResponse<Page>> {
return this.get<PaginatedResponse<Page>>(`/workspaces/${workspaceSlug}/projects/${projectId}/pages/`, params);
}
}
5 changes: 5 additions & 0 deletions src/models/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ export interface Page extends BaseModel {
}

export type CreatePage = Partial<Page>;

export interface ListPagesParams {
limit?: number;
offset?: number;
}
25 changes: 20 additions & 5 deletions tests/e2e/project.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createTestClient, randomizeName, wait } from "../helpers/test-utils";
import { e2eConfig } from "./config";
import { Project, Cycle, Module, WorkItem } from "../../src/models";
import { Project, Cycle, Module, WorkItem, Page } from "../../src/models";

describe("End to End Project Test", () => {
// Shared state across tests
Expand All @@ -9,6 +9,7 @@ describe("End to End Project Test", () => {
let project: Project;
let cycle: Cycle;
let module: Module;
let page: Page;
let workItem1: WorkItem;
let workItem2: WorkItem;
let workItem3: WorkItem;
Expand All @@ -31,6 +32,7 @@ describe("End to End Project Test", () => {
await client.projects.updateFeatures(e2eConfig.workspaceSlug, project.id, {
cycles: true,
modules: true,
pages: true,
});
});

Expand Down Expand Up @@ -72,6 +74,22 @@ describe("End to End Project Test", () => {
expect(modules.results.find((m) => m.name === module.name)).toBeDefined();
});

it("should create and list pages", async () => {
const pageName = randomizeName("Test Page");
page = await client.pages.createProjectPage(e2eConfig.workspaceSlug, project.id, {
name: pageName,
description_html: "<p>Test Page Description</p>",
});

expect(page).toBeDefined();
expect(page.id).toBeDefined();
expect(page.name).toBe(pageName);

const pages = await client.pages.listProjectPages(e2eConfig.workspaceSlug, project.id);
expect(pages.results.length).toBeGreaterThan(0);
expect(pages.results.find((p) => p.name === page.name)).toBeDefined();
});

it("should create work items with assignees", async () => {
workItem1 = await client.workItems.create(e2eConfig.workspaceSlug, project.id, {
name: randomizeName("Test Work Item 1"),
Expand Down Expand Up @@ -126,10 +144,7 @@ describe("End to End Project Test", () => {
and: [
...(stateId ? [{ state_id: stateId }] : []),
{
or: [
{ priority: "none" },
{ priority: "high" },
],
or: [{ priority: "none" }, { priority: "high" }],
},
],
},
Expand Down
Loading