fix(web): reuse project combobox in timeline popovers
This commit is contained in:
@@ -4845,10 +4845,12 @@ describe("assistant import/export and dispo tools", () => {
|
||||
const commentFindUnique = vi.fn().mockResolvedValue({
|
||||
id: "comment_1",
|
||||
authorId: "user_1",
|
||||
entityType: "estimate",
|
||||
entityId: "est_1",
|
||||
});
|
||||
const db = {
|
||||
user: {
|
||||
findUnique: vi.fn().mockResolvedValue({ id: "user_1", systemRole: "USER" }),
|
||||
estimate: {
|
||||
findUnique: vi.fn().mockResolvedValue({ id: "est_1" }),
|
||||
},
|
||||
comment: {
|
||||
findMany: vi.fn().mockResolvedValue([
|
||||
@@ -4931,8 +4933,17 @@ describe("assistant import/export and dispo tools", () => {
|
||||
},
|
||||
orderBy: { createdAt: "asc" },
|
||||
});
|
||||
expect(db.user.findUnique).toHaveBeenCalledWith({
|
||||
where: { email: "assistant@example.com" },
|
||||
expect(db.estimate.findUnique).toHaveBeenCalledTimes(3);
|
||||
expect(db.estimate.findUnique).toHaveBeenNthCalledWith(1, {
|
||||
where: { id: "est_1" },
|
||||
select: { id: true },
|
||||
});
|
||||
expect(db.estimate.findUnique).toHaveBeenNthCalledWith(2, {
|
||||
where: { id: "est_1" },
|
||||
select: { id: true },
|
||||
});
|
||||
expect(db.estimate.findUnique).toHaveBeenNthCalledWith(3, {
|
||||
where: { id: "est_1" },
|
||||
select: { id: true },
|
||||
});
|
||||
expect(db.comment.create).toHaveBeenCalledWith({
|
||||
@@ -4949,7 +4960,7 @@ describe("assistant import/export and dispo tools", () => {
|
||||
});
|
||||
expect(commentFindUnique).toHaveBeenCalledWith({
|
||||
where: { id: "comment_1" },
|
||||
select: { id: true, authorId: true },
|
||||
select: { id: true, authorId: true, entityType: true, entityId: true },
|
||||
});
|
||||
expect(db.comment.update).toHaveBeenCalledWith({
|
||||
where: { id: "comment_1" },
|
||||
@@ -5003,7 +5014,7 @@ describe("assistant import/export and dispo tools", () => {
|
||||
it("returns a stable assistant error when creating a comment with an empty body", async () => {
|
||||
const ctx = createToolContext(
|
||||
{
|
||||
user: {
|
||||
estimate: {
|
||||
findUnique: vi.fn(),
|
||||
},
|
||||
comment: {
|
||||
@@ -5026,14 +5037,13 @@ describe("assistant import/export and dispo tools", () => {
|
||||
expect(JSON.parse(result.content)).toEqual({
|
||||
error: "Comment body is required.",
|
||||
});
|
||||
expect(ctx.db.user.findUnique).not.toHaveBeenCalled();
|
||||
expect(ctx.db.comment.create).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("returns a stable assistant error when creating a comment with a body that is too long", async () => {
|
||||
const ctx = createToolContext(
|
||||
{
|
||||
user: {
|
||||
estimate: {
|
||||
findUnique: vi.fn(),
|
||||
},
|
||||
comment: {
|
||||
@@ -5056,15 +5066,14 @@ describe("assistant import/export and dispo tools", () => {
|
||||
expect(JSON.parse(result.content)).toEqual({
|
||||
error: "Comment body must be at most 10000 characters.",
|
||||
});
|
||||
expect(ctx.db.user.findUnique).not.toHaveBeenCalled();
|
||||
expect(ctx.db.comment.create).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("returns a stable assistant error when the comment author disappears during creation", async () => {
|
||||
const ctx = createToolContext(
|
||||
{
|
||||
user: {
|
||||
findUnique: vi.fn().mockResolvedValue({ id: "user_1" }),
|
||||
estimate: {
|
||||
findUnique: vi.fn().mockResolvedValue({ id: "est_1" }),
|
||||
},
|
||||
comment: {
|
||||
create: vi.fn().mockRejectedValue({
|
||||
@@ -5095,8 +5104,8 @@ describe("assistant import/export and dispo tools", () => {
|
||||
it("returns a stable assistant error when a mentioned user disappears during comment creation", async () => {
|
||||
const ctx = createToolContext(
|
||||
{
|
||||
user: {
|
||||
findUnique: vi.fn().mockResolvedValue({ id: "user_1" }),
|
||||
estimate: {
|
||||
findUnique: vi.fn().mockResolvedValue({ id: "est_1" }),
|
||||
},
|
||||
comment: {
|
||||
create: vi.fn().mockResolvedValue({
|
||||
@@ -5170,8 +5179,13 @@ describe("assistant import/export and dispo tools", () => {
|
||||
findUnique: vi.fn().mockResolvedValue({
|
||||
id: "comment_1",
|
||||
authorId: "user_2",
|
||||
entityType: "estimate",
|
||||
entityId: "est_1",
|
||||
}),
|
||||
},
|
||||
estimate: {
|
||||
findUnique: vi.fn().mockResolvedValue({ id: "est_1" }),
|
||||
},
|
||||
},
|
||||
{ userRole: SystemRole.CONTROLLER },
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user