Skip to content

Commit

Permalink
fix: change order of eventtypes and routingforms (calcom#17615)
Browse files Browse the repository at this point in the history
* change order of eventtypes and routingforms

* for workflows

* for filtered workflows

* update slug of first expected event-type

* updated due to latest merges

* test to ensure new eventtype added is first in the list

* test for workflows

---------

Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
  • Loading branch information
3 people authored Nov 25, 2024
1 parent 868cf91 commit ad44ca9
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 14 deletions.
12 changes: 6 additions & 6 deletions apps/web/playwright/embed-code-generator.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test.describe("Embed Code Generator Tests", () => {
await page.waitForTimeout(1000);
await expectToContainValidPreviewIframe(page, {
embedType: "inline",
calLink: `${pro.username}/30-min`,
calLink: `${pro.username}/multiple-duration`,
});
});

Expand Down Expand Up @@ -102,7 +102,7 @@ test.describe("Embed Code Generator Tests", () => {
await page.waitForTimeout(1000);
await expectToContainValidPreviewIframe(page, {
embedType: "floating-popup",
calLink: `${pro.username}/30-min`,
calLink: `${pro.username}/multiple-duration`,
});
});

Expand Down Expand Up @@ -140,7 +140,7 @@ test.describe("Embed Code Generator Tests", () => {
await page.waitForTimeout(1000);
await expectToContainValidPreviewIframe(page, {
embedType: "element-click",
calLink: `${pro.username}/30-min`,
calLink: `${pro.username}/multiple-duration`,
});
});
});
Expand Down Expand Up @@ -238,7 +238,7 @@ test.describe("Embed Code Generator Tests", () => {
await page.waitForTimeout(1000);
await expectToContainValidPreviewIframe(page, {
embedType: "inline",
calLink: `${user.username}/30-min`,
calLink: `${user.username}/multiple-duration`,
bookerUrl: getOrgFullOrigin(org?.slug ?? ""),
});
});
Expand Down Expand Up @@ -279,7 +279,7 @@ test.describe("Embed Code Generator Tests", () => {
await page.waitForTimeout(1000);
await expectToContainValidPreviewIframe(page, {
embedType: "floating-popup",
calLink: `${user.username}/30-min`,
calLink: `${user.username}/multiple-duration`,
bookerUrl: getOrgFullOrigin(org?.slug ?? ""),
});
});
Expand Down Expand Up @@ -319,7 +319,7 @@ test.describe("Embed Code Generator Tests", () => {
await page.waitForTimeout(1000);
await expectToContainValidPreviewIframe(page, {
embedType: "element-click",
calLink: `${user.username}/30-min`,
calLink: `${user.username}/multiple-duration`,
bookerUrl: getOrgFullOrigin(org?.slug ?? ""),
});
});
Expand Down
10 changes: 10 additions & 0 deletions apps/web/playwright/event-types.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ testBothFutureAndLegacyRoutes.describe("Event Types tests", () => {
await expect(page.locator(`text='${eventTitle}'`)).toBeVisible();
});

test("new event type appears first in the list", async ({ page }) => {
const nonce = randomString(3);
const eventTitle = `hello ${nonce}`;
await createNewEventType(page, { eventTitle });
await page.goto("/event-types");
const firstEvent = page.locator("[data-testid=event-types] > li a").first();
const firstEventTitle = await firstEvent.getAttribute("title");
await expect(firstEventTitle).toBe(eventTitle);
});

test("enabling recurring event comes with default options", async ({ page }) => {
const nonce = randomString(3);
const eventTitle = `my recurring event ${nonce}`;
Expand Down
15 changes: 15 additions & 0 deletions packages/app-store/routing-forms/playwright/tests/basic.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ test.describe("Routing Forms", () => {
await expect(page.getByTestId(`404-page`)).toBeVisible();
});

test("recently added form appears first in the list", async ({ page }) => {
await addForm(page, { name: "Test Form 1" });
await page.goto(`apps/routing-forms/forms`);
await page.waitForSelector('[data-testid="routing-forms-list"]');
await expect(page.locator('[data-testid="routing-forms-list"] > div h1')).toHaveCount(1);

await addForm(page, { name: "Test Form 2" });
await page.goto(`apps/routing-forms/forms`);
await page.waitForSelector('[data-testid="routing-forms-list"]');
await expect(page.locator('[data-testid="routing-forms-list"] > div h1')).toHaveCount(2);

const firstForm = page.locator('[data-testid="routing-forms-list"] > div h1').first();
await expect(firstForm).toHaveText("Test Form 2");
});

test("should be able to edit a newly created form", async ({ page }) => {
const formId = await addForm(page);
const description = "Test Description";
Expand Down
2 changes: 1 addition & 1 deletion packages/app-store/routing-forms/trpc/forms.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const formsHandler = async ({ ctx, input }: FormsHandlerOptions) => {
position: "desc",
},
{
createdAt: "asc",
createdAt: "desc",
},
],
include: {
Expand Down
4 changes: 2 additions & 2 deletions packages/lib/server/repository/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class WorkflowRepository {
position: "desc",
},
{
id: "asc",
id: "desc",
},
],
});
Expand Down Expand Up @@ -267,7 +267,7 @@ export class WorkflowRepository {
where,
include: includedFields,
orderBy: {
id: "asc",
id: "desc",
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const getEventTypesFromGroup = async ({
position: "desc",
},
{
id: "asc",
id: "desc",
},
],
limit,
Expand All @@ -94,7 +94,7 @@ export const getEventTypesFromGroup = async ({
position: "desc",
},
{
id: "asc",
id: "desc",
},
],
limit,
Expand All @@ -108,8 +108,8 @@ export const getEventTypesFromGroup = async ({
if (a.position !== b.position) {
return b.position - a.position;
}
// Then by id in ascending order
return a.id - b.id;
// Then by id in descending order
return b.id - a.id;
});

eventTypes.push(...userEventTypes);
Expand All @@ -136,7 +136,7 @@ export const getEventTypesFromGroup = async ({
position: "desc",
},
{
id: "asc",
id: "desc",
},
],
})) ?? [];
Expand Down

0 comments on commit ad44ca9

Please sign in to comment.