-
Notifications
You must be signed in to change notification settings - Fork 1.5k
test: wire desktop and utils coverage into turbo #1808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||||||||||||||||||||
| import { describe, expect, it } from "vitest"; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import { | ||||||||||||||||||||||
| calculateStrokeDashoffset, | ||||||||||||||||||||||
| classNames, | ||||||||||||||||||||||
| getDisplayProgress, | ||||||||||||||||||||||
| getProgressCircleConfig, | ||||||||||||||||||||||
| isEmailAllowedByRestriction, | ||||||||||||||||||||||
| uuidFormat, | ||||||||||||||||||||||
| uuidParse, | ||||||||||||||||||||||
| } from "./helpers"; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| describe("helpers", () => { | ||||||||||||||||||||||
| it("merges class names and resolves conflicting Tailwind utilities", () => { | ||||||||||||||||||||||
| expect(classNames("px-2 text-sm", false, "px-4")).toBe("text-sm px-4"); | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| it("round-trips uuid formatting helpers", () => { | ||||||||||||||||||||||
| const formatted = "123e4567-e89b-12d3-a456-426614174000"; | ||||||||||||||||||||||
| const compact = "123e4567e89b12d3a456426614174000"; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| expect(uuidParse(formatted)).toBe(compact); | ||||||||||||||||||||||
| expect(uuidFormat(compact)).toBe(formatted); | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| it("calculates progress circle geometry", () => { | ||||||||||||||||||||||
| const { circumference } = getProgressCircleConfig(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| expect(calculateStrokeDashoffset(25, circumference)).toBeCloseTo( | ||||||||||||||||||||||
| circumference * 0.75, | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
| expect(calculateStrokeDashoffset(100, circumference)).toBe(0); | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| it("prefers upload progress over processing progress", () => { | ||||||||||||||||||||||
| expect(getDisplayProgress(42, 10)).toBe(42); | ||||||||||||||||||||||
| expect(getDisplayProgress(undefined, 64)).toBe(64); | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
Comment on lines
+35
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: packages/utils/src/helpers.test.ts
Line: 35-38
Comment:
The `getDisplayProgress` test skips the `uploadProgress = 0` case. Because the implementation checks `uploadProgress !== undefined`, passing `0` returns `0` and never falls back to `processingProgress`. This is a non-obvious semantic boundary worth pinning so a future change to `=== undefined` vs. a falsy check doesn't silently regress.
```suggestion
it("prefers upload progress over processing progress", () => {
expect(getDisplayProgress(42, 10)).toBe(42);
expect(getDisplayProgress(undefined, 64)).toBe(64);
// uploadProgress=0 is defined, so processing progress is NOT used
expect(getDisplayProgress(0, 64)).toBe(0);
});
```
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| it("allows emails by exact address or domain restrictions", () => { | ||||||||||||||||||||||
| expect(isEmailAllowedByRestriction("owner@cap.so", "")).toBe(true); | ||||||||||||||||||||||
| expect(isEmailAllowedByRestriction("owner@cap.so", "cap.so")).toBe(true); | ||||||||||||||||||||||
| expect( | ||||||||||||||||||||||
| isEmailAllowedByRestriction("owner@cap.so", "admin@example.com"), | ||||||||||||||||||||||
| ).toBe(false); | ||||||||||||||||||||||
| expect( | ||||||||||||||||||||||
| isEmailAllowedByRestriction("admin@example.com", " admin@example.com "), | ||||||||||||||||||||||
| ).toBe(true); | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cap/utilshas novitest.config.ts. Vitest will default to Node environment and the standard**/*.test.*glob, which works for the current pure-function tests. As the package grows (or if path aliases fromtsconfigare needed), the absence of an explicit config may cause friction. Consider adding a minimal config now to make the test environment intentional.Prompt To Fix With AI