chore: Routing form - Add submitted_at and Sort entries with latest on top (#17491)

* chore: Routing form - Add submitted_at and sort rows by this timestamp in reporting

* fix e2e

* fix e2e

* Update basic.e2e.ts

* Update basic.e2e.ts

* Update
This commit is contained in:
Anik Dhabal Babu
2024-11-11 19:57:57 +05:30
committed by GitHub
parent ae9063804d
commit aaa75100d4
2 changed files with 12 additions and 5 deletions
@@ -327,12 +327,13 @@ test.describe("Routing Forms", () => {
// @see https://github.com/calcom/cal.com/pull/17229
"Routed To",
"Booked At",
"Submitted At",
]);
/* Last two columns are "Routed To" and "Booked At" */
expect(responses).toEqual([
["event-routing", "Option-2", "Option-2", "Option-2", "Option-2", "", ""],
["external-redirect", "Option-2", "Option-2", "Option-2", "Option-2", "", ""],
["custom-page", "Option-2", "Option-2", "Option-2", "Option-2", "", ""],
["custom-page", "Option-2", "Option-2", "Option-2", "Option-2", "", "", expect.any(String)],
["external-redirect", "Option-2", "Option-2", "Option-2", "Option-2", "", "", expect.any(String)],
["event-routing", "Option-2", "Option-2", "Option-2", "Option-2", "", "", expect.any(String)],
]);
await page.goto(`apps/routing-forms/route-builder/${routingForm.id}`);
@@ -592,7 +593,9 @@ test.describe("Routing Forms", () => {
await page.click('[data-testid="test-routing"]');
await page.waitForSelector("text=Attribute logic matched: No");
await page.waitForSelector("text=Attribute logic fallback matched: Yes");
await page.waitForSelector("text=All assigned members of the team event type. Consider adding some attribute rules to fallback.");
await page.waitForSelector(
"text=All assigned members of the team event type. Consider adding some attribute rules to fallback."
);
await page.click('[data-testid="dialog-rejection"]');
})();
});
@@ -61,6 +61,9 @@ const getRows = async ({ ctx: { prisma }, input }: ReportHandlerOptions) => {
},
},
},
orderBy: {
createdAt: "desc",
},
take,
skip,
});
@@ -120,13 +123,14 @@ function presenter(args: {
const formatDate = makeFormatDate(ctx.user.locale, ctx.user.timeZone);
return {
nextCursor,
headers: [...headers, "Routed To", "Booked At"],
headers: [...headers, "Routed To", "Booked At", "Submitted At"],
responses: responses.map((r, i) => {
const currentRow = rows[i];
return [
...r,
currentRow.routedToBooking?.user?.email || "",
currentRow.routedToBooking?.createdAt ? formatDate(currentRow.routedToBooking.createdAt) : "",
formatDate(currentRow.createdAt),
];
}),
};