From 47b252b8e20e334264a64db2322577e2cac82d00 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 16:29:47 +0000 Subject: [PATCH 1/3] Add regression test for PR #272: locked equity allocation Co-Authored-By: raulp@hey.com --- .../invoices/locked-equity-allocation.spec.ts | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 e2e/tests/company/invoices/locked-equity-allocation.spec.ts diff --git a/e2e/tests/company/invoices/locked-equity-allocation.spec.ts b/e2e/tests/company/invoices/locked-equity-allocation.spec.ts new file mode 100644 index 00000000..c6e0667f --- /dev/null +++ b/e2e/tests/company/invoices/locked-equity-allocation.spec.ts @@ -0,0 +1,55 @@ +import { db } from "@test/db"; +import { companiesFactory } from "@test/factories/companies"; +import { companyContractorsFactory } from "@test/factories/companyContractors"; +import { equityAllocationsFactory } from "@test/factories/equityAllocations"; +import { usersFactory } from "@test/factories/users"; +import { login } from "@test/helpers/auth"; +import { expect, test } from "@test/index"; +import { PayRateType } from "@/db/enums"; + +test.describe("Invoice equity percentage with locked allocations", () => { + test("sets default invoice equity percentage based on locked allocation", async ({ page }) => { + const { company } = await companiesFactory.createCompletedOnboarding({ + equityCompensationEnabled: true, + }); + + const { user } = await usersFactory.create(); + + const { companyContractor } = await companyContractorsFactory.create({ + companyId: company.id, + userId: user.id, + payRateInSubunits: 5000, // $50/hr + payRateType: PayRateType.Hourly, + }); + + const currentYear = new Date().getFullYear(); + await equityAllocationsFactory.create({ + companyContractorId: companyContractor.id, + equityPercentage: 30, + year: currentYear, + locked: true, + status: "approved", + }); + + await login(page, user); + + await page.goto("/invoices/new"); + + await expect(page.getByRole("textbox", { name: "Cash vs equity split" })).toHaveValue("30"); + + await expect(page.getByRole("textbox", { name: "Cash vs equity split" })).toBeDisabled(); + + await page.getByLabel("Hours").fill("2:00"); + await page.getByLabel("Date").fill(`${currentYear}-05-01`); + await page.getByPlaceholder("Description").fill("Test work"); + + const totalsLocator = page.locator("footer > div:last-child"); + await expect(totalsLocator).toContainText("Total services$100"); + await expect(totalsLocator).toContainText("Swapped for equity (not paid in cash)$30"); + await expect(totalsLocator).toContainText("Net amount in cash$70"); + + await page.getByRole("button", { name: "Send invoice" }).click(); + + await expect(page.locator("tbody")).toContainText("Awaiting approval"); + }); +}); From c8f28784cc16798c64c9aea0b838f7968193ebb5 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 16:34:39 +0000 Subject: [PATCH 2/3] Fix: Remove unused db import to fix linting errors Co-Authored-By: raulp@hey.com --- e2e/tests/company/invoices/locked-equity-allocation.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e/tests/company/invoices/locked-equity-allocation.spec.ts b/e2e/tests/company/invoices/locked-equity-allocation.spec.ts index c6e0667f..3d37a45a 100644 --- a/e2e/tests/company/invoices/locked-equity-allocation.spec.ts +++ b/e2e/tests/company/invoices/locked-equity-allocation.spec.ts @@ -1,4 +1,3 @@ -import { db } from "@test/db"; import { companiesFactory } from "@test/factories/companies"; import { companyContractorsFactory } from "@test/factories/companyContractors"; import { equityAllocationsFactory } from "@test/factories/equityAllocations"; From 9a6f48a89d987e3dbb94aa20791453fb06c29222 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 16:38:11 +0000 Subject: [PATCH 3/3] [autofix.ci] apply automated fixes --- .../invoices/locked-equity-allocation.spec.ts | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/e2e/tests/company/invoices/locked-equity-allocation.spec.ts b/e2e/tests/company/invoices/locked-equity-allocation.spec.ts index 3d37a45a..8aa58b30 100644 --- a/e2e/tests/company/invoices/locked-equity-allocation.spec.ts +++ b/e2e/tests/company/invoices/locked-equity-allocation.spec.ts @@ -11,16 +11,16 @@ test.describe("Invoice equity percentage with locked allocations", () => { const { company } = await companiesFactory.createCompletedOnboarding({ equityCompensationEnabled: true, }); - + const { user } = await usersFactory.create(); - + const { companyContractor } = await companyContractorsFactory.create({ companyId: company.id, userId: user.id, payRateInSubunits: 5000, // $50/hr payRateType: PayRateType.Hourly, }); - + const currentYear = new Date().getFullYear(); await equityAllocationsFactory.create({ companyContractorId: companyContractor.id, @@ -29,26 +29,26 @@ test.describe("Invoice equity percentage with locked allocations", () => { locked: true, status: "approved", }); - + await login(page, user); - + await page.goto("/invoices/new"); - + await expect(page.getByRole("textbox", { name: "Cash vs equity split" })).toHaveValue("30"); - + await expect(page.getByRole("textbox", { name: "Cash vs equity split" })).toBeDisabled(); - + await page.getByLabel("Hours").fill("2:00"); await page.getByLabel("Date").fill(`${currentYear}-05-01`); await page.getByPlaceholder("Description").fill("Test work"); - + const totalsLocator = page.locator("footer > div:last-child"); await expect(totalsLocator).toContainText("Total services$100"); await expect(totalsLocator).toContainText("Swapped for equity (not paid in cash)$30"); await expect(totalsLocator).toContainText("Net amount in cash$70"); - + await page.getByRole("button", { name: "Send invoice" }).click(); - + await expect(page.locator("tbody")).toContainText("Awaiting approval"); }); });