Compare commits

...

45 Commits

Author SHA1 Message Date
19a8a2bba8 add script to build on mac mini 2025-03-14 15:36:01 -04:00
e9806b83d7 Clip deltaY to +/- 100 (#5793)
* Clip deltaY to +/- 100
Should fix #5120

* Lint

* Fix the clip with @nickmccleery's suggestion
2025-03-14 13:17:10 -04:00
0229105158 fix: add better errors for missing commas in arrays and objects (#5210)
* fix: add better errors for missing commas in arrays and objects

* chore: add object prop shorthand missing comma test

* fix: wording on unexpected character in arrays and objects

* fix: don't eagerly evaluate whether there is a closing brace/bracket

* feat: exit early when detecting missing commas if encountering invalid tokens

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* fix: updated reserved word in test to replace removed one

---------

Co-authored-by: Tom Pridham <pridham.tom@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-14 16:52:10 +00:00
9e37e13b6b Further unfrig playwright (#5794)
* Bail on cleanup after 10s; move setup even higher

* Give macos time before starting an electron instance

* Try it again

* Again

* Remove stale TODO

* Use Kolmogorov complexity instead of text for ai assertions

* Help out prompt-to-edit test with being more explicit

* Try to give Mac more time to open a window

* Fix the other var change for prompt-to-edit test

* Forgot this

* Try some crazier shit

* 🤦 I forgot the return.

* Ok things were actually just not working well at all

* Fix export test to expect smaller size

* yarn tsc && yarn lint && yarn fmt
2025-03-14 10:19:58 +00:00
58e0c0e916 Improve KCL Samples (#5767)
* improve KCL Samples & .gitignore

* update block and car wheel assembly

* update flange and lego, delete flange xy

* artifacts

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* scale

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* docs

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: Jess Frazelle <github@jessfraz.com>
2025-03-13 23:38:51 -07:00
dd99c27d56 bump all the rust things (#5806)
* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* getrandom

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* simlimk

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* Revert "simlimk"

This reverts commit 3f5221db7e.

* terst

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-13 23:38:41 -07:00
3cff26b987 make sure all enter sketch mode are with the stuff they need in the same batch order always (#5646)
* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* comment out

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* update artifacts

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* small

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* last of the artifacts

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* update playwirght

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* add crazy multi-profile test

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* steps

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix artifact graph

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* cleanup

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates
;

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* more artifact grph

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* turn back on playwright

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fmt

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* playwright fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* playwright fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-13 21:59:39 -07:00
78ac5b0a11 make deterministic date cleaner (#5777)
* make deterministic date cleaner

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* update all the steps

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* more steps

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* steps

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-13 18:01:47 -07:00
24d0b14668 change runner (#5800)
Revert "try codspeed runner (#5796)"

This reverts commit ec64daa01f.
2025-03-13 13:57:24 -07:00
6fb32eeff2 fix python bindings building on linux (#5795)
* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates;

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-13 12:05:45 -07:00
ec64daa01f try codspeed runner (#5796)
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-13 12:05:15 -07:00
e8886bb358 hide program memory source ranges from the app (#5759)
* hide program memory source ranges from the app

Signed-off-by: Jess Frazelle <github@jessfraz.com>

fix unit tests

Signed-off-by: Jess Frazelle <github@jessfraz.com>

fix memory

Signed-off-by: Jess Frazelle <github@jessfraz.com>

remove from paths

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix program memory source ranges

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
2025-03-13 11:13:33 -07:00
05a6313d97 try execute bench with walltime (#5772)
* try execute bench

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* timeout longer

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* timeout longer

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-13 10:33:00 -07:00
80f78e1c61 Revolve/Sweep multiple sketches at once (#5779)
* revolve multiple sketches at once

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* do the same for swweep

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* do the same for swweep

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-13 09:38:22 -07:00
c441a3ab1c Fix playwright mental model, don't make me psycho, thanks (#5680)
* Fix flakey tests with new toolbar.exitSketch

* tsc && lint && fmt

* Disable pw electron thing again

* Unfrig Playwright-Electron a ton; fix another ton of flakes.

* More deflaky

* Fix a ton of tests and playwright related hell

* Run jess's magic incantation to build rust kcl things

* yarn tsc

* yarn lint

* yarn fmt

* Remove double logs

* Revert to old settings spreads momentarily

* Expect error *in the fixtureSetup*, does not circumvent typechecking for regular usage

* Fix unit tests
2025-03-13 10:54:00 -04:00
e894242768 Add warning when using a module with no return value (#5771)
* Add warning when using a module with no return value

* Update output files since changing source range of the pipeline argument

* Change wording of error message to not use the term unlabeled
2025-03-12 18:05:18 +00:00
d8dff03746 Add cache for wasm in build-apps (#5758)
* WIP: break out e2e snapshots

* Separate prepare-wasm job

* Force e2e to run on pierremtb/adhoc/break-out-snapshots

* Quick fix

* Quick fix2

* Quick fix3

* Quick fix4

* Quick fix5

* Remove ifs for flow tests

* Clean up for review

* Cache wasm on PR for build-apps

* Add checks on build wasm tings

* Clean up for review
2025-03-12 13:53:30 -04:00
60aee7ddba Bump the security group with 2 updates (#5773)
Bumps the security group with 2 updates: [@babel/helpers](https://github.com/babel/babel/tree/HEAD/packages/babel-helpers) and [@babel/runtime](https://github.com/babel/babel/tree/HEAD/packages/babel-runtime).


Updates `@babel/helpers` from 7.25.0 to 7.26.10
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.26.10/packages/babel-helpers)

Updates `@babel/runtime` from 7.25.0 to 7.26.10
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.26.10/packages/babel-runtime)

---
updated-dependencies:
- dependency-name: "@babel/helpers"
  dependency-type: indirect
  dependency-group: security
- dependency-name: "@babel/runtime"
  dependency-type: indirect
  dependency-group: security
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-12 10:03:14 -07:00
6c09da24a4 change server path for vscode extension (#5769)
change server path

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-12 16:46:18 +00:00
b61cd3123f KCL: Fix two cryptic error messages (#5745)
Firstly, before the code "{x = 1, y = }" would give the dreaded "unexpected token" error.

Now it says "This property has a label, but no value. Put some value after the equals sign".
And points to the = symbol with no matching right-hand side value. Yay!

Second fix: before, in the code `f(1, x=)`, the error complained that an unlabeled arg was not permitted there.

Now it says "This argument has a label, but no value. Put some value after the equals sign".
2025-03-12 16:27:10 +00:00
865bf8ae7a KCL: Fix cryptic error when using duplicate edges in fillet call (#5755)
Fixes https://github.com/KittyCAD/modeling-app/issues/4307

Now if you try to fillet the same edge twice in a single fillet command,
the error message is clearer, and the source range will highlight
the specific edges in the array which are duplicated.

Same goes for chamfer.

Note: although the Rust KCL interpreter sends back an array of SourceRange
for each KCL error, the frontend only puts the first one into CodeMirror
diagnostics. We should fix that: https://github.com/KittyCAD/modeling-app/issues/5754
2025-03-12 16:24:27 +00:00
f8e53c6577 Fix web onboarding dismissal infinite loop bug (#5742) 2025-03-12 13:34:11 +00:00
f31c2c6f81 Import geometry work w transforms (#5757)
* make work with imported geometry

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* iupdates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* update known issues

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-12 01:23:21 +00:00
e5c05e1980 change test names kcl-samples (#5766)
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-11 23:29:26 +00:00
6d0da100e5 benchmark retry (#5760)
* benchmark retry

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix times

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix times

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* dont use a custom iter

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* just parse

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* use runs on

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-11 22:21:28 +00:00
b8a0ad7144 Dedicated job for snapshot tests (#5752)
* WIP: break out e2e snapshots

* Separate prepare-wasm job

* Force e2e to run on pierremtb/adhoc/break-out-snapshots

* Quick fix

* Quick fix2

* Quick fix3

* Quick fix4

* Quick fix5

* Remove ifs for flow tests

* Clean up for review

* should-run == 'true' madness
2025-03-11 17:18:42 -04:00
724e65ac97 Hide selection-type args from command palette while in an edit flow (#5763)
* Allow `hidden` config to be a callback

* Hide selection type args if `nodeToEdit` is present

in workflows that have an edit flow set up

* Remove Selection from headerArguments in edit flow tests
2025-03-11 16:29:03 -04:00
b5028f7aa8 Change to not expose exec artifacts (#5700)
Now that the artifact graph is built completely in Rust, these are an
implementation detail that shouldn't be exposed to TS.
2025-03-11 19:09:11 +00:00
df6b4f4c37 Move consts to dir in docs (#5753)
* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* add consts to dir

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* add consts to dir

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-11 18:44:27 +00:00
41eb64925b Improve sketch constraint test (#5756) 2025-03-11 14:14:03 -04:00
fc076173ff Make any error show on ErrorPage, not just route error responses (#5623)
* Make any error show on ErrorPage, not just route error responses

Closes #5620 by making any error show on the page so the user can copy
it for use in an issue. Previously, the logic was too narrow and only
showed the error on the page if `isRouterErrorResponse` was true.

* @nadr0's feedback

thanks for giving my crap work a review

* Update src/components/ErrorPage.tsx

Co-authored-by: Jonathan Tran <jonnytran@gmail.com>

* @nadr0 feedback, handle overflowing error case

---------

Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
Co-authored-by: Kevin Nadro <nadr0@users.noreply.github.com>
2025-03-11 17:46:07 +00:00
98822869f7 fix settings docs names (#5751)
* fix settings docs names

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* add consts to dir

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-11 10:20:18 -07:00
df0510c199 cleandocs (#5750)
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-11 08:51:23 -07:00
fda65bcbd7 codspeed (#5741)
* codspeed

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* Update cargo-bench.yml

* Update cargo-bench.yml

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* Update settings.md (#5743)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-11 08:03:49 -07:00
c37e564b59 fix wheels (#5748)
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-11 08:01:49 -07:00
d6ad4b6e66 KCL: Fix cryptic error in type mismatch (#5735)
Previous error message:
"Expected a kcl_lib::execution::geometry::SolidSet but found Sketch"

New error message:
"Expected a SolidSet but found Sketch. You can convert a sketch (2D) into a Solid (3D) by calling a function like `extrude` or `revolve`"

Two improvements:
 - Don't print the fully-qualified Rust name (e.g. kcl_lib::executor::Solid) instead use the last part of that (e.g. just Solid)
 - Allow specific suggestions for combinations of got/want (e.g. "You can convert a sketch (2D) into a Solid (3D) by calling a function like `extrude` or `revolve`")

Closes #5616
2025-03-10 22:53:16 -05:00
546b4ea3b8 generate the settings docs (#5740)
* generate the settings docs

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fmt

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* Update docs/kcl/settings.md

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-10 18:59:10 -07:00
310932dc5a run rust benchmarks and compare on prs (#5734)
* run benchmarks and compare on prs

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* run benchmarks and compare on prs

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* benchmark kcl-samples

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
2025-03-10 18:04:16 -07:00
51459bb413 turn on insta snapshot for step file output (#5732)
* turn on insta snapshot for step file output

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* use a macro for the kcl-samples

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* Update rust/kcl-directory-test-macro/src/lib.rs

Co-authored-by: Jonathan Tran <jonnytran@gmail.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* control the order

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* engine

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* update steps

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-10 15:35:45 -07:00
e00dae11ba Fix cryptic parser error (#5731)
# Problem

Before: "unexpected token |>", highlights the |>

After: "This argument needs a label, but it doesn't have one", highlights the argument with no label

Closes #5724 

# Discussion

I am trying a new approach to the parser: instead of parsing the specific correct thing we need, parse a more general form, then later, narrow it down to specifics and return a nice error if it's wrong. For example, instead of parsing labeled arguments, parse labeled OR unlabeled arguments. Then later check that the only unlabeled arg is the first one, and return a nice error if there's any other. This worked nicely for this PR, hopefully the approach will work for other "cryptic error" issues.
2025-03-10 17:09:54 -05:00
831c7f764a cargo publish was too big (#5699)
* cargo publish too big

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* cargo publish too big

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* bunmp again

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-10 14:29:04 -07:00
ec4ad268f7 Fix toolchain file copy to work on all platforms (#5733) 2025-03-10 16:44:44 -04:00
be640ea0bd ci: Fix e2e workflow to install rust toolchain when needed (#5728)
* ci: Fix e2e workflow to install rust toolchain when needed

* Unify conditions

* Pull out condition to variable

* Add echo so that debuggin is easier
2025-03-10 14:53:43 -04:00
f8ceab2233 Fix a recast bug and don't delete the user's code if parsing fails (#5663)
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-03-08 09:33:45 -05:00
aea82e004a KCL: Convert x/y lines to use keyword arguments (#5615)
Previously, `xLine`, `xLineTo`, `yLine` and `yLineTo` used positional arguments. Now:

- `xLineTo` and `yLineTo` have been removed
- `xLine` and `yLine` both use keyword arguments:
  - `length`, optional (i.e. a relative distance along the X or Y axis)
  - `endAbsolute` optional (i.e. an absolute point along the X or Y axis)
  - `tag` optional
- Exactly one of `length` or `endAbsolute` must be given. Not both, not neither.

For example:

```
// Old way
|> xLine(6.04, %)
|> yLineTo(20, %, $base)

// New way
|> xLine(length = 6.04)
|> yLine(endAbsolute = 20, tag = $base)
```

This also improves some of the general-purpose keyword arguments code in modeling app's TS codebase.
2025-03-07 22:07:16 -06:00
927 changed files with 5955590 additions and 249441 deletions

View File

@ -16,15 +16,21 @@ jobs:
cache: 'yarn' cache: 'yarn'
- name: Install dependencies - name: Install dependencies
run: yarn run: yarn
- name: Setup Rust - name: Use correct Rust toolchain
uses: dtolnay/rust-toolchain@stable shell: bash
- name: Cache wasm run: |
uses: Swatinem/rust-cache@v2 [ -e rust-toolchain.toml ] || cp rust/rust-toolchain.toml ./
- name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with: with:
workspaces: './rust' cache: false # Configured below.
- uses: taiki-e/install-action@955a6ff1416eae278c9f833008a9beb4b7f9afe3 - uses: taiki-e/install-action@955a6ff1416eae278c9f833008a9beb4b7f9afe3
with: with:
tool: wasm-pack tool: wasm-pack
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: rust
- name: build wasm - name: build wasm
run: yarn build:wasm run: yarn build:wasm

View File

@ -33,19 +33,63 @@ jobs:
- run: yarn install - run: yarn install
- name: Setup Rust - id: filter
uses: dtolnay/rust-toolchain@stable name: Check for Rust changes
uses: dorny/paths-filter@v3
- uses: Swatinem/rust-cache@v2
with: with:
workspaces: './rust' filters: |
rust:
- 'rust/**'
- name: Download Wasm Cache
id: download-wasm
if: ${{ github.event_name == 'pull_request' && steps.filter.outputs.rust == 'false' }}
uses: dawidd6/action-download-artifact@v7
continue-on-error: true
with:
github_token: ${{secrets.GITHUB_TOKEN}}
name: wasm-bundle
workflow: build-and-store-wasm.yml
branch: main
path: rust/kcl-wasm-lib/pkg
- name: Build WASM condition
id: wasm
run: |
set -euox pipefail
# Build wasm if this is a push to main or tag, there are Rust changes, or
# downloading from the wasm cache failed.
if [[ ${{github.event_name}} == 'push' || ${{steps.filter.outputs.rust}} == 'true' || ${{steps.download-wasm.outcome}} == 'failure' ]]; then
echo "should-build-wasm=true" >> $GITHUB_OUTPUT
else
echo "should-build-wasm=false" >> $GITHUB_OUTPUT
fi
- name: Use correct Rust toolchain
if: ${{ steps.wasm.outputs.should-build-wasm == 'true' }}
shell: bash
run: |
[ -e rust-toolchain.toml ] || cp rust/rust-toolchain.toml ./
- name: Install rust
if: ${{ steps.wasm.outputs.should-build-wasm == 'true' }}
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache: false # Configured below.
# TODO: see if we can fetch from main instead if no diff at rust
- uses: taiki-e/install-action@955a6ff1416eae278c9f833008a9beb4b7f9afe3 - uses: taiki-e/install-action@955a6ff1416eae278c9f833008a9beb4b7f9afe3
if: ${{ steps.wasm.outputs.should-build-wasm == 'true' }}
with: with:
tool: wasm-pack tool: wasm-pack
- name: Rust Cache
if: ${{ steps.wasm.outputs.should-build-wasm == 'true' }}
uses: Swatinem/rust-cache@v2
with:
workspaces: rust
- name: Run build:wasm - name: Run build:wasm
if: ${{ steps.wasm.outputs.should-build-wasm == 'true' }}
run: "yarn build:wasm" run: "yarn build:wasm"
- name: Set nightly version, product name, release notes, and icons - name: Set nightly version, product name, release notes, and icons

62
.github/workflows/cargo-bench.yml vendored Normal file
View File

@ -0,0 +1,62 @@
on:
push:
branches:
- main
paths:
- '**.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
- '**/rust-toolchain.toml'
- .github/workflows/cargo-bench.yml
pull_request:
paths:
- '**.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
- '**/rust-toolchain.toml'
- .github/workflows/cargo-bench.yml
workflow_dispatch:
permissions:
contents: read
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
name: cargo bench
jobs:
cargo-bench:
name: cargo bench
runs-on:
- runs-on=${{ github.run_id }}
- runner=32cpu-linux-x64
- extras=s3-cache
steps:
- uses: runs-on/action@v1
- uses: actions/checkout@v4
- name: Use correct Rust toolchain
shell: bash
run: |
[ -e rust-toolchain.toml ] || cp rust/rust-toolchain.toml ./
- name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache: rust
- name: Install dependencies
run: |
cargo install cargo-criterion
cargo install cargo-codspeed
cd rust/kcl-lib
cargo add --dev codspeed-criterion-compat --rename criterion
- name: Build the benchmark target(s)
run: |
cd rust
cargo codspeed build --measurement-mode walltime
- name: Run the benchmarks
uses: CodSpeedHQ/action@v3
with:
working-directory: rust
run: cargo codspeed run
token: ${{ secrets.CODSPEED_TOKEN }}
mode: walltime
env:
KITTYCAD_API_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN }}

View File

@ -22,7 +22,7 @@ jobs:
- name: Use correct Rust toolchain - name: Use correct Rust toolchain
shell: bash shell: bash
run: | run: |
cp --update=none rust/rust-toolchain.toml ./ || true [ -e rust-toolchain.toml ] || cp rust/rust-toolchain.toml ./
- name: Install rust - name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1 uses: actions-rust-lang/setup-rust-toolchain@v1
with: with:

View File

@ -29,7 +29,7 @@ jobs:
- name: Use correct Rust toolchain - name: Use correct Rust toolchain
shell: bash shell: bash
run: | run: |
cp --update=none rust/rust-toolchain.toml ./ || true [ -e rust-toolchain.toml ] || cp rust/rust-toolchain.toml ./
- name: Install rust - name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1 uses: actions-rust-lang/setup-rust-toolchain@v1
with: with:

View File

@ -31,7 +31,7 @@ jobs:
- name: Use correct Rust toolchain - name: Use correct Rust toolchain
shell: bash shell: bash
run: | run: |
cp --update=none rust/rust-toolchain.toml ./ || true [ -e rust-toolchain.toml ] || cp rust/rust-toolchain.toml ./
- name: Install rust - name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1 uses: actions-rust-lang/setup-rust-toolchain@v1
with: with:

View File

@ -29,7 +29,7 @@ jobs:
- name: Use correct Rust toolchain - name: Use correct Rust toolchain
shell: bash shell: bash
run: | run: |
cp --update=none rust/rust-toolchain.toml ./ || true [ -e rust-toolchain.toml ] || cp rust/rust-toolchain.toml ./
- name: Install rust - name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1 uses: actions-rust-lang/setup-rust-toolchain@v1
with: with:

View File

@ -26,9 +26,11 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Fetch the base branch - name: Fetch the base branch
if: ${{ github.event_name == 'pull_request' }} if: ${{ github.event_name == 'pull_request' }}
run: git fetch origin ${{ github.base_ref }} --depth=1 run: git fetch origin ${{ github.base_ref }} --depth=1
- name: Check for path changes - name: Check for path changes
id: path-changes id: path-changes
shell: bash shell: bash
@ -48,6 +50,7 @@ jobs:
else else
echo "significant=false" >> $GITHUB_OUTPUT echo "significant=false" >> $GITHUB_OUTPUT
fi fi
- name: Should run - name: Should run
id: should-run id: should-run
shell: bash shell: bash
@ -60,6 +63,7 @@ jobs:
else else
echo "should-run=false" >> $GITHUB_OUTPUT echo "should-run=false" >> $GITHUB_OUTPUT
fi fi
- name: Display conditions - name: Display conditions
shell: bash shell: bash
run: | run: |
@ -68,7 +72,216 @@ jobs:
echo "significant: ${{ steps.path-changes.outputs.significant }}" echo "significant: ${{ steps.path-changes.outputs.significant }}"
echo "should-run: ${{ steps.should-run.outputs.should-run }}" echo "should-run: ${{ steps.should-run.outputs.should-run }}"
prepare-wasm:
# seperate job on Ubuntu to build or fetch the wasm blob once on the fastest runner
runs-on: namespace-profile-ubuntu-8-cores
needs: conditions
steps:
- uses: actions/checkout@v4
if: needs.conditions.outputs.should-run == 'true'
- id: filter
if: needs.conditions.outputs.should-run == 'true'
name: Check for Rust changes
uses: dorny/paths-filter@v3
with:
filters: |
rust:
- 'rust/**'
- uses: actions/setup-node@v4
if: needs.conditions.outputs.should-run == 'true'
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install dependencies
if: needs.conditions.outputs.should-run == 'true'
run: yarn
- name: Download Wasm Cache
id: download-wasm
if: ${{ needs.conditions.outputs.should-run == 'true' && github.event_name != 'schedule' && steps.filter.outputs.rust == 'false' }}
uses: dawidd6/action-download-artifact@v7
continue-on-error: true
with:
github_token: ${{secrets.GITHUB_TOKEN}}
name: wasm-bundle
workflow: build-and-store-wasm.yml
branch: main
path: rust/kcl-wasm-lib/pkg
- name: Build WASM condition
id: wasm
if: needs.conditions.outputs.should-run == 'true'
run: |
set -euox pipefail
# Build wasm if this is a scheduled run, there are Rust changes, or
# downloading from the wasm cache failed.
if [[ ${{github.event_name}} == 'schedule' || ${{steps.filter.outputs.rust}} == 'true' || ${{steps.download-wasm.outcome}} == 'failure' ]]; then
echo "should-build-wasm=true" >> $GITHUB_OUTPUT
else
echo "should-build-wasm=false" >> $GITHUB_OUTPUT
fi
- name: Use correct Rust toolchain
if: ${{ needs.conditions.outputs.should-run == 'true' && steps.wasm.outputs.should-build-wasm == 'true' }}
shell: bash
run: |
[ -e rust-toolchain.toml ] || cp rust/rust-toolchain.toml ./
- name: Install rust
if: ${{ needs.conditions.outputs.should-run == 'true' && steps.wasm.outputs.should-build-wasm == 'true' }}
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache: false # Configured below.
- uses: taiki-e/install-action@955a6ff1416eae278c9f833008a9beb4b7f9afe3
if: ${{ needs.conditions.outputs.should-run == 'true' && steps.wasm.outputs.should-build-wasm == 'true' }}
with:
tool: wasm-pack
- name: Rust Cache
if: ${{ needs.conditions.outputs.should-run == 'true' && steps.wasm.outputs.should-build-wasm == 'true' }}
uses: Swatinem/rust-cache@v2
with:
workspaces: './rust'
- name: Build Wasm
if: ${{ needs.conditions.outputs.should-run == 'true' && steps.wasm.outputs.should-build-wasm == 'true' }}
shell: bash
run: yarn build:wasm
- uses: actions/upload-artifact@v4
if: needs.conditions.outputs.should-run == 'true'
with:
name: prepared-wasm
path: |
rust/kcl-wasm-lib/pkg/kcl_wasm_lib*
snapshots:
name: playwright:snapshots:ubuntu
runs-on: namespace-profile-ubuntu-8-cores
needs: [conditions, prepare-wasm]
steps:
- uses: actions/create-github-app-token@v1
if: needs.conditions.outputs.should-run == 'true'
id: app-token
with:
app-id: ${{ secrets.MODELING_APP_GH_APP_ID }}
private-key: ${{ secrets.MODELING_APP_GH_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- uses: actions/checkout@v4
if: needs.conditions.outputs.should-run == 'true'
with:
token: ${{ steps.app-token.outputs.token }}
- uses: actions/download-artifact@v4
if: needs.conditions.outputs.should-run == 'true'
name: prepared-wasm
- name: Copy prepared wasm
if: needs.conditions.outputs.should-run == 'true'
run: |
ls -R prepared-wasm
cp prepared-wasm/kcl_wasm_lib_bg.wasm public
mkdir rust/kcl-wasm-lib/pkg
cp prepared-wasm/kcl_wasm_lib* rust/kcl-wasm-lib/pkg
- uses: actions/setup-node@v4
if: needs.conditions.outputs.should-run == 'true'
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install dependencies
id: deps-install
if: needs.conditions.outputs.should-run == 'true'
run: yarn
- name: Cache Playwright Browsers
if: needs.conditions.outputs.should-run == 'true'
uses: actions/cache@v4
with:
path: |
~/.cache/ms-playwright/
key: ${{ runner.os }}-playwright-${{ hashFiles('yarn.lock') }}
- name: Install Playwright Browsers
if: needs.conditions.outputs.should-run == 'true'
run: yarn playwright install --with-deps
- name: build web
if: needs.conditions.outputs.should-run == 'true'
run: yarn tronb:vite:dev
- name: Run ubuntu/chrome snapshots
if: needs.conditions.outputs.should-run == 'true'
run: |
yarn test:snapshots
env:
CI: true
NODE_ENV: development
VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
VITE_KC_SKIP_AUTH: true
token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
snapshottoken: ${{ secrets.KITTYCAD_API_TOKEN }}
- uses: actions/upload-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && !cancelled() && (success() || failure()) }}
with:
name: playwright-report-snapshots-${{ matrix.os }}-snapshot-${{ matrix.shardIndex }}-${{ github.sha }}
path: playwright-report/
include-hidden-files: true
retention-days: 30
overwrite: true
- name: Clean up test-results
if: ${{ needs.conditions.outputs.should-run == 'true' && !cancelled() && (success() || failure()) }}
continue-on-error: true
run: rm -r test-results
- name: check for changes
if: ${{ needs.conditions.outputs.should-run == 'true' && matrix.os == 'namespace-profile-ubuntu-8-cores' && matrix.shardIndex == 1 && github.ref != 'refs/heads/main' }}
shell: bash
id: git-check
run: |
git add e2e/playwright/snapshot-tests.spec.ts-snapshots e2e/playwright/snapshots
if git status | grep -q "Changes to be committed"
then echo "modified=true" >> $GITHUB_OUTPUT
else echo "modified=false" >> $GITHUB_OUTPUT
fi
- name: Commit changes, if any
if: ${{ needs.conditions.outputs.should-run == 'true' && steps.git-check.outputs.modified == 'true' }}
shell: bash
run: |
git add e2e/playwright/snapshot-tests.spec.ts-snapshots e2e/playwright/snapshots
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git fetch origin
echo ${{ github.head_ref }}
git checkout ${{ github.head_ref }}
git commit -m "A snapshot a day keeps the bugs away! 📷🐛 (OS: ${{matrix.os}})" || true
git push
git push origin ${{ github.head_ref }}
# only upload artifacts if there's actually changes
- uses: actions/upload-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && steps.git-check.outputs.modified == 'true' }}
with:
name: playwright-report-ubuntu-${{ github.sha }}
path: playwright-report/
include-hidden-files: true
retention-days: 30
electron: electron:
needs: [conditions, prepare-wasm]
timeout-minutes: 60 timeout-minutes: 60
name: playwright:electron:${{ matrix.os }} ${{ matrix.shardIndex }} ${{ matrix.shardTotal }} name: playwright:electron:${{ matrix.os }} ${{ matrix.shardIndex }} ${{ matrix.shardTotal }}
strategy: strategy:
@ -80,206 +293,94 @@ jobs:
shardTotal: [4] shardTotal: [4]
# TODO: add ref here for main and latest release tag # TODO: add ref here for main and latest release tag
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
needs: conditions
steps: steps:
- uses: actions/create-github-app-token@v1 - uses: actions/checkout@v4
id: app-token if: needs.conditions.outputs.should-run == 'true'
with:
app-id: ${{ secrets.MODELING_APP_GH_APP_ID }}
private-key: ${{ secrets.MODELING_APP_GH_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- id: filter
name: Check for Rust changes
uses: dorny/paths-filter@v3
with:
filters: |
rust:
- 'rust/**'
- uses: actions/setup-node@v4
if: needs.conditions.outputs.should-run == 'true'
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install dependencies
id: deps-install
if: needs.conditions.outputs.should-run == 'true'
shell: bash
run: yarn
- name: Cache Playwright Browsers
if: needs.conditions.outputs.should-run == 'true'
uses: actions/cache@v4
with:
path: |
~/.cache/ms-playwright/
key: ${{ runner.os }}-playwright-${{ hashFiles('yarn.lock') }}
- name: Install Playwright Browsers
if: needs.conditions.outputs.should-run == 'true'
shell: bash
run: yarn playwright install --with-deps
- name: Download Wasm Cache
id: download-wasm
if: ${{ needs.conditions.outputs.should-run == 'true' && github.event_name != 'schedule' && steps.filter.outputs.rust == 'false' }}
uses: dawidd6/action-download-artifact@v7
continue-on-error: true
with:
github_token: ${{secrets.GITHUB_TOKEN}}
name: wasm-bundle
workflow: build-and-store-wasm.yml
branch: main
path: rust/kcl-wasm-lib/pkg
- name: copy wasm blob
if: ${{ needs.conditions.outputs.should-run == 'true' && github.event_name != 'schedule' && steps.filter.outputs.rust == 'false' }}
shell: bash
run: cp rust/kcl-wasm-lib/pkg/kcl_wasm_lib_bg.wasm public
continue-on-error: true
- name: Setup Rust
if: ${{ needs.conditions.outputs.should-run == 'true' }}
uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@955a6ff1416eae278c9f833008a9beb4b7f9afe3
with:
tool: wasm-pack
- name: Cache Wasm (because rust diff)
if: ${{ needs.conditions.outputs.should-run == 'true' && (github.event_name == 'schedule' || steps.filter.outputs.rust == 'true') }}
uses: Swatinem/rust-cache@v2
with:
workspaces: './rust'
- name: OR Cache Wasm (because wasm cache failed)
if: ${{ needs.conditions.outputs.should-run == 'true' && steps.download-wasm.outcome == 'failure' }}
uses: Swatinem/rust-cache@v2
with:
workspaces: './rust'
- name: install good sed
if: ${{ needs.conditions.outputs.should-run == 'true' && startsWith(matrix.os, 'macos') }}
shell: bash
run: |
brew install gnu-sed
echo "/opt/homebrew/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH
- name: Install vector
shell: bash
# TODO: figure out what to do with this, it's failing
if: false
run: |
curl --proto '=https' --tlsv1.2 -sSfL https://sh.vector.dev > /tmp/vector.sh
chmod +x /tmp/vector.sh
/tmp/vector.sh -y -no-modify-path
mkdir -p /tmp/vector
cp .github/workflows/vector.toml /tmp/vector.toml
sed -i "s#GITHUB_WORKFLOW#${GITHUB_WORKFLOW}#g" /tmp/vector.toml
sed -i "s#GITHUB_REPOSITORY#${GITHUB_REPOSITORY}#g" /tmp/vector.toml
sed -i "s#GITHUB_SHA#${GITHUB_SHA}#g" /tmp/vector.toml
sed -i "s#GITHUB_REF_NAME#${GITHUB_REF_NAME}#g" /tmp/vector.toml
sed -i "s#GH_ACTIONS_AXIOM_TOKEN#${{secrets.GH_ACTIONS_AXIOM_TOKEN}}#g" /tmp/vector.toml
cat /tmp/vector.toml
${HOME}/.vector/bin/vector --config /tmp/vector.toml &
- name: Build Wasm (because rust diff)
if: ${{ needs.conditions.outputs.should-run == 'true' && (github.event_name == 'schedule' || steps.filter.outputs.rust == 'true') }}
shell: bash
run: yarn build:wasm
- name: OR Build Wasm (because wasm cache failed)
if: ${{ needs.conditions.outputs.should-run == 'true' && steps.download-wasm.outcome == 'failure' }}
shell: bash
run: yarn build:wasm
- name: build web
if: needs.conditions.outputs.should-run == 'true'
shell: bash
run: yarn tronb:vite:dev
- name: Run ubuntu/chrome snapshots
if: ${{ needs.conditions.outputs.should-run == 'true' && matrix.os == 'namespace-profile-ubuntu-8-cores' && matrix.shardIndex == 1 }}
shell: bash
# TODO: break this in its own job, for now it's not slowing down the overall execution as ubuntu is the quickest,
# but we could do better. This forces a large 1/1 shard of all 20 snapshot tests that runs in about 3 minutes.
run: |
yarn test:snapshots
env:
CI: true
NODE_ENV: development
VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
VITE_KC_SKIP_AUTH: true
token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
snapshottoken: ${{ secrets.KITTYCAD_API_TOKEN }}
- uses: actions/upload-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && !cancelled() && (success() || failure()) }}
with:
name: playwright-report-snapshots-${{ matrix.os }}-snapshot-${{ matrix.shardIndex }}-${{ github.sha }}
path: playwright-report/
include-hidden-files: true
retention-days: 30
overwrite: true
- name: Clean up test-results
if: ${{ needs.conditions.outputs.should-run == 'true' && !cancelled() && (success() || failure()) }}
continue-on-error: true
run: rm -r test-results
- name: check for changes
if: ${{ needs.conditions.outputs.should-run == 'true' && matrix.os == 'namespace-profile-ubuntu-8-cores' && matrix.shardIndex == 1 && github.ref != 'refs/heads/main' }}
shell: bash
id: git-check
run: |
git add e2e/playwright/snapshot-tests.spec.ts-snapshots e2e/playwright/snapshots
if git status | grep -q "Changes to be committed"
then echo "modified=true" >> $GITHUB_OUTPUT
else echo "modified=false" >> $GITHUB_OUTPUT
fi
- name: Commit changes, if any
if: ${{ needs.conditions.outputs.should-run == 'true' && steps.git-check.outputs.modified == 'true' }}
shell: bash
run: |
git add e2e/playwright/snapshot-tests.spec.ts-snapshots e2e/playwright/snapshots
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git fetch origin
echo ${{ github.head_ref }}
git checkout ${{ github.head_ref }}
git commit -m "A snapshot a day keeps the bugs away! 📷🐛 (OS: ${{matrix.os}})" || true
git push
git push origin ${{ github.head_ref }}
# only upload artifacts if there's actually changes
- uses: actions/upload-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && steps.git-check.outputs.modified == 'true' }}
with:
name: playwright-report-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }}
path: playwright-report/
include-hidden-files: true
retention-days: 30
- uses: actions/download-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && !cancelled() && (success() || failure()) }}
continue-on-error: true
with:
name: test-results-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }}
path: test-results/
- name: Run playwright/electron flow (with retries)
id: retry
if: ${{ needs.conditions.outputs.should-run == 'true' && !cancelled() && steps.deps-install.outcome == 'success' }}
uses: nick-fields/retry@v3.0.2
with:
shell: bash
command: .github/ci-cd-scripts/playwright-electron.sh ${{matrix.shardIndex}} ${{matrix.shardTotal}} ${{matrix.os}}
timeout_minutes: 30
max_attempts: 25
env:
CI: true
FAIL_ON_CONSOLE_ERRORS: true
NODE_ENV: development
VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
VITE_KC_SKIP_AUTH: true
token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
- uses: actions/upload-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && always() }}
with:
name: test-results-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }}
path: test-results/
include-hidden-files: true
retention-days: 30
overwrite: true
- uses: actions/upload-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && always() }}
with:
name: playwright-report-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }}
path: playwright-report/
include-hidden-files: true
retention-days: 30
overwrite: true
- uses: actions/download-artifact@v4
if: needs.conditions.outputs.should-run == 'true'
name: prepared-wasm
- name: Copy prepared wasm
if: needs.conditions.outputs.should-run == 'true'
run: |
ls -R prepared-wasm
cp prepared-wasm/kcl_wasm_lib_bg.wasm public
mkdir rust/kcl-wasm-lib/pkg
cp prepared-wasm/kcl_wasm_lib* rust/kcl-wasm-lib/pkg
- uses: actions/setup-node@v4
if: needs.conditions.outputs.should-run == 'true'
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install dependencies
id: deps-install
if: needs.conditions.outputs.should-run == 'true'
run: yarn
- name: Cache Playwright Browsers
uses: actions/cache@v4
with:
path: |
~/.cache/ms-playwright/
key: ${{ runner.os }}-playwright-${{ hashFiles('yarn.lock') }}
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Build web
if: needs.conditions.outputs.should-run == 'true'
run: yarn tronb:vite:dev
- name: Install good sed
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
brew install gnu-sed
echo "/opt/homebrew/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH
# TODO: Add back axiom logs
- uses: actions/download-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && !cancelled() && (success() || failure()) }}
continue-on-error: true
with:
name: test-results-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }}
path: test-results/
- name: Run playwright/electron flow (with retries)
id: retry
if: ${{ needs.conditions.outputs.should-run == 'true' && !cancelled() && steps.deps-install.outcome == 'success' }}
uses: nick-fields/retry@v3.0.2
with:
shell: bash
command: .github/ci-cd-scripts/playwright-electron.sh ${{matrix.shardIndex}} ${{matrix.shardTotal}} ${{matrix.os}}
timeout_minutes: 30
max_attempts: 25
env:
CI: true
FAIL_ON_CONSOLE_ERRORS: true
NODE_ENV: development
VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
VITE_KC_SKIP_AUTH: true
token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }}
- uses: actions/upload-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && always() }}
with:
name: test-results-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }}
path: test-results/
include-hidden-files: true
retention-days: 30
overwrite: true
- uses: actions/upload-artifact@v4
if: ${{ needs.conditions.outputs.should-run == 'true' && always() }}
with:
name: playwright-report-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }}
path: playwright-report/
include-hidden-files: true
retention-days: 30
overwrite: true

View File

@ -40,9 +40,13 @@ jobs:
# cleanup old # cleanup old
rm -rf documentation/content/pages/docs/kcl/*.md rm -rf documentation/content/pages/docs/kcl/*.md
rm -rf documentation/content/pages/docs/kcl/types rm -rf documentation/content/pages/docs/kcl/types
rm -rf documentation/content/pages/docs/kcl/settings
rm -rf documentation/content/pages/docs/kcl/consts
# move new # move new
mv -f docs/kcl/*.md documentation/content/pages/docs/kcl/ mv -f docs/kcl/*.md documentation/content/pages/docs/kcl/
mv -f docs/kcl/types documentation/content/pages/docs/kcl/ mv -f docs/kcl/types documentation/content/pages/docs/kcl/
mv -f docs/kcl/settings documentation/content/pages/docs/kcl/
mv -f docs/kcl/consts documentation/content/pages/docs/kcl/
- name: move kcl-samples - name: move kcl-samples
shell: bash shell: bash
run: | run: |

View File

@ -159,10 +159,13 @@ jobs:
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
needs: [linux-x86_64, windows, macos, sdist] needs: [linux-x86_64, windows, macos, sdist]
steps: steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4 - uses: actions/download-artifact@v4
with:
path: rust/kcl-python-bindings
- name: Install the latest version of uv - name: Install the latest version of uv
uses: astral-sh/setup-uv@v5 uses: astral-sh/setup-uv@v5
- name: Install codespell - name: do uv things
run: | run: |
cd rust/kcl-python-bindings cd rust/kcl-python-bindings
uv venv .venv uv venv .venv

3
.gitignore vendored
View File

@ -53,13 +53,14 @@ e2e/playwright/export-snapshots/*
/public/kcl-samples.zip /public/kcl-samples.zip
/public/kcl-samples/.github /public/kcl-samples/.github
/public/kcl-samples/screenshots/main.kcl
/public/kcl-samples/step/main.kcl
/test-results/ /test-results/
/playwright-report/ /playwright-report/
/blob-report/ /blob-report/
/playwright/.cache/ /playwright/.cache/
/src/lang/std/artifactMapCache /src/lang/std/artifactMapCache
## generated files ## generated files
src/**/*.typegen.ts src/**/*.typegen.ts

View File

@ -40,7 +40,7 @@ sketch001 = startSketchOn('XZ')
angle = angleToMatchLengthY(seg01, 15, %), angle = angleToMatchLengthY(seg01, 15, %),
length = 5 length = 5
}, %) }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
extrusion = extrude(sketch001, length = 5) extrusion = extrude(sketch001, length = 5)

View File

@ -35,10 +35,10 @@ angledLine(
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> yLineTo(15, %) |> yLine(endAbsolute = 15)
|> angledLine({ angle = 30, length = 15 }, %) |> angledLine({ angle = 30, length = 15 }, %)
|> line(end = [8, -10]) |> line(end = [8, -10])
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
example = extrude(exampleSketch, length = 10) example = extrude(exampleSketch, length = 10)

File diff suppressed because one or more lines are too long

View File

@ -37,7 +37,7 @@ sketch001 = startSketchOn('XZ')
angle = toDegrees(asin(0.5)), angle = toDegrees(asin(0.5)),
length = 20 length = 20
}, %) }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
extrude001 = extrude(sketch001, length = 5) extrude001 = extrude(sketch001, length = 5)

View File

@ -37,7 +37,7 @@ sketch001 = startSketchOn('XZ')
angle = toDegrees(atan(1.25)), angle = toDegrees(atan(1.25)),
length = 20 length = 20
}, %) }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
extrude001 = extrude(sketch001, length = 5) extrude001 = extrude(sketch001, length = 5)

View File

@ -41,7 +41,7 @@ sketch001 = startSketchOn('XZ')
angle = toDegrees(atan2(1.25, 2)), angle = toDegrees(atan2(1.25, 2)),
length = 20 length = 20
}, %) }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
extrude001 = extrude(sketch001, length = 5) extrude001 = extrude(sketch001, length = 5)

View File

@ -35,7 +35,7 @@ sketch001 = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(endAbsolute = [12, 10]) |> line(endAbsolute = [12, 10])
|> line(end = [ceil(7.02986), 0]) |> line(end = [ceil(7.02986), 0])
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
extrude001 = extrude(sketch001, length = 5) extrude001 = extrude(sketch001, length = 5)

File diff suppressed because one or more lines are too long

25
docs/kcl/consts.md Normal file
View File

@ -0,0 +1,25 @@
---
title: "KCL Constants"
excerpt: "Documentation for the KCL constants."
layout: manual
---
## Table of Contents
### `std`
- [`HALF_TURN`](/docs/kcl/consts/std-HALF_TURN)
- [`QUARTER_TURN`](/docs/kcl/consts/std-QUARTER_TURN)
- [`THREE_QUARTER_TURN`](/docs/kcl/consts/std-THREE_QUARTER_TURN)
- [`XY`](/docs/kcl/consts/std-XY)
- [`XZ`](/docs/kcl/consts/std-XZ)
- [`YZ`](/docs/kcl/consts/std-YZ)
- [`ZERO`](/docs/kcl/consts/std-ZERO)
### `std::math`
- [`E`](/docs/kcl/consts/std-math-E)
- [`PI`](/docs/kcl/consts/std-math-PI)
- [`TAU`](/docs/kcl/consts/std-math-TAU)

View File

@ -21,7 +21,7 @@ exampleSketch = startSketchOn("XZ")
angle = 30, angle = 30,
length = 2 * E ^ 2, length = 2 * E ^ 2,
}, %) }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
example = extrude(exampleSketch, length = 10) example = extrude(exampleSketch, length = 10)

View File

@ -21,7 +21,7 @@ exampleSketch = startSketchOn("XZ")
angle = 50, angle = 50,
length = 10 * TAU, length = 10 * TAU,
}, %) }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
example = extrude(exampleSketch, length = 5) example = extrude(exampleSketch, length = 5)

View File

@ -31,7 +31,7 @@ e(): number
exampleSketch = startSketchOn("XZ") exampleSketch = startSketchOn("XZ")
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle = 30, length = 2 * e() ^ 2 }, %) |> angledLine({ angle = 30, length = 2 * e() ^ 2 }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
example = extrude(exampleSketch, length = 10) example = extrude(exampleSketch, length = 10)

View File

@ -6,7 +6,7 @@ layout: manual
Extend a 2-dimensional sketch through a third dimension in order to create new 3-dimensional volume, or if extruded into an existing volume, cut into an existing solid. Extend a 2-dimensional sketch through a third dimension in order to create new 3-dimensional volume, or if extruded into an existing volume, cut into an existing solid.
You can provide more than one sketch to extrude, and they will all be extruded in the same direction.
```js ```js
extrude( extrude(
@ -20,7 +20,7 @@ extrude(
| Name | Type | Description | Required | | Name | Type | Description | Required |
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `sketchSet` | [`SketchSet`](/docs/kcl/types/SketchSet) | Which sketches should be extruded | Yes | | `sketchSet` | [`SketchSet`](/docs/kcl/types/SketchSet) | Which sketch or set of sketches should be extruded | Yes |
| `length` | [`number`](/docs/kcl/types/number) | How far to extrude the given sketches | Yes | | `length` | [`number`](/docs/kcl/types/number) | How far to extrude the given sketches | Yes |
### Returns ### Returns

View File

@ -35,7 +35,7 @@ sketch001 = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(endAbsolute = [12, 10]) |> line(endAbsolute = [12, 10])
|> line(end = [floor(7.02986), 0]) |> line(end = [floor(7.02986), 0])
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
extrude001 = extrude(sketch001, length = 5) extrude001 = extrude(sketch001, length = 5)

File diff suppressed because one or more lines are too long

View File

@ -12,25 +12,26 @@ layout: manual
* [`Modules`](kcl/modules) * [`Modules`](kcl/modules)
* [`Settings`](kcl/settings) * [`Settings`](kcl/settings)
* [`Known Issues`](kcl/known-issues) * [`Known Issues`](kcl/known-issues)
* [`Constants`](kcl/consts)
### Standard library ### Standard library
* **Primitive types** * **Primitive types**
* [`bool`](kcl/bool) * [`bool`](kcl/types/bool)
* [`number`](kcl/number) * [`number`](kcl/types/number)
* [`string`](kcl/string) * [`string`](kcl/types/string)
* [`tag`](kcl/tag) * [`tag`](kcl/types/tag)
* **std** * **std**
* [`HALF_TURN`](kcl/const_std-HALF_TURN) * [`HALF_TURN`](kcl/consts/std-HALF_TURN)
* [`Plane`](kcl/Plane) * [`Plane`](kcl/types/Plane)
* [`QUARTER_TURN`](kcl/const_std-QUARTER_TURN) * [`QUARTER_TURN`](kcl/consts/std-QUARTER_TURN)
* [`Sketch`](kcl/Sketch) * [`Sketch`](kcl/types/Sketch)
* [`Solid`](kcl/Solid) * [`Solid`](kcl/types/Solid)
* [`THREE_QUARTER_TURN`](kcl/const_std-THREE_QUARTER_TURN) * [`THREE_QUARTER_TURN`](kcl/consts/std-THREE_QUARTER_TURN)
* [`XY`](kcl/const_std-XY) * [`XY`](kcl/consts/std-XY)
* [`XZ`](kcl/const_std-XZ) * [`XZ`](kcl/consts/std-XZ)
* [`YZ`](kcl/const_std-YZ) * [`YZ`](kcl/consts/std-YZ)
* [`ZERO`](kcl/const_std-ZERO) * [`ZERO`](kcl/consts/std-ZERO)
* [`abs`](kcl/abs) * [`abs`](kcl/abs)
* [`acos`](kcl/acos) * [`acos`](kcl/acos)
* [`angleToMatchLengthX`](kcl/angleToMatchLengthX) * [`angleToMatchLengthX`](kcl/angleToMatchLengthX)
@ -131,14 +132,12 @@ layout: manual
* [`toRadians`](kcl/toRadians) * [`toRadians`](kcl/toRadians)
* [`translate`](kcl/translate) * [`translate`](kcl/translate)
* [`xLine`](kcl/xLine) * [`xLine`](kcl/xLine)
* [`xLineTo`](kcl/xLineTo)
* [`yLine`](kcl/yLine) * [`yLine`](kcl/yLine)
* [`yLineTo`](kcl/yLineTo)
* [`yd`](kcl/yd) * [`yd`](kcl/yd)
* **std::math** * **std::math**
* [`E`](kcl/const_std-math-E) * [`E`](kcl/consts/std-math-E)
* [`PI`](kcl/const_std-math-PI) * [`PI`](kcl/consts/std-math-PI)
* [`TAU`](kcl/const_std-math-TAU) * [`TAU`](kcl/consts/std-math-TAU)
* [`cos`](kcl/std-math-cos) * [`cos`](kcl/std-math-cos)
* [`sin`](kcl/std-math-sin) * [`sin`](kcl/std-math-sin)
* [`tan`](kcl/std-math-tan) * [`tan`](kcl/std-math-tan)

View File

@ -13,9 +13,7 @@ once fixed in engine will just start working here with no language changes.
If you see a red line around your model, it means this is happening. If you see a red line around your model, it means this is happening.
- **Import**: Right now you can import a file, even if that file has brep data - **Import**: Right now you can import a file, even if that file has brep data
you cannot edit it, after v1, the engine will account for this. You also cannot you cannot edit it, after v1, the engine will account for this.
currently move or transform the imported objects at all, once we have assemblies
this will work.
- **Fillets**: Fillets cannot intersect, you will get an error. Only simple fillet - **Fillets**: Fillets cannot intersect, you will get an error. Only simple fillet
cases work currently. cases work currently.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -38,7 +38,7 @@ pow(
exampleSketch = startSketchOn("XZ") exampleSketch = startSketchOn("XZ")
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle = 50, length = pow(5, 2) }, %) |> angledLine({ angle = 50, length = pow(5, 2) }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
example = extrude(exampleSketch, length = 5) example = extrude(exampleSketch, length = 5)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -35,7 +35,7 @@ sketch001 = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(endAbsolute = [12, 10]) |> line(endAbsolute = [12, 10])
|> line(end = [round(7.02986), 0]) |> line(end = [round(7.02986), 0])
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
extrude001 = extrude(sketch001, length = 5) extrude001 = extrude(sketch001, length = 5)

File diff suppressed because one or more lines are too long

View File

@ -1,16 +1,31 @@
--- ---
title: "KCL settings" title: "KCL Settings"
excerpt: "Documentation of settings for the KCL language and Zoo Modeling App." excerpt: "Documentation of settings for the KCL language and Zoo Modeling App."
layout: manual layout: manual
--- ---
# Per-file settings # KCL Settings
There are three levels of settings available in the KittyCAD modeling application:
1. [User Settings](/docs/kcl/settings/user): Global settings that apply to all projects, stored in `user.toml`
2. [Project Settings](/docs/kcl/settings/project): Settings specific to a project, stored in `project.toml`
3. Per-file Settings: Settings that apply to a single KCL file, specified using the `@settings` attribute
## Configuration Files
The KittyCAD modeling app uses TOML files for configuration:
* **User Settings**: `user.toml` - See [complete documentation](/docs/kcl/settings/user)
* **Project Settings**: `project.toml` - See [complete documentation](/docs/kcl/settings/project)
## Per-file settings
Settings which affect a single file are configured using the settings attribute. Settings which affect a single file are configured using the settings attribute.
This must be at the top of the KCL file (comments before the attribute are permitted). This must be at the top of the KCL file (comments before the attribute are permitted).
E.g., For example:
``` ```js
// The settings attribute. // The settings attribute.
@settings(defaultLengthUnit = in) @settings(defaultLengthUnit = in)

View File

@ -0,0 +1,208 @@
---
title: "Project Settings"
excerpt: "Project specific settings for the app. These live in `project.toml` in the base of the project directory. Updating the settings for the project in the app will update this file automatically. Do not edit this file manually, as it may be overwritten by the app. Manual edits can cause corruption of the settings file."
layout: manual
---
# Project Settings
Project specific settings for the app. These live in `project.toml` in the base of the project directory. Updating the settings for the project in the app will update this file automatically. Do not edit this file manually, as it may be overwritten by the app. Manual edits can cause corruption of the settings file.
## Project Configuration Structure
```toml
[settings.app]
# Set the appearance of the application
name = "My Awesome Project"
[settings.app.appearance]
# Use dark mode theme
theme = "dark"
# Set the app color to blue (240.0 = blue, 0.0 = red, 120.0 = green)
color = 240.0
[settings.modeling]
# Use inches as the default measurement unit
base_unit = "in"
```
## Available Settings
### settings
#### app
The settings for the modeling app.
**Default:** None
This setting has the following nested options:
##### appearance
The settings for the appearance of the app.
**Default:** None
This setting has further nested options. See the schema for full details.
##### onboarding_status
The onboarding status of the app.
**Default:** None
##### theme_color
The hue of the primary theme color for the app.
**Default:** None
##### enable_ssao
Whether or not Screen Space Ambient Occlusion (SSAO) is enabled.
**Default:** None
##### dismiss_web_banner
Permanently dismiss the banner warning to download the desktop app. This setting only applies to the web app. And is temporary until we have Linux support.
**Default:** None
##### stream_idle_mode
When the user is idle, and this is true, the stream will be torn down.
**Default:** None
##### allow_orbit_in_sketch_mode
When the user is idle, and this is true, the stream will be torn down.
**Default:** None
##### show_debug_panel
Whether to show the debug panel, which lets you see various states of the app to aid in development.
**Default:** None
##### named_views
Settings that affect the behavior of the command bar.
**Default:** None
#### modeling
Settings that affect the behavior while modeling.
**Default:** None
This setting has the following nested options:
##### base_unit
The default unit to use in modeling dimensions.
**Default:** None
##### highlight_edges
Highlight edges of 3D objects?
**Default:** None
##### show_debug_panel
Whether to show the debug panel, which lets you see various states of the app to aid in development. Remove this when we remove backwards compatibility with the old settings file.
**Default:** None
##### enable_ssao
Whether or not Screen Space Ambient Occlusion (SSAO) is enabled.
**Default:** None
#### text_editor
Settings that affect the behavior of the KCL text editor.
**Default:** None
This setting has the following nested options:
##### text_wrapping
Whether to wrap text in the editor or overflow with scroll.
**Default:** None
##### blinking_cursor
Whether to make the cursor blink in the editor.
**Default:** None
#### command_bar
Settings that affect the behavior of the command bar.
**Default:** None
This setting has the following nested options:
##### include_settings
Whether to include settings in the command bar.
**Default:** None
## Complete Example
```toml
[settings.app]
# Set the appearance of the application
name = "My Awesome Project"
[settings.app.appearance]
# Use dark mode theme
theme = "dark"
# Set the app color to blue (240.0 = blue, 0.0 = red, 120.0 = green)
color = 240.0
[settings.modeling]
# Use inches as the default measurement unit
base_unit = "in"
```

272
docs/kcl/settings/user.md Normal file
View File

@ -0,0 +1,272 @@
---
title: "User Settings"
excerpt: "User specific settings for the app. These live in `user.toml` in the app's configuration directory. Updating the settings in the app will update this file automatically. Do not edit this file manually, as it may be overwritten by the app. Manual edits can cause corruption of the settings file."
layout: manual
---
# User Settings
User specific settings for the app. These live in `user.toml` in the app's configuration directory. Updating the settings in the app will update this file automatically. Do not edit this file manually, as it may be overwritten by the app. Manual edits can cause corruption of the settings file.
## User Configuration Structure
```toml
[settings.app]
# Set the appearance of the application
[settings.app.appearance]
# Use dark mode theme
theme = "dark"
# Set the app color to blue (240.0 = blue, 0.0 = red, 120.0 = green)
color = 240.0
[settings.modeling]
# Use millimeters as the default measurement unit
base_unit = "mm"
[settings.text_editor]
# Disable text wrapping in the editor
text_wrapping = false
```
## Available Settings
### settings
#### app
The settings for the modeling app.
**Default:** None
This setting has the following nested options:
##### appearance
The settings for the appearance of the app.
**Default:** None
This setting has further nested options. See the schema for full details.
##### onboarding_status
The onboarding status of the app.
**Default:** None
##### project_directory
Backwards compatible project directory setting.
**Default:** None
##### theme
Backwards compatible theme setting.
**Default:** None
##### theme_color
The hue of the primary theme color for the app.
**Default:** None
##### enable_ssao
Whether or not Screen Space Ambient Occlusion (SSAO) is enabled.
**Default:** None
##### dismiss_web_banner
Permanently dismiss the banner warning to download the desktop app. This setting only applies to the web app. And is temporary until we have Linux support.
**Default:** None
##### stream_idle_mode
When the user is idle, and this is true, the stream will be torn down.
**Default:** None
##### allow_orbit_in_sketch_mode
When the user is idle, and this is true, the stream will be torn down.
**Default:** None
##### show_debug_panel
Whether to show the debug panel, which lets you see various states of the app to aid in development.
**Default:** None
#### modeling
Settings that affect the behavior while modeling.
**Default:** None
This setting has the following nested options:
##### base_unit
The default unit to use in modeling dimensions.
**Default:** None
##### camera_projection
The projection mode the camera should use while modeling.
**Default:** None
##### camera_orbit
The methodology the camera should use to orbit around the model.
**Default:** None
##### mouse_controls
The controls for how to navigate the 3D view.
**Possible values:** `zoo`, `onshape`, `trackpad_friendly`, `solidworks`, `nx`, `creo`, `autocad`
**Default:** None
##### highlight_edges
Highlight edges of 3D objects?
**Default:** None
##### show_debug_panel
Whether to show the debug panel, which lets you see various states of the app to aid in development. Remove this when we remove backwards compatibility with the old settings file.
**Default:** None
##### enable_ssao
Whether or not Screen Space Ambient Occlusion (SSAO) is enabled.
**Default:** None
##### show_scale_grid
Whether or not to show a scale grid in the 3D modeling view
**Default:** None
#### text_editor
Settings that affect the behavior of the KCL text editor.
**Default:** None
This setting has the following nested options:
##### text_wrapping
Whether to wrap text in the editor or overflow with scroll.
**Default:** None
##### blinking_cursor
Whether to make the cursor blink in the editor.
**Default:** None
#### project
Settings that affect the behavior of project management.
**Default:** None
This setting has the following nested options:
##### directory
The directory to save and load projects from.
**Default:** None
##### default_project_name
The default project name to use when creating a new project.
**Default:** None
#### command_bar
Settings that affect the behavior of the command bar.
**Default:** None
This setting has the following nested options:
##### include_settings
Whether to include settings in the command bar.
**Default:** None
## Complete Example
```toml
[settings.app]
# Set the appearance of the application
[settings.app.appearance]
# Use dark mode theme
theme = "dark"
# Set the app color to blue (240.0 = blue, 0.0 = red, 120.0 = green)
color = 240.0
[settings.modeling]
# Use millimeters as the default measurement unit
base_unit = "mm"
[settings.text_editor]
# Disable text wrapping in the editor
text_wrapping = false
```

View File

@ -34,7 +34,7 @@ sqrt(num: number): number
exampleSketch = startSketchOn("XZ") exampleSketch = startSketchOn("XZ")
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle = 50, length = sqrt(2500) }, %) |> angledLine({ angle = 50, length = sqrt(2500) }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
example = extrude(exampleSketch, length = 5) example = extrude(exampleSketch, length = 5)

View File

@ -137,9 +137,9 @@ a1 = startSketchOn({
}) })
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> line(end = [100.0, 0]) |> line(end = [100.0, 0])
|> yLine(-100.0, %) |> yLine(length = -100.0)
|> xLine(-100.0, %) |> xLine(length = -100.0)
|> yLine(100.0, %) |> yLine(length = 100.0)
|> close() |> close()
|> extrude(length = 3.14) |> extrude(length = 3.14)
``` ```

View File

@ -33,7 +33,7 @@ exampleSketch = startSketchOn("XZ")
angle = 30, angle = 30,
length = 3 / cos(toRadians(30)), length = 3 / cos(toRadians(30)),
}, %) }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
example = extrude(exampleSketch, length = 5) example = extrude(exampleSketch, length = 5)

View File

@ -33,7 +33,7 @@ exampleSketch = startSketchOn("XZ")
angle = 50, angle = 50,
length = 15 / sin(toDegrees(135)), length = 15 / sin(toDegrees(135)),
}, %) }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
example = extrude(exampleSketch, length = 5) example = extrude(exampleSketch, length = 5)

View File

@ -33,7 +33,7 @@ exampleSketch = startSketchOn("XZ")
angle = 50, angle = 50,
length = 50 * tan(1/2), length = 50 * tan(1/2),
}, %) }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
example = extrude(exampleSketch, length = 5) example = extrude(exampleSketch, length = 5)

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -31,7 +31,7 @@ tau(): number
exampleSketch = startSketchOn("XZ") exampleSketch = startSketchOn("XZ")
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle = 50, length = 10 * tau() }, %) |> angledLine({ angle = 50, length = 10 * tau() }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
example = extrude(exampleSketch, length = 5) example = extrude(exampleSketch, length = 5)

View File

@ -37,7 +37,7 @@ exampleSketch = startSketchOn("XZ")
angle = 50, angle = 50,
length = 70 * cos(toDegrees(pi() / 4)) length = 70 * cos(toDegrees(pi() / 4))
}, %) }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
example = extrude(exampleSketch, length = 5) example = extrude(exampleSketch, length = 5)

View File

@ -37,7 +37,7 @@ exampleSketch = startSketchOn("XZ")
angle = 50, angle = 50,
length = 70 * cos(toRadians(45)) length = 70 * cos(toRadians(45))
}, %) }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
example = extrude(exampleSketch, length = 5) example = extrude(exampleSketch, length = 5)

File diff suppressed because one or more lines are too long

View File

@ -24,6 +24,5 @@ A face.
| `zAxis` |[`Point3d`](/docs/kcl/types/Point3d)| The z-axis (normal). | No | | `zAxis` |[`Point3d`](/docs/kcl/types/Point3d)| The z-axis (normal). | No |
| `solid` |[`Solid`](/docs/kcl/types/Solid)| The solid the face is on. | No | | `solid` |[`Solid`](/docs/kcl/types/Solid)| The solid the face is on. | No |
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No | | `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |

View File

@ -22,6 +22,5 @@ A helix.
| `angleStart` |[`number`](/docs/kcl/types/number)| Start angle (in degrees). | No | | `angleStart` |[`number`](/docs/kcl/types/number)| Start angle (in degrees). | No |
| `ccw` |`boolean`| Is the helix rotation counter clockwise? | No | | `ccw` |`boolean`| Is the helix rotation counter clockwise? | No |
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No | | `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |

View File

@ -22,6 +22,5 @@ A helix.
| `angleStart` |[`number`](/docs/kcl/types/number)| Start angle (in degrees). | No | | `angleStart` |[`number`](/docs/kcl/types/number)| Start angle (in degrees). | No |
| `ccw` |`boolean`| Is the helix rotation counter clockwise? | No | | `ccw` |`boolean`| Is the helix rotation counter clockwise? | No |
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No | | `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |

View File

@ -18,6 +18,5 @@ Data for an imported geometry.
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `id` |[`string`](/docs/kcl/types/string)| The ID of the imported geometry. | No | | `id` |[`string`](/docs/kcl/types/string)| The ID of the imported geometry. | No |
| `value` |`[` [`string`](/docs/kcl/types/string) `]`| The original file paths. | No | | `value` |`[` [`string`](/docs/kcl/types/string) `]`| The original file paths. | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |

View File

@ -25,7 +25,6 @@ Any KCL value.
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `type` |enum: `Uuid`| | No | | `type` |enum: `Uuid`| | No |
| `value` |[`string`](/docs/kcl/types/string)| | No | | `value` |[`string`](/docs/kcl/types/string)| | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
---- ----
@ -42,7 +41,6 @@ Any KCL value.
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `type` |enum: `Bool`| | No | | `type` |enum: `Bool`| | No |
| `value` |`boolean`| | No | | `value` |`boolean`| | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
---- ----
@ -60,7 +58,6 @@ Any KCL value.
| `type` |enum: `Number`| | No | | `type` |enum: `Number`| | No |
| `value` |[`number`](/docs/kcl/types/number)| | No | | `value` |[`number`](/docs/kcl/types/number)| | No |
| `ty` |[`NumericType`](/docs/kcl/types/NumericType)| | No | | `ty` |[`NumericType`](/docs/kcl/types/NumericType)| | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
---- ----
@ -77,7 +74,6 @@ Any KCL value.
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `type` |enum: `String`| | No | | `type` |enum: `String`| | No |
| `value` |[`string`](/docs/kcl/types/string)| | No | | `value` |[`string`](/docs/kcl/types/string)| | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
---- ----
@ -94,7 +90,6 @@ Any KCL value.
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `type` |enum: `MixedArray`| | No | | `type` |enum: `MixedArray`| | No |
| `value` |`[` [`KclValue`](/docs/kcl/types/KclValue) `]`| | No | | `value` |`[` [`KclValue`](/docs/kcl/types/KclValue) `]`| | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
---- ----
@ -111,7 +106,6 @@ Any KCL value.
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `type` |enum: `Object`| | No | | `type` |enum: `Object`| | No |
| `value` |`object`| | No | | `value` |`object`| | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
---- ----
@ -129,7 +123,6 @@ Any KCL value.
| `type` |enum: [`TagIdentifier`](/docs/kcl/types#tag-identifier)| | No | | `type` |enum: [`TagIdentifier`](/docs/kcl/types#tag-identifier)| | No |
| `value` |[`string`](/docs/kcl/types/string)| | No | | `value` |[`string`](/docs/kcl/types/string)| | No |
| `info` |[`TagEngineInfo`](/docs/kcl/types/TagEngineInfo)| | No | | `info` |[`TagEngineInfo`](/docs/kcl/types/TagEngineInfo)| | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
---- ----
@ -279,7 +272,6 @@ Data for an imported geometry.
| `type` |enum: [`ImportedGeometry`](/docs/kcl/types/ImportedGeometry)| | No | | `type` |enum: [`ImportedGeometry`](/docs/kcl/types/ImportedGeometry)| | No |
| `id` |[`string`](/docs/kcl/types/string)| The ID of the imported geometry. | No | | `id` |[`string`](/docs/kcl/types/string)| The ID of the imported geometry. | No |
| `value` |`[` [`string`](/docs/kcl/types/string) `]`| The original file paths. | No | | `value` |`[` [`string`](/docs/kcl/types/string) `]`| The original file paths. | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
---- ----
@ -295,7 +287,6 @@ Data for an imported geometry.
| Property | Type | Description | Required | | Property | Type | Description | Required |
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `type` |enum: `Function`| | No | | `type` |enum: `Function`| | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
---- ----
@ -312,7 +303,6 @@ Data for an imported geometry.
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `type` |enum: `Module`| | No | | `type` |enum: `Module`| | No |
| `value` |[`ModuleId`](/docs/kcl/types/ModuleId)| Identifier of a source file. Uses a u32 to keep the size small. | No | | `value` |[`ModuleId`](/docs/kcl/types/ModuleId)| Identifier of a source file. Uses a u32 to keep the size small. | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
---- ----
@ -328,7 +318,6 @@ Data for an imported geometry.
| Property | Type | Description | Required | | Property | Type | Description | Required |
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `type` |enum: `Type`| | No | | `type` |enum: `Type`| | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
---- ----
@ -345,7 +334,6 @@ Data for an imported geometry.
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `type` |enum: [`KclNone`](/docs/kcl/types/KclNone)| | No | | `type` |enum: [`KclNone`](/docs/kcl/types/KclNone)| | No |
| `value` |[`KclNone`](/docs/kcl/types/KclNone)| KCL value for an optional parameter which was not given an argument. (remember, parameters are in the function declaration, arguments are in the function call/application). | No | | `value` |[`KclNone`](/docs/kcl/types/KclNone)| KCL value for an optional parameter which was not given an argument. (remember, parameters are in the function declaration, arguments are in the function call/application). | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
---- ----
@ -362,7 +350,6 @@ Data for an imported geometry.
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `type` |enum: `Tombstone`| | No | | `type` |enum: `Tombstone`| | No |
| `value` |`null`| | No | | `value` |`null`| | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
---- ----

View File

@ -32,7 +32,6 @@ A sketch or a group of sketches.
| `artifactId` |[`ArtifactId`](/docs/kcl/types/ArtifactId)| The original id of the sketch. This stays the same even if the sketch is is sketched on face etc. | No | | `artifactId` |[`ArtifactId`](/docs/kcl/types/ArtifactId)| The original id of the sketch. This stays the same even if the sketch is is sketched on face etc. | No |
| `originalId` |[`string`](/docs/kcl/types/string)| | No | | `originalId` |[`string`](/docs/kcl/types/string)| | No |
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No | | `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| Metadata. | No |
---- ----

View File

@ -32,7 +32,6 @@ A sketch type.
| `yAxis` |[`Point3d`](/docs/kcl/types/Point3d)| What should the plane's Y axis be? | No | | `yAxis` |[`Point3d`](/docs/kcl/types/Point3d)| What should the plane's Y axis be? | No |
| `zAxis` |[`Point3d`](/docs/kcl/types/Point3d)| The z-axis (normal). | No | | `zAxis` |[`Point3d`](/docs/kcl/types/Point3d)| The z-axis (normal). | No |
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No | | `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
---- ----
@ -57,7 +56,6 @@ A face.
| `zAxis` |[`Point3d`](/docs/kcl/types/Point3d)| The z-axis (normal). | No | | `zAxis` |[`Point3d`](/docs/kcl/types/Point3d)| The z-axis (normal). | No |
| `solid` |[`Solid`](/docs/kcl/types/Solid)| The solid the face is on. | No | | `solid` |[`Solid`](/docs/kcl/types/Solid)| The solid the face is on. | No |
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No | | `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |
---- ----

View File

@ -0,0 +1,75 @@
---
title: "SolidOrImportedGeometry"
excerpt: "Data for a solid or an imported geometry."
layout: manual
---
Data for a solid or an imported geometry.
**This schema accepts exactly one of the following:**
**Type:** `object`
## Properties
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `type` |enum: `solid`| | No |
| `id` |[`string`](/docs/kcl/types/string)| The id of the solid. | No |
| `artifactId` |[`ArtifactId`](/docs/kcl/types/ArtifactId)| The artifact ID of the solid. Unlike `id`, this doesn't change. | No |
| `value` |`[` [`ExtrudeSurface`](/docs/kcl/types/ExtrudeSurface) `]`| The extrude surfaces. | No |
| `sketch` |[`Sketch`](/docs/kcl/types/Sketch)| The sketch. | No |
| `height` |[`number`](/docs/kcl/types/number)| The height of the solid. | No |
| `startCapId` |[`string`](/docs/kcl/types/string)| The id of the extrusion start cap | No |
| `endCapId` |[`string`](/docs/kcl/types/string)| The id of the extrusion end cap | No |
| `edgeCuts` |`[` [`EdgeCut`](/docs/kcl/types/EdgeCut) `]`| Chamfers or fillets on this solid. | No |
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
----
Data for an imported geometry.
**Type:** `object`
## Properties
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `type` |enum: `importedGeometry`| | No |
| `id` |[`string`](/docs/kcl/types/string)| The ID of the imported geometry. | No |
| `value` |`[` [`string`](/docs/kcl/types/string) `]`| The original file paths. | No |
----
**Type:** `[object, array]`
`[` [`Solid`](/docs/kcl/types/Solid) `]`
## Properties
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `type` |enum: `solidSet`| | No |
----

View File

@ -33,7 +33,6 @@ A solid or a group of solids.
| `endCapId` |[`string`](/docs/kcl/types/string)| The id of the extrusion end cap | No | | `endCapId` |[`string`](/docs/kcl/types/string)| The id of the extrusion end cap | No |
| `edgeCuts` |`[` [`EdgeCut`](/docs/kcl/types/EdgeCut) `]`| Chamfers or fillets on this solid. | No | | `edgeCuts` |`[` [`EdgeCut`](/docs/kcl/types/EdgeCut) `]`| Chamfers or fillets on this solid. | No |
| `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No | | `units` |[`UnitLen`](/docs/kcl/types/UnitLen)| A unit of length. | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| Metadata. | No |
---- ----

View File

@ -10,8 +10,9 @@ Draw a line relative to the current origin to a specified distance away from the
```js ```js
xLine( xLine(
length: number,
sketch: Sketch, sketch: Sketch,
length?: number,
endAbsolute?: number,
tag?: TagDeclarator, tag?: TagDeclarator,
): Sketch ): Sketch
``` ```
@ -21,9 +22,10 @@ xLine(
| Name | Type | Description | Required | | Name | Type | Description | Required |
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `length` | [`number`](/docs/kcl/types/number) | | Yes | | `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | Which sketch should this path be added to? | Yes |
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | | Yes | | `length` | [`number`](/docs/kcl/types/number) | How far away along the X axis should this line go? Incompatible with `endAbsolute`. | No |
| [`tag`](/docs/kcl/types/tag) | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No | | `endAbsolute` | [`number`](/docs/kcl/types/number) | Which absolute X value should this line go to? Incompatible with `length`. | No |
| [`tag`](/docs/kcl/types/tag) | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | Create a new tag which refers to this line | No |
### Returns ### Returns
@ -35,12 +37,12 @@ xLine(
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> xLine(15, %) |> xLine(length = 15)
|> angledLine({ angle = 80, length = 15 }, %) |> angledLine({ angle = 80, length = 15 }, %)
|> line(end = [8, -10]) |> line(end = [8, -10])
|> xLine(10, %) |> xLine(length = 10)
|> angledLine({ angle = 120, length = 30 }, %) |> angledLine({ angle = 120, length = 30 }, %)
|> xLine(-15, %) |> xLine(length = -15)
|> close() |> close()
example = extrude(exampleSketch, length = 10) example = extrude(exampleSketch, length = 10)

File diff suppressed because one or more lines are too long

View File

@ -10,8 +10,9 @@ Draw a line relative to the current origin to a specified distance away from the
```js ```js
yLine( yLine(
length: number,
sketch: Sketch, sketch: Sketch,
length?: number,
endAbsolute?: number,
tag?: TagDeclarator, tag?: TagDeclarator,
): Sketch ): Sketch
``` ```
@ -21,9 +22,10 @@ yLine(
| Name | Type | Description | Required | | Name | Type | Description | Required |
|----------|------|-------------|----------| |----------|------|-------------|----------|
| `length` | [`number`](/docs/kcl/types/number) | | Yes | | `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | Which sketch should this path be added to? | Yes |
| `sketch` | [`Sketch`](/docs/kcl/types/Sketch) | | Yes | | `length` | [`number`](/docs/kcl/types/number) | How far away along the Y axis should this line go? Incompatible with `endAbsolute`. | No |
| [`tag`](/docs/kcl/types/tag) | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | | No | | `endAbsolute` | [`number`](/docs/kcl/types/number) | Which absolute Y value should this line go to? Incompatible with `length`. | No |
| [`tag`](/docs/kcl/types/tag) | [`TagDeclarator`](/docs/kcl/types#tag-declaration) | Create a new tag which refers to this line | No |
### Returns ### Returns
@ -35,10 +37,10 @@ yLine(
```js ```js
exampleSketch = startSketchOn(XZ) exampleSketch = startSketchOn(XZ)
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> yLine(15, %) |> yLine(length = 15)
|> angledLine({ angle = 30, length = 15 }, %) |> angledLine({ angle = 30, length = 15 }, %)
|> line(end = [8, -10]) |> line(end = [8, -10])
|> yLine(-5, %) |> yLine(length = -5)
|> close() |> close()
example = extrude(exampleSketch, length = 10) example = extrude(exampleSketch, length = 10)

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,5 @@
import { test, expect, Page } from './zoo-test' import { Page } from '@playwright/test'
import { test, expect } from './zoo-test'
import { import {
getUtils, getUtils,
TEST_COLORS, TEST_COLORS,
@ -65,7 +66,7 @@ async function doBasicSketch(
if (openPanes.includes('code')) { if (openPanes.includes('code')) {
await expect(u.codeLocator) await expect(u.codeLocator)
.toHaveText(`sketch001 = startSketchOn('XZ')profile001 = startProfileAt(${commonPoints.startAt}, sketch001) .toHaveText(`sketch001 = startSketchOn('XZ')profile001 = startProfileAt(${commonPoints.startAt}, sketch001)
|> xLine(${commonPoints.num1}, %)`) |> xLine(length = ${commonPoints.num1})`)
} }
await page.waitForTimeout(500) await page.waitForTimeout(500)
await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20) await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20)
@ -74,8 +75,8 @@ async function doBasicSketch(
.toHaveText(`sketch001 = startSketchOn('XZ')profile001 = startProfileAt(${ .toHaveText(`sketch001 = startSketchOn('XZ')profile001 = startProfileAt(${
commonPoints.startAt commonPoints.startAt
}, sketch001) }, sketch001)
|> xLine(${commonPoints.num1}, %) |> xLine(length = ${commonPoints.num1})
|> yLine(${commonPoints.num1 + 0.01}, %)`) |> yLine(length = ${commonPoints.num1 + 0.01})`)
} else { } else {
await page.waitForTimeout(500) await page.waitForTimeout(500)
} }
@ -86,9 +87,9 @@ async function doBasicSketch(
.toHaveText(`sketch001 = startSketchOn('XZ')profile001 = startProfileAt(${ .toHaveText(`sketch001 = startSketchOn('XZ')profile001 = startProfileAt(${
commonPoints.startAt commonPoints.startAt
}, sketch001) }, sketch001)
|> xLine(${commonPoints.num1}, %) |> xLine(length = ${commonPoints.num1})
|> yLine(${commonPoints.num1 + 0.01}, %) |> yLine(length = ${commonPoints.num1 + 0.01})
|> xLine(${commonPoints.num2 * -1}, %)`) |> xLine(length = ${commonPoints.num2 * -1})`)
} }
// deselect line tool // deselect line tool
@ -146,9 +147,9 @@ async function doBasicSketch(
.toHaveText(`sketch001 = startSketchOn('XZ')profile001 = startProfileAt(${ .toHaveText(`sketch001 = startSketchOn('XZ')profile001 = startProfileAt(${
commonPoints.startAt commonPoints.startAt
}, sketch001) }, sketch001)
|> xLine(${commonPoints.num1}, %, $seg01) |> xLine(length = ${commonPoints.num1}, tag = $seg01)
|> yLine(${commonPoints.num1 + 0.01}, %) |> yLine(length = ${commonPoints.num1 + 0.01})
|> xLine(-segLen(seg01), %)`) |> xLine(length = -segLen(seg01))`)
} }
test.describe('Basic sketch', { tag: ['@skipWin'] }, () => { test.describe('Basic sketch', { tag: ['@skipWin'] }, () => {

View File

@ -1,4 +1,5 @@
import { test, expect, Page } from './zoo-test' import { Page } from '@playwright/test'
import { test, expect } from './zoo-test'
import { HomePageFixture } from './fixtures/homePageFixture' import { HomePageFixture } from './fixtures/homePageFixture'
import { getUtils } from './test-utils' import { getUtils } from './test-utils'
import { EngineCommand } from 'lang/std/artifactGraph' import { EngineCommand } from 'lang/std/artifactGraph'

View File

@ -16,7 +16,7 @@ test.describe('Command bar tests', { tag: ['@skipWin'] }, () => {
|> startProfileAt([-10, -10], %) |> startProfileAt([-10, -10], %)
|> line(end = [20, 0]) |> line(end = [20, 0])
|> line(end = [0, 20]) |> line(end = [0, 20])
|> xLine(-20, %) |> xLine(length = -20)
|> close() |> close()
` `
) )

View File

@ -10,7 +10,11 @@ import fsp from 'fs/promises'
test( test(
'export works on the first try', 'export works on the first try',
{ tag: ['@electron', '@skipLocalEngine'] }, { tag: ['@electron', '@skipLocalEngine'] },
async ({ page, context, scene }, testInfo) => { async ({ page, context, scene, tronApp }, testInfo) => {
if (!tronApp) {
fail()
}
await context.folderSetupFn(async (dir) => { await context.folderSetupFn(async (dir) => {
const bracketDir = path.join(dir, 'bracket') const bracketDir = path.join(dir, 'bracket')
await Promise.all([fsp.mkdir(bracketDir, { recursive: true })]) await Promise.all([fsp.mkdir(bracketDir, { recursive: true })])
@ -86,7 +90,7 @@ test(
await expect(exportingToastMessage).not.toBeVisible() await expect(exportingToastMessage).not.toBeVisible()
const firstFileFullPath = path.resolve( const firstFileFullPath = path.resolve(
getPlaywrightDownloadDir(page), getPlaywrightDownloadDir(tronApp.projectDirName),
exportFileName exportFileName
) )
await test.step('Check the export size', async () => { await test.step('Check the export size', async () => {
@ -165,7 +169,7 @@ test(
])) ]))
const secondFileFullPath = path.resolve( const secondFileFullPath = path.resolve(
getPlaywrightDownloadDir(page), getPlaywrightDownloadDir(tronApp.projectDirName),
exportFileName exportFileName
) )
await test.step('Check the export size', async () => { await test.step('Check the export size', async () => {
@ -181,7 +185,7 @@ test(
}, },
{ timeout: 15_000 } { timeout: 15_000 }
) )
.toBeGreaterThan(100_000) .toBeGreaterThan(70_000)
}) })
}) })
} }

View File

@ -800,10 +800,10 @@ test.describe('Editor tests', { tag: ['@skipWin'] }, () => {
await page.keyboard.press('ArrowDown') await page.keyboard.press('ArrowDown')
await page.keyboard.press('Enter') await page.keyboard.press('Enter')
// finish line with comment // finish line with comment
await page.keyboard.type('5')
await page.waitForTimeout(100)
await page.keyboard.press('Tab') await page.keyboard.press('Tab')
await page.waitForTimeout(100) await page.waitForTimeout(100)
await page.keyboard.type('5')
await page.waitForTimeout(100)
await page.keyboard.press('Tab') await page.keyboard.press('Tab')
await page.keyboard.type(' // ') await page.keyboard.type(' // ')
@ -817,7 +817,7 @@ test.describe('Editor tests', { tag: ['@skipWin'] }, () => {
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`sketch001 = startSketchOn('XZ') .toHaveText(`sketch001 = startSketchOn('XZ')
|> startProfileAt([3.14, 12], %) |> startProfileAt([3.14, 12], %)
|> xLine(5, %) // lin`) |> xLine(%, length = 5) // lin`)
// expect there to be no KCL errors // expect there to be no KCL errors
await expect(page.locator('.cm-lint-marker-error')).toHaveCount(0) await expect(page.locator('.cm-lint-marker-error')).toHaveCount(0)
@ -873,10 +873,10 @@ test.describe('Editor tests', { tag: ['@skipWin'] }, () => {
await page.keyboard.press('ArrowDown') await page.keyboard.press('ArrowDown')
await page.keyboard.press('Tab') await page.keyboard.press('Tab')
// finish line with comment // finish line with comment
await page.keyboard.type('5')
await page.waitForTimeout(100)
await page.keyboard.press('Tab') await page.keyboard.press('Tab')
await page.waitForTimeout(100) await page.waitForTimeout(100)
await page.keyboard.type('5')
await page.waitForTimeout(100)
await page.keyboard.press('Tab') await page.keyboard.press('Tab')
await page.keyboard.type(' // ') await page.keyboard.type(' // ')
@ -890,7 +890,7 @@ test.describe('Editor tests', { tag: ['@skipWin'] }, () => {
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`sketch001 = startSketchOn('XZ') .toHaveText(`sketch001 = startSketchOn('XZ')
|> startProfileAt([3.14, 12], %) |> startProfileAt([3.14, 12], %)
|> xLine(5, %) // lin`) |> xLine(%, length = 5) // lin`)
}) })
}) })
test('Can undo a click and point extrude with ctrl+z', async ({ test('Can undo a click and point extrude with ctrl+z', async ({

View File

@ -8,7 +8,7 @@ const FEATURE_TREE_EXAMPLE_CODE = `export fn timesFive(x) {
export fn triangle() { export fn triangle() {
return startSketchOn('XZ') return startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> xLine(10, %) |> xLine(length = 10)
|> line(end = [-10, -5]) |> line(end = [-10, -5])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
@ -28,7 +28,7 @@ plane001 = offsetPlane('XY', offset = 10)
sketch002 = startSketchOn(plane001) sketch002 = startSketchOn(plane001)
|> startProfileAt([-20, 0], %) |> startProfileAt([-20, 0], %)
|> line(end = [5, -15]) |> line(end = [5, -15])
|> xLine(-10, %) |> xLine(length = -10)
|> line(endAbsolute = [-40, 0]) |> line(endAbsolute = [-40, 0])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
@ -274,7 +274,6 @@ test.describe('Feature Tree pane', () => {
currentArgKey: 'distance', currentArgKey: 'distance',
currentArgValue: initialInput, currentArgValue: initialInput,
headerArguments: { headerArguments: {
Selection: '1 face',
Distance: initialInput, Distance: initialInput,
}, },
highlightedHeaderArg: 'distance', highlightedHeaderArg: 'distance',
@ -291,7 +290,6 @@ test.describe('Feature Tree pane', () => {
await cmdBar.expectState({ await cmdBar.expectState({
stage: 'review', stage: 'review',
headerArguments: { headerArguments: {
Selection: '1 face',
// The calculated value is shown in the argument summary // The calculated value is shown in the argument summary
Distance: initialInput, Distance: initialInput,
}, },
@ -402,7 +400,7 @@ test.describe('Feature Tree pane', () => {
sketch001 = startSketchOn(plane001) sketch001 = startSketchOn(plane001)
profile001 = circle(sketch001, center = [0, 20], radius = 12) profile001 = circle(sketch001, center = [0, 20], radius = 12)
profile002 = startProfileAt([0, 7.25], sketch001) profile002 = startProfileAt([0, 7.25], sketch001)
|> xLine(13.3, %) |> xLine(length = 13.3)
profile003 = startProfileAt([0, -4.93], sketch001) profile003 = startProfileAt([0, -4.93], sketch001)
|> line(endAbsolute = [-5.56, 0])` |> line(endAbsolute = [-5.56, 0])`
await context.folderSetupFn(async (dir) => { await context.folderSetupFn(async (dir) => {

View File

@ -158,11 +158,14 @@ test.describe('when using the file tree to', () => {
await createNewFile('lee') await createNewFile('lee')
await test.step('Postcondition: there are 5 new lee-*.kcl files', async () => { await test.step('Postcondition: there are 5 new lee-*.kcl files', async () => {
await expect( await expect
page .poll(() =>
.locator('[data-testid="file-pane-scroll-container"] button') page
.filter({ hasText: /lee[-]?[0-5]?/ }) .locator('[data-testid="file-pane-scroll-container"] button')
).toHaveCount(5) .filter({ hasText: /lee[-]?[0-5]?/ })
.count()
)
.toEqual(5)
}) })
} }
) )

View File

@ -27,28 +27,19 @@ type CmdBarSerialised =
export class CmdBarFixture { export class CmdBarFixture {
public page: Page public page: Page
public cmdBarOpenBtn!: Locator
get cmdBarOpenBtn() { public cmdBarElement!: Locator
return this.page.getByTestId('command-bar-open-button')
}
get cmdBarElement() {
return this.page.getByTestId('command-bar')
}
constructor(page: Page) { constructor(page: Page) {
this.page = page this.page = page
this.cmdBarOpenBtn = this.page.getByTestId('command-bar-open-button')
this.cmdBarElement = this.page.getByTestId('command-bar')
} }
get currentArgumentInput() { get currentArgumentInput() {
return this.page.getByTestId('cmd-bar-arg-value') return this.page.getByTestId('cmd-bar-arg-value')
} }
// Put all selectors here because this method is re-run on fixture creation.
reConstruct = (page: Page) => {
this.page = page
}
private _serialiseCmdBar = async (): Promise<CmdBarSerialised> => { private _serialiseCmdBar = async (): Promise<CmdBarSerialised> => {
if (!(await this.page.getByTestId('command-bar-wrapper').isVisible())) { if (!(await this.page.getByTestId('command-bar-wrapper').isVisible())) {
return { stage: 'commandBarClosed' } return { stage: 'commandBarClosed' }

View File

@ -24,11 +24,6 @@ export class EditorFixture {
constructor(page: Page) { constructor(page: Page) {
this.page = page this.page = page
this.reConstruct(page)
}
reConstruct = (page: Page) => {
this.page = page
this.codeContent = page.locator('.cm-content[data-language="kcl"]') this.codeContent = page.locator('.cm-content[data-language="kcl"]')
this.diagnosticsTooltip = page.locator('.cm-tooltip-lint') this.diagnosticsTooltip = page.locator('.cm-tooltip-lint')
this.diagnosticsGutterIcon = page.locator('.cm-lint-marker-error') this.diagnosticsGutterIcon = page.locator('.cm-lint-marker-error')
@ -87,6 +82,30 @@ export class EditorFixture {
toContain: this._expectEditorToContain(), toContain: this._expectEditorToContain(),
not: { toContain: this._expectEditorToContain(true) }, not: { toContain: this._expectEditorToContain(true) },
} }
snapshot = async (options?: { timeout?: number; name?: string }) => {
const wasPaneOpen = await this.checkIfPaneIsOpen()
if (!wasPaneOpen) {
await this.openPane()
}
try {
// Use expect.poll to implement retry logic
await expect
.poll(
async () => {
const code = await this.codeContent.textContent()
return code || ''
},
{ timeout: options?.timeout || 5000 }
)
.toMatchSnapshot(options?.name || 'editor-content')
} finally {
// Reset pane state if needed
if (!wasPaneOpen) {
await this.closePane()
}
}
}
private _serialiseDiagnostics = async (): Promise<Array<string>> => { private _serialiseDiagnostics = async (): Promise<Array<string>> => {
const diagnostics = await this.diagnosticsGutterIcon.all() const diagnostics = await this.diagnosticsGutterIcon.all()
const diagnosticsContent: string[] = [] const diagnosticsContent: string[] = []

View File

@ -1,13 +1,31 @@
/* eslint-disable react-hooks/rules-of-hooks */
import type { import type {
BrowserContext, BrowserContext,
ElectronApplication, ElectronApplication,
Fixtures as PlaywrightFixtures,
TestInfo, TestInfo,
Page, Page,
} from '@playwright/test' } from '@playwright/test'
import { getUtils, setup, setupElectron } from '../test-utils' import {
_electron as electron,
PlaywrightTestArgs,
PlaywrightWorkerArgs,
} from '@playwright/test'
import * as TOML from '@iarna/toml'
import {
TEST_SETTINGS_KEY,
TEST_SETTINGS_CORRUPTED,
TEST_SETTINGS,
TEST_SETTINGS_DEFAULT_THEME,
} from '../storageStates'
import { SETTINGS_FILE_NAME, PROJECT_SETTINGS_FILE_NAME } from 'lib/constants'
import { getUtils, setup } from '../test-utils'
import fsp from 'fs/promises' import fsp from 'fs/promises'
import { join } from 'path' import fs from 'node:fs'
import path from 'path'
import { CmdBarFixture } from './cmdBarFixture' import { CmdBarFixture } from './cmdBarFixture'
import { EditorFixture } from './editorFixture' import { EditorFixture } from './editorFixture'
import { ToolbarFixture } from './toolbarFixture' import { ToolbarFixture } from './toolbarFixture'
@ -23,7 +41,7 @@ export class AuthenticatedApp {
public readonly testInfo: TestInfo public readonly testInfo: TestInfo
public readonly viewPortSize = { width: 1200, height: 500 } public readonly viewPortSize = { width: 1200, height: 500 }
public electronApp: undefined | ElectronApplication public electronApp: undefined | ElectronApplication
public dir: string = '' public projectDirName: string = ''
constructor(context: BrowserContext, page: Page, testInfo: TestInfo) { constructor(context: BrowserContext, page: Page, testInfo: TestInfo) {
this.context = context this.context = context
@ -46,7 +64,7 @@ export class AuthenticatedApp {
} }
getInputFile = (fileName: string) => { getInputFile = (fileName: string) => {
return fsp.readFile( return fsp.readFile(
join('rust', 'kcl-lib', 'e2e', 'executor', 'inputs', fileName), path.join('rust', 'kcl-lib', 'e2e', 'executor', 'inputs', fileName),
'utf-8' 'utf-8'
) )
} }
@ -59,101 +77,326 @@ export interface Fixtures {
scene: SceneFixture scene: SceneFixture
homePage: HomePageFixture homePage: HomePageFixture
} }
export class AuthenticatedTronApp {
public originalPage: Page
public page: Page
public browserContext: BrowserContext
public context: BrowserContext
public readonly testInfo: TestInfo
public electronApp: ElectronApplication | undefined
public readonly viewPortSize = { width: 1200, height: 500 }
public dir: string = ''
constructor( export class ElectronZoo {
browserContext: BrowserContext, public available: boolean = true
originalPage: Page, public electron!: ElectronApplication
testInfo: TestInfo public firstUrl = ''
) { public viewPortSize = { width: 1200, height: 500 }
this.page = originalPage public projectDirName = ''
this.originalPage = originalPage
this.browserContext = browserContext public page!: Page
// Will be overwritten in the initializer public context!: BrowserContext
this.context = browserContext
this.testInfo = testInfo constructor() {}
}
async initialise( // Help remote end by signaling we're done with the connection.
arg: { // If it takes longer than 10s to stop, just resolve.
fixtures: Partial<Fixtures> async makeAvailableAgain() {
folderSetupFn?: (projectDirName: string) => Promise<void> await this.page.evaluate(async () => {
cleanProjectDir?: boolean return new Promise((resolve) => {
appSettings?: DeepPartial<Settings> if (!window.engineCommandManager.engineConnection?.state?.type) {
} = { fixtures: {} } return resolve(undefined)
) { }
const { electronApp, page, context, dir } = await setupElectron({
testInfo: this.testInfo, window.engineCommandManager.tearDown()
folderSetupFn: arg.folderSetupFn,
cleanProjectDir: arg.cleanProjectDir, // Keep polling (per js event tick) until state is Disconnected.
appSettings: arg.appSettings, const timeA = Date.now()
viewport: this.viewPortSize, const checkDisconnected = () => {
// It's possible we never even created an engineConnection
// e.g. never left Projects view.
if (
window.engineCommandManager?.engineConnection?.state.type ===
'disconnected'
) {
return resolve(undefined)
}
if (Date.now() - timeA > 10000) {
return resolve(undefined)
}
setTimeout(checkDisconnected, 0)
}
checkDisconnected()
})
}) })
this.page = page
// These assignments "fix" some brokenness in the Playwright Workbench when await this.context.tracing.stopChunk({ path: 'trace.zip' })
// running against electron applications.
// The timeline is still broken but failure screenshots work again.
this.context = context
// TODO: try to get this to work again for screenshots, but it messed with test ends when enabled
// Object.assign(this.browserContext, this.context)
this.electronApp = electronApp // Only after cleanup we're ready.
this.dir = dir this.available = true
}
// Easier to access throughout utils async createInstanceIfMissing(testInfo: TestInfo) {
this.page.dir = dir // Create or otherwise clear the folder.
this.projectDirName = testInfo.outputPath('electron-test-projects-dir')
// Setup localStorage, addCookies, reload // We need to expose this in order for some tests that require folder
await setup(this.context, this.page, this.testInfo) // creation and some code below.
const that = this
for (const key of unsafeTypedKeys(arg.fixtures)) { const options = {
const fixture = arg.fixtures[key] timeout: 120000,
if ( args: ['.', '--no-sandbox'],
!fixture || env: {
fixture instanceof AuthenticatedApp || ...process.env,
fixture instanceof AuthenticatedTronApp TEST_SETTINGS_FILE_KEY: this.projectDirName,
) IS_PLAYWRIGHT: 'true',
continue },
fixture.reConstruct(page) ...(process.env.ELECTRON_OVERRIDE_DIST_PATH
? {
executablePath:
process.env.ELECTRON_OVERRIDE_DIST_PATH + 'electron',
}
: {}),
...(process.env.PLAYWRIGHT_RECORD_VIDEO
? {
recordVideo: {
dir: testInfo.snapshotPath(),
size: this.viewPortSize,
},
}
: {}),
} }
// Do this once and then reuse window on subsequent calls.
if (!this.electron) {
this.electron = await electron.launch(options)
// Mac takes quite a long time to create the first window in CI.
// Turns out we can't trust firstWindow() either. So loop.
let timeoutId: ReturnType<typeof setTimeout>
const tryToGetWindowPage = () =>
new Promise((resolve) => {
const fn = () => {
this.page = this.electron.windows()[0]
timeoutId = setTimeout(() => {
if (this.page) {
clearTimeout(timeoutId)
return resolve(undefined)
}
fn()
}, 0)
}
fn()
})
await tryToGetWindowPage()
this.context = this.electron.context()
await this.context.tracing.start({ screenshots: true, snapshots: true })
}
await this.context.tracing.startChunk()
await setup(this.context, this.page, testInfo)
await this.cleanProjectDir()
// Create a consistent way to resize the page across electron and web.
// (lee) I had to do everything in the book to make electron change its
// damn window size. I succeeded in making it consistently and reliably
// do it after a whole afternoon.
this.page.setBodyDimensions = async function (dims: {
width: number
height: number
}) {
await this.setViewportSize(dims)
await that.electron?.evaluateHandle(async ({ app }, dims) => {
// @ts-ignore sorry jon but see comment in main.ts why this is ignored
await app.resizeWindow(dims.width, dims.height)
}, dims)
return this.evaluate(async (dims: { width: number; height: number }) => {
await window.electron.resizeWindow(dims.width, dims.height)
window.document.body.style.width = dims.width + 'px'
window.document.body.style.height = dims.height + 'px'
window.document.documentElement.style.width = dims.width + 'px'
window.document.documentElement.style.height = dims.height + 'px'
}, dims)
}
await this.page.setBodyDimensions(this.viewPortSize)
this.context.folderSetupFn = async function (fn) {
return fn(that.projectDirName)
.then(() => that.page.reload())
.then(() => ({
dir: that.projectDirName,
}))
}
// We need to patch this because addInitScript will bind too late in our
// electron tests, never running. We need to call reload() after each call
// to guarantee it runs.
const oldContextAddInitScript = this.context.addInitScript
this.context.addInitScript = async function (a, b) {
// @ts-ignore pretty sure way out of tsc's type checking capabilities.
// This code works perfectly fine.
await oldContextAddInitScript.apply(this, [a, b])
await that.page.reload()
}
// No idea why we mix and match page and context's addInitScript but we do
const oldPageAddInitScript = this.page.addInitScript
this.page.addInitScript = async function (a: any, b: any) {
// @ts-ignore pretty sure way out of tsc's type checking capabilities.
// This code works perfectly fine.
await oldPageAddInitScript.apply(this, [a, b])
await that.page.reload()
}
if (!this.firstUrl) {
await this.page.getByText('Your Projects').count()
this.firstUrl = this.page.url()
}
// Due to the app controlling its own window context we need to inject new
// options and context here.
// NOTE TO LEE: Seems to destroy page context when calling an electron loadURL.
// await tronApp.electronApp.evaluate(({ app }) => {
// return app.reuseWindowForTest();
// });
await this.electron?.evaluate(({ app }, projectDirName) => {
// @ts-ignore can't declaration merge see main.ts
app.testProperty['TEST_SETTINGS_FILE_KEY'] = projectDirName
}, this.projectDirName)
// Always start at the root view
await this.page.goto(this.firstUrl)
// Force a hard reload, destroying the stream and other state
await this.page.reload()
} }
close = async () => { async cleanProjectDir(appSettings?: DeepPartial<Settings>) {
await this.electronApp?.close?.() try {
if (fs.existsSync(this.projectDirName)) {
await fsp.rm(this.projectDirName, { recursive: true })
}
} catch (e) {
console.error(e)
}
try {
await fsp.mkdir(this.projectDirName)
} catch (e) {
// Not a problem if it already exists.
}
const tempSettingsFilePath = path.join(
this.projectDirName,
SETTINGS_FILE_NAME
)
let settingsOverridesToml = ''
if (appSettings) {
settingsOverridesToml = TOML.stringify({
// @ts-expect-error
settings: {
...TEST_SETTINGS,
...appSettings,
app: {
...TEST_SETTINGS.app,
project_directory: this.projectDirName,
...appSettings.app,
},
},
})
} else {
settingsOverridesToml = TOML.stringify({
// @ts-expect-error
settings: {
...TEST_SETTINGS,
app: {
...TEST_SETTINGS.app,
project_directory: this.projectDirName,
},
},
})
}
await fsp.writeFile(tempSettingsFilePath, settingsOverridesToml)
} }
debugPause = () =>
new Promise(() => {
console.log('UN-RESOLVING PROMISE')
})
} }
export const fixtures = { // If yee encounter this, please try to type it.
cmdBar: async ({ page }: { page: Page }, use: any) => { type FnUse = any
// eslint-disable-next-line react-hooks/rules-of-hooks
const fixturesForElectron = {
page: async (
{ tronApp }: { tronApp: ElectronZoo },
use: FnUse,
testInfo: TestInfo
) => {
await use(tronApp.page)
},
context: async (
{ tronApp }: { tronApp: ElectronZoo },
use: FnUse,
testInfo: TestInfo
) => {
await use(tronApp.context)
},
}
const fixturesForWeb = {
page: async (
{ page, context }: { page: Page; context: BrowserContext },
use: FnUse,
testInfo: TestInfo
) => {
page.setBodyDimensions = page.setViewportSize
// We do the same thing in ElectronZoo. addInitScript simply doesn't fire
// at the correct time, so we reload the page and it fires appropriately.
const oldPageAddInitScript = page.addInitScript
page.addInitScript = async function (...args) {
// @ts-expect-error
await oldPageAddInitScript.apply(this, args)
await page.reload()
}
const oldContextAddInitScript = context.addInitScript
context.addInitScript = async function (...args) {
// @ts-expect-error
await oldContextAddInitScript.apply(this, args)
await page.reload()
}
const webApp = new AuthenticatedApp(context, page, testInfo)
await webApp.initialise()
await use(page)
},
}
const fixturesBasedOnProcessEnvPlatform = {
cmdBar: async ({ page }: { page: Page }, use: FnUse) => {
await use(new CmdBarFixture(page)) await use(new CmdBarFixture(page))
}, },
editor: async ({ page }: { page: Page }, use: any) => { editor: async ({ page }: { page: Page }, use: FnUse) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
await use(new EditorFixture(page)) await use(new EditorFixture(page))
}, },
toolbar: async ({ page }: { page: Page }, use: any) => { toolbar: async ({ page }: { page: Page }, use: FnUse) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
await use(new ToolbarFixture(page)) await use(new ToolbarFixture(page))
}, },
scene: async ({ page }: { page: Page }, use: any) => { scene: async ({ page }: { page: Page }, use: FnUse) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
await use(new SceneFixture(page)) await use(new SceneFixture(page))
}, },
homePage: async ({ page }: { page: Page }, use: any) => { homePage: async ({ page }: { page: Page }, use: FnUse) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
await use(new HomePageFixture(page)) await use(new HomePageFixture(page))
}, },
} }
if (process.env.PLATFORM === 'web') {
Object.assign(fixturesBasedOnProcessEnvPlatform, fixturesForWeb)
} else {
Object.assign(fixturesBasedOnProcessEnvPlatform, fixturesForElectron)
}
export { fixturesBasedOnProcessEnvPlatform }

View File

@ -27,10 +27,6 @@ export class HomePageFixture {
constructor(page: Page) { constructor(page: Page) {
this.page = page this.page = page
this.reConstruct(page)
}
reConstruct = (page: Page) => {
this.page = page
this.projectSection = this.page.getByTestId('home-section') this.projectSection = this.page.getByTestId('home-section')
@ -96,8 +92,12 @@ export class HomePageFixture {
} }
} }
createAndGoToProject = async (projectTitle = 'project-$nnn') => { projectsLoaded = async () => {
await expect(this.projectSection).not.toHaveText('Loading your Projects...') await expect(this.projectSection).not.toHaveText('Loading your Projects...')
}
createAndGoToProject = async (projectTitle = 'project-$nnn') => {
await this.projectsLoaded()
await this.projectButtonNew.click() await this.projectButtonNew.click()
await this.projectTextName.click() await this.projectTextName.click()
await this.projectTextName.fill(projectTitle) await this.projectTextName.fill(projectTitle)

View File

@ -53,7 +53,12 @@ export class SceneFixture {
constructor(page: Page) { constructor(page: Page) {
this.page = page this.page = page
this.reConstruct(page) this.streamWrapper = page.getByTestId('stream')
this.networkToggleConnected = page.getByTestId('network-toggle-ok')
this.loadingIndicator = this.streamWrapper.getByTestId('loading')
this.startEditSketchBtn = page
.getByRole('button', { name: 'Start Sketch' })
.or(page.getByRole('button', { name: 'Edit Sketch' }))
} }
private _serialiseScene = async (): Promise<SceneSerialised> => { private _serialiseScene = async (): Promise<SceneSerialised> => {
const camera = await this.getCameraInfo() const camera = await this.getCameraInfo()
@ -72,17 +77,6 @@ export class SceneFixture {
.toEqual(expected) .toEqual(expected)
} }
reConstruct = (page: Page) => {
this.page = page
this.streamWrapper = page.getByTestId('stream')
this.networkToggleConnected = page.getByTestId('network-toggle-ok')
this.loadingIndicator = this.streamWrapper.getByTestId('loading')
this.startEditSketchBtn = page
.getByRole('button', { name: 'Start Sketch' })
.or(page.getByRole('button', { name: 'Edit Sketch' }))
}
makeMouseHelpers = ( makeMouseHelpers = (
x: number, x: number,
y: number, y: number,
@ -253,7 +247,7 @@ export class SceneFixture {
await u.openDebugPanel() await u.openDebugPanel()
await u.expectCmdLog('[data-message-type="execution-done"]') await u.expectCmdLog('[data-message-type="execution-done"]')
await u.clearAndCloseDebugPanel() await u.closeDebugPanel()
await this.waitForExecutionDone() await this.waitForExecutionDone()
await expect(this.startEditSketchBtn).not.toBeDisabled() await expect(this.startEditSketchBtn).not.toBeDisabled()

View File

@ -37,13 +37,12 @@ export class ToolbarFixture {
featureTreeId = 'feature-tree' as const featureTreeId = 'feature-tree' as const
/** The pane element for the Feature Tree */ /** The pane element for the Feature Tree */
featureTreePane!: Locator featureTreePane!: Locator
gizmo!: Locator
gizmoDisabled!: Locator
constructor(page: Page) { constructor(page: Page) {
this.page = page this.page = page
this.reConstruct(page)
}
reConstruct = (page: Page) => {
this.page = page
this.extrudeButton = page.getByTestId('extrude') this.extrudeButton = page.getByTestId('extrude')
this.loftButton = page.getByTestId('loft') this.loftButton = page.getByTestId('loft')
this.sweepButton = page.getByTestId('sweep') this.sweepButton = page.getByTestId('sweep')
@ -67,6 +66,13 @@ export class ToolbarFixture {
this.filePane = page.locator('#files-pane') this.filePane = page.locator('#files-pane')
this.featureTreePane = page.locator('#feature-tree-pane') this.featureTreePane = page.locator('#feature-tree-pane')
this.fileCreateToast = page.getByText('Successfully created') this.fileCreateToast = page.getByText('Successfully created')
// Note to test writers: having two locators like this is preferable to one
// which changes another el property because it means our test "signal" is
// completely decoupled from the elements themselves. It means the same
// element or two different elements can represent these states.
this.gizmo = page.getByTestId('gizmo')
this.gizmoDisabled = page.getByTestId('gizmo-disabled')
} }
get editSketchBtn() { get editSketchBtn() {
@ -86,6 +92,18 @@ export class ToolbarFixture {
startSketchPlaneSelection = async () => startSketchPlaneSelection = async () =>
doAndWaitForImageDiff(this.page, () => this.startSketchBtn.click(), 500) doAndWaitForImageDiff(this.page, () => this.startSketchBtn.click(), 500)
waitUntilSketchingReady = async () => {
await expect(this.gizmoDisabled).toBeVisible()
}
startSketchThenCallbackThenWaitUntilReady = async (
cb: () => Promise<void>
) => {
await this.startSketchBtn.click()
await cb()
await this.waitUntilSketchingReady()
}
exitSketch = async () => { exitSketch = async () => {
await this.exitSketchBtn.click() await this.exitSketchBtn.click()
await expect( await expect(

View File

@ -21,58 +21,54 @@ import { expectPixelColor } from './fixtures/sceneFixture'
// we must set it to empty for the tests where we want to see the onboarding immediately. // we must set it to empty for the tests where we want to see the onboarding immediately.
test.describe('Onboarding tests', () => { test.describe('Onboarding tests', () => {
test( test('Onboarding code is shown in the editor', async ({
'Onboarding code is shown in the editor', page,
{ homePage,
appSettings: { tronApp,
app: { }) => {
onboarding_status: '', if (!tronApp) {
}, fail()
},
cleanProjectDir: true,
},
async ({ page, homePage }) => {
const u = await getUtils(page)
await page.setBodyDimensions({ width: 1200, height: 500 })
await homePage.goToModelingScene()
// Test that the onboarding pane loaded
await expect(
page.getByText('Welcome to Modeling App! This')
).toBeVisible()
// Test that the onboarding pane loaded
await expect(
page.getByText('Welcome to Modeling App! This')
).toBeVisible()
// *and* that the code is shown in the editor
await expect(page.locator('.cm-content')).toContainText(
'// Shelf Bracket'
)
// Make sure the model loaded
const XYPlanePoint = { x: 774, y: 116 } as const
const modelColor: [number, number, number] = [45, 45, 45]
await page.mouse.move(XYPlanePoint.x, XYPlanePoint.y)
expect(await u.getGreatestPixDiff(XYPlanePoint, modelColor)).toBeLessThan(
8
)
} }
) await tronApp.cleanProjectDir({
app: {
onboarding_status: '',
},
})
const u = await getUtils(page)
await page.setBodyDimensions({ width: 1200, height: 500 })
await homePage.goToModelingScene()
// Test that the onboarding pane loaded
await expect(page.getByText('Welcome to Modeling App! This')).toBeVisible()
// Test that the onboarding pane loaded
await expect(page.getByText('Welcome to Modeling App! This')).toBeVisible()
// *and* that the code is shown in the editor
await expect(page.locator('.cm-content')).toContainText('// Shelf Bracket')
// Make sure the model loaded
const XYPlanePoint = { x: 774, y: 116 } as const
const modelColor: [number, number, number] = [45, 45, 45]
await page.mouse.move(XYPlanePoint.x, XYPlanePoint.y)
expect(await u.getGreatestPixDiff(XYPlanePoint, modelColor)).toBeLessThan(8)
})
test( test(
'Desktop: fresh onboarding executes and loads', 'Desktop: fresh onboarding executes and loads',
{ {
tag: '@electron', tag: '@electron',
appSettings: { },
async ({ page, tronApp }) => {
if (!tronApp) {
fail()
}
await tronApp.cleanProjectDir({
app: { app: {
onboarding_status: '', onboarding_status: '',
}, },
}, })
cleanProjectDir: true,
},
async ({ page }) => {
const u = await getUtils(page) const u = await getUtils(page)
const viewportSize = { width: 1200, height: 500 } const viewportSize = { width: 1200, height: 500 }
@ -107,223 +103,235 @@ test.describe('Onboarding tests', () => {
} }
) )
test( test('Code resets after confirmation', async ({
'Code resets after confirmation', context,
{ page,
cleanProjectDir: true, homePage,
}, tronApp,
async ({ context, page, homePage }) => { scene,
const initialCode = `sketch001 = startSketchOn('XZ')` cmdBar,
}) => {
if (!tronApp) {
fail()
}
await tronApp.cleanProjectDir()
// Load the page up with some code so we see the confirmation warning const initialCode = `sketch001 = startSketchOn('XZ')`
// when we go to replay onboarding
await context.addInitScript((code) => {
localStorage.setItem('persistCode', code)
}, initialCode)
await page.setBodyDimensions({ width: 1200, height: 500 }) // Load the page up with some code so we see the confirmation warning
await homePage.goToModelingScene() // when we go to replay onboarding
await page.addInitScript((code) => {
localStorage.setItem('persistCode', code)
}, initialCode)
// Replay the onboarding await page.setBodyDimensions({ width: 1200, height: 500 })
await page.getByRole('link', { name: 'Settings' }).last().click() await homePage.goToModelingScene()
const replayButton = page.getByRole('button', { await scene.connectionEstablished()
name: 'Replay onboarding',
})
await expect(replayButton).toBeVisible()
await replayButton.click()
// Ensure we see the warning, and that the code has not yet updated // Replay the onboarding
await expect(page.getByText('Would you like to create')).toBeVisible() await page.getByRole('link', { name: 'Settings' }).last().click()
await expect(page.locator('.cm-content')).toHaveText(initialCode) const replayButton = page.getByRole('button', {
name: 'Replay onboarding',
})
await expect(replayButton).toBeVisible()
await replayButton.click()
const nextButton = page.getByTestId('onboarding-next') // Ensure we see the warning, and that the code has not yet updated
await expect(page.getByText('Would you like to create')).toBeVisible()
await expect(page.locator('.cm-content')).toHaveText(initialCode)
const nextButton = page.getByTestId('onboarding-next')
await nextButton.hover()
await nextButton.click()
// Ensure we see the introduction and that the code has been reset
await expect(page.getByText('Welcome to Modeling App!')).toBeVisible()
await expect(page.locator('.cm-content')).toContainText('// Shelf Bracket')
// There used to be old code here that checked if we stored the reset
// code into localStorage but that isn't the case on desktop. It gets
// saved to the file system, which we have other tests for.
})
test('Click through each onboarding step and back', async ({
context,
page,
homePage,
tronApp,
}) => {
if (!tronApp) {
fail()
}
await tronApp.cleanProjectDir({
app: {
onboarding_status: '',
},
})
// Override beforeEach test setup
await context.addInitScript(
async ({ settingsKey, settings }) => {
// Give no initial code, so that the onboarding start is shown immediately
localStorage.setItem('persistCode', '')
localStorage.setItem(settingsKey, settings)
},
{
settingsKey: TEST_SETTINGS_KEY,
settings: settingsToToml({
settings: TEST_SETTINGS_ONBOARDING_START,
}),
}
)
await page.setBodyDimensions({ width: 1200, height: 1080 })
await homePage.goToModelingScene()
// Test that the onboarding pane loaded
await expect(page.getByText('Welcome to Modeling App! This')).toBeVisible()
const nextButton = page.getByTestId('onboarding-next')
const prevButton = page.getByTestId('onboarding-prev')
while ((await nextButton.innerText()) !== 'Finish') {
await nextButton.hover() await nextButton.hover()
await nextButton.click() await nextButton.click()
// Ensure we see the introduction and that the code has been reset
await expect(page.getByText('Welcome to Modeling App!')).toBeVisible()
await expect(page.locator('.cm-content')).toContainText(
'// Shelf Bracket'
)
// There used to be old code here that checked if we stored the reset
// code into localStorage but that isn't the case on desktop. It gets
// saved to the file system, which we have other tests for.
} }
)
test( while ((await prevButton.innerText()) !== 'Dismiss') {
'Click through each onboarding step and back',
{
appSettings: {
app: {
onboarding_status: '',
},
},
},
async ({ context, page, homePage }) => {
// Override beforeEach test setup
await context.addInitScript(
async ({ settingsKey, settings }) => {
// Give no initial code, so that the onboarding start is shown immediately
localStorage.setItem('persistCode', '')
localStorage.setItem(settingsKey, settings)
},
{
settingsKey: TEST_SETTINGS_KEY,
settings: settingsToToml({
settings: TEST_SETTINGS_ONBOARDING_START,
}),
}
)
await page.setBodyDimensions({ width: 1200, height: 1080 })
await homePage.goToModelingScene()
// Test that the onboarding pane loaded
await expect(
page.getByText('Welcome to Modeling App! This')
).toBeVisible()
const nextButton = page.getByTestId('onboarding-next')
const prevButton = page.getByTestId('onboarding-prev')
while ((await nextButton.innerText()) !== 'Finish') {
await nextButton.hover()
await nextButton.click()
}
while ((await prevButton.innerText()) !== 'Dismiss') {
await prevButton.hover()
await prevButton.click()
}
// Dismiss the onboarding
await prevButton.hover() await prevButton.hover()
await prevButton.click() await prevButton.click()
// Test that the onboarding pane is gone
await expect(page.getByTestId('onboarding-content')).not.toBeVisible()
await expect.poll(() => page.url()).not.toContain('/onboarding')
} }
)
test( // Dismiss the onboarding
'Onboarding redirects and code updating', await prevButton.hover()
{ await prevButton.click()
appSettings: {
app: { // Test that the onboarding pane is gone
onboarding_status: '/export', await expect(page.getByTestId('onboarding-content')).not.toBeVisible()
}, await expect.poll(() => page.url()).not.toContain('/onboarding')
})
test('Onboarding redirects and code updating', async ({
context,
page,
homePage,
tronApp,
}) => {
if (!tronApp) {
fail()
}
await tronApp.cleanProjectDir({
app: {
onboarding_status: '/export',
}, },
cleanProjectDir: true, })
},
async ({ context, page, homePage }) => {
const originalCode = 'sigmaAllow = 15000'
// Override beforeEach test setup const originalCode = 'sigmaAllow = 15000'
await context.addInitScript(
async ({ settingsKey, settings }) => {
// Give some initial code, so we can test that it's cleared
localStorage.setItem('persistCode', originalCode)
localStorage.setItem(settingsKey, settings)
},
{
settingsKey: TEST_SETTINGS_KEY,
settings: settingsToToml({
settings: TEST_SETTINGS_ONBOARDING_EXPORT,
}),
}
)
await page.setBodyDimensions({ width: 1200, height: 500 }) // Override beforeEach test setup
await homePage.goToModelingScene() await context.addInitScript(
async ({ settingsKey, settings }) => {
// Test that the redirect happened // Give some initial code, so we can test that it's cleared
await expect.poll(() => page.url()).toContain('/onboarding/export') localStorage.setItem('persistCode', originalCode)
localStorage.setItem(settingsKey, settings)
// Test that you come back to this page when you refresh
await page.reload()
await expect.poll(() => page.url()).toContain('/onboarding/export')
// Test that the code changes when you advance to the next step
await page.getByTestId('onboarding-next').hover()
await page.getByTestId('onboarding-next').click()
// Test that the onboarding pane loaded
const title = page.locator('[data-testid="onboarding-content"]')
await expect(title).toBeAttached()
await expect(page.locator('.cm-content')).not.toHaveText(originalCode)
// Test that the code is not empty when you click on the next step
await page.locator('[data-testid="onboarding-next"]').hover()
await page.locator('[data-testid="onboarding-next"]').click()
await expect(page.locator('.cm-content')).toHaveText(/.+/)
}
)
test(
'Onboarding code gets reset to demo on Interactive Numbers step',
{
appSettings: {
app: {
onboarding_status: '/parametric-modeling',
},
}, },
cleanProjectDir: true, {
}, settingsKey: TEST_SETTINGS_KEY,
settings: settingsToToml({
settings: TEST_SETTINGS_ONBOARDING_EXPORT,
}),
}
)
async ({ page, homePage }) => { await page.setBodyDimensions({ width: 1200, height: 500 })
const u = await getUtils(page) await homePage.goToModelingScene()
const badCode = `// This is bad code we shouldn't see`
await page.setBodyDimensions({ width: 1200, height: 1080 }) // Test that the redirect happened
await homePage.goToModelingScene() await expect.poll(() => page.url()).toContain('/onboarding/export')
await expect // Test that you come back to this page when you refresh
.poll(() => page.url()) await page.reload()
.toContain(onboardingPaths.PARAMETRIC_MODELING) await expect.poll(() => page.url()).toContain('/onboarding/export')
const bracketNoNewLines = bracket.replace(/\n/g, '') // Test that the code changes when you advance to the next step
await page.getByTestId('onboarding-next').hover()
await page.getByTestId('onboarding-next').click()
// Check the code got reset on load // Test that the onboarding pane loaded
await expect(page.locator('#code-pane')).toBeVisible() const title = page.locator('[data-testid="onboarding-content"]')
await expect(u.codeLocator).toHaveText(bracketNoNewLines, { await expect(title).toBeAttached()
timeout: 10_000,
})
// Mess with the code again await expect(page.locator('.cm-content')).not.toHaveText(originalCode)
await u.codeLocator.selectText()
await u.codeLocator.fill(badCode)
await expect(u.codeLocator).toHaveText(badCode)
// Click to the next step // Test that the code is not empty when you click on the next step
await page.locator('[data-testid="onboarding-next"]').hover() await page.locator('[data-testid="onboarding-next"]').hover()
await page.locator('[data-testid="onboarding-next"]').click() await page.locator('[data-testid="onboarding-next"]').click()
await page.waitForURL('**' + onboardingPaths.INTERACTIVE_NUMBERS, { await expect(page.locator('.cm-content')).toHaveText(/.+/)
waitUntil: 'domcontentloaded', })
})
// Check that the code has been reset test('Onboarding code gets reset to demo on Interactive Numbers step', async ({
await expect(u.codeLocator).toHaveText(bracketNoNewLines) page,
homePage,
tronApp,
}) => {
if (!tronApp) {
fail()
} }
) await tronApp.cleanProjectDir({
app: {
onboarding_status: '/parametric-modeling',
},
})
const u = await getUtils(page)
const badCode = `// This is bad code we shouldn't see`
await page.setBodyDimensions({ width: 1200, height: 1080 })
await homePage.goToModelingScene()
await expect
.poll(() => page.url())
.toContain(onboardingPaths.PARAMETRIC_MODELING)
const bracketNoNewLines = bracket.replace(/\n/g, '')
// Check the code got reset on load
await expect(page.locator('#code-pane')).toBeVisible()
await expect(u.codeLocator).toHaveText(bracketNoNewLines, {
timeout: 10_000,
})
// Mess with the code again
await u.codeLocator.selectText()
await u.codeLocator.fill(badCode)
await expect(u.codeLocator).toHaveText(badCode)
// Click to the next step
await page.locator('[data-testid="onboarding-next"]').hover()
await page.locator('[data-testid="onboarding-next"]').click()
await page.waitForURL('**' + onboardingPaths.INTERACTIVE_NUMBERS, {
waitUntil: 'domcontentloaded',
})
// Check that the code has been reset
await expect(u.codeLocator).toHaveText(bracketNoNewLines)
})
// (lee) The two avatar tests are weird because even on main, we don't have // (lee) The two avatar tests are weird because even on main, we don't have
// anything to do with the avatar inside the onboarding test. Due to the // anything to do with the avatar inside the onboarding test. Due to the
// low impact of an avatar not showing I'm changing this to fixme. // low impact of an avatar not showing I'm changing this to fixme.
test.fixme( test.fixme(
'Avatar text updates depending on image load success', 'Avatar text updates depending on image load success',
{ async ({ context, page, homePage, tronApp }) => {
appSettings: { if (!tronApp) {
fail()
}
await tronApp.cleanProjectDir({
app: { app: {
onboarding_status: '', onboarding_status: '',
}, },
}, })
cleanProjectDir: true,
},
async ({ context, page, homePage }) => {
// Override beforeEach test setup // Override beforeEach test setup
await context.addInitScript( await context.addInitScript(
async ({ settingsKey, settings }) => { async ({ settingsKey, settings }) => {
@ -388,15 +396,16 @@ test.describe('Onboarding tests', () => {
test.fixme( test.fixme(
"Avatar text doesn't mention avatar when no avatar", "Avatar text doesn't mention avatar when no avatar",
{ async ({ context, page, homePage, tronApp }) => {
appSettings: { if (!tronApp) {
fail()
}
await tronApp.cleanProjectDir({
app: { app: {
onboarding_status: '', onboarding_status: '',
}, },
}, })
cleanProjectDir: true,
},
async ({ context, page, homePage }) => {
// Override beforeEach test setup // Override beforeEach test setup
await context.addInitScript( await context.addInitScript(
async ({ settingsKey, settings }) => { async ({ settingsKey, settings }) => {
@ -444,15 +453,17 @@ test.describe('Onboarding tests', () => {
test.fixme( test.fixme(
'Restarting onboarding on desktop takes one attempt', 'Restarting onboarding on desktop takes one attempt',
{ async ({ context, page, tronApp }) => {
appSettings: { if (!tronApp) {
fail()
}
await tronApp.cleanProjectDir({
app: { app: {
onboarding_status: 'dismissed', onboarding_status: 'dismissed',
}, },
}, })
cleanProjectDir: true,
},
async ({ context, page }) => {
await context.folderSetupFn(async (dir) => { await context.folderSetupFn(async (dir) => {
const routerTemplateDir = join(dir, 'router-template-slate') const routerTemplateDir = join(dir, 'router-template-slate')
await fsp.mkdir(routerTemplateDir, { recursive: true }) await fsp.mkdir(routerTemplateDir, { recursive: true })

View File

@ -1,4 +1,5 @@
import { test, expect, Page } from './zoo-test' import { Page } from '@playwright/test'
import { test, expect } from './zoo-test'
import { EditorFixture } from './fixtures/editorFixture' import { EditorFixture } from './fixtures/editorFixture'
import { SceneFixture } from './fixtures/sceneFixture' import { SceneFixture } from './fixtures/sceneFixture'
import { ToolbarFixture } from './fixtures/toolbarFixture' import { ToolbarFixture } from './fixtures/toolbarFixture'
@ -524,7 +525,7 @@ profile001 = startProfileAt([205.96, 254.59], sketch002)
const expectedCodeSnippets = { const expectedCodeSnippets = {
sketchOnXzPlane: `sketch001 = startSketchOn('XZ')`, sketchOnXzPlane: `sketch001 = startSketchOn('XZ')`,
pointAtOrigin: `startProfileAt([${originSloppy.kcl[0]}, ${originSloppy.kcl[1]}], sketch001)`, pointAtOrigin: `startProfileAt([${originSloppy.kcl[0]}, ${originSloppy.kcl[1]}], sketch001)`,
segmentOnXAxis: `xLine(${xAxisSloppy.kcl[0]}, %)`, segmentOnXAxis: `xLine(length = ${xAxisSloppy.kcl[0]})`,
afterSegmentDraggedOffYAxis: `startProfileAt([${offYAxis.kcl[0]}, ${offYAxis.kcl[1]}], sketch001)`, afterSegmentDraggedOffYAxis: `startProfileAt([${offYAxis.kcl[0]}, ${offYAxis.kcl[1]}], sketch001)`,
afterSegmentDraggedOnYAxis: `startProfileAt([${yAxisSloppy.kcl[0]}, ${yAxisSloppy.kcl[1]}], sketch001)`, afterSegmentDraggedOnYAxis: `startProfileAt([${yAxisSloppy.kcl[0]}, ${yAxisSloppy.kcl[1]}], sketch001)`,
} }
@ -585,7 +586,7 @@ profile001 = startProfileAt([205.96, 254.59], sketch002)
openSketch = startSketchOn('XY') openSketch = startSketchOn('XY')
|> startProfileAt([-5, 0], %) |> startProfileAt([-5, 0], %)
|> line(endAbsolute = [0, 5]) |> line(endAbsolute = [0, 5])
|> xLine(5, %) |> xLine(length = 5)
|> tangentialArcTo([10, 0], %) |> tangentialArcTo([10, 0], %)
` `
const viewPortSize = { width: 1000, height: 500 } const viewPortSize = { width: 1000, height: 500 }
@ -1350,7 +1351,7 @@ loft001 = loft([sketch001, sketch002])
) )
sketch002 = startSketchOn('XZ') sketch002 = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> xLine(-500, %) |> xLine(length = -500)
|> tangentialArcTo([-2000, 500], %) |> tangentialArcTo([-2000, 500], %)
` `
await context.addInitScript((initialCode) => { await context.addInitScript((initialCode) => {
@ -1407,7 +1408,7 @@ sketch002 = startSketchOn('XZ')
}) })
await test.step(`Confirm code is added to the editor, scene has changed`, async () => { await test.step(`Confirm code is added to the editor, scene has changed`, async () => {
await scene.expectPixelColor([135, 64, 73], testPoint, 15) // await scene.expectPixelColor([135, 64, 73], testPoint, 15) // FIXME
await editor.expectEditor.toContain(sweepDeclaration) await editor.expectEditor.toContain(sweepDeclaration)
await editor.expectState({ await editor.expectState({
diagnostics: [], diagnostics: [],
@ -1444,7 +1445,7 @@ sketch002 = startSketchOn('XZ')
) )
sketch002 = startSketchOn('XZ') sketch002 = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> xLine(-500, %) |> xLine(length = -500)
|> line(endAbsolute = [-2000, 500]) |> line(endAbsolute = [-2000, 500])
` `
await context.addInitScript((initialCode) => { await context.addInitScript((initialCode) => {
@ -2365,9 +2366,9 @@ chamfer04 = chamfer(extrude001, length = 5, tags = [getOppositeEdge(seg02)])
}) => { }) => {
const initialCode = `sketch001 = startSketchOn('XY') const initialCode = `sketch001 = startSketchOn('XY')
|> startProfileAt([-20, 20], %) |> startProfileAt([-20, 20], %)
|> xLine(40, %) |> xLine(length = 40)
|> yLine(-60, %) |> yLine(length = -60)
|> xLine(-40, %) |> xLine(length = -40)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
extrude001 = extrude(sketch001, length = 40) extrude001 = extrude(sketch001, length = 40)
@ -2383,7 +2384,7 @@ extrude001 = extrude(sketch001, length = 40)
const testPoint = { x: 580, y: 180 } const testPoint = { x: 580, y: 180 }
const [clickOnCap] = scene.makeMouseHelpers(testPoint.x, testPoint.y) const [clickOnCap] = scene.makeMouseHelpers(testPoint.x, testPoint.y)
const [clickOnWall] = scene.makeMouseHelpers(testPoint.x, testPoint.y + 70) const [clickOnWall] = scene.makeMouseHelpers(testPoint.x, testPoint.y + 70)
const mutatedCode = 'xLine(-40, %, $seg01)' const mutatedCode = 'xLine(length = -40, tag = $seg01)'
const shellDeclaration = const shellDeclaration =
"shell001 = shell(extrude001, faces = ['end', seg01], thickness = 5)" "shell001 = shell(extrude001, faces = ['end', seg01], thickness = 5)"
@ -2549,9 +2550,9 @@ extrude002 = extrude(sketch002, length = 50)
}) => { }) => {
const sketchCode = `sketch001 = startSketchOn('XY') const sketchCode = `sketch001 = startSketchOn('XY')
profile001 = startProfileAt([-20, 20], sketch001) profile001 = startProfileAt([-20, 20], sketch001)
|> xLine(40, %) |> xLine(length = 40)
|> yLine(-60, %) |> yLine(length = -60)
|> xLine(-40, %) |> xLine(length = -40)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
` `
@ -2637,7 +2638,7 @@ profile001 = startProfileAt([-20, 20], sketch001)
) )
sketch002 = startSketchOn('XZ') sketch002 = startSketchOn('XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> xLine(-2000, %) |> xLine(length = -2000)
sweep001 = sweep(sketch001, path = sketch002) sweep001 = sweep(sketch001, path = sketch002)
` `
await context.addInitScript((initialCode) => { await context.addInitScript((initialCode) => {
@ -2798,7 +2799,7 @@ radius = 8.69
const initialCode = ` const initialCode = `
sketch002 = startSketchOn('XY') sketch002 = startSketchOn('XY')
|> startProfileAt([-2.02, 1.79], %) |> startProfileAt([-2.02, 1.79], %)
|> xLine(2.6, %) |> xLine(length = 2.6)
sketch001 = startSketchOn('-XY') sketch001 = startSketchOn('-XY')
|> startProfileAt([-0.48, 1.25], %) |> startProfileAt([-0.48, 1.25], %)
|> angledLine([0, 2.38], %, $rectangleSegmentA001) |> angledLine([0, 2.38], %, $rectangleSegmentA001)
@ -2830,7 +2831,7 @@ radius = 8.69
await page.getByText(codeToSelecton).click() await page.getByText(codeToSelecton).click()
await toolbar.revolveButton.click() await toolbar.revolveButton.click()
await page.getByText('Edge', { exact: true }).click() await page.getByText('Edge', { exact: true }).click()
const lineCodeToSelection = `|> xLine(2.6, %)` const lineCodeToSelection = `|> xLine(length = 2.6)`
await page.getByText(lineCodeToSelection).click() await page.getByText(lineCodeToSelection).click()
await cmdBar.progressCmdBar() await cmdBar.progressCmdBar()

View File

@ -163,7 +163,7 @@ test(
.poll(() => u.getGreatestPixDiff(pointOnModel, [85, 85, 85]), { .poll(() => u.getGreatestPixDiff(pointOnModel, [85, 85, 85]), {
timeout: 10_000, timeout: 10_000,
}) })
.toBeLessThan(15) .toBeLessThan(20)
}) })
await test.step('Clicking the logo takes us back to the projects page / home', async () => { await test.step('Clicking the logo takes us back to the projects page / home', async () => {
@ -464,7 +464,11 @@ test.describe('Can export from electron app', () => {
test( test(
`Can export using ${method}`, `Can export using ${method}`,
{ tag: ['@electron', '@skipLocalEngine'] }, { tag: ['@electron', '@skipLocalEngine'] },
async ({ context, page }, testInfo) => { async ({ context, page, tronApp }, testInfo) => {
if (!tronApp) {
fail()
}
await context.folderSetupFn(async (dir) => { await context.folderSetupFn(async (dir) => {
const bracketDir = path.join(dir, 'bracket') const bracketDir = path.join(dir, 'bracket')
await fsp.mkdir(bracketDir, { recursive: true }) await fsp.mkdir(bracketDir, { recursive: true })
@ -516,6 +520,7 @@ test.describe('Can export from electron app', () => {
storage: 'embedded', storage: 'embedded',
presentation: 'pretty', presentation: 'pretty',
}, },
tronApp.projectDirName,
page, page,
method method
) )
@ -523,7 +528,7 @@ test.describe('Can export from electron app', () => {
}) })
const filepath = path.resolve( const filepath = path.resolve(
getPlaywrightDownloadDir(page), getPlaywrightDownloadDir(tronApp.projectDirName),
'main.gltf' 'main.gltf'
) )
@ -781,6 +786,7 @@ test(
page.on('console', console.log) page.on('console', console.log)
await expect(page.getByText('router-template-slate')).toBeVisible() await expect(page.getByText('router-template-slate')).toBeVisible()
await expect(page.getByText('Loading your Projects...')).not.toBeVisible()
await expect(page.getByText('Your Projects')).toBeVisible() await expect(page.getByText('Your Projects')).toBeVisible()
await page.keyboard.press('Delete') await page.keyboard.press('Delete')
@ -858,7 +864,7 @@ test.describe(`Project management commands`, () => {
test( test(
`Delete from project page`, `Delete from project page`,
{ tag: '@electron' }, { tag: '@electron' },
async ({ context, page }, testInfo) => { async ({ context, page, scene, cmdBar }, testInfo) => {
const projectName = `my_project_to_delete` const projectName = `my_project_to_delete`
await context.folderSetupFn(async (dir) => { await context.folderSetupFn(async (dir) => {
await fsp.mkdir(`${dir}/${projectName}`, { recursive: true }) await fsp.mkdir(`${dir}/${projectName}`, { recursive: true })
@ -887,6 +893,8 @@ test.describe(`Project management commands`, () => {
await projectHomeLink.click() await projectHomeLink.click()
await u.waitForPageLoad() await u.waitForPageLoad()
await scene.connectionEstablished()
await scene.settled(cmdBar)
}) })
await test.step(`Run delete command via command palette`, async () => { await test.step(`Run delete command via command palette`, async () => {
@ -909,7 +917,7 @@ test.describe(`Project management commands`, () => {
test( test(
`Rename from home page`, `Rename from home page`,
{ tag: '@electron' }, { tag: '@electron' },
async ({ context, page }, testInfo) => { async ({ context, page, homePage }, testInfo) => {
const projectName = `my_project_to_rename` const projectName = `my_project_to_rename`
await context.folderSetupFn(async (dir) => { await context.folderSetupFn(async (dir) => {
await fsp.mkdir(`${dir}/${projectName}`, { recursive: true }) await fsp.mkdir(`${dir}/${projectName}`, { recursive: true })
@ -936,6 +944,7 @@ test.describe(`Project management commands`, () => {
await test.step(`Setup`, async () => { await test.step(`Setup`, async () => {
await page.setBodyDimensions({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
page.on('console', console.log) page.on('console', console.log)
await homePage.projectsLoaded()
await expect(projectHomeLink).toBeVisible() await expect(projectHomeLink).toBeVisible()
}) })
@ -1682,7 +1691,11 @@ test(
test( test(
'You can change the root projects directory and nothing is lost', 'You can change the root projects directory and nothing is lost',
{ tag: '@electron' }, { tag: '@electron' },
async ({ context, page, electronApp }, testInfo) => { async ({ context, page, tronApp, homePage }, testInfo) => {
if (!tronApp) {
fail()
}
await context.folderSetupFn(async (dir) => { await context.folderSetupFn(async (dir) => {
await Promise.all([ await Promise.all([
fsp.mkdir(`${dir}/router-template-slate`, { recursive: true }), fsp.mkdir(`${dir}/router-template-slate`, { recursive: true }),
@ -1712,6 +1725,8 @@ test(
await fsp.rm(newProjectDirName, { recursive: true }) await fsp.rm(newProjectDirName, { recursive: true })
} }
await homePage.projectsLoaded()
await test.step('We can change the root project directory', async () => { await test.step('We can change the root project directory', async () => {
// expect to see the project directory settings link // expect to see the project directory settings link
await expect( await expect(
@ -1725,7 +1740,7 @@ test(
.locator('section#projectDirectory input') .locator('section#projectDirectory input')
.inputValue() .inputValue()
const handleFile = electronApp?.evaluate( const handleFile = tronApp.electron.evaluate(
async ({ dialog }, filePaths) => { async ({ dialog }, filePaths) => {
dialog.showOpenDialog = () => dialog.showOpenDialog = () =>
Promise.resolve({ canceled: false, filePaths }) Promise.resolve({ canceled: false, filePaths })
@ -1741,6 +1756,8 @@ test(
await page.getByTestId('settings-close-button').click() await page.getByTestId('settings-close-button').click()
await homePage.projectsLoaded()
await expect(page.getByText('No Projects found')).toBeVisible() await expect(page.getByText('No Projects found')).toBeVisible()
await createProject({ name: 'project-000', page, returnHome: true }) await createProject({ name: 'project-000', page, returnHome: true })
await expect( await expect(
@ -1755,7 +1772,7 @@ test(
await page.getByTestId('project-directory-settings-link').click() await page.getByTestId('project-directory-settings-link').click()
const handleFile = electronApp?.evaluate( const handleFile = tronApp.electron.evaluate(
async ({ dialog }, filePaths) => { async ({ dialog }, filePaths) => {
dialog.showOpenDialog = () => dialog.showOpenDialog = () =>
Promise.resolve({ canceled: false, filePaths }) Promise.resolve({ canceled: false, filePaths })
@ -1767,6 +1784,7 @@ test(
await page.getByTestId('project-directory-button').click() await page.getByTestId('project-directory-button').click()
await handleFile await handleFile
await homePage.projectsLoaded()
await expect(page.locator('section#projectDirectory input')).toHaveValue( await expect(page.locator('section#projectDirectory input')).toHaveValue(
originalProjectDirName originalProjectDirName
) )
@ -2000,8 +2018,8 @@ test(
test( test(
'Settings persist across restarts', 'Settings persist across restarts',
{ tag: '@electron', cleanProjectDir: true }, { tag: '@electron' },
async ({ page }, testInfo) => { async ({ page, scene, cmdBar }, testInfo) => {
await test.step('We can change a user setting like theme', async () => { await test.step('We can change a user setting like theme', async () => {
await page.setBodyDimensions({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
@ -2014,6 +2032,10 @@ test(
await expect(page.getByTestId('app-theme')).toHaveValue('dark') await expect(page.getByTestId('app-theme')).toHaveValue('dark')
await page.getByTestId('app-theme').selectOption('light') await page.getByTestId('app-theme').selectOption('light')
await expect(page.getByTestId('app-theme')).toHaveValue('light')
// Give time to system for writing to a persistent store
await page.waitForTimeout(1000)
}) })
await test.step('Starting the app again and we can see the same theme', async () => { await test.step('Starting the app again and we can see the same theme', async () => {

View File

@ -32,9 +32,9 @@ profile001 = startProfileAt([57.81, 250.51], sketch001)
extrude001 = extrude(profile001, length = 200) extrude001 = extrude(profile001, length = 200)
sketch002 = startSketchOn('XZ') sketch002 = startSketchOn('XZ')
|> startProfileAt([-73.64, -42.89], %) |> startProfileAt([-73.64, -42.89], %)
|> xLine(173.71, %) |> xLine(length = 173.71)
|> line(end = [-22.12, -94.4]) |> line(end = [-22.12, -94.4])
|> xLine(-156.98, %) |> xLine(length = -156.98)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
extrude002 = extrude(sketch002, length = 50) extrude002 = extrude(sketch002, length = 50)

View File

@ -13,9 +13,9 @@ profile001 = startProfileAt([57.81, 250.51], sketch001)
extrude001 = extrude(profile001, length = 200) extrude001 = extrude(profile001, length = 200)
sketch002 = startSketchOn('XZ') sketch002 = startSketchOn('XZ')
|> startProfileAt([-114, 85.52], %) |> startProfileAt([-114, 85.52], %)
|> xLine(265.36, %) |> xLine(length = 265.36)
|> line(end = [33.17, -261.22]) |> line(end = [33.17, -261.22])
|> xLine(-297.25, %) |> xLine(length = -297.25)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
extrude002 = extrude(sketch002, length = 50) extrude002 = extrude(sketch002, length = 50)
@ -233,7 +233,7 @@ test.describe('Prompt-to-edit tests', { tag: '@skipWin' }, () => {
await cmdBar.openCmdBar('promptToEdit') await cmdBar.openCmdBar('promptToEdit')
await page await page
.getByTestId('cmd-bar-arg-value') .getByTestId('cmd-bar-arg-value')
.fill('Please rename to mySketch') .fill('Please rename to mySketch001')
await page.waitForTimeout(100) await page.waitForTimeout(100)
await cmdBar.progressCmdBar() await cmdBar.progressCmdBar()
await expect(submittingToast).toBeVisible() await expect(submittingToast).toBeVisible()
@ -244,10 +244,10 @@ test.describe('Prompt-to-edit tests', { tag: '@skipWin' }, () => {
}) })
await test.step('verify rename change and accept it', async () => { await test.step('verify rename change and accept it', async () => {
await editor.expectEditor.toContain('mySketch = startSketchOn') await editor.expectEditor.toContain('mySketch001 = startSketchOn')
await editor.expectEditor.not.toContain('sketch002 = startSketchOn') await editor.expectEditor.not.toContain('sketch002 = startSketchOn')
await editor.expectEditor.toContain( await editor.expectEditor.toContain(
'extrude002 = extrude(mySketch, length = 50)' 'extrude002 = extrude(mySketch001, length = 50)'
) )
await acceptBtn.click() await acceptBtn.click()

View File

@ -1,4 +1,5 @@
import { test, expect, Page } from './zoo-test' import { Page } from '@playwright/test'
import { test, expect } from './zoo-test'
import path from 'path' import path from 'path'
import * as fsp from 'fs/promises' import * as fsp from 'fs/promises'
import { getUtils, executorInputPath } from './test-utils' import { getUtils, executorInputPath } from './test-utils'
@ -249,7 +250,7 @@ extrude001 = extrude(sketch001, length = 50)
`exampleSketch = startSketchOn("XZ") `exampleSketch = startSketchOn("XZ")
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle: 50, length: 45 }, %) |> angledLine({ angle: 50, length: 45 }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
|> |>
@ -305,7 +306,7 @@ extrude001 = extrude(sketch001, length = 50)
.toContainText(`exampleSketch = startSketchOn("XZ") .toContainText(`exampleSketch = startSketchOn("XZ")
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> angledLine({ angle: 50, length: 45 }, %) |> angledLine({ angle: 50, length: 45 }, %)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
thing: "blah"`) thing: "blah"`)

View File

@ -1,4 +1,5 @@
import { test, expect, Page } from './zoo-test' import { Page } from '@playwright/test'
import { test, expect } from './zoo-test'
import fs from 'node:fs/promises' import fs from 'node:fs/promises'
import path from 'node:path' import path from 'node:path'
import { HomePageFixture } from './fixtures/homePageFixture' import { HomePageFixture } from './fixtures/homePageFixture'
@ -48,26 +49,26 @@ test.describe('Sketch tests', { tag: ['@skipWin'] }, () => {
part001 = startSketchOn('XY') part001 = startSketchOn('XY')
${startProfileAt2} ${startProfileAt2}
|> xLine(width * .5, %) |> xLine(length = width * .5)
|> yLine(height, %) |> yLine(length = height)
|> xLine(-width * .5, %) |> xLine(length = -width * .5)
|> close() |> close()
|> hole(screwHole, %) |> hole(screwHole, %)
|> extrude(length = thickness) |> extrude(length = thickness)
part002 = startSketchOn('-XZ') part002 = startSketchOn('-XZ')
${startProfileAt3} ${startProfileAt3}
|> xLine(width / 4, %) |> xLine(length = width / 4)
|> tangentialArcTo([width / 2, 0], %) |> tangentialArcTo([width / 2, 0], %)
|> xLine(-width / 4 + wireRadius, %) |> xLine(length = -width / 4 + wireRadius)
|> yLine(wireOffset, %) |> yLine(length = wireOffset)
|> arc({ |> arc({
radius = wireRadius, radius = wireRadius,
angleStart = 0, angleStart = 0,
angleEnd = 180 angleEnd = 180
}, %) }, %)
|> yLine(-wireOffset, %) |> yLine(length = -wireOffset)
|> xLine(-width / 4, %) |> xLine(length = -width / 4)
|> close() |> close()
|> extrude(length = -height) |> extrude(length = -height)
` `
@ -111,7 +112,7 @@ test.describe('Sketch tests', { tag: ['@skipWin'] }, () => {
'persistCode', 'persistCode',
`sketch001 = startSketchOn('XZ') `sketch001 = startSketchOn('XZ')
|> startProfileAt([2.61, -4.01], %) |> startProfileAt([2.61, -4.01], %)
|> xLine(8.73, %) |> xLine(length = 8.73)
|> tangentialArcTo([8.33, -1.31], %)` |> tangentialArcTo([8.33, -1.31], %)`
) )
}) })
@ -157,7 +158,7 @@ test.describe('Sketch tests', { tag: ['@skipWin'] }, () => {
await expect.poll(u.normalisedEditorCode, { timeout: 1000 }) await expect.poll(u.normalisedEditorCode, { timeout: 1000 })
.toBe(`sketch002 = startSketchOn('XZ') .toBe(`sketch002 = startSketchOn('XZ')
sketch001 = startProfileAt([12.34, -12.34], sketch002) sketch001 = startProfileAt([12.34, -12.34], sketch002)
|> yLine(12.34, %) |> yLine(length = 12.34)
`) `)
}).toPass({ timeout: 5_000, intervals: [1_000] }) }).toPass({ timeout: 5_000, intervals: [1_000] })
@ -691,15 +692,15 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
await click00r(50, 0) await click00r(50, 0)
await page.waitForTimeout(100) await page.waitForTimeout(100)
codeStr += ` |> xLine(${toU(50, 0)[0]}, %)` codeStr += ` |> xLine(length = ${toU(50, 0)[0]})`
await expect(u.codeLocator).toHaveText(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
await click00r(0, 50) await click00r(0, 50)
codeStr += ` |> yLine(${toU(0, 50)[1]}, %)` codeStr += ` |> yLine(length = ${toU(0, 50)[1]})`
await expect(u.codeLocator).toHaveText(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
await click00r(-50, 0) await click00r(-50, 0)
codeStr += ` |> xLine(${toU(-50, 0)[0]}, %)` codeStr += ` |> xLine(length = ${toU(-50, 0)[0]})`
await expect(u.codeLocator).toHaveText(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
// exit the sketch, reset relative clicker // exit the sketch, reset relative clicker
@ -728,15 +729,15 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
// TODO: I couldn't use `toSU` here because of some rounding error causing // TODO: I couldn't use `toSU` here because of some rounding error causing
// it to be off by 0.01 // it to be off by 0.01
await click00r(30, 0) await click00r(30, 0)
codeStr += ` |> xLine(2.04, %)` codeStr += ` |> xLine(length = 2.04)`
await expect(u.codeLocator).toHaveText(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
await click00r(0, 30) await click00r(0, 30)
codeStr += ` |> yLine(-2.03, %)` codeStr += ` |> yLine(length = -2.03)`
await expect(u.codeLocator).toHaveText(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
await click00r(-30, 0) await click00r(-30, 0)
codeStr += ` |> xLine(-2.04, %)` codeStr += ` |> xLine(length = -2.04)`
await expect(u.codeLocator).toHaveText(codeStr) await expect(u.codeLocator).toHaveText(codeStr)
await click00r(undefined, undefined) await click00r(undefined, undefined)
@ -761,8 +762,8 @@ sketch001 = startProfileAt([12.34, -12.34], sketch002)
profile001 = startProfileAt([${roundOff(scale * 69.6)}, ${roundOff( profile001 = startProfileAt([${roundOff(scale * 69.6)}, ${roundOff(
scale * 34.8 scale * 34.8
)}], sketch001) )}], sketch001)
|> xLine(${roundOff(scale * 139.19)}, %) |> xLine(length = ${roundOff(scale * 139.19)})
|> yLine(-${roundOff(scale * 139.2)}, %) |> yLine(length = -${roundOff(scale * 139.2)})
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close()` |> close()`
@ -1018,7 +1019,7 @@ profile001 = startProfileAt([${roundOff(scale * 69.6)}, ${roundOff(
|> startProfileAt([-10, -10], %) |> startProfileAt([-10, -10], %)
|> line(end = [20, 0]) |> line(end = [20, 0])
|> line(end = [0, 20]) |> line(end = [0, 20])
|> xLine(-20, %) |> xLine(length = -20)
`) `)
await u.expectCmdLog('[data-message-type="execution-done"]') await u.expectCmdLog('[data-message-type="execution-done"]')
@ -1094,8 +1095,8 @@ profile001 = startProfileAt([${roundOff(scale * 69.6)}, ${roundOff(
lugSketch = startSketchOn(plane) lugSketch = startSketchOn(plane)
|> startProfileAt([origin[0] + lugDiameter / 2, origin[1]], %) |> startProfileAt([origin[0] + lugDiameter / 2, origin[1]], %)
|> angledLineOfYLength({ angle = 60, length = lugHeadLength }, %) |> angledLineOfYLength({ angle = 60, length = lugHeadLength }, %)
|> xLineTo(0 + .001, %) |> xLine(endAbsolute = 0 + .001)
|> yLineTo(0, %) |> yLine(endAbsolute = 0)
|> close() |> close()
|> revolve({ axis = "Y" }, %) |> revolve({ axis = "Y" }, %)
@ -1368,7 +1369,7 @@ profile001 = startProfileAt([121.52, 168.25], sketch001)
|> close() |> close()
profile002 = startProfileAt([117.2, 56.08], sketch001) profile002 = startProfileAt([117.2, 56.08], sketch001)
|> line(end = [166.82, 25.89]) |> line(end = [166.82, 25.89])
|> yLine(-107.86, %) |> yLine(length = -107.86)
` `
) )
@ -1456,9 +1457,9 @@ profile002 = startProfileAt([117.2, 56.08], sketch001)
'persistCode', 'persistCode',
`sketch001 = startSketchOn('XZ') `sketch001 = startSketchOn('XZ')
profile002 = startProfileAt([40.68, 87.67], sketch001) profile002 = startProfileAt([40.68, 87.67], sketch001)
|> xLine(239.17, %) |> xLine(length = 239.17)
profile003 = startProfileAt([206.63, -56.73], sketch001) profile003 = startProfileAt([206.63, -56.73], sketch001)
|> xLine(-156.32, %) |> xLine(length = -156.32)
` `
) )
}) })
@ -2153,6 +2154,8 @@ extrude001 = extrude(profile003, length = 5)
await page.setBodyDimensions({ width: 1000, height: 500 }) await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene() await homePage.goToModelingScene()
await page.waitForTimeout(5000)
await expect( await expect(
page.getByRole('button', { name: 'Start Sketch' }) page.getByRole('button', { name: 'Start Sketch' })
).not.toBeDisabled() ).not.toBeDisabled()
@ -2165,7 +2168,7 @@ extrude001 = extrude(profile003, length = 5)
await page.waitForTimeout(600) await page.waitForTimeout(600)
await editor.expectEditor.toContain(`sketch001 = startSketchOn('XZ')`) await editor.expectEditor.toContain(`sketch001 = startSketchOn('XZ')`)
await toolbar.exitSketchBtn.click() await toolbar.exitSketch()
await editor.expectEditor.not.toContain(`sketch001 = startSketchOn('XZ')`) await editor.expectEditor.not.toContain(`sketch001 = startSketchOn('XZ')`)
@ -2181,6 +2184,8 @@ extrude001 = extrude(profile003, length = 5)
)` )`
) )
await scene.settled(cmdBar)
await scene.expectPixelColor([255, 255, 255], { x: 633, y: 211 }, 15) await scene.expectPixelColor([255, 255, 255], { x: 633, y: 211 }, 15)
}) })
}) })
@ -2318,7 +2323,7 @@ profile003 = startProfileAt([3.19, 13.3], sketch002)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
profile004 = startProfileAt([3.15, 9.39], sketch002) profile004 = startProfileAt([3.15, 9.39], sketch002)
|> xLine(6.92, %) |> xLine(length = 6.92)
|> line(end = [-7.41, -2.85]) |> line(end = [-7.41, -2.85])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
@ -2556,7 +2561,7 @@ profile001 = startProfileAt([34, 42.66], sketch001)
plane001 = offsetPlane('XZ', offset = 50) plane001 = offsetPlane('XZ', offset = 50)
sketch002 = startSketchOn(plane001) sketch002 = startSketchOn(plane001)
profile002 = startProfileAt([39.43, 172.21], sketch002) profile002 = startProfileAt([39.43, 172.21], sketch002)
|> xLine(183.99, %) |> xLine(length = 183.99)
|> line(end = [-77.95, -145.93]) |> line(end = [-77.95, -145.93])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()
@ -2609,7 +2614,7 @@ profile001 = startProfileAt([34, 42.66], sketch001)
plane001 = offsetPlane('XZ', offset = 50) plane001 = offsetPlane('XZ', offset = 50)
sketch002 = startSketchOn(plane001) sketch002 = startSketchOn(plane001)
profile002 = startProfileAt([39.43, 172.21], sketch002) profile002 = startProfileAt([39.43, 172.21], sketch002)
|> xLine(183.99, %) |> xLine(length = 183.99)
|> line(end = [-77.95, -145.93]) |> line(end = [-77.95, -145.93])
|> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|> close() |> close()

View File

@ -31,8 +31,7 @@ test.beforeEach(async ({ page, context }) => {
// Help engine-manager: tear shit down. // Help engine-manager: tear shit down.
test.afterEach(async ({ page }) => { test.afterEach(async ({ page }) => {
await page.evaluate(() => { await page.evaluate(() => {
// @ts-expect-error window.engineCommandManager.tearDown()
window.tearDown()
}) })
}) })
@ -45,7 +44,11 @@ test.setTimeout(60_000)
test.skip( test.skip(
'exports of each format should work', 'exports of each format should work',
{ tag: ['@snapshot', '@skipWin', '@skipMacos'] }, { tag: ['@snapshot', '@skipWin', '@skipMacos'] },
async ({ page, context, scene, cmdBar }) => { async ({ page, context, scene, cmdBar, tronApp }) => {
if (!tronApp) {
fail()
}
// FYI this test doesn't work with only engine running locally // FYI this test doesn't work with only engine running locally
// And you will need to have the KittyCAD CLI installed // And you will need to have the KittyCAD CLI installed
const u = await getUtils(page) const u = await getUtils(page)
@ -62,14 +65,14 @@ armThick = 0.5
totalLen = 9.5 totalLen = 9.5
part001 = startSketchOn('-XZ') part001 = startSketchOn('-XZ')
|> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
|> yLine(baseHeight, %) |> yLine(length = baseHeight)
|> xLine(baseLen, %) |> xLine(length = baseLen)
|> angledLineToY({ |> angledLineToY({
angle = topAng, angle = topAng,
to = totalHeightHalf, to = totalHeightHalf,
}, %, $seg04) }, %, $seg04)
|> xLineTo(totalLen, %, $seg03) |> xLine(endAbsolute = totalLen, tag = $seg03)
|> yLine(-armThick, %, $seg01) |> yLine(length = -armThick, tag = $seg01)
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle = HALF_TURN, angle = HALF_TURN,
offset = -armThick, offset = -armThick,
@ -80,15 +83,15 @@ part001 = startSketchOn('-XZ')
angle = -bottomAng, angle = -bottomAng,
to = -totalHeightHalf - armThick, to = -totalHeightHalf - armThick,
}, %, $seg02) }, %, $seg02)
|> xLineTo(segEndX(seg03, %) + 0, %) |> xLine(length = endAbsolute = segEndX(seg03) + 0)
|> yLine(-segLen(seg01, %), %) |> yLine(length = -segLen(seg01, %))
|> angledLineThatIntersects({ |> angledLineThatIntersects({
angle = HALF_TURN, angle = HALF_TURN,
offset = -armThick, offset = -armThick,
intersectTag = seg02 intersectTag = seg02
}, %) }, %)
|> angledLineToY([segAng(seg02, %) + 180, -baseHeight], %) |> angledLineToY([segAng(seg02, %) + 180, -baseHeight], %)
|> xLineTo(ZERO, %) |> xLine(endAbsolute = ZERO)
|> close() |> close()
|> extrude(length = 4)` |> extrude(length = 4)`
) )
@ -134,6 +137,7 @@ part001 = startSketchOn('-XZ')
storage: 'ascii', storage: 'ascii',
units: 'in', units: 'in',
}, },
tronApp.projectDirName,
page page
) )
) )
@ -146,6 +150,7 @@ part001 = startSketchOn('-XZ')
selection: { type: 'default_scene' }, selection: { type: 'default_scene' },
units: 'in', units: 'in',
}, },
tronApp.projectDirName,
page page
) )
) )
@ -158,6 +163,7 @@ part001 = startSketchOn('-XZ')
selection: { type: 'default_scene' }, selection: { type: 'default_scene' },
units: 'in', units: 'in',
}, },
tronApp.projectDirName,
page page
) )
) )
@ -170,6 +176,7 @@ part001 = startSketchOn('-XZ')
units: 'in', units: 'in',
selection: { type: 'default_scene' }, selection: { type: 'default_scene' },
}, },
tronApp.projectDirName,
page page
) )
) )
@ -182,6 +189,7 @@ part001 = startSketchOn('-XZ')
units: 'in', units: 'in',
selection: { type: 'default_scene' }, selection: { type: 'default_scene' },
}, },
tronApp.projectDirName,
page page
) )
) )
@ -193,6 +201,7 @@ part001 = startSketchOn('-XZ')
coords: sysType, coords: sysType,
units: 'in', units: 'in',
}, },
tronApp.projectDirName,
page page
) )
) )
@ -203,6 +212,7 @@ part001 = startSketchOn('-XZ')
storage: 'embedded', storage: 'embedded',
presentation: 'pretty', presentation: 'pretty',
}, },
tronApp.projectDirName,
page page
) )
) )
@ -213,6 +223,7 @@ part001 = startSketchOn('-XZ')
storage: 'binary', storage: 'binary',
presentation: 'pretty', presentation: 'pretty',
}, },
tronApp.projectDirName,
page page
) )
) )
@ -223,6 +234,7 @@ part001 = startSketchOn('-XZ')
storage: 'standard', storage: 'standard',
presentation: 'pretty', presentation: 'pretty',
}, },
tronApp.projectDirName,
page page
) )
) )
@ -443,7 +455,7 @@ test(
await page.waitForTimeout(500) await page.waitForTimeout(500)
code += ` code += `
|> xLine(7.25, %)` |> xLine(length = 7.25)`
await expect(page.locator('.cm-content')).toHaveText(code) await expect(page.locator('.cm-content')).toHaveText(code)
await page await page
@ -609,7 +621,7 @@ test.describe(
await page.waitForTimeout(100) await page.waitForTimeout(100)
code += ` code += `
|> xLine(7.25, %)` |> xLine(length = 7.25)`
await expect(u.codeLocator).toHaveText(code) await expect(u.codeLocator).toHaveText(code)
await page await page
@ -704,7 +716,7 @@ test.describe(
await page.waitForTimeout(100) await page.waitForTimeout(100)
code += ` code += `
|> xLine(184.3, %)` |> xLine(length = 184.3)`
await expect(u.codeLocator).toHaveText(code) await expect(u.codeLocator).toHaveText(code)
await page await page

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Some files were not shown because too many files have changed in this diff Show More