Compare commits
	
		
			3 Commits
		
	
	
		
			v0.36.1
			...
			achalmers/
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 50cf30c0d9 | |||
| 47532e5fc4 | |||
| 0da92411c4 | 
| @ -1,3 +1,3 @@ | ||||
| [codespell] | ||||
| ignore-words-list: crate,everytime,inout,co-ordinate,ot,nwo,atleast,ue,afterall | ||||
| skip: **/target,node_modules,build,dist,./out,**/Cargo.lock,./docs/kcl/*.md,.yarn.lock,**/yarn.lock,./openapi/*.json,./packages/codemirror-lang-kcl/test/all.test.ts,tsconfig.tsbuildinfo | ||||
| ignore-words-list: crate,everytime,inout,co-ordinate,ot,nwo,absolutey,atleast,ue,afterall | ||||
| skip: **/target,node_modules,build,**/Cargo.lock,./docs/kcl/*.md,.yarn.lock,**/yarn.lock,./openapi/*.json,./src/lib/machine-api.d.ts | ||||
|  | ||||
							
								
								
									
										28
									
								
								.eslintrc
									
									
									
									
									
								
							
							
						
						| @ -5,32 +5,16 @@ | ||||
|     }, | ||||
|     "plugins": [ | ||||
|       "css-modules", | ||||
|       "jest", | ||||
|       "jsx-a11y", | ||||
|       "react", | ||||
|       "react-hooks", | ||||
|       "suggest-no-throw", | ||||
|       "testing-library", | ||||
|       "@typescript-eslint" | ||||
|     ], | ||||
|     "extends": [ | ||||
|       "plugin:css-modules/recommended", | ||||
|       "plugin:jsx-a11y/recommended", | ||||
|       "plugin:react-hooks/recommended" | ||||
|       "react-app", | ||||
|       "react-app/jest", | ||||
|       "plugin:css-modules/recommended" | ||||
|     ], | ||||
|     "rules": { | ||||
|       "@typescript-eslint/no-floating-promises": "error", | ||||
|       "@typescript-eslint/no-misused-promises": "error", | ||||
|       "jsx-a11y/click-events-have-key-events": "off", | ||||
|       "jsx-a11y/no-autofocus": "off", | ||||
|       "jsx-a11y/no-noninteractive-element-interactions": "off", | ||||
|       "no-restricted-globals": [ | ||||
|         "error", | ||||
|         { | ||||
|           "name": "isNaN", | ||||
|           "message": "Use Number.isNaN() instead." | ||||
|         } | ||||
|       ], | ||||
|       "semi": [ | ||||
|         "error", | ||||
|         "never" | ||||
| @ -41,9 +25,6 @@ | ||||
|     "overrides": [ | ||||
|       { | ||||
|         "files": ["e2e/**/*.ts"], // Update the pattern based on your file structure | ||||
|         "extends": [ | ||||
|           "plugin:testing-library/react" | ||||
|         ], | ||||
|         "rules": { | ||||
|           "suggest-no-throw/suggest-no-throw": "off", | ||||
|           "testing-library/prefer-screen-queries": "off", | ||||
| @ -52,9 +33,6 @@ | ||||
|       }, | ||||
|       { | ||||
|         "files": ["src/**/*.test.ts"], | ||||
|         "extends": [ | ||||
|           "plugin:testing-library/react" | ||||
|         ], | ||||
|         "rules": { | ||||
|           "suggest-no-throw/suggest-no-throw": "off", | ||||
|         } | ||||
|  | ||||
							
								
								
									
										59
									
								
								.github/ci-cd-scripts/playwright-browser-chrome.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						| @ -0,0 +1,59 @@ | ||||
| # bash strict mode | ||||
| set -euo pipefail | ||||
|  | ||||
| if [[ ! -f "test-results/.last-run.json" ]]; then | ||||
|     # if no last run artifact, than run plawright normally | ||||
|     echo "run playwright normally" | ||||
|     if [[ "$3" == ubuntu-latest* ]]; then | ||||
|         yarn test:playwright:browser:chrome:ubuntu -- --shard=$1/$2 || true | ||||
|     elif [[ "$3" == windows-latest* ]]; then | ||||
|         yarn test:playwright:browser:chrome:windows -- --shard=$1/$2 || true | ||||
|     else | ||||
|         echo "Do not run playwright. Unable to detect os runtime." | ||||
|         exit 1 | ||||
|     fi | ||||
|     # # send to axiom | ||||
|     node playwrightProcess.mjs | tee /tmp/github-actions.log > /dev/null 2>&1 | ||||
| fi | ||||
|  | ||||
| retry=1 | ||||
| max_retrys=4 | ||||
|  | ||||
| # retry failed tests, doing our own retries because using inbuilt playwright retries causes connection issues | ||||
| while [[ $retry -le $max_retrys ]]; do | ||||
|     if [[ -f "test-results/.last-run.json" ]]; then | ||||
|         failed_tests=$(jq '.failedTests | length' test-results/.last-run.json) | ||||
|         if [[ $failed_tests -gt 0 ]]; then | ||||
|             echo "retried=true" >>$GITHUB_OUTPUT | ||||
|             echo "run playwright with last failed tests and retry $retry" | ||||
|             if [[ "$3" == ubuntu-latest* ]]; then | ||||
|                 yarn test:playwright:browser:chrome:ubuntu -- --last-failed || true | ||||
|             elif [[ "$3" == windows-latest* ]]; then | ||||
|                 yarn test:playwright:browser:chrome:windows -- --last-failed || true | ||||
|             else | ||||
|                 echo "Do not run playwright. Unable to detect os runtime." | ||||
|                 exit 1 | ||||
|             fi | ||||
|             # send to axiom | ||||
|             node playwrightProcess.mjs | tee /tmp/github-actions.log > /dev/null 2>&1 | ||||
|             retry=$((retry + 1)) | ||||
|         else | ||||
|             echo "retried=false" >>$GITHUB_OUTPUT | ||||
|             exit 0 | ||||
|         fi | ||||
|     else | ||||
|         echo "retried=false" >>$GITHUB_OUTPUT | ||||
|         exit 0 | ||||
|     fi | ||||
| done | ||||
|  | ||||
| echo "retried=false" >>$GITHUB_OUTPUT | ||||
|  | ||||
| if [[ -f "test-results/.last-run.json" ]]; then | ||||
|     failed_tests=$(jq '.failedTests | length' test-results/.last-run.json) | ||||
|     if [[ $failed_tests -gt 0 ]]; then | ||||
|         # if it still fails after 3 retrys, then fail the job | ||||
|         exit 1 | ||||
|     fi | ||||
| fi | ||||
| exit 0 | ||||
							
								
								
									
										22
									
								
								.github/ci-cd-scripts/playwright-electron.sh
									
									
									
									
										vendored
									
									
								
							
							
						
						| @ -1,17 +1,15 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| # bash strict mode | ||||
| set -euo pipefail | ||||
|  | ||||
| if [[ ! -f "test-results/.last-run.json" ]]; then | ||||
|     # if no last run artifact, than run plawright normally | ||||
|     echo "run playwright normally" | ||||
|         if [[ "$3" == *ubuntu* ]]; then | ||||
|             xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test:playwright:electron:ubuntu -- --shard=$1/$2 || true | ||||
|         elif [[ "$3" == *windows* ]]; then | ||||
|             yarn test:playwright:electron:windows -- --shard=$1/$2 || true | ||||
|         elif [[ "$3" == *macos* ]]; then | ||||
|             yarn test:playwright:electron:macos  -- --shard=$1/$2 || true | ||||
|         if [[ "$1" == ubuntu-latest* ]]; then | ||||
|             xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test:playwright:electron:ubuntu || true | ||||
|         elif [[ "$1" == windows-latest* ]]; then | ||||
|             yarn test:playwright:electron:windows || true | ||||
|         elif [[ "$1" == macos-14* ]]; then | ||||
|             yarn test:playwright:electron:macos || true | ||||
|         else | ||||
|             echo "Do not run playwright. Unable to detect os runtime." | ||||
|             exit 1 | ||||
| @ -21,7 +19,7 @@ if [[ ! -f "test-results/.last-run.json" ]]; then | ||||
| fi | ||||
|  | ||||
| retry=1 | ||||
| max_retrys=5 | ||||
| max_retrys=4 | ||||
|  | ||||
| # retry failed tests, doing our own retries because using inbuilt playwright retries causes connection issues | ||||
| while [[ $retry -le $max_retrys ]]; do | ||||
| @ -30,11 +28,11 @@ while [[ $retry -le $max_retrys ]]; do | ||||
|         if [[ $failed_tests -gt 0 ]]; then | ||||
|             echo "retried=true" >>$GITHUB_OUTPUT | ||||
|             echo "run playwright with last failed tests and retry $retry" | ||||
|             if [[ "$3" == *ubuntu* ]]; then | ||||
|             if [[ "$1" == ubuntu-latest* ]]; then | ||||
|                 xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- yarn test:playwright:electron:ubuntu -- --last-failed || true | ||||
|             elif [[ "$3" == *windows* ]]; then | ||||
|             elif [[ "$1" == windows-latest* ]]; then | ||||
|                 yarn test:playwright:electron:windows -- --last-failed || true | ||||
|             elif [[ "$3" == *macos* ]]; then | ||||
|             elif [[ "$1" == macos-14* ]]; then | ||||
|                 yarn test:playwright:electron:macos -- --last-failed || true | ||||
|             else | ||||
|                 echo "Do not run playwright. Unable to detect os runtime." | ||||
|  | ||||
							
								
								
									
										21
									
								
								.github/dependabot.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						| @ -6,36 +6,23 @@ | ||||
| version: 2 | ||||
| updates: | ||||
|     - package-ecosystem: 'npm' # See documentation for possible values | ||||
|     directories: | ||||
|       - '/' | ||||
|       - '/packages/codemirror-lang-kcl/' | ||||
|       - '/packages/codemirror-lsp-client/' | ||||
|       directory: '/' # Location of package manifests | ||||
|       schedule: | ||||
|       interval: weekly | ||||
|       day: monday | ||||
|           interval: 'weekly' | ||||
|       reviewers: | ||||
|           - franknoirot | ||||
|           - irev-dev | ||||
|     - package-ecosystem: 'github-actions' # See documentation for possible values | ||||
|       directory: '/' # Location of package manifests | ||||
|       schedule: | ||||
|       interval: weekly | ||||
|       day: monday | ||||
|           interval: 'weekly' | ||||
|       reviewers: | ||||
|           - adamchalmers | ||||
|           - jessfraz | ||||
|     - package-ecosystem: 'cargo' # See documentation for possible values | ||||
|       directory: '/src/wasm-lib/' # Location of package manifests | ||||
|       schedule: | ||||
|       interval: weekly | ||||
|       day: monday | ||||
|           interval: 'weekly' | ||||
|       reviewers: | ||||
|           - adamchalmers | ||||
|           - jessfraz | ||||
|     groups: | ||||
|       serde-dependencies: | ||||
|         patterns: | ||||
|           - "serde*" | ||||
|       wasm-bindgen-deps: | ||||
|         patterns: | ||||
|           - "wasm-bindgen*" | ||||
|  | ||||
							
								
								
									
										16
									
								
								.github/workflows/build-apps.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						| @ -173,13 +173,7 @@ jobs: | ||||
|           CSC_KEY_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} | ||||
|           CSC_KEYCHAIN: ${{ secrets.APPLE_SIGNING_IDENTITY }} | ||||
|           WINDOWS_CERTIFICATE_THUMBPRINT: ${{ secrets.WINDOWS_CERTIFICATE_THUMBPRINT }} | ||||
|           DEBUG: "electron-notarize*" | ||||
|         # TODO: Fix electron-notarize flakes. The logs above should help gather more data on failures | ||||
|         uses: nick-fields/retry@v3.0.0 | ||||
|         with: | ||||
|           timeout_minutes: 10 | ||||
|           max_attempts: 3 | ||||
|           command: yarn electron-builder --config --publish always | ||||
|         run: yarn electron-builder --config --publish always | ||||
|  | ||||
|       - name: List artifacts in out/ | ||||
|         run: ls -R out | ||||
| @ -234,13 +228,7 @@ jobs: | ||||
|           CSC_KEY_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} | ||||
|           CSC_KEYCHAIN: ${{ secrets.APPLE_SIGNING_IDENTITY }} | ||||
|           WINDOWS_CERTIFICATE_THUMBPRINT: ${{ secrets.WINDOWS_CERTIFICATE_THUMBPRINT }} | ||||
|           DEBUG: "electron-notarize*" | ||||
|         # TODO: Fix electron-notarize flakes. The logs above should help gather more data on failures | ||||
|         uses: nick-fields/retry@v3.0.0 | ||||
|         with: | ||||
|           timeout_minutes: 10 | ||||
|           max_attempts: 3 | ||||
|           command: yarn electron-builder --config --publish always | ||||
|         run: yarn electron-builder --config --publish always | ||||
|  | ||||
|       - uses: actions/upload-artifact@v4 | ||||
|         if: ${{ env.IS_RELEASE == 'true' }} | ||||
|  | ||||
							
								
								
									
										32
									
								
								.github/workflows/codemirror-lang-kcl.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						| @ -1,32 +0,0 @@ | ||||
| name: CodeMirror Lang KCL | ||||
|  | ||||
| on: | ||||
|   pull_request: | ||||
|   push: | ||||
|     branches: | ||||
|       - main | ||||
|  | ||||
| concurrency: | ||||
|   group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||||
|   cancel-in-progress: true | ||||
|  | ||||
| jobs: | ||||
|   yarn-unit-test: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|  | ||||
|       - uses: actions/setup-node@v4 | ||||
|         with: | ||||
|           node-version-file: '.nvmrc' | ||||
|           cache: 'yarn' | ||||
|  | ||||
|       - run: yarn install | ||||
|         working-directory: packages/codemirror-lang-kcl | ||||
|  | ||||
|       - run: yarn tsc | ||||
|         working-directory: packages/codemirror-lang-kcl | ||||
|  | ||||
|       - name: run unit tests | ||||
|         run: yarn test | ||||
|         working-directory: packages/codemirror-lang-kcl | ||||
							
								
								
									
										166
									
								
								.github/workflows/e2e-tests.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						| @ -33,19 +33,20 @@ jobs: | ||||
|             rust: | ||||
|               - 'src/wasm-lib/**' | ||||
|  | ||||
|   electron: | ||||
|     timeout-minutes: 60 | ||||
|     name: playwright:electron:${{ matrix.os }} ${{ matrix.shardIndex }} ${{ matrix.shardTotal }} | ||||
|   browser: | ||||
|     timeout-minutes: ${{ matrix.os == 'macos-14' && 60 || 50 }} | ||||
|     name: playwright:browser:${{ matrix.os }} ${{ matrix.shardIndex }} ${{ matrix.shardTotal }} | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         # TODO: enable self-hosted-windows-8-cores once available | ||||
|         os: [namespace-profile-ubuntu-8-cores, namespace-profile-macos-8-cores, windows-16-cores] | ||||
|         os: [ubuntu-latest-8-cores, windows-latest-8-cores] | ||||
|         shardIndex: [1, 2, 3, 4] | ||||
|         shardTotal: [4] | ||||
|     runs-on: ${{ matrix.os }} | ||||
|     needs: check-rust-changes | ||||
|     steps: | ||||
|     - name: Tune GitHub-hosted runner network | ||||
|       uses: smorimoto/tune-github-hosted-runner-network@v1 | ||||
|     - uses: actions/checkout@v4 | ||||
|     - uses: actions/setup-node@v4 | ||||
|       with: | ||||
| @ -100,8 +101,7 @@ jobs: | ||||
|         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 | ||||
|       if:  ${{ !startsWith(matrix.os, 'windows') }} | ||||
|       run: | | ||||
|         curl --proto '=https' --tlsv1.2 -sSfL https://sh.vector.dev > /tmp/vector.sh | ||||
|         chmod +x /tmp/vector.sh | ||||
| @ -123,16 +123,13 @@ jobs: | ||||
|       if: steps.download-wasm.outcome == 'failure' | ||||
|       shell: bash | ||||
|       run: yarn build:wasm | ||||
|     - name: build electron | ||||
|     - name: build web | ||||
|       run: yarn build:local | ||||
|       shell: bash | ||||
|       run: yarn tron:package | ||||
|     - name: Run ubuntu/chrome snapshots | ||||
|       if: ${{ 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: | | ||||
|         PLATFORM=web yarn playwright test --config=playwright.config.ts --retries="3" --update-snapshots --grep=@snapshot  --shard=1/1 | ||||
|         yarn playwright test --project="Google Chrome" --config=playwright.ci.config.ts --retries="3" --update-snapshots --grep=@snapshot  --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} | ||||
|       env: | ||||
|         CI: true | ||||
|         NODE_ENV: development | ||||
| @ -153,7 +150,6 @@ jobs: | ||||
|       continue-on-error: true | ||||
|       run: rm -r test-results | ||||
|     - name: check for changes | ||||
|       if: ${{ matrix.os == 'namespace-profile-ubuntu-8-cores' && matrix.shardIndex == 1 }} | ||||
|       shell: bash | ||||
|       id: git-check | ||||
|       run: | | ||||
| @ -190,12 +186,12 @@ jobs: | ||||
|       with: | ||||
|         name: test-results-${{ matrix.os }}-${{ matrix.shardIndex }}-${{ github.sha }} | ||||
|         path: test-results/ | ||||
|     - name: Run playwright/electron flow (with retries) | ||||
|     - name: Run playwright/chrome flow (with retries) | ||||
|       id: retry | ||||
|       if: ${{ !cancelled() && (success() || failure()) }} | ||||
|       shell: bash | ||||
|       run: | | ||||
|         .github/ci-cd-scripts/playwright-electron.sh ${{matrix.shardIndex}} ${{matrix.shardTotal}} ${{matrix.os}} | ||||
|         .github/ci-cd-scripts/playwright-browser-chrome.sh ${{matrix.shardIndex}} ${{matrix.shardTotal}} ${{matrix.os}} | ||||
|       env: | ||||
|         CI: true | ||||
|         FAIL_ON_CONSOLE_ERRORS: true | ||||
| @ -203,6 +199,11 @@ jobs: | ||||
|         VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }} | ||||
|         VITE_KC_SKIP_AUTH: true | ||||
|         token: ${{ secrets.KITTYCAD_API_TOKEN_DEV }} | ||||
|     - name: send to axiom | ||||
|       if: always() | ||||
|       shell: bash | ||||
|       run: | | ||||
|         node playwrightProcess.mjs | tee /tmp/github-actions.log | ||||
|     - uses: actions/upload-artifact@v4 | ||||
|       if: always() | ||||
|       with: | ||||
| @ -220,3 +221,136 @@ jobs: | ||||
|         retention-days: 30 | ||||
|         overwrite: true | ||||
|  | ||||
|  | ||||
|   electron: | ||||
|     name: playwright:electron:${{matrix.os}} | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [ubuntu-latest-8-cores, windows-latest-8-cores, macos-14-large] | ||||
|     timeout-minutes: 60 | ||||
|     runs-on: ${{ matrix.os }} | ||||
|     needs: check-rust-changes | ||||
|     steps: | ||||
|     - name: Tune GitHub-hosted runner network | ||||
|       uses: smorimoto/tune-github-hosted-runner-network@v1 | ||||
|     - uses: actions/checkout@v4 | ||||
|     - uses: actions/setup-node@v4 | ||||
|       with: | ||||
|         node-version-file: '.nvmrc' | ||||
|         cache: 'yarn' | ||||
|     - uses: KittyCAD/action-install-cli@main | ||||
|     - name: Install dependencies | ||||
|       shell: bash | ||||
|       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 | ||||
|       shell: bash | ||||
|       run: yarn playwright install chromium --with-deps | ||||
|     - name: Download Wasm Cache | ||||
|       id: download-wasm | ||||
|       if: needs.check-rust-changes.outputs.rust-changed == '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: src/wasm-lib/pkg | ||||
|     - name: copy wasm blob | ||||
|       if: needs.check-rust-changes.outputs.rust-changed == 'false' | ||||
|       shell: bash | ||||
|       run: cp src/wasm-lib/pkg/wasm_lib_bg.wasm public | ||||
|       continue-on-error: true | ||||
|     - name: Setup Rust | ||||
|       uses: dtolnay/rust-toolchain@stable | ||||
|     - name: Cache Wasm (because rust diff) | ||||
|       if: needs.check-rust-changes.outputs.rust-changed == 'true' | ||||
|       uses: Swatinem/rust-cache@v2 | ||||
|       with: | ||||
|         workspaces: './src/wasm-lib' | ||||
|     - name: OR Cache Wasm (because wasm cache failed) | ||||
|       if: steps.download-wasm.outcome == 'failure' | ||||
|       uses: Swatinem/rust-cache@v2 | ||||
|       with: | ||||
|         workspaces: './src/wasm-lib' | ||||
|     - 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 | ||||
|     - name: Install vector | ||||
|       if:  ${{ startsWith(matrix.os, 'ubuntu') }} | ||||
|       shell: bash | ||||
|       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.check-rust-changes.outputs.rust-changed == 'true' | ||||
|       shell: bash | ||||
|       run: yarn build:wasm | ||||
|     - name: OR Build Wasm (because wasm cache failed) | ||||
|       if: steps.download-wasm.outcome == 'failure' | ||||
|       shell: bash | ||||
|       run: yarn build:wasm | ||||
|     - name: build electron | ||||
|       shell: bash | ||||
|       run: yarn tron:package | ||||
|     - uses: actions/download-artifact@v4 | ||||
|       if: ${{ !cancelled() && (success() || failure()) }} | ||||
|       continue-on-error: true | ||||
|       with: | ||||
|         name: test-results-electron-${{ matrix.os }}-${{ github.sha }} | ||||
|         path: test-results/ | ||||
|     - name: Run electron tests (with retries) | ||||
|       id: retry | ||||
|       if: ${{ !cancelled() && (success() || failure()) }} | ||||
|       shell: bash | ||||
|       run: | | ||||
|         .github/ci-cd-scripts/playwright-electron.sh ${{ matrix.os }} | ||||
|       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 | ||||
|         IS_UBUNTU: ${{ startsWith(matrix.os, 'ubuntu') && 'true' || 'false' }} | ||||
|         #DEBUG: 'pw:browser*' | ||||
|     - name: send to axiom | ||||
|       if: ${{ !cancelled() && (success() || failure()) && !startsWith(matrix.os, 'windows') }} | ||||
|       shell: bash | ||||
|       run: | | ||||
|         node playwrightProcess.mjs | tee /tmp/github-actions.log | ||||
|     - uses: actions/upload-artifact@v4 | ||||
|       if: ${{ !cancelled() && (success() || failure()) }} | ||||
|       with: | ||||
|         name: test-results-electron-${{ matrix.os }}-${{ github.sha }} | ||||
|         path: test-results/ | ||||
|         include-hidden-files: true | ||||
|         retention-days: 30 | ||||
|         overwrite: true | ||||
|     - uses: actions/upload-artifact@v4 | ||||
|       if: ${{ !cancelled() && (success() || failure()) }} | ||||
|       with: | ||||
|         name: playwright-report-electron-${{ matrix.os }}-${{ github.sha }} | ||||
|         path: playwright-report/ | ||||
|         include-hidden-files: true | ||||
|         retention-days: 30 | ||||
|         overwrite: true | ||||
|  | ||||
							
								
								
									
										55
									
								
								README.md
									
									
									
									
									
								
							
							
						
						| @ -337,47 +337,13 @@ For individual testing: | ||||
| yarn test abstractSyntaxTree -t "unexpected closed curly brace" --silent=false | ||||
| ``` | ||||
|  | ||||
| Which will run our suite of [Vitest unit](https://vitest.dev/) and [React Testing Library E2E](https://testing-library.com/docs/react-testing-library/intro) tests, in interactive mode by default. | ||||
| Which will run our suite of [Vitest unit](https://vitest.dev/) and [React Testing Library E2E](https://testing-library.com/docs/react-testing-library/intro/) tests, in interactive mode by default. | ||||
|  | ||||
| ### Rust tests | ||||
|  | ||||
| **Dependencies** | ||||
|  | ||||
| - `KITTYCAD_API_TOKEN` | ||||
| - `cargo-nextest` | ||||
| - `just` | ||||
|  | ||||
| #### Setting KITTYCAD_API_TOKEN | ||||
| Use the production zoo.dev token, set this environment variable before running the tests | ||||
|  | ||||
| #### Installing cargonextest | ||||
|  | ||||
| ``` | ||||
| cd src/wasm-lib | ||||
| cargo search cargo-nextest | ||||
| cargo install cargo-nextest | ||||
| ``` | ||||
|  | ||||
| #### just | ||||
| install [`just`](https://github.com/casey/just?tab=readme-ov-file#pre-built-binaries) | ||||
|  | ||||
| #### Running the tests | ||||
|  | ||||
| ```bash | ||||
| # With just | ||||
| # Make sure KITTYCAD_API_TOKEN=<prod zoo.dev token> is set | ||||
| # Make sure you installed cargo-nextest | ||||
| # Make sure you installed just | ||||
| cd src/wasm-lib | ||||
| just test | ||||
| ``` | ||||
|  | ||||
| ```bash | ||||
| # Without just | ||||
| # Make sure KITTYCAD_API_TOKEN=<prod zoo.dev token> is set | ||||
| # Make sure you installed cargo-nextest | ||||
| cd src/wasm-lib | ||||
| export RUST_BRACKTRACE="full" && cargo nextest run --workspace --test-threads=1 | ||||
| KITTYCAD_API_TOKEN=XXX cargo test -- --test-threads=1 | ||||
| ``` | ||||
|  | ||||
| Where `XXX` is an API token from the production engine (NOT the dev environment). | ||||
| @ -422,6 +388,23 @@ yarn test:unit:local | ||||
|  | ||||
| #### E2E Tests | ||||
|  | ||||
| **Playwright Browser** | ||||
|  | ||||
| These E2E tests run in a browser (without electron). | ||||
| There are tests that are skipped if they are ran in a windows OS or Linux OS. We can use playwright tags to implement test skipping. | ||||
|  | ||||
| Breaking down the command `yarn test:playwright:browser:chrome:windows` | ||||
| - The application is `playwright` | ||||
| - The runtime is a `browser` | ||||
| - The specific `browser` is `chrome` | ||||
| - The test should run in a `windows` environment. It will skip tests that are broken or flaky in the windows OS. | ||||
|  | ||||
| ``` | ||||
| yarn test:playwright:browser:chrome | ||||
| yarn test:playwright:browser:chrome:windows | ||||
| yarn test:playwright:browser:chrome:ubuntu | ||||
| ``` | ||||
|  | ||||
| **Playwright Electron** | ||||
|  | ||||
| These E2E tests run in electron. There are tests that are skipped if they are ran in a windows, linux, or macos environment. We can use playwright tags to implement test skipping. | ||||
|  | ||||
| @ -24,5 +24,3 @@ once fixed in engine will just start working here with no language changes. | ||||
|     chamfer cases work currently. | ||||
|  | ||||
| - **Appearance**: Changing the appearance on a loft does not work. | ||||
|  | ||||
| - **Helix**: Currently sweeping a helix does not work. | ||||
|  | ||||
| @ -35,7 +35,6 @@ layout: manual | ||||
| * [`ceil`](kcl/ceil) | ||||
| * [`chamfer`](kcl/chamfer) | ||||
| * [`circle`](kcl/circle) | ||||
| * [`circleThreePoint`](kcl/circleThreePoint) | ||||
| * [`close`](kcl/close) | ||||
| * [`cm`](kcl/cm) | ||||
| * [`cos`](kcl/cos) | ||||
| @ -48,7 +47,6 @@ layout: manual | ||||
| * [`getOppositeEdge`](kcl/getOppositeEdge) | ||||
| * [`getPreviousAdjacentEdge`](kcl/getPreviousAdjacentEdge) | ||||
| * [`helix`](kcl/helix) | ||||
| * [`helixRevolutions`](kcl/helixRevolutions) | ||||
| * [`hole`](kcl/hole) | ||||
| * [`hollow`](kcl/hollow) | ||||
| * [`import`](kcl/import) | ||||
| @ -82,7 +80,6 @@ layout: manual | ||||
| * [`pi`](kcl/pi) | ||||
| * [`polar`](kcl/polar) | ||||
| * [`polygon`](kcl/polygon) | ||||
| * [`pop`](kcl/pop) | ||||
| * [`pow`](kcl/pow) | ||||
| * [`profileStart`](kcl/profileStart) | ||||
| * [`profileStartX`](kcl/profileStartX) | ||||
| @ -104,6 +101,7 @@ layout: manual | ||||
| * [`sin`](kcl/sin) | ||||
| * [`sqrt`](kcl/sqrt) | ||||
| * [`startProfileAt`](kcl/startProfileAt) | ||||
| * [`startSketchAt`](kcl/startSketchAt) | ||||
| * [`startSketchOn`](kcl/startSketchOn) | ||||
| * [`sweep`](kcl/sweep) | ||||
| * [`tan`](kcl/tan) | ||||
|  | ||||
| @ -9,7 +9,7 @@ Create a 3D surface or solid by interpolating between two or more sketches. | ||||
| The sketches need to closed and on the same plane. | ||||
|  | ||||
| ```js | ||||
| loft(sketches: [Sketch], v_degree: NonZeroU32, bez_approximate_rational: bool, base_curve_index?: integer, tolerance?: number) -> Solid | ||||
| loft(sketches: [Sketch], v_degree: NonZeroU32, bez_approximate_rational: bool, base_curve_index?: u32, tolerance?: number) -> Solid | ||||
| ``` | ||||
|  | ||||
|  | ||||
| @ -20,7 +20,7 @@ loft(sketches: [Sketch], v_degree: NonZeroU32, bez_approximate_rational: bool, b | ||||
| | `sketches` | [`[Sketch]`](/docs/kcl/types/Sketch) | Which sketches to loft. Must include at least 2 sketches. | Yes | | ||||
| | `v_degree` | `NonZeroU32` | Degree of the interpolation. Must be greater than zero. For example, use 2 for quadratic, or 3 for cubic interpolation in the V direction. This defaults to 2, if not specified. | Yes | | ||||
| | `bez_approximate_rational` | `bool` | Attempt to approximate rational curves (such as arcs) using a bezier. This will remove banding around interpolations between arcs and non-arcs. It may produce errors in other scenarios Over time, this field won't be necessary. | Yes | | ||||
| | `base_curve_index` | `integer` | This can be set to override the automatically determined topological base curve, which is usually the first section encountered. | No | | ||||
| | `base_curve_index` | `u32` | This can be set to override the automatically determined topological base curve, which is usually the first section encountered. | No | | ||||
| | `tolerance` | `number` | Tolerance for the loft operation. | No | | ||||
|  | ||||
| ### Returns | ||||
|  | ||||
| @ -35,7 +35,7 @@ The transform function returns a transform object. All properties of the object | ||||
|    - `rotation.origin` (either "local" i.e. rotate around its own center, "global" i.e. rotate around the scene's center, or a 3D point, defaults to "local") | ||||
|  | ||||
| ```js | ||||
| patternTransform(total_instances: integer, transform_function: FunctionParam, solid_set: SolidSet) -> [Solid] | ||||
| patternTransform(total_instances: u32, transform_function: FunctionParam, solid_set: SolidSet) -> [Solid] | ||||
| ``` | ||||
|  | ||||
|  | ||||
| @ -43,7 +43,7 @@ patternTransform(total_instances: integer, transform_function: FunctionParam, so | ||||
|  | ||||
| | Name | Type | Description | Required | | ||||
| |----------|------|-------------|----------| | ||||
| | `total_instances` | `integer` |  | Yes | | ||||
| | `total_instances` | `u32` |  | Yes | | ||||
| | `transform_function` | `FunctionParam` |  | Yes | | ||||
| | `solid_set` | [`SolidSet`](/docs/kcl/types/SolidSet) | A solid or a group of solids. | Yes | | ||||
|  | ||||
| @ -95,8 +95,7 @@ fn cube(length, center) { | ||||
|   p2 = [l + x, l + y] | ||||
|   p3 = [l + x, -l + y] | ||||
|  | ||||
|   return startSketchOn('XY') | ||||
|     |> startProfileAt(p0, %) | ||||
|   return startSketchAt(p0) | ||||
|     |> lineTo(p1, %) | ||||
|     |> lineTo(p2, %) | ||||
|     |> lineTo(p3, %) | ||||
| @ -133,8 +132,7 @@ fn cube(length, center) { | ||||
|   p2 = [l + x, l + y] | ||||
|   p3 = [l + x, -l + y] | ||||
|  | ||||
|   return startSketchOn('XY') | ||||
|     |> startProfileAt(p0, %) | ||||
|   return startSketchAt(p0) | ||||
|     |> lineTo(p1, %) | ||||
|     |> lineTo(p2, %) | ||||
|     |> lineTo(p3, %) | ||||
| @ -197,8 +195,7 @@ fn transform(i) { | ||||
|     { rotation = { angle = 45 * i } } | ||||
|   ] | ||||
| } | ||||
| startSketchOn('XY') | ||||
|   |> startProfileAt([0, 0], %) | ||||
| startSketchAt([0, 0]) | ||||
|   |> polygon({ | ||||
|        radius = 10, | ||||
|        numSides = 4, | ||||
|  | ||||
| @ -9,7 +9,7 @@ Just like patternTransform, but works on 2D sketches not 3D solids. | ||||
|  | ||||
|  | ||||
| ```js | ||||
| patternTransform2d(total_instances: integer, transform_function: FunctionParam, solid_set: SketchSet) -> [Sketch] | ||||
| patternTransform2d(total_instances: u32, transform_function: FunctionParam, solid_set: SketchSet) -> [Sketch] | ||||
| ``` | ||||
|  | ||||
|  | ||||
| @ -17,7 +17,7 @@ patternTransform2d(total_instances: integer, transform_function: FunctionParam, | ||||
|  | ||||
| | Name | Type | Description | Required | | ||||
| |----------|------|-------------|----------| | ||||
| | `total_instances` | `integer` |  | Yes | | ||||
| | `total_instances` | `u32` |  | Yes | | ||||
| | `transform_function` | `FunctionParam` |  | Yes | | ||||
| | `solid_set` | [`SketchSet`](/docs/kcl/types/SketchSet) | A sketch or a group of sketches. | Yes | | ||||
|  | ||||
|  | ||||
| @ -79,8 +79,7 @@ fn decagon(radius) { | ||||
|   stepAngle = 1 / 10 * tau() | ||||
|  | ||||
|   // Start the decagon sketch at this point. | ||||
|   startOfDecagonSketch = startSketchOn('XY') | ||||
|     |> startProfileAt([cos(0) * radius, sin(0) * radius], %) | ||||
|   startOfDecagonSketch = startSketchAt([cos(0) * radius, sin(0) * radius]) | ||||
|  | ||||
|   // Use a `reduce` to draw the remaining decagon sides. | ||||
|   // For each number in the array 1..10, run the given function, | ||||
| @ -98,8 +97,7 @@ fn decagon(radius) { | ||||
| /* The `decagon` above is basically like this pseudo-code: | ||||
| fn decagon(radius): | ||||
|     stepAngle = (1/10) * tau() | ||||
|     plane = startSketchOn('XY') | ||||
|     startOfDecagonSketch = startProfileAt([(cos(0)*radius), (sin(0) * radius)], plane) | ||||
|     startOfDecagonSketch = startSketchAt([(cos(0)*radius), (sin(0) * radius)]) | ||||
|  | ||||
|     // Here's the reduce part. | ||||
|     partialDecagon = startOfDecagonSketch | ||||
|  | ||||
| @ -28,8 +28,7 @@ segEnd(tag: TagIdentifier) -> [number] | ||||
|  | ||||
| ```js | ||||
| w = 15 | ||||
| cube = startSketchOn('XY') | ||||
|   |> startProfileAt([0, 0], %) | ||||
| cube = startSketchAt([0, 0]) | ||||
|   |> line([w, 0], %, $line1) | ||||
|   |> line([0, w], %, $line2) | ||||
|   |> line([-w, 0], %, $line3) | ||||
| @ -38,8 +37,7 @@ cube = startSketchOn('XY') | ||||
|   |> extrude(5, %) | ||||
|  | ||||
| fn cylinder(radius, tag) { | ||||
|   return startSketchOn('XY') | ||||
|     |> startProfileAt([0, 0], %) | ||||
|   return startSketchAt([0, 0]) | ||||
|     |> circle({ | ||||
|          radius = radius, | ||||
|          center = segEnd(tag) | ||||
|  | ||||
| @ -28,8 +28,7 @@ segStart(tag: TagIdentifier) -> [number] | ||||
|  | ||||
| ```js | ||||
| w = 15 | ||||
| cube = startSketchOn('XY') | ||||
|   |> startProfileAt([0, 0], %) | ||||
| cube = startSketchAt([0, 0]) | ||||
|   |> line([w, 0], %, $line1) | ||||
|   |> line([0, w], %, $line2) | ||||
|   |> line([-w, 0], %, $line3) | ||||
| @ -38,8 +37,7 @@ cube = startSketchOn('XY') | ||||
|   |> extrude(5, %) | ||||
|  | ||||
| fn cylinder(radius, tag) { | ||||
|   return startSketchOn('XY') | ||||
|     |> startProfileAt([0, 0], %) | ||||
|   return startSketchAt([0, 0]) | ||||
|     |> circle({ | ||||
|          radius = radius, | ||||
|          center = segStart(tag) | ||||
|  | ||||
| @ -4,8 +4,6 @@ excerpt: "Start a new 2-dimensional sketch at a given point on the 'XY' plane." | ||||
| layout: manual | ||||
| --- | ||||
|  | ||||
| **WARNING:** This function is deprecated. | ||||
|  | ||||
| Start a new 2-dimensional sketch at a given point on the 'XY' plane. | ||||
|  | ||||
|  | ||||
|  | ||||
							
								
								
									
										104177
									
								
								docs/kcl/std.json
									
									
									
									
									
								
							
							
						
						| @ -13,18 +13,13 @@ Data to draw an angled line. | ||||
|  | ||||
| An angle and length with explicitly named parameters | ||||
|  | ||||
| **Type:** `object` | ||||
| [`PolarCoordsData`](/docs/kcl/types/PolarCoordsData) | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ## Properties | ||||
|  | ||||
| | Property | Type | Description | Required | | ||||
| |----------|------|-------------|----------| | ||||
| | `angle` |`number`| The angle of the line (in degrees). | No | | ||||
| | `length` |`number`| The length of the line. | No | | ||||
|  | ||||
|  | ||||
| ---- | ||||
|  | ||||
| @ -1,42 +0,0 @@ | ||||
| --- | ||||
| title: "Axis3dOrEdgeReference" | ||||
| excerpt: "A 3D axis or tagged edge." | ||||
| layout: manual | ||||
| --- | ||||
|  | ||||
| A 3D axis or tagged edge. | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| **This schema accepts any of the following:** | ||||
|  | ||||
| 3D axis and origin. | ||||
|  | ||||
| [`AxisAndOrigin3d`](/docs/kcl/types/AxisAndOrigin3d) | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ---- | ||||
| Tagged edge. | ||||
|  | ||||
| [`EdgeReference`](/docs/kcl/types/EdgeReference) | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ---- | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -1,10 +1,10 @@ | ||||
| --- | ||||
| title: "AxisAndOrigin2d" | ||||
| excerpt: "A 2D axis and origin." | ||||
| title: "AxisAndOrigin" | ||||
| excerpt: "Axis and origin." | ||||
| layout: manual | ||||
| --- | ||||
| 
 | ||||
| A 2D axis and origin. | ||||
| Axis and origin. | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @ -1,105 +0,0 @@ | ||||
| --- | ||||
| title: "AxisAndOrigin3d" | ||||
| excerpt: "A 3D axis and origin." | ||||
| layout: manual | ||||
| --- | ||||
|  | ||||
| A 3D axis and origin. | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| **This schema accepts exactly one of the following:** | ||||
|  | ||||
| X-axis. | ||||
|  | ||||
| **enum:** `X` | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ---- | ||||
| Y-axis. | ||||
|  | ||||
| **enum:** `Y` | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ---- | ||||
| Z-axis. | ||||
|  | ||||
| **enum:** `Z` | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ---- | ||||
| Flip the X-axis. | ||||
|  | ||||
| **enum:** `-X` | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ---- | ||||
| Flip the Y-axis. | ||||
|  | ||||
| **enum:** `-Y` | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ---- | ||||
| Flip the Z-axis. | ||||
|  | ||||
| **enum:** `-Z` | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ---- | ||||
|  | ||||
| **Type:** `object` | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ## Properties | ||||
|  | ||||
| | Property | Type | Description | Required | | ||||
| |----------|------|-------------|----------| | ||||
| | `custom` |`object`|  | No | | ||||
|  | ||||
|  | ||||
| ---- | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -1,19 +1,19 @@ | ||||
| --- | ||||
| title: "Axis2dOrEdgeReference" | ||||
| excerpt: "A 2D axis or tagged edge." | ||||
| title: "AxisOrEdgeReference" | ||||
| excerpt: "Axis or tagged edge." | ||||
| layout: manual | ||||
| --- | ||||
| 
 | ||||
| A 2D axis or tagged edge. | ||||
| Axis or tagged edge. | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| **This schema accepts any of the following:** | ||||
| 
 | ||||
| 2D axis and origin. | ||||
| Axis and origin. | ||||
| 
 | ||||
| [`AxisAndOrigin2d`](/docs/kcl/types/AxisAndOrigin2d) | ||||
| [`AxisAndOrigin`](/docs/kcl/types/AxisAndOrigin) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @ -1,23 +0,0 @@ | ||||
| --- | ||||
| title: "CircleThreePointData" | ||||
| excerpt: "Data for drawing a 3-point circle" | ||||
| layout: manual | ||||
| --- | ||||
|  | ||||
| Data for drawing a 3-point circle | ||||
|  | ||||
| **Type:** `object` | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ## Properties | ||||
|  | ||||
| | Property | Type | Description | Required | | ||||
| |----------|------|-------------|----------| | ||||
| | `p1` |`[number, number]`| Point one for circle derivation. | No | | ||||
| | `p2` |`[number, number]`| Point two for circle derivation. | No | | ||||
| | `p3` |`[number, number]`| Point three for circle derivation. | No | | ||||
|  | ||||
|  | ||||
| @ -1,25 +0,0 @@ | ||||
| --- | ||||
| title: "Helix" | ||||
| excerpt: "A helix." | ||||
| layout: manual | ||||
| --- | ||||
|  | ||||
| A helix. | ||||
|  | ||||
| **Type:** `object` | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ## Properties | ||||
|  | ||||
| | Property | Type | Description | Required | | ||||
| |----------|------|-------------|----------| | ||||
| | `value` |`string`| The id of the helix. | No | | ||||
| | `revolutions` |`number`| Number of revolutions. | No | | ||||
| | `angleStart` |`number`| Start angle (in degrees). | No | | ||||
| | `ccw` |`boolean`| Is the helix rotation counter clockwise? | No | | ||||
| | `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`|  | No | | ||||
|  | ||||
|  | ||||
| @ -1,10 +1,10 @@ | ||||
| --- | ||||
| title: "HelixData" | ||||
| excerpt: "Data for a helix." | ||||
| excerpt: "Data for helices." | ||||
| layout: manual | ||||
| --- | ||||
|  | ||||
| Data for a helix. | ||||
| Data for helices. | ||||
|  | ||||
| **Type:** `object` | ||||
|  | ||||
| @ -19,8 +19,6 @@ Data for a helix. | ||||
| | `revolutions` |`number`| Number of revolutions. | No | | ||||
| | `angleStart` |`number`| Start angle (in degrees). | No | | ||||
| | `ccw` |`boolean`| Is the helix rotation counter clockwise? The default is `false`. | No | | ||||
| | `length` |`number`| Length of the helix. This is not necessary if the helix is created around an edge. If not given the length of the edge is used. | No | | ||||
| | `radius` |`number`| Radius of the helix. | No | | ||||
| | `axis` |[`Axis3dOrEdgeReference`](/docs/kcl/types/Axis3dOrEdgeReference)| Axis to use as mirror. | No | | ||||
| | `length` |`number`| Length of the helix. If this argument is not provided, the height of the solid is used. | No | | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -1,24 +0,0 @@ | ||||
| --- | ||||
| title: "HelixRevolutionsData" | ||||
| excerpt: "Data for helix revolutions." | ||||
| layout: manual | ||||
| --- | ||||
|  | ||||
| Data for helix revolutions. | ||||
|  | ||||
| **Type:** `object` | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ## Properties | ||||
|  | ||||
| | Property | Type | Description | Required | | ||||
| |----------|------|-------------|----------| | ||||
| | `revolutions` |`number`| Number of revolutions. | No | | ||||
| | `angleStart` |`number`| Start angle (in degrees). | No | | ||||
| | `ccw` |`boolean`| Is the helix rotation counter clockwise? The default is `false`. | No | | ||||
| | `length` |`number`| Length of the helix. If this argument is not provided, the height of the solid is used. | No | | ||||
|  | ||||
|  | ||||
| @ -1,25 +0,0 @@ | ||||
| --- | ||||
| title: "HelixValue" | ||||
| excerpt: "A helix." | ||||
| layout: manual | ||||
| --- | ||||
|  | ||||
| A helix. | ||||
|  | ||||
| **Type:** `object` | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ## Properties | ||||
|  | ||||
| | Property | Type | Description | Required | | ||||
| |----------|------|-------------|----------| | ||||
| | `value` |`string`| The id of the helix. | No | | ||||
| | `revolutions` |`number`| Number of revolutions. | No | | ||||
| | `angleStart` |`number`| Start angle (in degrees). | No | | ||||
| | `ccw` |`boolean`| Is the helix rotation counter clockwise? | No | | ||||
| | `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`|  | No | | ||||
|  | ||||
|  | ||||
| @ -285,27 +285,6 @@ An solid is a collection of extrude surfaces. | ||||
| | `value` |`[` [`Solid`](/docs/kcl/types/Solid) `]`|  | No | | ||||
|  | ||||
|  | ||||
| ---- | ||||
| A helix. | ||||
|  | ||||
| **Type:** `object` | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ## Properties | ||||
|  | ||||
| | Property | Type | Description | Required | | ||||
| |----------|------|-------------|----------| | ||||
| | `type` |enum: [`Helix`](/docs/kcl/types/Helix)|  | No | | ||||
| | `value` |`string`| The id of the helix. | No | | ||||
| | `revolutions` |`number`| Number of revolutions. | No | | ||||
| | `angleStart` |`number`| Start angle (in degrees). | No | | ||||
| | `ccw` |`boolean`| Is the helix rotation counter clockwise? | No | | ||||
| | `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`|  | No | | ||||
|  | ||||
|  | ||||
| ---- | ||||
| Data for an imported geometry. | ||||
|  | ||||
| @ -350,23 +329,6 @@ Data for an imported geometry. | ||||
|  | ||||
|  | ||||
|  | ||||
| ## Properties | ||||
|  | ||||
| | Property | Type | Description | Required | | ||||
| |----------|------|-------------|----------| | ||||
| | `type` |enum: `Module`|  | No | | ||||
| | `value` |[`ModuleId`](/docs/kcl/types/ModuleId)| Any KCL value. | No | | ||||
| | `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`|  | No | | ||||
|  | ||||
|  | ||||
| ---- | ||||
|  | ||||
| **Type:** `object` | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ## Properties | ||||
|  | ||||
| | Property | Type | Description | Required | | ||||
|  | ||||
| @ -16,6 +16,6 @@ Data for a mirror. | ||||
|  | ||||
| | Property | Type | Description | Required | | ||||
| |----------|------|-------------|----------| | ||||
| | `axis` |[`Axis2dOrEdgeReference`](/docs/kcl/types/Axis2dOrEdgeReference)| Axis to use as mirror. | No | | ||||
| | `axis` |[`AxisOrEdgeReference`](/docs/kcl/types/AxisOrEdgeReference)| Axis to use as mirror. | No | | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -1,16 +0,0 @@ | ||||
| --- | ||||
| title: "ModuleId" | ||||
| excerpt: "Identifier of a source file.  Uses a u32 to keep the size small." | ||||
| layout: manual | ||||
| --- | ||||
|  | ||||
| Identifier of a source file.  Uses a u32 to keep the size small. | ||||
|  | ||||
| **Type:** `integer` (`uint32`) | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -17,7 +17,7 @@ Data for revolution surfaces. | ||||
| | Property | Type | Description | Required | | ||||
| |----------|------|-------------|----------| | ||||
| | `angle` |`number` (**maximum:** 360.0) (**minimum:** -360.0)| Angle to revolve (in degrees). Default is 360. | No | | ||||
| | `axis` |[`Axis2dOrEdgeReference`](/docs/kcl/types/Axis2dOrEdgeReference)| Axis of revolution. | No | | ||||
| | `axis` |[`AxisOrEdgeReference`](/docs/kcl/types/AxisOrEdgeReference)| Axis of revolution. | No | | ||||
| | `tolerance` |`number`| Tolerance for the revolve operation. | No | | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -21,6 +21,7 @@ A sketch is a collection of paths. | ||||
| | `on` |[`SketchSurface`](/docs/kcl/types/SketchSurface)| What the sketch is on (can be a plane or a face). | No | | ||||
| | `start` |[`BasePath`](/docs/kcl/types/BasePath)| The starting path. | No | | ||||
| | `tags` |`object`| Tag identifiers that have been declared in this sketch. | No | | ||||
| | `originalId` |`string`| The original id of the sketch. This stays the same even if the sketch is sketched on face etc. | No | | ||||
| | `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| Metadata. | No | | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -30,6 +30,7 @@ A sketch is a collection of paths. | ||||
| | `on` |[`SketchSurface`](/docs/kcl/types/SketchSurface)| What the sketch is on (can be a plane or a face). | No | | ||||
| | `start` |[`BasePath`](/docs/kcl/types/BasePath)| The starting path. | No | | ||||
| | `tags` |`object`| Tag identifiers that have been declared in this sketch. | No | | ||||
| | `originalId` |`string`| The original id of the sketch. This stays the same even if the sketch is sketched on face etc. | No | | ||||
| | `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| Metadata. | No | | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -16,7 +16,7 @@ Data for a sweep. | ||||
|  | ||||
| | Property | Type | Description | Required | | ||||
| |----------|------|-------------|----------| | ||||
| | `path` |[`SweepPath`](/docs/kcl/types/SweepPath)| The path to sweep along. | No | | ||||
| | `path` |[`Sketch`](/docs/kcl/types/Sketch)| The path to sweep along. | No | | ||||
| | `sectional` |`boolean`| If true, the sweep will be broken up into sub-sweeps (extrusions, revolves, sweeps) based on the trajectory path components. | No | | ||||
| | `tolerance` |`number`| Tolerance for the sweep operation. | No | | ||||
|  | ||||
|  | ||||
| @ -1,42 +0,0 @@ | ||||
| --- | ||||
| title: "SweepPath" | ||||
| excerpt: "A path to sweep along." | ||||
| layout: manual | ||||
| --- | ||||
|  | ||||
| A path to sweep along. | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| **This schema accepts any of the following:** | ||||
|  | ||||
| A path to sweep along. | ||||
|  | ||||
| [`Sketch`](/docs/kcl/types/Sketch) | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ---- | ||||
| A path to sweep along. | ||||
|  | ||||
| [`Helix`](/docs/kcl/types/Helix) | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| ---- | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -1,11 +1,22 @@ | ||||
| import { test, expect } from './zoo-test' | ||||
| import { test, expect } from '@playwright/test' | ||||
|  | ||||
| import { setupElectron, tearDown } from './test-utils' | ||||
|  | ||||
| test.afterEach(async ({ page }, testInfo) => { | ||||
|   await tearDown(page, testInfo) | ||||
| }) | ||||
|  | ||||
| test.describe('Electron app header tests', () => { | ||||
|   test( | ||||
|     'Open Command Palette button has correct shortcut', | ||||
|     { tag: '@electron' }, | ||||
|     async ({ page }, testInfo) => { | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     async ({ browserName }, testInfo) => { | ||||
|       const { electronApp, page } = await setupElectron({ | ||||
|         testInfo, | ||||
|         folderSetupFn: async () => {}, | ||||
|       }) | ||||
|  | ||||
|       await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|       // No space before the shortcut since it checks textContent. | ||||
|       let text | ||||
| @ -23,14 +34,21 @@ test.describe('Electron app header tests', () => { | ||||
|       const commandsButton = page.getByRole('button', { name: 'Commands' }) | ||||
|       await expect(commandsButton).toBeVisible() | ||||
|       await expect(commandsButton).toHaveText(text) | ||||
|  | ||||
|       await electronApp.close() | ||||
|     } | ||||
|   ) | ||||
|  | ||||
|   test( | ||||
|     'User settings has correct shortcut', | ||||
|     { tag: '@electron' }, | ||||
|     async ({ page }, testInfo) => { | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     async ({ browserName }, testInfo) => { | ||||
|       const { electronApp, page } = await setupElectron({ | ||||
|         testInfo, | ||||
|         folderSetupFn: async () => {}, | ||||
|       }) | ||||
|  | ||||
|       await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|       // Open the user sidebar menu. | ||||
|       await page.getByTestId('user-sidebar-toggle').click() | ||||
| @ -41,6 +59,8 @@ test.describe('Electron app header tests', () => { | ||||
|       const userSettingsButton = page.getByTestId('user-settings') | ||||
|       await expect(userSettingsButton).toBeVisible() | ||||
|       await expect(userSettingsButton).toHaveText(text) | ||||
|  | ||||
|       await electronApp.close() | ||||
|     } | ||||
|   ) | ||||
| }) | ||||
|  | ||||
| @ -1,26 +1,29 @@ | ||||
| import { test, expect, Page } from './zoo-test' | ||||
| import { test, expect, Page } from '@playwright/test' | ||||
| import { | ||||
|   getUtils, | ||||
|   TEST_COLORS, | ||||
|   setup, | ||||
|   tearDown, | ||||
|   commonPoints, | ||||
|   PERSIST_MODELING_CONTEXT, | ||||
| } from './test-utils' | ||||
| import { HomePageFixture } from './fixtures/homePageFixture' | ||||
|  | ||||
| test.beforeEach(async ({ context, page }, testInfo) => { | ||||
|   await setup(context, page, testInfo) | ||||
| }) | ||||
|  | ||||
| test.afterEach(async ({ page }, testInfo) => { | ||||
|   await tearDown(page, testInfo) | ||||
| }) | ||||
|  | ||||
| test.setTimeout(120000) | ||||
|  | ||||
| async function doBasicSketch( | ||||
|   page: Page, | ||||
|   homePage: HomePageFixture, | ||||
|   openPanes: string[] | ||||
| ) { | ||||
| async function doBasicSketch(page: Page, openPanes: string[]) { | ||||
|   const u = await getUtils(page) | ||||
|   await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|   await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|   const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|  | ||||
|   await homePage.goToModelingScene() | ||||
|   await u.waitForPageLoad() | ||||
|   await page.waitForTimeout(1000) | ||||
|   await u.waitForAuthSkipAppStart() | ||||
|   await u.openDebugPanel() | ||||
|  | ||||
|   // If we have the code pane open, we should see the code. | ||||
| @ -54,23 +57,26 @@ async function doBasicSketch( | ||||
|   const startXPx = 600 | ||||
|   await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10) | ||||
|   if (openPanes.includes('code')) { | ||||
|     await expect(u.codeLocator).toHaveText(`sketch001 = startSketchOn('XZ') | ||||
|   |> startProfileAt(${commonPoints.startAt}, %)`) | ||||
|     await expect(u.codeLocator).toContainText( | ||||
|       `sketch001 = startSketchOn('XZ')profile001 = startProfileAt(${commonPoints.startAt}, sketch001)` | ||||
|     ) | ||||
|   } | ||||
|   await page.waitForTimeout(500) | ||||
|   await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 10) | ||||
|   await page.waitForTimeout(500) | ||||
|  | ||||
|   if (openPanes.includes('code')) { | ||||
|     await expect(u.codeLocator).toHaveText(`sketch001 = startSketchOn('XZ') | ||||
|   |> startProfileAt(${commonPoints.startAt}, %) | ||||
|     await expect(u.codeLocator) | ||||
|       .toHaveText(`sketch001 = startSketchOn('XZ')profile001 = startProfileAt(${commonPoints.startAt}, sketch001) | ||||
|   |> xLine(${commonPoints.num1}, %)`) | ||||
|   } | ||||
|   await page.waitForTimeout(500) | ||||
|   await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20) | ||||
|   if (openPanes.includes('code')) { | ||||
|     await expect(u.codeLocator).toHaveText(`sketch001 = startSketchOn('XZ') | ||||
|   |> startProfileAt(${commonPoints.startAt}, %) | ||||
|     await expect(u.codeLocator) | ||||
|       .toHaveText(`sketch001 = startSketchOn('XZ')profile001 = startProfileAt(${ | ||||
|       commonPoints.startAt | ||||
|     }, sketch001) | ||||
|   |> xLine(${commonPoints.num1}, %) | ||||
|   |> yLine(${commonPoints.num1 + 0.01}, %)`) | ||||
|   } else { | ||||
| @ -79,8 +85,10 @@ async function doBasicSketch( | ||||
|   await page.waitForTimeout(200) | ||||
|   await page.mouse.click(startXPx, 500 - PUR * 20) | ||||
|   if (openPanes.includes('code')) { | ||||
|     await expect(u.codeLocator).toHaveText(`sketch001 = startSketchOn('XZ') | ||||
|   |> startProfileAt(${commonPoints.startAt}, %) | ||||
|     await expect(u.codeLocator) | ||||
|       .toHaveText(`sketch001 = startSketchOn('XZ')profile001 = startProfileAt(${ | ||||
|       commonPoints.startAt | ||||
|     }, sketch001) | ||||
|   |> xLine(${commonPoints.num1}, %) | ||||
|   |> yLine(${commonPoints.num1 + 0.01}, %) | ||||
|   |> xLine(${commonPoints.num2 * -1}, %)`) | ||||
| @ -137,19 +145,23 @@ async function doBasicSketch( | ||||
|  | ||||
|   // Open the code pane. | ||||
|   await u.openKclCodePanel() | ||||
|   await expect(u.codeLocator).toHaveText(`sketch001 = startSketchOn('XZ') | ||||
|   |> startProfileAt(${commonPoints.startAt}, %) | ||||
|   await expect(u.codeLocator) | ||||
|     .toHaveText(`sketch001 = startSketchOn('XZ')profile001 = startProfileAt(${ | ||||
|     commonPoints.startAt | ||||
|   }, sketch001) | ||||
|   |> xLine(${commonPoints.num1}, %, $seg01) | ||||
|   |> yLine(${commonPoints.num1 + 0.01}, %) | ||||
|   |> xLine(-segLen(seg01), %)`) | ||||
| } | ||||
|  | ||||
| test.describe('Basic sketch', () => { | ||||
|   test.fixme('code pane open at start', async ({ page, homePage }) => { | ||||
|     await doBasicSketch(page, homePage, ['code']) | ||||
|   test('code pane open at start', { tag: ['@skipWin'] }, async ({ page }) => { | ||||
|     // Skip on windows it is being weird. | ||||
|     test.skip(process.platform === 'win32', 'Skip on windows') | ||||
|     await doBasicSketch(page, ['code']) | ||||
|   }) | ||||
|  | ||||
|   test('code pane closed at start', async ({ page, homePage }) => { | ||||
|   test('code pane closed at start', async ({ page }) => { | ||||
|     // Load the app with the code panes | ||||
|     await page.addInitScript(async (persistModelingContext) => { | ||||
|       localStorage.setItem( | ||||
| @ -157,6 +169,6 @@ test.describe('Basic sketch', () => { | ||||
|         JSON.stringify({ openPanes: [] }) | ||||
|       ) | ||||
|     }, PERSIST_MODELING_CONTEXT) | ||||
|     await doBasicSketch(page, homePage, []) | ||||
|     await doBasicSketch(page, []) | ||||
|   }) | ||||
| }) | ||||
|  | ||||
| @ -1,21 +1,27 @@ | ||||
| import { test, expect, Page } from './zoo-test' | ||||
| import { HomePageFixture } from './fixtures/homePageFixture' | ||||
| import { getUtils } from './test-utils' | ||||
| import { test, expect } from '@playwright/test' | ||||
| import { getUtils, setup, tearDown } from './test-utils' | ||||
| import { EngineCommand } from 'lang/std/artifactGraph' | ||||
| import { uuidv4 } from 'lib/utils' | ||||
|  | ||||
| test.beforeEach(async ({ context, page }, testInfo) => { | ||||
|   await setup(context, page, testInfo) | ||||
| }) | ||||
|  | ||||
| test.afterEach(async ({ page }, testInfo) => { | ||||
|   await tearDown(page, testInfo) | ||||
| }) | ||||
|  | ||||
| test.describe('Can create sketches on all planes and their back sides', () => { | ||||
|   const sketchOnPlaneAndBackSideTest = async ( | ||||
|     page: Page, | ||||
|     homePage: HomePageFixture, | ||||
|     page: any, | ||||
|     plane: string, | ||||
|     clickCoords: { x: number; y: number } | ||||
|   ) => { | ||||
|     const u = await getUtils(page) | ||||
|     const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|     await u.openDebugPanel() | ||||
|  | ||||
|     const coord = | ||||
| @ -38,8 +44,7 @@ test.describe('Can create sketches on all planes and their back sides', () => { | ||||
|       }, | ||||
|     } | ||||
|  | ||||
|     const code = `sketch001 = startSketchOn('${plane}') | ||||
|     |> startProfileAt([0.9, -1.22], %)` | ||||
|     const code = `sketch001 = startSketchOn('${plane}')profile001 = startProfileAt([0.9, -1.22], sketch001)` | ||||
|  | ||||
|     await u.openDebugPanel() | ||||
|  | ||||
| @ -77,39 +82,32 @@ test.describe('Can create sketches on all planes and their back sides', () => { | ||||
|     await u.clearCommandLogs() | ||||
|     await u.removeCurrentCode() | ||||
|   } | ||||
|   test('XY', async ({ page, homePage }) => { | ||||
|   test('XY', async ({ page }) => { | ||||
|     await sketchOnPlaneAndBackSideTest( | ||||
|       page, | ||||
|       homePage, | ||||
|       'XY', | ||||
|       { x: 600, y: 388 } // red plane | ||||
|       // { x: 600, y: 400 }, // red plane // clicks grid helper and that causes problems, should fix so that these coords work too. | ||||
|     ) | ||||
|   }) | ||||
|  | ||||
|   test('YZ', async ({ page, homePage }) => { | ||||
|     await sketchOnPlaneAndBackSideTest(page, homePage, 'YZ', { x: 700, y: 250 }) // green plane | ||||
|   test('YZ', async ({ page }) => { | ||||
|     await sketchOnPlaneAndBackSideTest(page, 'YZ', { x: 700, y: 250 }) // green plane | ||||
|   }) | ||||
|  | ||||
|   test('XZ', async ({ page, homePage }) => { | ||||
|     await sketchOnPlaneAndBackSideTest(page, homePage, '-XZ', { x: 700, y: 80 }) // blue plane | ||||
|   test('XZ', async ({ page }) => { | ||||
|     await sketchOnPlaneAndBackSideTest(page, '-XZ', { x: 700, y: 80 }) // blue plane | ||||
|   }) | ||||
|  | ||||
|   test('-XY', async ({ page, homePage }) => { | ||||
|     await sketchOnPlaneAndBackSideTest(page, homePage, '-XY', { | ||||
|       x: 600, | ||||
|       y: 118, | ||||
|     }) // back of red plane | ||||
|   test('-XY', async ({ page }) => { | ||||
|     await sketchOnPlaneAndBackSideTest(page, '-XY', { x: 600, y: 118 }) // back of red plane | ||||
|   }) | ||||
|  | ||||
|   test('-YZ', async ({ page, homePage }) => { | ||||
|     await sketchOnPlaneAndBackSideTest(page, homePage, '-YZ', { | ||||
|       x: 700, | ||||
|       y: 219, | ||||
|     }) // back of green plan | ||||
|   test('-YZ', async ({ page }) => { | ||||
|     await sketchOnPlaneAndBackSideTest(page, '-YZ', { x: 700, y: 219 }) // back of green plane | ||||
|   }) | ||||
|  | ||||
|   test('-XZ', async ({ page, homePage }) => { | ||||
|     await sketchOnPlaneAndBackSideTest(page, homePage, 'XZ', { x: 700, y: 427 }) // back of blue plane | ||||
|   test('-XZ', async ({ page }) => { | ||||
|     await sketchOnPlaneAndBackSideTest(page, 'XZ', { x: 700, y: 427 }) // back of blue plane | ||||
|   }) | ||||
| }) | ||||
|  | ||||
| @ -1,15 +1,28 @@ | ||||
| import { test, expect } from './zoo-test' | ||||
| import { test, expect } from '@playwright/test' | ||||
|  | ||||
| import { getUtils, executorInputPath } from './test-utils' | ||||
| import { | ||||
|   getUtils, | ||||
|   setup, | ||||
|   setupElectron, | ||||
|   tearDown, | ||||
|   executorInputPath, | ||||
| } from './test-utils' | ||||
| import { join } from 'path' | ||||
| import { bracket } from 'lib/exampleKcl' | ||||
| import { TEST_CODE_LONG_WITH_ERROR_OUT_OF_VIEW } from './storageStates' | ||||
| import fsp from 'fs/promises' | ||||
|  | ||||
| test.beforeEach(async ({ context, page }, testInfo) => { | ||||
|   await setup(context, page, testInfo) | ||||
| }) | ||||
|  | ||||
| test.afterEach(async ({ page }, testInfo) => { | ||||
|   await tearDown(page, testInfo) | ||||
| }) | ||||
|  | ||||
| test.describe('Code pane and errors', () => { | ||||
|   test('Typing KCL errors induces a badge on the code pane button', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     const u = await getUtils(page) | ||||
|  | ||||
| @ -18,18 +31,18 @@ test.describe('Code pane and errors', () => { | ||||
|       localStorage.setItem( | ||||
|         'persistCode', | ||||
|         `// Extruded Triangle | ||||
|   sketch001 = startSketchOn('XZ') | ||||
| sketch001 = startSketchOn('XZ') | ||||
|   |> startProfileAt([0, 0], %) | ||||
|   |> line([10, 0], %) | ||||
|   |> line([-5, 10], %) | ||||
|   |> lineTo([profileStartX(%), profileStartY(%)], %) | ||||
|   |> close(%) | ||||
|   extrude001 = extrude(5, sketch001)` | ||||
| extrude001 = extrude(5, sketch001)` | ||||
|       ) | ||||
|     }) | ||||
|  | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await homePage.goToModelingScene() | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // wait for execution done | ||||
|     await u.openDebugPanel() | ||||
| @ -49,11 +62,11 @@ test.describe('Code pane and errors', () => { | ||||
|     await expect(codePaneButtonHolder).toContainText('notification') | ||||
|   }) | ||||
|  | ||||
|   test.skip('Opening and closing the code pane will consistently show error diagnostics', async ({ | ||||
|   test('Opening and closing the code pane will consistently show error diagnostics', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|     editor, | ||||
|   }) => { | ||||
|     await page.goto('http://localhost:3000') | ||||
|  | ||||
|     const u = await getUtils(page) | ||||
|  | ||||
|     // Load the app with the working starter code | ||||
| @ -61,8 +74,8 @@ test.describe('Code pane and errors', () => { | ||||
|       localStorage.setItem('persistCode', code) | ||||
|     }, bracket) | ||||
|  | ||||
|     await page.setBodyDimensions({ width: 1200, height: 900 }) | ||||
|     await homePage.goToModelingScene() | ||||
|     await page.setViewportSize({ width: 1200, height: 900 }) | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // wait for execution done | ||||
|     await u.openDebugPanel() | ||||
| @ -78,9 +91,8 @@ test.describe('Code pane and errors', () => { | ||||
|     await expect(codePaneButtonHolder).not.toContainText('notification') | ||||
|  | ||||
|     // Delete a character to break the KCL | ||||
|     await editor.openPane() | ||||
|     await editor.scrollToText('thickness, bracketLeg1Sketch)') | ||||
|     await page.getByText('extrude(thickness, bracketLeg1Sketch)').click() | ||||
|     await u.openKclCodePanel() | ||||
|     await page.getByText('thickness, bracketLeg1Sketch)').click() | ||||
|     await page.keyboard.press('Backspace') | ||||
|  | ||||
|     // Ensure that a badge appears on the button | ||||
| @ -104,10 +116,7 @@ test.describe('Code pane and errors', () => { | ||||
|     await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible() | ||||
|  | ||||
|     // Open the code pane | ||||
|     await editor.openPane() | ||||
|  | ||||
|     // Go to our problematic code again (missing closing paren!) | ||||
|     await editor.scrollToText('extrude(thickness, bracketLeg1Sketch') | ||||
|     await u.openKclCodePanel() | ||||
|  | ||||
|     // Ensure that a badge appears on the button | ||||
|     await expect(codePaneButtonHolder).toContainText('notification') | ||||
| @ -120,16 +129,18 @@ test.describe('Code pane and errors', () => { | ||||
|     await expect(page.locator('.cm-tooltip').first()).toBeVisible() | ||||
|   }) | ||||
|  | ||||
|   test.fixme( | ||||
|     'When error is not in view you can click the badge to scroll to it', | ||||
|     async ({ page, homePage, context }) => { | ||||
|   test('When error is not in view you can click the badge to scroll to it', async ({ | ||||
|     page, | ||||
|   }) => { | ||||
|     const u = await getUtils(page) | ||||
|  | ||||
|     // Load the app with the working starter code | ||||
|       await context.addInitScript((code) => { | ||||
|     await page.addInitScript((code) => { | ||||
|       localStorage.setItem('persistCode', code) | ||||
|     }, TEST_CODE_LONG_WITH_ERROR_OUT_OF_VIEW) | ||||
|  | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|       await homePage.goToModelingScene() | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await page.waitForTimeout(1000) | ||||
|  | ||||
| @ -153,25 +164,24 @@ test.describe('Code pane and errors', () => { | ||||
|     await expect( | ||||
|       page | ||||
|         .getByText( | ||||
|             'Modeling command failed: [ApiError { error_code: InternalEngine, message: "Solid3D revolve failed:  sketch profile must lie entirely on one side of the revolution axis" }]' | ||||
|           'sketch profile must lie entirely on one side of the revolution axis' | ||||
|         ) | ||||
|         .first() | ||||
|     ).toBeVisible() | ||||
|     } | ||||
|   ) | ||||
|   }) | ||||
|  | ||||
|   test('When error is not in view WITH LINTS you can click the badge to scroll to it', async ({ | ||||
|     context, | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     const u = await getUtils(page) | ||||
|  | ||||
|     // Load the app with the working starter code | ||||
|     await context.addInitScript((code) => { | ||||
|     await page.addInitScript((code) => { | ||||
|       localStorage.setItem('persistCode', code) | ||||
|     }, TEST_CODE_LONG_WITH_ERROR_OUT_OF_VIEW) | ||||
|  | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await homePage.goToModelingScene() | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await page.waitForTimeout(1000) | ||||
|  | ||||
| @ -231,9 +241,11 @@ test.describe('Code pane and errors', () => { | ||||
| test( | ||||
|   'Opening multiple panes persists when switching projects', | ||||
|   { tag: '@electron' }, | ||||
|   async ({ context, page }, testInfo) => { | ||||
|   async ({ browserName }, testInfo) => { | ||||
|     // Setup multiple projects. | ||||
|     await context.folderSetupFn(async (dir) => { | ||||
|     const { electronApp, page } = await setupElectron({ | ||||
|       testInfo, | ||||
|       folderSetupFn: async (dir) => { | ||||
|         const routerTemplateDir = join(dir, 'router-template-slate') | ||||
|         const bracketDir = join(dir, 'bracket') | ||||
|         await Promise.all([ | ||||
| @ -250,10 +262,11 @@ test( | ||||
|             join(bracketDir, 'main.kcl') | ||||
|           ), | ||||
|         ]) | ||||
|       }, | ||||
|     }) | ||||
|  | ||||
|     const u = await getUtils(page) | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await test.step('Opening the bracket project should load', async () => { | ||||
|       await expect(page.getByText('bracket')).toBeVisible() | ||||
| @ -296,21 +309,30 @@ test( | ||||
|       await expect(page.locator('#variables-pane')).toBeVisible() | ||||
|       await expect(page.locator('#logs-pane')).toBeVisible() | ||||
|     }) | ||||
|  | ||||
|     await electronApp.close() | ||||
|   } | ||||
| ) | ||||
|  | ||||
| test( | ||||
|   'external change of file contents are reflected in editor', | ||||
|   { tag: '@electron' }, | ||||
|   async ({ context, page }, testInfo) => { | ||||
|   async ({ browserName }, testInfo) => { | ||||
|     const PROJECT_DIR_NAME = 'lee-was-here' | ||||
|     const { dir: projectsDir } = await context.folderSetupFn(async (dir) => { | ||||
|     const { | ||||
|       electronApp, | ||||
|       page, | ||||
|       dir: projectsDir, | ||||
|     } = await setupElectron({ | ||||
|       testInfo, | ||||
|       folderSetupFn: async (dir) => { | ||||
|         const aProjectDir = join(dir, PROJECT_DIR_NAME) | ||||
|         await fsp.mkdir(aProjectDir, { recursive: true }) | ||||
|       }, | ||||
|     }) | ||||
|  | ||||
|     const u = await getUtils(page) | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await test.step('Open the project', async () => { | ||||
|       await expect(page.getByText(PROJECT_DIR_NAME)).toBeVisible() | ||||
| @ -329,5 +351,7 @@ test( | ||||
|       ) | ||||
|       await u.editorTextMatches(content) | ||||
|     }) | ||||
|  | ||||
|     await electronApp.close() | ||||
|   } | ||||
| ) | ||||
|  | ||||
| @ -1,12 +1,19 @@ | ||||
| import { test, expect } from './zoo-test' | ||||
| import { test, expect } from '@playwright/test' | ||||
|  | ||||
| import { getUtils } from './test-utils' | ||||
| import { getUtils, setup, tearDown } from './test-utils' | ||||
| import { KCL_DEFAULT_LENGTH } from 'lib/constants' | ||||
|  | ||||
| test.beforeEach(async ({ context, page }, testInfo) => { | ||||
|   await setup(context, page, testInfo) | ||||
| }) | ||||
|  | ||||
| test.afterEach(async ({ page }, testInfo) => { | ||||
|   await tearDown(page, testInfo) | ||||
| }) | ||||
|  | ||||
| test.describe('Command bar tests', () => { | ||||
|   test('Extrude from command bar selects extrude line after', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     await page.addInitScript(async () => { | ||||
|       localStorage.setItem( | ||||
| @ -22,9 +29,9 @@ test.describe('Command bar tests', () => { | ||||
|     }) | ||||
|  | ||||
|     const u = await getUtils(page) | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.openDebugPanel() | ||||
|     await u.expectCmdLog('[data-message-type="execution-done"]') | ||||
| @ -45,8 +52,7 @@ test.describe('Command bar tests', () => { | ||||
|     ) | ||||
|   }) | ||||
|  | ||||
|   // TODO: fix this test after the electron migration | ||||
|   test.fixme('Fillet from command bar', async ({ page, homePage }) => { | ||||
|   test('Fillet from command bar', async ({ page }) => { | ||||
|     await page.addInitScript(async () => { | ||||
|       localStorage.setItem( | ||||
|         'persistCode', | ||||
| @ -57,13 +63,13 @@ test.describe('Command bar tests', () => { | ||||
|   |> line([0, -10], %) | ||||
|   |> lineTo([profileStartX(%), profileStartY(%)], %) | ||||
|   |> close(%) | ||||
|   extrude001 = extrude(-10, sketch001)` | ||||
| extrude001 = extrude(-10, sketch001)` | ||||
|       ) | ||||
|     }) | ||||
|  | ||||
|     const u = await getUtils(page) | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await homePage.goToModelingScene() | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|     await u.openDebugPanel() | ||||
|     await u.expectCmdLog('[data-message-type="execution-done"]') | ||||
|     await u.closeDebugPanel() | ||||
| @ -87,10 +93,10 @@ test.describe('Command bar tests', () => { | ||||
|  | ||||
|   test('Command bar can change a setting, and switch back and forth between arguments', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await homePage.goToModelingScene() | ||||
|     const u = await getUtils(page) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     const commandBarButton = page.getByRole('button', { name: 'Commands' }) | ||||
|     const cmdSearchBar = page.getByPlaceholder('Search commands') | ||||
| @ -147,7 +153,7 @@ test.describe('Command bar tests', () => { | ||||
|     // Check that the visibility changed | ||||
|     await expect(paneSelector).not.toBeVisible() | ||||
|  | ||||
|     commandOptionInput = page.locator('[id="option-input"]') | ||||
|     commandOptionInput = page.getByPlaceholder('off') | ||||
|  | ||||
|     // Test case for https://github.com/KittyCAD/modeling-app/issues/2882 | ||||
|     await commandBarButton.click() | ||||
| @ -168,10 +174,10 @@ test.describe('Command bar tests', () => { | ||||
|  | ||||
|   test('Command bar keybinding works from code editor and can change a setting', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await homePage.goToModelingScene() | ||||
|     const u = await getUtils(page) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await expect( | ||||
|       page.getByRole('button', { name: 'Start Sketch' }) | ||||
| @ -215,7 +221,7 @@ test.describe('Command bar tests', () => { | ||||
|     await expect(page.locator('body')).not.toHaveClass(`body-bg dark`) | ||||
|   }) | ||||
|  | ||||
|   test('Can extrude from the command bar', async ({ page, homePage }) => { | ||||
|   test('Can extrude from the command bar', async ({ page }) => { | ||||
|     await page.addInitScript(async () => { | ||||
|       localStorage.setItem( | ||||
|         'persistCode', | ||||
| @ -231,9 +237,9 @@ test.describe('Command bar tests', () => { | ||||
|     }) | ||||
|  | ||||
|     const u = await getUtils(page) | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // Make sure the stream is up | ||||
|     await u.openDebugPanel() | ||||
| @ -287,19 +293,26 @@ test.describe('Command bar tests', () => { | ||||
|     await continueButton.click() | ||||
|     await submitButton.click() | ||||
|  | ||||
|     // Check that the code was updated | ||||
|     await u.waitForCmdReceive('extrude') | ||||
|  | ||||
|     await expect(page.locator('.cm-content')).toContainText( | ||||
|       'extrude001 = extrude(distance001, sketch001)' | ||||
|     // Unfortunately this indentation seems to matter for the test | ||||
|     await expect(page.locator('.cm-content')).toHaveText( | ||||
|       `distance = sqrt(20) | ||||
| distance001 = ${KCL_DEFAULT_LENGTH} | ||||
| sketch001 = startSketchOn('XZ') | ||||
|     |> startProfileAt([-6.95, 10.98], %) | ||||
|     |> line([25.1, 0.41], %) | ||||
|     |> line([0.73, -20.93], %) | ||||
|     |> line([-23.44, 0.52], %) | ||||
|     |> close(%) | ||||
| extrude001 = extrude(distance001, sketch001)`.replace(/(\r\n|\n|\r)/gm, '') // remove newlines | ||||
|     ) | ||||
|   }) | ||||
|  | ||||
|   test('Can switch between sketch tools via command bar', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await homePage.goToModelingScene() | ||||
|   test('Can switch between sketch tools via command bar', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     const sketchButton = page.getByRole('button', { name: 'Start Sketch' }) | ||||
|     const cmdBarButton = page.getByRole('button', { name: 'Commands' }) | ||||
|  | ||||
| @ -1,16 +1,23 @@ | ||||
| import { test, expect } from './zoo-test' | ||||
| import { getUtils } from './test-utils' | ||||
| import { test, expect } from '@playwright/test' | ||||
| import { getUtils, setup, tearDown } from './test-utils' | ||||
|  | ||||
| test.beforeEach(async ({ context, page }, testInfo) => { | ||||
|   await setup(context, page, testInfo) | ||||
| }) | ||||
|  | ||||
| test.afterEach(async ({ page }, testInfo) => { | ||||
|   await tearDown(page, testInfo) | ||||
| }) | ||||
| test.describe('Copilot ghost text', () => { | ||||
|   // eslint-disable-next-line jest/valid-title | ||||
|   test.skip(true, 'Needs to get covered again') | ||||
|  | ||||
|   test('completes code in empty file', async ({ page, homePage }) => { | ||||
|   test('completes code in empty file', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.codeLocator.click() | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
| @ -45,13 +52,12 @@ test.describe('Copilot ghost text', () => { | ||||
|  | ||||
|   test.skip('copilot disabled in sketch mode no select plane', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     const u = await getUtils(page) | ||||
|     // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.codeLocator.click() | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
| @ -95,13 +101,12 @@ test.describe('Copilot ghost text', () => { | ||||
|  | ||||
|   test('copilot disabled in sketch mode after selecting plane', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     const u = await getUtils(page) | ||||
|     // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.codeLocator.click() | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
| @ -179,12 +184,12 @@ test.describe('Copilot ghost text', () => { | ||||
|     await expect(page.locator('.cm-ghostText')).not.toBeVisible() | ||||
|   }) | ||||
|  | ||||
|   test('ArrowUp in code rejects the suggestion', async ({ page, homePage }) => { | ||||
|   test('ArrowUp in code rejects the suggestion', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.codeLocator.click() | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
| @ -207,15 +212,12 @@ test.describe('Copilot ghost text', () => { | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
|   }) | ||||
|  | ||||
|   test('ArrowDown in code rejects the suggestion', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|   test('ArrowDown in code rejects the suggestion', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.codeLocator.click() | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
| @ -238,15 +240,12 @@ test.describe('Copilot ghost text', () => { | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
|   }) | ||||
|  | ||||
|   test('ArrowLeft in code rejects the suggestion', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|   test('ArrowLeft in code rejects the suggestion', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.codeLocator.click() | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
| @ -269,15 +268,12 @@ test.describe('Copilot ghost text', () => { | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
|   }) | ||||
|  | ||||
|   test('ArrowRight in code rejects the suggestion', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|   test('ArrowRight in code rejects the suggestion', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.codeLocator.click() | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
| @ -300,12 +296,12 @@ test.describe('Copilot ghost text', () => { | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
|   }) | ||||
|  | ||||
|   test('Enter in code scoots it down', async ({ page, homePage }) => { | ||||
|   test('Enter in code scoots it down', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.codeLocator.click() | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
| @ -330,15 +326,12 @@ test.describe('Copilot ghost text', () => { | ||||
|     ) | ||||
|   }) | ||||
|  | ||||
|   test('Ctrl+shift+z in code rejects the suggestion', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|   test('Ctrl+shift+z in code rejects the suggestion', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.codeLocator.click() | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
| @ -367,13 +360,12 @@ test.describe('Copilot ghost text', () => { | ||||
|  | ||||
|   test('Ctrl+z in code rejects the suggestion and undos the last code', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     const u = await getUtils(page) | ||||
|     // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await page.waitForTimeout(800) | ||||
|     await u.codeLocator.click() | ||||
| @ -428,17 +420,15 @@ test.describe('Copilot ghost text', () => { | ||||
|     await expect(page.locator('.cm-ghostText').first()).not.toBeVisible() | ||||
|  | ||||
|     // TODO when we make codemirror a widget, we can test this. | ||||
|     //await expect(page.locator('.cm-content')).toHaveText(``) }) | ||||
|     //await expect(page.locator('.cm-content')).toHaveText(``) | ||||
|   }) | ||||
|  | ||||
|     test('delete in code rejects the suggestion', async ({ | ||||
|       page, | ||||
|       homePage, | ||||
|     }) => { | ||||
|   test('delete in code rejects the suggestion', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|       await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.codeLocator.click() | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
| @ -463,15 +453,12 @@ test.describe('Copilot ghost text', () => { | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
|   }) | ||||
|  | ||||
|     test('backspace in code rejects the suggestion', async ({ | ||||
|       page, | ||||
|       homePage, | ||||
|     }) => { | ||||
|   test('backspace in code rejects the suggestion', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|       await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.codeLocator.click() | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
| @ -496,15 +483,12 @@ test.describe('Copilot ghost text', () => { | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
|   }) | ||||
|  | ||||
|     test('focus outside code pane rejects the suggestion', async ({ | ||||
|       page, | ||||
|       homePage, | ||||
|     }) => { | ||||
|   test('focus outside code pane rejects the suggestion', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|       await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.codeLocator.click() | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
| @ -530,5 +514,4 @@ test.describe('Copilot ghost text', () => { | ||||
|  | ||||
|     await expect(page.locator('.cm-content')).toHaveText(``) | ||||
|   }) | ||||
|   }) | ||||
| }) | ||||
|  | ||||
| @ -1,6 +1,14 @@ | ||||
| import { test, expect } from './zoo-test' | ||||
| import { test, expect } from '@playwright/test' | ||||
|  | ||||
| import { getUtils } from './test-utils' | ||||
| import { getUtils, setup, tearDown } from './test-utils' | ||||
|  | ||||
| test.beforeEach(async ({ context, page }, testInfo) => { | ||||
|   await setup(context, page, testInfo) | ||||
| }) | ||||
|  | ||||
| test.afterEach(async ({ page }, testInfo) => { | ||||
|   await tearDown(page, testInfo) | ||||
| }) | ||||
|  | ||||
| function countNewlines(input: string): number { | ||||
|   let count = 0 | ||||
| @ -16,14 +24,13 @@ test.describe('Debug pane', () => { | ||||
|   test('Artifact IDs in the artifact graph are stable across code edits', async ({ | ||||
|     page, | ||||
|     context, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     const code = `sketch001 = startSketchOn('XZ') | ||||
|   |> startProfileAt([0, 0], %) | ||||
|   |> line([1, 1], %) | ||||
|   ` | ||||
| |> line([1, 1], %) | ||||
| ` | ||||
|     const u = await getUtils(page) | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     const tree = page.getByTestId('debug-feature-tree') | ||||
|     const segment = tree.locator('li', { | ||||
| @ -32,7 +39,7 @@ test.describe('Debug pane', () => { | ||||
|     }) | ||||
|  | ||||
|     await test.step('Test setup', async () => { | ||||
|       await homePage.goToModelingScene() | ||||
|       await u.waitForAuthSkipAppStart() | ||||
|       await u.openKclCodePanel() | ||||
|       await u.openDebugPanel() | ||||
|       // Set the code in the code editor. | ||||
|  | ||||
| @ -1,31 +1,39 @@ | ||||
| import { test, expect } from './zoo-test' | ||||
| import path from 'path' | ||||
| import { test, expect } from '@playwright/test' | ||||
| import { join } from 'path' | ||||
| import { | ||||
|   getUtils, | ||||
|   setupElectron, | ||||
|   tearDown, | ||||
|   executorInputPath, | ||||
|   getPlaywrightDownloadDir, | ||||
| } from './test-utils' | ||||
| import fsp from 'fs/promises' | ||||
|  | ||||
| test.afterEach(async ({ page }, testInfo) => { | ||||
|   await tearDown(page, testInfo) | ||||
| }) | ||||
|  | ||||
| test( | ||||
|   'export works on the first try', | ||||
|   { tag: '@electron' }, | ||||
|   async ({ page, context }, testInfo) => { | ||||
|     await context.folderSetupFn(async (dir) => { | ||||
|       const bracketDir = path.join(dir, 'bracket') | ||||
|   async ({ browserName }, testInfo) => { | ||||
|     const { electronApp, page } = await setupElectron({ | ||||
|       testInfo, | ||||
|       folderSetupFn: async (dir) => { | ||||
|         const bracketDir = join(dir, 'bracket') | ||||
|         await Promise.all([fsp.mkdir(bracketDir, { recursive: true })]) | ||||
|         await Promise.all([ | ||||
|           fsp.copyFile( | ||||
|             executorInputPath('router-template-slate.kcl'), | ||||
|           path.join(bracketDir, 'other.kcl') | ||||
|             join(bracketDir, 'other.kcl') | ||||
|           ), | ||||
|           fsp.copyFile( | ||||
|             executorInputPath('focusrite_scarlett_mounting_braket.kcl'), | ||||
|           path.join(bracketDir, 'main.kcl') | ||||
|             join(bracketDir, 'main.kcl') | ||||
|           ), | ||||
|         ]) | ||||
|       }, | ||||
|     }) | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     page.on('console', console.log) | ||||
|  | ||||
| @ -85,16 +93,12 @@ test( | ||||
|       await expect(successToastMessage).toBeVisible() | ||||
|       await expect(exportingToastMessage).not.toBeVisible() | ||||
|  | ||||
|       const firstFileFullPath = path.resolve( | ||||
|         getPlaywrightDownloadDir(page), | ||||
|         exportFileName | ||||
|       ) | ||||
|       await test.step('Check the export size', async () => { | ||||
|         await expect | ||||
|           .poll( | ||||
|             async () => { | ||||
|               try { | ||||
|                 const outputGltf = await fsp.readFile(firstFileFullPath) | ||||
|                 const outputGltf = await fsp.readFile(exportFileName) | ||||
|                 return outputGltf.byteLength | ||||
|               } catch (e) { | ||||
|                 return 0 | ||||
| @ -103,6 +107,9 @@ test( | ||||
|             { timeout: 15_000 } | ||||
|           ) | ||||
|           .toBeGreaterThan(300_000) | ||||
|  | ||||
|         // clean up exported file | ||||
|         await fsp.rm(exportFileName) | ||||
|       }) | ||||
|     }) | ||||
|  | ||||
| @ -163,16 +170,12 @@ test( | ||||
|           expect(exportingToastMessage).not.toBeVisible(), | ||||
|         ])) | ||||
|  | ||||
|       const secondFileFullPath = path.resolve( | ||||
|         getPlaywrightDownloadDir(page), | ||||
|         exportFileName | ||||
|       ) | ||||
|       await test.step('Check the export size', async () => { | ||||
|         await expect | ||||
|           .poll( | ||||
|             async () => { | ||||
|               try { | ||||
|                 const outputGltf = await fsp.readFile(secondFileFullPath) | ||||
|                 const outputGltf = await fsp.readFile(exportFileName) | ||||
|                 return outputGltf.byteLength | ||||
|               } catch (e) { | ||||
|                 return 0 | ||||
| @ -181,7 +184,13 @@ test( | ||||
|             { timeout: 15_000 } | ||||
|           ) | ||||
|           .toBeGreaterThan(100_000) | ||||
|  | ||||
|         // clean up exported file | ||||
|         await fsp.rm(exportFileName) | ||||
|       }) | ||||
|       await electronApp.close() | ||||
|     }) | ||||
|  | ||||
|     await electronApp.close() | ||||
|   } | ||||
| ) | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| import { test, expect } from './zoo-test' | ||||
| import { test, expect } from '@playwright/test' | ||||
| import fsp from 'fs/promises' | ||||
| import { uuidv4 } from 'lib/utils' | ||||
| import { | ||||
| @ -6,16 +6,26 @@ import { | ||||
|   darkModePlaneColorXZ, | ||||
|   executorInputPath, | ||||
|   getUtils, | ||||
|   setup, | ||||
|   setupElectron, | ||||
|   tearDown, | ||||
| } from './test-utils' | ||||
|  | ||||
| import { join } from 'path' | ||||
|  | ||||
| test.describe('Editor tests', () => { | ||||
|   test('can comment out code with ctrl+/', async ({ page, homePage }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
| test.beforeEach(async ({ context, page }, testInfo) => { | ||||
|   await setup(context, page, testInfo) | ||||
| }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
| test.afterEach(async ({ page }, testInfo) => { | ||||
|   await tearDown(page, testInfo) | ||||
| }) | ||||
|  | ||||
| test.describe('Editor tests', () => { | ||||
|   test('can comment out code with ctrl+/', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // check no error to begin with | ||||
|     await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible() | ||||
| @ -54,116 +64,13 @@ test.describe('Editor tests', () => { | ||||
|     |> close(%)`) | ||||
|   }) | ||||
|  | ||||
|   test('ensure we use the cache, and do not re-execute', async ({ | ||||
|     homePage, | ||||
|     page, | ||||
|   }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForPageLoad() | ||||
|  | ||||
|     await u.codeLocator.click() | ||||
|     await page.keyboard.type(`sketch001 = startSketchOn('XY') | ||||
|   |> startProfileAt([-10, -10], %) | ||||
|   |> line([20, 0], %) | ||||
|   |> line([0, 20], %) | ||||
|   |> line([-20, 0], %) | ||||
|   |> close(%)`) | ||||
|  | ||||
|     // Ensure we execute the first time. | ||||
|     await u.openDebugPanel() | ||||
|     await expect( | ||||
|       page.locator('[data-receive-command-type="scene_clear_all"]') | ||||
|     ).toHaveCount(1) | ||||
|     await expect( | ||||
|       page.locator('[data-message-type="execution-done"]') | ||||
|     ).toHaveCount(2) | ||||
|  | ||||
|     // Add whitespace to the end of the code. | ||||
|     await u.codeLocator.click() | ||||
|     await page.keyboard.press('ArrowUp') | ||||
|     await page.keyboard.press('ArrowUp') | ||||
|     await page.keyboard.press('ArrowUp') | ||||
|     await page.keyboard.press('ArrowUp') | ||||
|     await page.keyboard.press('Home') | ||||
|     await page.keyboard.type('    ') | ||||
|     await page.keyboard.press('Enter') | ||||
|     await page.keyboard.type('    ') | ||||
|  | ||||
|     // Ensure we don't execute the second time. | ||||
|     await u.openDebugPanel() | ||||
|     // Make sure we didn't clear the scene. | ||||
|     await expect( | ||||
|       page.locator('[data-message-type="execution-done"]') | ||||
|     ).toHaveCount(3) | ||||
|     await expect( | ||||
|       page.locator('[data-receive-command-type="scene_clear_all"]') | ||||
|     ).toHaveCount(1) | ||||
|   }) | ||||
|  | ||||
|   test('ensure we use the cache, and do not clear on append', async ({ | ||||
|     homePage, | ||||
|     page, | ||||
|   }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForPageLoad() | ||||
|  | ||||
|     await u.codeLocator.click() | ||||
|     await page.keyboard.type(`sketch001 = startSketchOn('XY') | ||||
|   |> startProfileAt([-10, -10], %) | ||||
|   |> line([20, 0], %) | ||||
|   |> line([0, 20], %) | ||||
|   |> line([-20, 0], %) | ||||
|   |> close(%)`) | ||||
|  | ||||
|     // Ensure we execute the first time. | ||||
|     await u.openDebugPanel() | ||||
|     await expect( | ||||
|       page.locator('[data-receive-command-type="scene_clear_all"]') | ||||
|     ).toHaveCount(1) | ||||
|     await expect( | ||||
|       page.locator('[data-message-type="execution-done"]') | ||||
|     ).toHaveCount(2) | ||||
|  | ||||
|     // Add whitespace to the end of the code. | ||||
|     await u.codeLocator.click() | ||||
|     await page.keyboard.press('ArrowDown') | ||||
|     await page.keyboard.press('ArrowDown') | ||||
|     await page.keyboard.press('ArrowDown') | ||||
|     await page.keyboard.press('ArrowDown') | ||||
|     await page.keyboard.press('ArrowDown') | ||||
|     await page.keyboard.press('ArrowDown') | ||||
|     await page.keyboard.press('ArrowDown') | ||||
|     await page.keyboard.press('ArrowDown') | ||||
|     await page.keyboard.press('ArrowDown') | ||||
|     await page.keyboard.press('End') | ||||
|     await page.keyboard.press('Enter') | ||||
|     await page.keyboard.press('Enter') | ||||
|     await page.keyboard.type('const x = 1') | ||||
|     await page.keyboard.press('Enter') | ||||
|  | ||||
|     await u.openDebugPanel() | ||||
|     await expect( | ||||
|       page.locator('[data-message-type="execution-done"]') | ||||
|     ).toHaveCount(3) | ||||
|     await expect( | ||||
|       page.locator('[data-receive-command-type="scene_clear_all"]') | ||||
|     ).toHaveCount(1) | ||||
|   }) | ||||
|  | ||||
|   test('if you click the format button it formats your code', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // check no error to begin with | ||||
|     await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible() | ||||
| @ -187,14 +94,58 @@ test.describe('Editor tests', () => { | ||||
|     |> close(%)`) | ||||
|   }) | ||||
|  | ||||
|   test('ensure we use the cache, and do not re-execute', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.codeLocator.click() | ||||
|     await page.keyboard.type(`sketch001 = startSketchOn('XY') | ||||
|   |> startProfileAt([-10, -10], %) | ||||
|   |> line([20, 0], %) | ||||
|   |> line([0, 20], %) | ||||
|   |> line([-20, 0], %) | ||||
|   |> close(%)`) | ||||
|  | ||||
|     // Ensure we execute the first time. | ||||
|     await u.openDebugPanel() | ||||
|     await expect( | ||||
|       page.locator('[data-receive-command-type="scene_clear_all"]') | ||||
|     ).toHaveCount(2) | ||||
|     await expect( | ||||
|       page.locator('[data-message-type="execution-done"]') | ||||
|     ).toHaveCount(2) | ||||
|  | ||||
|     // Add whitespace to the end of the code. | ||||
|     await u.codeLocator.click() | ||||
|     await page.keyboard.press('ArrowUp') | ||||
|     await page.keyboard.press('ArrowUp') | ||||
|     await page.keyboard.press('ArrowUp') | ||||
|     await page.keyboard.press('ArrowUp') | ||||
|     await page.keyboard.press('Home') | ||||
|     await page.keyboard.type('    ') | ||||
|     await page.keyboard.press('Enter') | ||||
|     await page.keyboard.type('    ') | ||||
|  | ||||
|     // Ensure we don't execute the second time. | ||||
|     await u.openDebugPanel() | ||||
|     // Make sure we didn't clear the scene. | ||||
|     await expect( | ||||
|       page.locator('[data-message-type="execution-done"]') | ||||
|     ).toHaveCount(3) | ||||
|     await expect( | ||||
|       page.locator('[data-receive-command-type="scene_clear_all"]') | ||||
|     ).toHaveCount(2) | ||||
|   }) | ||||
|  | ||||
|   test('if you click the format button it formats your code and executes so lints are still there', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // check no error to begin with | ||||
|     await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible() | ||||
| @ -245,7 +196,9 @@ test.describe('Editor tests', () => { | ||||
|     ).toBeVisible() | ||||
|   }) | ||||
|  | ||||
|   test('fold gutters work', async ({ page, homePage }) => { | ||||
|   test('fold gutters work', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|  | ||||
|     const fullCode = `sketch001 = startSketchOn('XY') | ||||
|      |> startProfileAt([-10, -10], %) | ||||
|      |> line([20, 0], %) | ||||
| @ -263,9 +216,9 @@ test.describe('Editor tests', () => { | ||||
|      |> close(%)` | ||||
|       ) | ||||
|     }) | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // TODO: Jess needs to fix this but you have to mod the code to get them to show | ||||
|     // up, its an annoying codemirror thing. | ||||
| @ -316,10 +269,7 @@ test.describe('Editor tests', () => { | ||||
|     await expect(foldGutterFoldLine).not.toBeVisible() | ||||
|   }) | ||||
|  | ||||
|   test('hover over functions shows function description', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|   test('hover over functions shows function description', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.addInitScript(async () => { | ||||
|       localStorage.setItem( | ||||
| @ -332,9 +282,9 @@ test.describe('Editor tests', () => { | ||||
|   |> close(%)` | ||||
|       ) | ||||
|     }) | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // check no error to begin with | ||||
|     await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible() | ||||
| @ -363,7 +313,6 @@ test.describe('Editor tests', () => { | ||||
|  | ||||
|   test('if you use the format keyboard binding it formats your code', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.addInitScript(async () => { | ||||
| @ -378,9 +327,9 @@ test.describe('Editor tests', () => { | ||||
|       ) | ||||
|       localStorage.setItem('disableAxis', 'true') | ||||
|     }) | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // check no error to begin with | ||||
|     await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible() | ||||
| @ -406,7 +355,6 @@ test.describe('Editor tests', () => { | ||||
|  | ||||
|   test('if you use the format keyboard binding it formats your code and executes so lints are shown', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.addInitScript(async () => { | ||||
| @ -421,9 +369,9 @@ test.describe('Editor tests', () => { | ||||
|       ) | ||||
|       localStorage.setItem('disableAxis', 'true') | ||||
|     }) | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.openDebugPanel() | ||||
|     await u.expectCmdLog('[data-message-type="execution-done"]') | ||||
| @ -466,14 +414,11 @@ test.describe('Editor tests', () => { | ||||
|     ).toBeVisible() | ||||
|   }) | ||||
|  | ||||
|   test('if you write kcl with lint errors you get lints', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|   test('if you write kcl with lint errors you get lints', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // check no error to begin with | ||||
|     await expect(page.locator('.cm-lint-marker-info')).not.toBeVisible() | ||||
| @ -509,10 +454,7 @@ test.describe('Editor tests', () => { | ||||
|     await expect(page.locator('.cm-lint-marker-info')).not.toBeVisible() | ||||
|   }) | ||||
|  | ||||
|   test('if you fixup kcl errors you clear lints', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|   test('if you fixup kcl errors you clear lints', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.addInitScript(async () => { | ||||
|       localStorage.setItem( | ||||
| @ -526,9 +468,9 @@ test.describe('Editor tests', () => { | ||||
|       ) | ||||
|     }) | ||||
|  | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // check no error to begin with | ||||
|     await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible() | ||||
| @ -550,27 +492,22 @@ test.describe('Editor tests', () => { | ||||
|     ).not.toBeVisible() | ||||
|   }) | ||||
|  | ||||
|   test('if you write invalid kcl you get inlined errors', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|   test('if you write invalid kcl you get inlined errors', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // check no error to begin with | ||||
|     await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible() | ||||
|  | ||||
|     /* add the following code to the editor (~ error is not a valid line) | ||||
|       * the old check here used $ but this is for tags so it changed meaning. | ||||
|       * hopefully ~ doesn't change meaning | ||||
|     ~ error | ||||
|     const topAng = 30 | ||||
|     const bottomAng = 25 | ||||
|     /* add the following code to the editor ($ error is not a valid line) | ||||
|       $ error | ||||
|       topAng = 30 | ||||
|       bottomAng = 25 | ||||
|      */ | ||||
|     await u.codeLocator.click() | ||||
|     await page.keyboard.type('~ error') | ||||
|     await page.keyboard.type('$ error') | ||||
|  | ||||
|     // press arrows to clear autocomplete | ||||
|     await page.keyboard.press('ArrowLeft') | ||||
| @ -582,17 +519,17 @@ test.describe('Editor tests', () => { | ||||
|     await page.keyboard.type('bottomAng = 25') | ||||
|     await page.keyboard.press('Enter') | ||||
|  | ||||
|     // error in guter | ||||
|     // error in gutter | ||||
|     await expect(page.locator('.cm-lint-marker-error')).toBeVisible() | ||||
|  | ||||
|     // error text on hover | ||||
|     await page.hover('.cm-lint-marker-error') | ||||
|     await expect( | ||||
|       page.getByText("found unknown token '~'").first() | ||||
|       page.getByText('Tag names must not be empty').first() | ||||
|     ).toBeVisible() | ||||
|  | ||||
|     // select the line that's causing the error and delete it | ||||
|     await page.getByText('~ error').click() | ||||
|     await page.getByText('$ error').click() | ||||
|     await page.keyboard.press('End') | ||||
|     await page.keyboard.down('Shift') | ||||
|     await page.keyboard.press('Home') | ||||
| @ -628,9 +565,10 @@ test.describe('Editor tests', () => { | ||||
|     await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible() | ||||
|   }) | ||||
|  | ||||
|   test.fixme( | ||||
|     'error with 2 source ranges gets 2 diagnostics', | ||||
|     async ({ page, homePage }) => { | ||||
|   // TODO currently multiple source ranges are not supported | ||||
|   test.skip('error with 2 source ranges gets 2 diagnostics', async ({ | ||||
|     page, | ||||
|   }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.addInitScript(async () => { | ||||
|       localStorage.setItem( | ||||
| @ -652,11 +590,9 @@ test.describe('Editor tests', () => { | ||||
|   ` | ||||
|       ) | ||||
|     }) | ||||
|       await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|       await homePage.goToModelingScene() | ||||
|       await u.waitForPageLoad() | ||||
|       await page.waitForTimeout(1000) | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await u.openDebugPanel() | ||||
|     await u.expectCmdLog('[data-message-type="execution-done"]') | ||||
| @ -682,7 +618,7 @@ test.describe('Editor tests', () => { | ||||
|     await page.keyboard.press('ArrowDown') | ||||
|     await page.keyboard.press('Enter') | ||||
|     await page.keyboard.type(`extrusion = startSketchOn('XY') | ||||
|   |> circle({ center: [0, 0], radius: dia/2 }, %) | ||||
|     |> circle({ center = [0, 0], radius = dia/2 }, %) | ||||
|   |> hole(squareHole(length, width, height), %) | ||||
|   |> extrude(height, %)`) | ||||
|  | ||||
| @ -695,14 +631,12 @@ test.describe('Editor tests', () => { | ||||
|  | ||||
|     // Make sure there are two diagnostics | ||||
|     await expect(page.locator('.cm-lint-marker-error')).toHaveCount(2) | ||||
|     } | ||||
|   ) | ||||
|   }) | ||||
|   test('if your kcl gets an error from the engine it is inlined', async ({ | ||||
|     context, | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     await context.addInitScript(async () => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.addInitScript(async () => { | ||||
|       localStorage.setItem( | ||||
|         'persistCode', | ||||
|         `box = startSketchOn('XY') | ||||
| @ -720,16 +654,17 @@ test.describe('Editor tests', () => { | ||||
|   |> line([0, -10], %) | ||||
|   |> close(%) | ||||
|   |> revolve({ | ||||
|     axis: revolveAxis, | ||||
|     angle: 90 | ||||
|   axis = revolveAxis, | ||||
|   angle = 90 | ||||
|   }, %) | ||||
|       ` | ||||
|       ) | ||||
|     }) | ||||
|  | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await page.goto('/') | ||||
|     await u.waitForPageLoad() | ||||
|  | ||||
|     await expect(page.locator('.cm-lint-marker-error')).toBeVisible() | ||||
|  | ||||
| @ -740,15 +675,12 @@ test.describe('Editor tests', () => { | ||||
|     await expect(page.getByText(searchText)).toBeVisible() | ||||
|   }) | ||||
|   test.describe('Autocomplete works', () => { | ||||
|     test('with enter/click to accept the completion', async ({ | ||||
|       page, | ||||
|       homePage, | ||||
|     }) => { | ||||
|     test('with enter/click to accept the completion', async ({ page }) => { | ||||
|       const u = await getUtils(page) | ||||
|       // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|       await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|       await homePage.goToModelingScene() | ||||
|       await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|       // tests clicking on an option, selection the first option | ||||
|       // and arrowing down to an option | ||||
| @ -817,12 +749,12 @@ test.describe('Editor tests', () => { | ||||
|       await expect(page.locator('.cm-lint-marker-error')).toHaveCount(0) | ||||
|     }) | ||||
|  | ||||
|     test('with tab to accept the completion', async ({ page, homePage }) => { | ||||
|     test('with tab to accept the completion', async ({ page }) => { | ||||
|       const u = await getUtils(page) | ||||
|       // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|       await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|       await homePage.goToModelingScene() | ||||
|       await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|       // this test might be brittle as we add and remove functions | ||||
|       // but should also be easy to update. | ||||
| @ -888,13 +820,9 @@ test.describe('Editor tests', () => { | ||||
|     |> xLine(5, %) // lin`) | ||||
|     }) | ||||
|   }) | ||||
|   test('Can undo a click and point extrude with ctrl+z', async ({ | ||||
|     page, | ||||
|     context, | ||||
|     homePage, | ||||
|   }) => { | ||||
|   test('Can undo a click and point extrude with ctrl+z', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await context.addInitScript(async () => { | ||||
|     await page.addInitScript(async () => { | ||||
|       localStorage.setItem( | ||||
|         'persistCode', | ||||
|         `sketch001 = startSketchOn('XZ') | ||||
| @ -905,9 +833,9 @@ test.describe('Editor tests', () => { | ||||
|       ) | ||||
|     }) | ||||
|  | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|     await expect( | ||||
|       page.getByRole('button', { name: 'Start Sketch' }) | ||||
|     ).not.toBeDisabled() | ||||
| @ -966,10 +894,7 @@ test.describe('Editor tests', () => { | ||||
|     |> close(%)`) | ||||
|   }) | ||||
|  | ||||
|   test('Can undo a sketch modification with ctrl+z', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|   test('Can undo a sketch modification with ctrl+z', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.addInitScript(async () => { | ||||
|       localStorage.setItem( | ||||
| @ -983,9 +908,9 @@ test.describe('Editor tests', () => { | ||||
|       ) | ||||
|     }) | ||||
|  | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|     await expect( | ||||
|       page.getByRole('button', { name: 'Start Sketch' }) | ||||
|     ).not.toBeDisabled() | ||||
| @ -1012,7 +937,7 @@ test.describe('Editor tests', () => { | ||||
|     }) | ||||
|     await page.waitForTimeout(100) | ||||
|  | ||||
|     const startPX = [1200 / 2, 500 / 2] | ||||
|     const startPX = [665, 397] | ||||
|  | ||||
|     const dragPX = 40 | ||||
|  | ||||
| @ -1026,9 +951,9 @@ test.describe('Editor tests', () => { | ||||
|  | ||||
|     await expect(page.getByTestId('segment-overlay')).toHaveCount(2) | ||||
|  | ||||
|     // drag startProfileAt handle | ||||
|     // drag startProfieAt handle | ||||
|     await page.dragAndDrop('#stream', '#stream', { | ||||
|       sourcePosition: { x: startPX[0] + 68, y: startPX[1] + 147 }, | ||||
|       sourcePosition: { x: startPX[0], y: startPX[1] }, | ||||
|       targetPosition: { x: startPX[0] + dragPX, y: startPX[1] + dragPX }, | ||||
|     }) | ||||
|     await page.waitForTimeout(100) | ||||
| @ -1066,12 +991,12 @@ test.describe('Editor tests', () => { | ||||
|     // expect the code to have changed | ||||
|     await expect(page.locator('.cm-content')) | ||||
|       .toHaveText(`sketch001 = startSketchOn('XZ') | ||||
|     |> startProfileAt([2.71, -2.71], %) | ||||
|     |> line([15.4, -2.78], %) | ||||
|   |> startProfileAt([7.12, -12.68], %) | ||||
|   |> line([15.39, -2.78], %) | ||||
|   |> tangentialArcTo([27.6, -3.05], %) | ||||
|   |> close(%) | ||||
|   |> extrude(5, %) | ||||
|   `) | ||||
| `) | ||||
|  | ||||
|     // Hit undo | ||||
|     await page.keyboard.down('Control') | ||||
| @ -1080,8 +1005,8 @@ test.describe('Editor tests', () => { | ||||
|  | ||||
|     await expect(page.locator('.cm-content')) | ||||
|       .toHaveText(`sketch001 = startSketchOn('XZ') | ||||
|     |> startProfileAt([2.71, -2.71], %) | ||||
|     |> line([15.4, -2.78], %) | ||||
|   |> startProfileAt([7.12, -12.68], %) | ||||
|   |> line([15.39, -2.78], %) | ||||
|   |> tangentialArcTo([24.95, -0.38], %) | ||||
|   |> close(%) | ||||
|   |> extrude(5, %)`) | ||||
| @ -1093,12 +1018,12 @@ test.describe('Editor tests', () => { | ||||
|  | ||||
|     await expect(page.locator('.cm-content')) | ||||
|       .toHaveText(`sketch001 = startSketchOn('XZ') | ||||
|     |> startProfileAt([2.71, -2.71], %) | ||||
|   |> startProfileAt([7.12, -12.68], %) | ||||
|   |> line([12.73, -0.09], %) | ||||
|   |> tangentialArcTo([24.95, -0.38], %) | ||||
|   |> close(%) | ||||
|   |> extrude(5, %) | ||||
|   `) | ||||
| `) | ||||
|  | ||||
|     // Hit undo again. | ||||
|     await page.keyboard.down('Control') | ||||
| @ -1118,8 +1043,10 @@ test.describe('Editor tests', () => { | ||||
|   test.fixme( | ||||
|     `Can use the import stdlib function on a local OBJ file`, | ||||
|     { tag: '@electron' }, | ||||
|     async ({ page, context }, testInfo) => { | ||||
|       await context.folderSetupFn(async (dir) => { | ||||
|     async ({ browserName }, testInfo) => { | ||||
|       const { electronApp, page } = await setupElectron({ | ||||
|         testInfo, | ||||
|         folderSetupFn: async (dir) => { | ||||
|           const bracketDir = join(dir, 'cube') | ||||
|           await fsp.mkdir(bracketDir, { recursive: true }) | ||||
|           await fsp.copyFile( | ||||
| @ -1127,10 +1054,10 @@ test.describe('Editor tests', () => { | ||||
|             join(bracketDir, 'cube.obj') | ||||
|           ) | ||||
|           await fsp.writeFile(join(bracketDir, 'main.kcl'), '') | ||||
|         }, | ||||
|       }) | ||||
|  | ||||
|       const viewportSize = { width: 1200, height: 500 } | ||||
|       await page.setBodyDimensions(viewportSize) | ||||
|       await page.setViewportSize(viewportSize) | ||||
|  | ||||
|       // Locators and constants | ||||
|       const u = await getUtils(page) | ||||
| @ -1188,6 +1115,8 @@ test.describe('Editor tests', () => { | ||||
|           }) | ||||
|           .toBeGreaterThan(15) | ||||
|       }) | ||||
|  | ||||
|       await electronApp.close() | ||||
|     } | ||||
|   ) | ||||
| }) | ||||
|  | ||||
| @ -1,127 +0,0 @@ | ||||
| import { test, expect } from './zoo-test' | ||||
| import * as fsp from 'fs/promises' | ||||
| import { join } from 'path' | ||||
|  | ||||
| const FEATURE_TREE_EXAMPLE_CODE = `export fn timesFive(x) { | ||||
|   return 5 * x | ||||
| } | ||||
| export fn triangle() { | ||||
|   return startSketchOn('XZ') | ||||
|     |> startProfileAt([0, 0], %) | ||||
|     |> xLine(10, %) | ||||
|     |> line([-10, -5], %) | ||||
|     |> lineTo([profileStartX(%), profileStartY(%)], %) | ||||
|     |> close(%) | ||||
| } | ||||
|  | ||||
| length001 = timesFive(1) * 5 | ||||
| sketch001 = startSketchOn('XZ') | ||||
|   |> startProfileAt([20, 10], %) | ||||
|   |> line([10, 10], %) | ||||
|   |> angledLine([-45, length001], %) | ||||
|   |> lineTo([profileStartX(%), profileStartY(%)], %) | ||||
|   |> close(%) | ||||
| revolve001 = revolve({ axis = "X" }, sketch001) | ||||
| triangle() | ||||
|   |> extrude(30, %) | ||||
| plane001 = offsetPlane('XY', 10) | ||||
| sketch002 = startSketchOn(plane001) | ||||
|   |> startProfileAt([-20, 0], %) | ||||
|   |> line([5, -15], %) | ||||
|   |> xLine(-10, %) | ||||
|   |> lineTo([-40, 0], %) | ||||
|   |> lineTo([profileStartX(%), profileStartY(%)], %) | ||||
|   |> close(%) | ||||
| extrude001 = extrude(10, sketch002) | ||||
| ` | ||||
|  | ||||
| test.describe('Feature Tree pane', () => { | ||||
|   test( | ||||
|     'User can go to definition and go to function definition', | ||||
|     { tag: '@electron' }, | ||||
|     async ({ context, homePage, scene, editor, toolbar }) => { | ||||
|       await context.folderSetupFn(async (dir) => { | ||||
|         const bracketDir = join(dir, 'test-sample') | ||||
|         await fsp.mkdir(bracketDir, { recursive: true }) | ||||
|         await fsp.writeFile( | ||||
|           join(bracketDir, 'main.kcl'), | ||||
|           FEATURE_TREE_EXAMPLE_CODE, | ||||
|           'utf-8' | ||||
|         ) | ||||
|       }) | ||||
|  | ||||
|       await test.step('setup test', async () => { | ||||
|         await homePage.expectState({ | ||||
|           projectCards: [ | ||||
|             { | ||||
|               title: 'test-sample', | ||||
|               fileCount: 1, | ||||
|             }, | ||||
|           ], | ||||
|           sortBy: 'last-modified-desc', | ||||
|         }) | ||||
|         await homePage.openProject('test-sample') | ||||
|         await scene.waitForExecutionDone() | ||||
|         await editor.closePane() | ||||
|         await toolbar.openFeatureTreePane() | ||||
|       }) | ||||
|  | ||||
|       async function testViewSource({ | ||||
|         operationName, | ||||
|         operationIndex, | ||||
|         expectedActiveLine, | ||||
|       }: { | ||||
|         operationName: string | ||||
|         operationIndex: number | ||||
|         expectedActiveLine: string | ||||
|       }) { | ||||
|         await test.step(`Go to definition of the ${operationName}`, async () => { | ||||
|           await toolbar.viewSourceOnOperation(operationName, operationIndex) | ||||
|           await editor.expectState({ | ||||
|             highlightedCode: '', | ||||
|             diagnostics: [], | ||||
|             activeLines: [expectedActiveLine], | ||||
|           }) | ||||
|           await expect( | ||||
|             editor.activeLine.first(), | ||||
|             `${operationName} code should be scrolled into view` | ||||
|           ).toBeVisible() | ||||
|         }) | ||||
|       } | ||||
|  | ||||
|       await testViewSource({ | ||||
|         operationName: 'Offset Plane', | ||||
|         operationIndex: 0, | ||||
|         expectedActiveLine: "plane001 = offsetPlane('XY', 10)", | ||||
|       }) | ||||
|       await testViewSource({ | ||||
|         operationName: 'Extrude', | ||||
|         operationIndex: 1, | ||||
|         expectedActiveLine: 'extrude001 = extrude(10, sketch002)', | ||||
|       }) | ||||
|       await testViewSource({ | ||||
|         operationName: 'Revolve', | ||||
|         operationIndex: 0, | ||||
|         expectedActiveLine: 'revolve001 = revolve({ axis = "X" }, sketch001)', | ||||
|       }) | ||||
|       await testViewSource({ | ||||
|         operationName: 'Triangle', | ||||
|         operationIndex: 0, | ||||
|         expectedActiveLine: 'triangle()', | ||||
|       }) | ||||
|  | ||||
|       await test.step('Go to definition on the triangle function', async () => { | ||||
|         await toolbar.goToDefinitionOnOperation('Triangle', 0) | ||||
|         await editor.expectState({ | ||||
|           highlightedCode: '', | ||||
|           diagnostics: [], | ||||
|           activeLines: ['export fn triangle() {'], | ||||
|         }) | ||||
|         await expect( | ||||
|           editor.activeLine.first(), | ||||
|           'Triangle function definition should be scrolled into view' | ||||
|         ).toBeVisible() | ||||
|       }) | ||||
|     } | ||||
|   ) | ||||
| }) | ||||
| @ -1,4 +1,4 @@ | ||||
| import type { Page, Locator } from '@playwright/test' | ||||
| import type { Page } from '@playwright/test' | ||||
| import { expect } from '@playwright/test' | ||||
|  | ||||
| type CmdBarSerialised = | ||||
| @ -26,11 +26,9 @@ type CmdBarSerialised = | ||||
|  | ||||
| export class CmdBarFixture { | ||||
|   public page: Page | ||||
|   cmdBarOpenBtn!: Locator | ||||
|  | ||||
|   constructor(page: Page) { | ||||
|     this.page = page | ||||
|     this.cmdBarOpenBtn = page.getByTestId('command-bar-open-button') | ||||
|   } | ||||
|   reConstruct = (page: Page) => { | ||||
|     this.page = page | ||||
| @ -118,21 +116,4 @@ export class CmdBarFixture { | ||||
|       await this.page.keyboard.press('Enter') | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   openCmdBar = async (selectCmd?: 'promptToEdit') => { | ||||
|     // TODO why does this button not work in electron tests? | ||||
|     // await this.cmdBarOpenBtn.click() | ||||
|     await this.page.keyboard.down('ControlOrMeta') | ||||
|     await this.page.keyboard.press('KeyK') | ||||
|     await this.page.keyboard.up('ControlOrMeta') | ||||
|     await expect(this.page.getByPlaceholder('Search commands')).toBeVisible() | ||||
|     if (selectCmd === 'promptToEdit') { | ||||
|       const promptEditCommand = this.page.getByText( | ||||
|         'Use Zoo AI to edit your kcl' | ||||
|       ) | ||||
|       await expect(promptEditCommand.first()).toBeVisible() | ||||
|       await promptEditCommand.first().scrollIntoViewIfNeeded() | ||||
|       await promptEditCommand.first().click() | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -20,7 +20,7 @@ export class EditorFixture { | ||||
|   private diagnosticsTooltip!: Locator | ||||
|   private diagnosticsGutterIcon!: Locator | ||||
|   private codeContent!: Locator | ||||
|   public activeLine!: Locator | ||||
|   private activeLine!: Locator | ||||
|  | ||||
|   constructor(page: Page) { | ||||
|     this.page = page | ||||
| @ -29,7 +29,7 @@ export class EditorFixture { | ||||
|   reConstruct = (page: Page) => { | ||||
|     this.page = page | ||||
|  | ||||
|     this.codeContent = page.locator('.cm-content[data-language="kcl"]') | ||||
|     this.codeContent = page.locator('.cm-content') | ||||
|     this.diagnosticsTooltip = page.locator('.cm-tooltip-lint') | ||||
|     this.diagnosticsGutterIcon = page.locator('.cm-lint-marker-error') | ||||
|     this.activeLine = this.page.locator('.cm-activeLine') | ||||
| @ -54,13 +54,13 @@ export class EditorFixture { | ||||
|         } | ||||
|       } | ||||
|       if (!shouldNormalise) { | ||||
|         const expectStart = expect.poll(() => this.codeContent.textContent()) | ||||
|         const expectStart = expect(this.codeContent) | ||||
|         if (not) { | ||||
|           const result = await expectStart.not.toContain(code) | ||||
|           const result = await expectStart.not.toContainText(code, { timeout }) | ||||
|           await resetPane() | ||||
|           return result | ||||
|         } | ||||
|         const result = await expectStart.toContain(code) | ||||
|         const result = await expectStart.toContainText(code, { timeout }) | ||||
|         await resetPane() | ||||
|         return result | ||||
|       } | ||||
| @ -147,28 +147,4 @@ export class EditorFixture { | ||||
|   openPane() { | ||||
|     return openPane(this.page, this.paneButtonTestId) | ||||
|   } | ||||
|   scrollToText(text: string, placeCursor?: boolean) { | ||||
|     return this.page.evaluate( | ||||
|       (args: { text: string; placeCursor?: boolean }) => { | ||||
|         // error TS2339: Property 'docView' does not exist on type 'EditorView'. | ||||
|         // Except it does so :shrug: | ||||
|         // @ts-ignore | ||||
|         let index = window.editorManager._editorView?.docView.view.state.doc | ||||
|           .toString() | ||||
|           .indexOf(args.text) | ||||
|         window.editorManager._editorView?.focus() | ||||
|         window.editorManager._editorView?.dispatch({ | ||||
|           selection: window.EditorSelection.create([ | ||||
|             window.EditorSelection.cursor(index), | ||||
|           ]), | ||||
|           effects: [ | ||||
|             window.EditorView.scrollIntoView( | ||||
|               window.EditorSelection.range(index, index + 1) | ||||
|             ), | ||||
|           ], | ||||
|         }) | ||||
|       }, | ||||
|       { text, placeCursor } | ||||
|     ) | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -1,11 +1,11 @@ | ||||
| import type { | ||||
|   BrowserContext, | ||||
|   ElectronApplication, | ||||
|   TestInfo, | ||||
|   Page, | ||||
|   TestInfo, | ||||
| } from '@playwright/test' | ||||
|  | ||||
| import { getUtils, setup, setupElectron } from '../test-utils' | ||||
| import { test as base } from '@playwright/test' | ||||
| import { getUtils, setup, setupElectron, tearDown } from '../test-utils' | ||||
| import fsp from 'fs/promises' | ||||
| import { join } from 'path' | ||||
| import { CmdBarFixture } from './cmdBarFixture' | ||||
| @ -20,13 +20,11 @@ export class AuthenticatedApp { | ||||
|   public readonly page: Page | ||||
|   public readonly context: BrowserContext | ||||
|   public readonly testInfo: TestInfo | ||||
|   public readonly viewPortSize = { width: 1200, height: 500 } | ||||
|   public electronApp: undefined | ElectronApplication | ||||
|   public dir: string = '' | ||||
|   public readonly viewPortSize = { width: 1000, height: 500 } | ||||
|  | ||||
|   constructor(context: BrowserContext, page: Page, testInfo: TestInfo) { | ||||
|     this.context = context | ||||
|     this.page = page | ||||
|     this.context = context | ||||
|     this.testInfo = testInfo | ||||
|   } | ||||
|  | ||||
| @ -51,7 +49,9 @@ export class AuthenticatedApp { | ||||
|   } | ||||
| } | ||||
|  | ||||
| export interface Fixtures { | ||||
| interface Fixtures { | ||||
|   app: AuthenticatedApp | ||||
|   tronApp: AuthenticatedTronApp | ||||
|   cmdBar: CmdBarFixture | ||||
|   editor: EditorFixture | ||||
|   toolbar: ToolbarFixture | ||||
| @ -61,11 +61,9 @@ export interface Fixtures { | ||||
| export class AuthenticatedTronApp { | ||||
|   public readonly _page: Page | ||||
|   public page: Page | ||||
|   public context: BrowserContext | ||||
|   public readonly context: BrowserContext | ||||
|   public readonly testInfo: TestInfo | ||||
|   public electronApp: ElectronApplication | undefined | ||||
|   public readonly viewPortSize = { width: 1200, height: 500 } | ||||
|   public dir: string = '' | ||||
|   public electronApp?: ElectronApplication | ||||
|  | ||||
|   constructor(context: BrowserContext, page: Page, testInfo: TestInfo) { | ||||
|     this._page = page | ||||
| @ -81,22 +79,15 @@ export class AuthenticatedTronApp { | ||||
|       appSettings?: Partial<SaveSettingsPayload> | ||||
|     } = { fixtures: {} } | ||||
|   ) { | ||||
|     const { electronApp, page, context, dir } = await setupElectron({ | ||||
|     const { electronApp, page } = await setupElectron({ | ||||
|       testInfo: this.testInfo, | ||||
|       folderSetupFn: arg.folderSetupFn, | ||||
|       cleanProjectDir: arg.cleanProjectDir, | ||||
|       appSettings: arg.appSettings, | ||||
|     }) | ||||
|     this.page = page | ||||
|     this.context = context | ||||
|     this.electronApp = electronApp | ||||
|     this.dir = dir | ||||
|  | ||||
|     // Easier to access throughout utils | ||||
|     this.page.dir = dir | ||||
|  | ||||
|     // Setup localStorage, addCookies, reload | ||||
|     await setup(this.context, this.page, this.testInfo) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     for (const key of unsafeTypedKeys(arg.fixtures)) { | ||||
|       const fixture = arg.fixtures[key] | ||||
| @ -119,25 +110,32 @@ export class AuthenticatedTronApp { | ||||
|     }) | ||||
| } | ||||
|  | ||||
| export const fixtures = { | ||||
|   cmdBar: async ({ page }: { page: Page }, use: any) => { | ||||
|     // eslint-disable-next-line react-hooks/rules-of-hooks | ||||
| export const test = base.extend<Fixtures>({ | ||||
|   app: async ({ page, context }, use, testInfo) => { | ||||
|     await use(new AuthenticatedApp(context, page, testInfo)) | ||||
|   }, | ||||
|   tronApp: async ({ page, context }, use, testInfo) => { | ||||
|     await use(new AuthenticatedTronApp(context, page, testInfo)) | ||||
|   }, | ||||
|   cmdBar: async ({ page }, use) => { | ||||
|     await use(new CmdBarFixture(page)) | ||||
|   }, | ||||
|   editor: async ({ page }: { page: Page }, use: any) => { | ||||
|     // eslint-disable-next-line react-hooks/rules-of-hooks | ||||
|   editor: async ({ page }, use) => { | ||||
|     await use(new EditorFixture(page)) | ||||
|   }, | ||||
|   toolbar: async ({ page }: { page: Page }, use: any) => { | ||||
|     // eslint-disable-next-line react-hooks/rules-of-hooks | ||||
|   toolbar: async ({ page }, use) => { | ||||
|     await use(new ToolbarFixture(page)) | ||||
|   }, | ||||
|   scene: async ({ page }: { page: Page }, use: any) => { | ||||
|     // eslint-disable-next-line react-hooks/rules-of-hooks | ||||
|   scene: async ({ page }, use) => { | ||||
|     await use(new SceneFixture(page)) | ||||
|   }, | ||||
|   homePage: async ({ page }: { page: Page }, use: any) => { | ||||
|     // eslint-disable-next-line react-hooks/rules-of-hooks | ||||
|   homePage: async ({ page }, use) => { | ||||
|     await use(new HomePageFixture(page)) | ||||
|   }, | ||||
| } | ||||
| }) | ||||
|  | ||||
| test.afterEach(async ({ page }, testInfo) => { | ||||
|   await tearDown(page, testInfo) | ||||
| }) | ||||
|  | ||||
| export { expect } from '@playwright/test' | ||||
|  | ||||
| @ -14,14 +14,10 @@ interface HomePageState { | ||||
| export class HomePageFixture { | ||||
|   public page: Page | ||||
|  | ||||
|   projectSection!: Locator | ||||
|   projectCard!: Locator | ||||
|   projectCardTitle!: Locator | ||||
|   projectCardFile!: Locator | ||||
|   projectCardFolder!: Locator | ||||
|   projectButtonNew!: Locator | ||||
|   projectButtonContinue!: Locator | ||||
|   projectTextName!: Locator | ||||
|   sortByDateBtn!: Locator | ||||
|   sortByNameBtn!: Locator | ||||
|  | ||||
| @ -32,19 +28,11 @@ export class HomePageFixture { | ||||
|   reConstruct = (page: Page) => { | ||||
|     this.page = page | ||||
|  | ||||
|     this.projectSection = this.page.getByTestId('home-section') | ||||
|  | ||||
|     this.projectCard = this.page.getByTestId('project-link') | ||||
|     this.projectCardTitle = this.page.getByTestId('project-title') | ||||
|     this.projectCardFile = this.page.getByTestId('project-file-count') | ||||
|     this.projectCardFolder = this.page.getByTestId('project-folder-count') | ||||
|  | ||||
|     this.projectButtonNew = this.page.getByTestId('home-new-file') | ||||
|     this.projectTextName = this.page.getByTestId('cmd-bar-arg-value') | ||||
|     this.projectButtonContinue = this.page.getByRole('button', { | ||||
|       name: 'Continue', | ||||
|     }) | ||||
|  | ||||
|     this.sortByDateBtn = this.page.getByTestId('home-sort-by-modified') | ||||
|     this.sortByNameBtn = this.page.getByTestId('home-sort-by-name') | ||||
|   } | ||||
| @ -103,25 +91,10 @@ export class HomePageFixture { | ||||
|       .toEqual(expectedState) | ||||
|   } | ||||
|  | ||||
|   createAndGoToProject = async (projectTitle: string) => { | ||||
|     await expect(this.projectSection).not.toHaveText('Loading your Projects...') | ||||
|     await this.projectButtonNew.click() | ||||
|     await this.projectTextName.click() | ||||
|     await this.projectTextName.fill(projectTitle) | ||||
|     await this.projectButtonContinue.click() | ||||
|   } | ||||
|  | ||||
|   openProject = async (projectTitle: string) => { | ||||
|     const projectCard = this.projectCard.locator( | ||||
|       this.page.getByText(projectTitle) | ||||
|     ) | ||||
|     await projectCard.click() | ||||
|   } | ||||
|  | ||||
|   goToModelingScene = async (name: string = 'testDefault') => { | ||||
|     // On web this is a no-op. There is no project view. | ||||
|     if (process.env.PLATFORM === 'web') return | ||||
|  | ||||
|     await this.createAndGoToProject(name) | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -11,6 +11,7 @@ import { | ||||
|  | ||||
| type mouseParams = { | ||||
|   pixelDiff?: number | ||||
|   shouldDbClick?: boolean | ||||
| } | ||||
| type mouseDragToParams = mouseParams & { | ||||
|   fromPoint: { x: number; y: number } | ||||
| @ -36,8 +37,7 @@ type DragFromHandler = ( | ||||
|  | ||||
| export class SceneFixture { | ||||
|   public page: Page | ||||
|   public streamWrapper!: Locator | ||||
|   public loadingIndicator!: Locator | ||||
|  | ||||
|   private exeIndicator!: Locator | ||||
|  | ||||
|   constructor(page: Page) { | ||||
| @ -54,9 +54,8 @@ export class SceneFixture { | ||||
|  | ||||
|   expectState = async (expected: SceneSerialised) => { | ||||
|     return expect | ||||
|       .poll(async () => await this._serialiseScene(), { | ||||
|         intervals: [1_000, 2_000, 10_000], | ||||
|         timeout: 60000, | ||||
|       .poll(() => this._serialiseScene(), { | ||||
|         message: `Expected scene state to match`, | ||||
|       }) | ||||
|       .toEqual(expected) | ||||
|   } | ||||
| @ -65,8 +64,6 @@ export class SceneFixture { | ||||
|     this.page = page | ||||
|  | ||||
|     this.exeIndicator = page.getByTestId('model-state-indicator-execution-done') | ||||
|     this.streamWrapper = page.getByTestId('stream') | ||||
|     this.loadingIndicator = this.streamWrapper.getByTestId('loading') | ||||
|   } | ||||
|  | ||||
|   makeMouseHelpers = ( | ||||
| @ -79,11 +76,16 @@ export class SceneFixture { | ||||
|         if (clickParams?.pixelDiff) { | ||||
|           return doAndWaitForImageDiff( | ||||
|             this.page, | ||||
|             () => this.page.mouse.click(x, y), | ||||
|             () => | ||||
|               clickParams?.shouldDbClick | ||||
|                 ? this.page.mouse.dblclick(x, y) | ||||
|                 : this.page.mouse.click(x, y), | ||||
|             clickParams.pixelDiff | ||||
|           ) | ||||
|         } | ||||
|         return this.page.mouse.click(x, y) | ||||
|         return clickParams?.shouldDbClick | ||||
|           ? this.page.mouse.dblclick(x, y) | ||||
|           : this.page.mouse.click(x, y) | ||||
|       }, | ||||
|       (moveParams?: mouseParams) => { | ||||
|         if (moveParams?.pixelDiff) { | ||||
| @ -191,10 +193,7 @@ export class SceneFixture { | ||||
|         type: 'default_camera_get_settings', | ||||
|       }, | ||||
|     }) | ||||
|     await this.page | ||||
|       .locator(`[data-receive-command-type="default_camera_get_settings"]`) | ||||
|       .first() | ||||
|       .waitFor() | ||||
|     await this.waitForExecutionDone() | ||||
|     const position = await Promise.all([ | ||||
|       this.page.getByTestId('cam-x-position').inputValue().then(Number), | ||||
|       this.page.getByTestId('cam-y-position').inputValue().then(Number), | ||||
| @ -217,7 +216,7 @@ export class SceneFixture { | ||||
|   } | ||||
|  | ||||
|   expectPixelColor = async ( | ||||
|     colour: [number, number, number], | ||||
|     colour: [number, number, number] | [number, number, number][], | ||||
|     coords: { x: number; y: number }, | ||||
|     diff: number | ||||
|   ) => { | ||||
| @ -229,7 +228,6 @@ export class SceneFixture { | ||||
|   } | ||||
|  | ||||
|   async clickGizmoMenuItem(name: string) { | ||||
|     await this.gizmo.hover() | ||||
|     await this.gizmo.click({ button: 'right' }) | ||||
|     const buttonToTest = this.page.getByRole('button', { | ||||
|       name: name, | ||||
| @ -239,22 +237,36 @@ export class SceneFixture { | ||||
|   } | ||||
| } | ||||
|  | ||||
| function isColourArray( | ||||
|   colour: [number, number, number] | [number, number, number][] | ||||
| ): colour is [number, number, number][] { | ||||
|   return Array.isArray(colour[0]) | ||||
| } | ||||
|  | ||||
| export async function expectPixelColor( | ||||
|   page: Page, | ||||
|   colour: [number, number, number], | ||||
|   colour: [number, number, number] | [number, number, number][], | ||||
|   coords: { x: number; y: number }, | ||||
|   diff: number | ||||
| ) { | ||||
|   let finalValue = colour | ||||
|   await expect | ||||
|     .poll(async () => { | ||||
|     .poll( | ||||
|       async () => { | ||||
|         const pixel = (await getPixelRGBs(page)(coords, 1))[0] | ||||
|         if (!pixel) return null | ||||
|         finalValue = pixel | ||||
|         if (!isColourArray(colour)) { | ||||
|           return pixel.every( | ||||
|             (channel, index) => Math.abs(channel - colour[index]) < diff | ||||
|           ) | ||||
|     }) | ||||
|         } | ||||
|         return colour.some((c) => | ||||
|           c.every((channel, index) => Math.abs(pixel[index] - channel) < diff) | ||||
|         ) | ||||
|       }, | ||||
|       { timeout: 10_000 } | ||||
|     ) | ||||
|     .toBeTruthy() | ||||
|     .catch((cause) => { | ||||
|       throw new Error( | ||||
|  | ||||
| @ -1,25 +1,20 @@ | ||||
| import type { Page, Locator } from '@playwright/test' | ||||
| import { expect } from '../zoo-test' | ||||
| import { | ||||
|   checkIfPaneIsOpen, | ||||
|   closePane, | ||||
|   doAndWaitForImageDiff, | ||||
|   openPane, | ||||
| } from '../test-utils' | ||||
| import { SidebarType } from 'components/ModelingSidebar/ModelingPanes' | ||||
| import { SIDEBAR_BUTTON_SUFFIX } from 'lib/constants' | ||||
| import { expect } from './fixtureSetup' | ||||
| import { doAndWaitForImageDiff } from '../test-utils' | ||||
|  | ||||
| export class ToolbarFixture { | ||||
|   public page: Page | ||||
|  | ||||
|   extrudeButton!: Locator | ||||
|   loftButton!: Locator | ||||
|   sweepButton!: Locator | ||||
|   shellButton!: Locator | ||||
|   offsetPlaneButton!: Locator | ||||
|   startSketchBtn!: Locator | ||||
|   lineBtn!: Locator | ||||
|   tangentialArcBtn!: Locator | ||||
|   circleBtn!: Locator | ||||
|   rectangleBtn!: Locator | ||||
|   lengthConstraintBtn!: Locator | ||||
|   exitSketchBtn!: Locator | ||||
|   editSketchBtn!: Locator | ||||
|   fileTreeBtn!: Locator | ||||
| @ -28,10 +23,6 @@ export class ToolbarFixture { | ||||
|   filePane!: Locator | ||||
|   exeIndicator!: Locator | ||||
|   treeInputField!: Locator | ||||
|   /** The sidebar button for the Feature Tree pane */ | ||||
|   featureTreeId = 'feature-tree' as const | ||||
|   /** The pane element for the Feature Tree */ | ||||
|   featureTreePane!: Locator | ||||
|  | ||||
|   constructor(page: Page) { | ||||
|     this.page = page | ||||
| @ -41,12 +32,14 @@ export class ToolbarFixture { | ||||
|     this.page = page | ||||
|     this.extrudeButton = page.getByTestId('extrude') | ||||
|     this.loftButton = page.getByTestId('loft') | ||||
|     this.sweepButton = page.getByTestId('sweep') | ||||
|     this.shellButton = page.getByTestId('shell') | ||||
|     this.offsetPlaneButton = page.getByTestId('plane-offset') | ||||
|     this.startSketchBtn = page.getByTestId('sketch') | ||||
|     this.lineBtn = page.getByTestId('line') | ||||
|     this.tangentialArcBtn = page.getByTestId('tangential-arc') | ||||
|     this.circleBtn = page.getByTestId('circle-center') | ||||
|     this.rectangleBtn = page.getByTestId('corner-rectangle') | ||||
|     this.lengthConstraintBtn = page.getByTestId('constraint-length') | ||||
|     this.exitSketchBtn = page.getByTestId('sketch-exit') | ||||
|     this.editSketchBtn = page.getByText('Edit Sketch') | ||||
|     this.fileTreeBtn = page.locator('[id="files-button-holder"]') | ||||
| @ -54,7 +47,6 @@ export class ToolbarFixture { | ||||
|     this.treeInputField = page.getByTestId('tree-input-field') | ||||
|  | ||||
|     this.filePane = page.locator('#files-pane') | ||||
|     this.featureTreePane = page.locator('#feature-tree-pane') | ||||
|     this.fileCreateToast = page.getByText('Successfully created') | ||||
|     this.exeIndicator = page.getByTestId('model-state-indicator-execution-done') | ||||
|   } | ||||
| @ -105,76 +97,13 @@ export class ToolbarFixture { | ||||
|       await expect(this.exeIndicator).toBeVisible({ timeout: 15_000 }) | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   async closePane(paneId: SidebarType) { | ||||
|     return closePane(this.page, paneId + SIDEBAR_BUTTON_SUFFIX) | ||||
|   } | ||||
|   async openPane(paneId: SidebarType) { | ||||
|     return openPane(this.page, paneId + SIDEBAR_BUTTON_SUFFIX) | ||||
|   } | ||||
|   async checkIfPaneIsOpen(paneId: SidebarType) { | ||||
|     return checkIfPaneIsOpen(this.page, paneId + SIDEBAR_BUTTON_SUFFIX) | ||||
|   } | ||||
|  | ||||
|   async openFeatureTreePane() { | ||||
|     return this.openPane(this.featureTreeId) | ||||
|   } | ||||
|   async closeFeatureTreePane() { | ||||
|     await this.closePane(this.featureTreeId) | ||||
|   } | ||||
|   async checkIfFeatureTreePaneIsOpen() { | ||||
|     return this.checkIfPaneIsOpen(this.featureTreeId) | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Get a specific operation button from the Feature Tree pane | ||||
|    */ | ||||
|   async getFeatureTreeOperation(operationName: string, operationIndex: number) { | ||||
|     await this.openFeatureTreePane() | ||||
|     await expect(this.featureTreePane).toBeVisible() | ||||
|     return this.featureTreePane | ||||
|       .getByRole('button', { | ||||
|         name: operationName, | ||||
|       }) | ||||
|       .nth(operationIndex) | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * View source on a specific operation in the Feature Tree pane. | ||||
|    * @param operationName The name of the operation type | ||||
|    * @param operationIndex The index out of operations of this type | ||||
|    */ | ||||
|   async viewSourceOnOperation(operationName: string, operationIndex: number) { | ||||
|     const operationButton = await this.getFeatureTreeOperation( | ||||
|       operationName, | ||||
|       operationIndex | ||||
|     ) | ||||
|     const viewSourceMenuButton = this.page.getByRole('button', { | ||||
|       name: 'View KCL source code', | ||||
|     }) | ||||
|  | ||||
|     await operationButton.click({ button: 'right' }) | ||||
|     await expect(viewSourceMenuButton).toBeVisible() | ||||
|     await viewSourceMenuButton.click() | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Go to definition on a specific operation in the Feature Tree pane | ||||
|    */ | ||||
|   async goToDefinitionOnOperation( | ||||
|     operationName: string, | ||||
|     operationIndex: number | ||||
|   ) { | ||||
|     const operationButton = await this.getFeatureTreeOperation( | ||||
|       operationName, | ||||
|       operationIndex | ||||
|     ) | ||||
|     const goToDefinitionMenuButton = this.page.getByRole('button', { | ||||
|       name: 'View function definition', | ||||
|     }) | ||||
|  | ||||
|     await operationButton.click({ button: 'right' }) | ||||
|     await expect(goToDefinitionMenuButton).toBeVisible() | ||||
|     await goToDefinitionMenuButton.click() | ||||
|   selectCenterRectangle = async () => { | ||||
|     await this.page | ||||
|       .getByRole('button', { name: 'caret down Corner rectangle:' }) | ||||
|       .click() | ||||
|     await expect( | ||||
|       this.page.getByTestId('dropdown-center-rectangle') | ||||
|     ).toBeVisible() | ||||
|     await this.page.getByTestId('dropdown-center-rectangle').click() | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -1,22 +1,29 @@ | ||||
| import { test, expect } from './zoo-test' | ||||
| import { executorInputPath } from './test-utils' | ||||
| import { test, expect } from '@playwright/test' | ||||
| import { setupElectron, tearDown, executorInputPath } from './test-utils' | ||||
| import { join } from 'path' | ||||
| import fsp from 'fs/promises' | ||||
|  | ||||
| test.afterEach(async ({ page }, testInfo) => { | ||||
|   await tearDown(page, testInfo) | ||||
| }) | ||||
|  | ||||
| test( | ||||
|   'When machine-api server not found butt is disabled and shows the reason', | ||||
|   { tag: '@electron' }, | ||||
|   async ({ context, page }, testInfo) => { | ||||
|     await context.folderSetupFn(async (dir) => { | ||||
|   async ({ browserName }, testInfo) => { | ||||
|     const { electronApp, page } = await setupElectron({ | ||||
|       testInfo, | ||||
|       folderSetupFn: async (dir) => { | ||||
|         const bracketDir = join(dir, 'bracket') | ||||
|         await fsp.mkdir(bracketDir, { recursive: true }) | ||||
|         await fsp.copyFile( | ||||
|           executorInputPath('focusrite_scarlett_mounting_braket.kcl'), | ||||
|           join(bracketDir, 'main.kcl') | ||||
|         ) | ||||
|       }, | ||||
|     }) | ||||
|  | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await expect(page.getByText('bracket')).toBeVisible() | ||||
|  | ||||
| @ -40,23 +47,28 @@ test( | ||||
|     // that the machine-api server is not found | ||||
|     await makeButton.hover() | ||||
|     await expect(page.getByText(notFoundText).first()).toBeVisible() | ||||
|  | ||||
|     await electronApp.close() | ||||
|   } | ||||
| ) | ||||
|  | ||||
| test( | ||||
|   'When machine-api server not found home screen & project status shows the reason', | ||||
|   { tag: '@electron' }, | ||||
|   async ({ context, page }, testInfo) => { | ||||
|     await context.folderSetupFn(async (dir) => { | ||||
|   async ({ browserName }, testInfo) => { | ||||
|     const { electronApp, page } = await setupElectron({ | ||||
|       testInfo, | ||||
|       folderSetupFn: async (dir) => { | ||||
|         const bracketDir = join(dir, 'bracket') | ||||
|         await fsp.mkdir(bracketDir, { recursive: true }) | ||||
|         await fsp.copyFile( | ||||
|           executorInputPath('focusrite_scarlett_mounting_braket.kcl'), | ||||
|           join(bracketDir, 'main.kcl') | ||||
|         ) | ||||
|       }, | ||||
|     }) | ||||
|  | ||||
|     await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     const notFoundText = 'Machine API server was not discovered' | ||||
|  | ||||
| @ -79,5 +91,7 @@ test( | ||||
|  | ||||
|     await networkMachineToggle.hover() | ||||
|     await expect(page.getByText(notFoundText).nth(1)).toBeVisible() | ||||
|  | ||||
|     await electronApp.close() | ||||
|   } | ||||
| ) | ||||
|  | ||||
| @ -1,12 +0,0 @@ | ||||
| // These tests are meant to simply test starting and stopping the electron | ||||
| // application, check it can make it to the project pane, and nothing more. | ||||
| // It also tests our test wrappers are working. | ||||
| // Additionally this serves as a nice minimal example. | ||||
|  | ||||
| import { test, expect } from './zoo-test' | ||||
|  | ||||
| test.describe('Open the application', () => { | ||||
|   test('see the project view', async ({ page, context }) => { | ||||
|     await expect(page.getByTestId('home-section')).toBeVisible() | ||||
|   }) | ||||
| }) | ||||
| @ -1,78 +1,86 @@ | ||||
| import { test, expect } from './zoo-test' | ||||
| import { test, expect } from '@playwright/test' | ||||
| import { join } from 'path' | ||||
| import fsp from 'fs/promises' | ||||
| import { getUtils, executorInputPath, createProject } from './test-utils' | ||||
| import { | ||||
|   getUtils, | ||||
|   setup, | ||||
|   setupElectron, | ||||
|   tearDown, | ||||
|   executorInputPath, | ||||
|   createProject, | ||||
| } from './test-utils' | ||||
| import { bracket } from 'lib/exampleKcl' | ||||
| import { onboardingPaths } from 'routes/Onboarding/paths' | ||||
| import { | ||||
|   TEST_SETTINGS_KEY, | ||||
|   TEST_SETTINGS_ONBOARDING_START, | ||||
|   TEST_SETTINGS_ONBOARDING_EXPORT, | ||||
|   TEST_SETTINGS_ONBOARDING_PARAMETRIC_MODELING, | ||||
|   TEST_SETTINGS_ONBOARDING_USER_MENU, | ||||
| } from './storageStates' | ||||
| import * as TOML from '@iarna/toml' | ||||
| import { expectPixelColor } from './fixtures/sceneFixture' | ||||
|  | ||||
| // Because onboarding relies on an app setting we need to set it as incompletel | ||||
| // for all these tests. | ||||
| test.beforeEach(async ({ context, page }, testInfo) => { | ||||
|   if (testInfo.tags.includes('@electron')) { | ||||
|     return | ||||
|   } | ||||
|   await setup(context, page) | ||||
| }) | ||||
|  | ||||
| test.afterEach(async ({ page }, testInfo) => { | ||||
|   await tearDown(page, testInfo) | ||||
| }) | ||||
|  | ||||
| test.describe('Onboarding tests', () => { | ||||
|   test( | ||||
|     'Onboarding code is shown in the editor', | ||||
|     { | ||||
|       appSettings: { | ||||
|         app: { | ||||
|           onboardingStatus: 'incomplete', | ||||
|         }, | ||||
|       }, | ||||
|       cleanProjectDir: true, | ||||
|     }, | ||||
|     async ({ context, page, homePage }) => { | ||||
|   test('Onboarding code is shown in the editor', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|       await homePage.goToModelingScene() | ||||
|  | ||||
|     // Override beforeEach test setup | ||||
|     await page.addInitScript( | ||||
|       async ({ settingsKey }) => { | ||||
|         // Give no initial code, so that the onboarding start is shown immediately | ||||
|         localStorage.removeItem('persistCode') | ||||
|         localStorage.removeItem(settingsKey) | ||||
|       }, | ||||
|       { settingsKey: TEST_SETTINGS_KEY } | ||||
|     ) | ||||
|  | ||||
|     await page.setViewportSize({ width: 1200, height: 1000 }) | ||||
|  | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // 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() | ||||
|     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' | ||||
|       ) | ||||
|     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 | ||||
|       ) | ||||
|     } | ||||
|   ) | ||||
|     expect(await u.getGreatestPixDiff(XYPlanePoint, modelColor)).toBeLessThan(8) | ||||
|   }) | ||||
|  | ||||
|   test( | ||||
|     'Desktop: fresh onboarding executes and loads', | ||||
|     { | ||||
|       tag: '@electron', | ||||
|     { tag: '@electron' }, | ||||
|     async ({ browserName: _ }, testInfo) => { | ||||
|       const { electronApp, page } = await setupElectron({ | ||||
|         testInfo, | ||||
|         appSettings: { | ||||
|           app: { | ||||
|             onboardingStatus: 'incomplete', | ||||
|           }, | ||||
|         }, | ||||
|         cleanProjectDir: true, | ||||
|     }, | ||||
|     async ({ page, homePage }, testInfo) => { | ||||
|       }) | ||||
|  | ||||
|       const u = await getUtils(page) | ||||
|  | ||||
|       const viewportSize = { width: 1200, height: 500 } | ||||
|       await page.setBodyDimensions(viewportSize) | ||||
|       const viewportSize = { width: 1200, height: 1000 } | ||||
|       await page.setViewportSize(viewportSize) | ||||
|  | ||||
|       await test.step(`Create a project and open to the onboarding`, async () => { | ||||
|         await createProject({ name: 'project-link', page }) | ||||
| @ -100,71 +108,66 @@ test.describe('Onboarding tests', () => { | ||||
|  | ||||
|         //await expectPixelColor(page, modelColor, XYPlanePoint, 8) | ||||
|       }) | ||||
|  | ||||
|       await electronApp.close() | ||||
|     } | ||||
|   ) | ||||
|  | ||||
|   test( | ||||
|     'Code resets after confirmation', | ||||
|     { | ||||
|       appSettings: { | ||||
|         app: { | ||||
|           onboardingStatus: 'incomplete', | ||||
|         }, | ||||
|       }, | ||||
|       cleanProjectDir: true, | ||||
|     }, | ||||
|     async ({ context, page, homePage }) => { | ||||
|   test('Code resets after confirmation', async ({ page }) => { | ||||
|     const initialCode = `sketch001 = startSketchOn('XZ')` | ||||
|  | ||||
|     // Load the page up with some code so we see the confirmation warning | ||||
|     // when we go to replay onboarding | ||||
|       await context.addInitScript((code) => { | ||||
|     await page.addInitScript((code) => { | ||||
|       localStorage.setItem('persistCode', code) | ||||
|     }, initialCode) | ||||
|  | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|       await homePage.goToModelingScene() | ||||
|     const u = await getUtils(page) | ||||
|     await page.setViewportSize({ width: 1200, height: 1000 }) | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // Replay the onboarding | ||||
|     await page.getByRole('link', { name: 'Settings' }).last().click() | ||||
|       const replayButton = page.getByRole('button', { | ||||
|         name: 'Replay onboarding', | ||||
|       }) | ||||
|     const replayButton = page.getByRole('button', { name: 'Replay onboarding' }) | ||||
|     await expect(replayButton).toBeVisible() | ||||
|     await replayButton.click() | ||||
|  | ||||
|     // 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.getByText('Replaying onboarding resets your code') | ||||
|     ).toBeVisible() | ||||
|     await expect(page.locator('.cm-content')).toHaveText(initialCode) | ||||
|  | ||||
|     const nextButton = page.getByTestId('onboarding-next') | ||||
|       await nextButton.hover() | ||||
|     await expect(nextButton).toBeVisible() | ||||
|     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' | ||||
|       ) | ||||
|     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. | ||||
|     } | ||||
|   ) | ||||
|     // Ensure we persisted the code to local storage. | ||||
|     // Playwright's addInitScript method unfortunately will reset | ||||
|     // this code if we try reloading the page as a test, | ||||
|     // so this is our best way to test persistence afaik. | ||||
|     expect( | ||||
|       await page.evaluate(() => { | ||||
|         return localStorage.getItem('persistCode') | ||||
|       }) | ||||
|     ).toContain('// Shelf Bracket') | ||||
|  | ||||
|     // Make sure the model loaded | ||||
|     const XYPlanePoint = { x: 986, y: 522 } as const | ||||
|     const modelColor: [number, number, number] = [76, 76, 76] | ||||
|     await page.mouse.move(XYPlanePoint.x, XYPlanePoint.y) | ||||
|     await expectPixelColor(page, modelColor, XYPlanePoint, 8) | ||||
|   }) | ||||
|  | ||||
|   test('Click through each onboarding step', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|  | ||||
|   test( | ||||
|     'Click through each onboarding step', | ||||
|     { | ||||
|       appSettings: { | ||||
|         app: { | ||||
|           onboardingStatus: 'incomplete', | ||||
|         }, | ||||
|       }, | ||||
|     }, | ||||
|     async ({ context, page, homePage }) => { | ||||
|     // Override beforeEach test setup | ||||
|       await context.addInitScript( | ||||
|     await page.addInitScript( | ||||
|       async ({ settingsKey, settings }) => { | ||||
|         // Give no initial code, so that the onboarding start is shown immediately | ||||
|         localStorage.setItem('persistCode', '') | ||||
| @ -172,113 +175,118 @@ test.describe('Onboarding tests', () => { | ||||
|       }, | ||||
|       { | ||||
|         settingsKey: TEST_SETTINGS_KEY, | ||||
|           settings: TOML.stringify({ | ||||
|             settings: TEST_SETTINGS_ONBOARDING_START, | ||||
|           }), | ||||
|         settings: TOML.stringify({ settings: TEST_SETTINGS_ONBOARDING_START }), | ||||
|       } | ||||
|     ) | ||||
|  | ||||
|       await page.setBodyDimensions({ width: 1200, height: 1080 }) | ||||
|       await homePage.goToModelingScene() | ||||
|     await page.setViewportSize({ width: 1200, height: 1080 }) | ||||
|  | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // Test that the onboarding pane loaded | ||||
|       await expect( | ||||
|         page.getByText('Welcome to Modeling App! This') | ||||
|       ).toBeVisible() | ||||
|     await expect(page.getByText('Welcome to Modeling App! This')).toBeVisible() | ||||
|  | ||||
|     const nextButton = page.getByTestId('onboarding-next') | ||||
|  | ||||
|     while ((await nextButton.innerText()) !== 'Finish') { | ||||
|         await nextButton.hover() | ||||
|       await expect(nextButton).toBeVisible() | ||||
|       await nextButton.click() | ||||
|     } | ||||
|  | ||||
|     // Finish the onboarding | ||||
|       await nextButton.hover() | ||||
|     await expect(nextButton).toBeVisible() | ||||
|     await nextButton.click() | ||||
|  | ||||
|     // Test that the onboarding pane is gone | ||||
|     await expect(page.getByTestId('onboarding-content')).not.toBeVisible() | ||||
|       await expect.poll(() => page.url()).not.toContain('/onboarding') | ||||
|     } | ||||
|   ) | ||||
|     await expect(page.url()).not.toContain('onboarding') | ||||
|  | ||||
|   test( | ||||
|     'Onboarding redirects and code updating', | ||||
|     { | ||||
|       appSettings: { | ||||
|         app: { | ||||
|           onboardingStatus: '/export', | ||||
|         }, | ||||
|       }, | ||||
|       cleanProjectDir: true, | ||||
|     }, | ||||
|     async ({ context, page, homePage }) => { | ||||
|       const originalCode = 'sigmaAllow = 15000' | ||||
|     await u.openAndClearDebugPanel() | ||||
|     await u.expectCmdLog('[data-message-type="execution-done"]') | ||||
|     await u.closeDebugPanel() | ||||
|  | ||||
|     // TODO: jess to fix | ||||
|     // Make sure the model loaded | ||||
|     //const XYPlanePoint = { x: 774, y: 516 } as const | ||||
|     // const modelColor: [number, number, number] = [129, 129, 129] | ||||
|     // await page.mouse.move(XYPlanePoint.x, XYPlanePoint.y) | ||||
|     // await expectPixelColor(page, modelColor, XYPlanePoint, 20) | ||||
|   }) | ||||
|  | ||||
|   test('Onboarding redirects and code updating', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|  | ||||
|     // Override beforeEach test setup | ||||
|       await context.addInitScript( | ||||
|     await page.addInitScript( | ||||
|       async ({ settingsKey, settings }) => { | ||||
|         // Give some initial code, so we can test that it's cleared | ||||
|           localStorage.setItem('persistCode', originalCode) | ||||
|         localStorage.setItem('persistCode', 'sigmaAllow = 15000') | ||||
|         localStorage.setItem(settingsKey, settings) | ||||
|       }, | ||||
|       { | ||||
|         settingsKey: TEST_SETTINGS_KEY, | ||||
|           settings: TOML.stringify({ | ||||
|             settings: TEST_SETTINGS_ONBOARDING_EXPORT, | ||||
|           }), | ||||
|         settings: TOML.stringify({ settings: TEST_SETTINGS_ONBOARDING_EXPORT }), | ||||
|       } | ||||
|     ) | ||||
|  | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|       await homePage.goToModelingScene() | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|  | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // Test that the redirect happened | ||||
|       await expect.poll(() => page.url()).toContain('/onboarding/export') | ||||
|     await expect(page.url().split(':3000').slice(-1)[0]).toBe( | ||||
|       `/file/%2Fbrowser%2Fmain.kcl/onboarding/export` | ||||
|     ) | ||||
|  | ||||
|     // 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() | ||||
|     await expect(page.url().split(':3000').slice(-1)[0]).toBe( | ||||
|       `/file/%2Fbrowser%2Fmain.kcl/onboarding/export` | ||||
|     ) | ||||
|  | ||||
|     // 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 changes when you advance to the next step | ||||
|     await page.locator('[data-testid="onboarding-next"]').click() | ||||
|     await expect(page.locator('.cm-content')).toHaveText('') | ||||
|  | ||||
|     // 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', async ({ | ||||
|     page, | ||||
|   }) => { | ||||
|     test.skip( | ||||
|       process.platform === 'darwin', | ||||
|       "Skip on macOS, because Playwright isn't behaving the same as the actual browser" | ||||
|     ) | ||||
|     const u = await getUtils(page) | ||||
|     const badCode = `// This is bad code we shouldn't see` | ||||
|     // Override beforeEach test setup | ||||
|     await page.addInitScript( | ||||
|       async ({ settingsKey, settings, badCode }) => { | ||||
|         localStorage.setItem('persistCode', badCode) | ||||
|         localStorage.setItem(settingsKey, settings) | ||||
|       }, | ||||
|       { | ||||
|         settingsKey: TEST_SETTINGS_KEY, | ||||
|         settings: TOML.stringify({ | ||||
|           settings: TEST_SETTINGS_ONBOARDING_PARAMETRIC_MODELING, | ||||
|         }), | ||||
|         badCode, | ||||
|       } | ||||
|     ) | ||||
|  | ||||
|   test( | ||||
|     'Onboarding code gets reset to demo on Interactive Numbers step', | ||||
|     { | ||||
|       appSettings: { | ||||
|         app: { | ||||
|           onboardingStatus: '/parametric-modeling', | ||||
|         }, | ||||
|       }, | ||||
|       cleanProjectDir: true, | ||||
|     }, | ||||
|     await page.setViewportSize({ width: 1200, height: 1080 }) | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     async ({ context, page, homePage }) => { | ||||
|       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) | ||||
|     await page.waitForURL('**' + onboardingPaths.PARAMETRIC_MODELING, { | ||||
|       waitUntil: 'domcontentloaded', | ||||
|     }) | ||||
|  | ||||
|     const bracketNoNewLines = bracket.replace(/\n/g, '') | ||||
|  | ||||
| @ -294,7 +302,6 @@ test.describe('Onboarding tests', () => { | ||||
|     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', | ||||
| @ -302,25 +309,13 @@ test.describe('Onboarding tests', () => { | ||||
|  | ||||
|     // 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 | ||||
|   // 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. | ||||
|   test.fixme( | ||||
|     'Avatar text updates depending on image load success', | ||||
|     { | ||||
|       appSettings: { | ||||
|         app: { | ||||
|           onboardingStatus: 'incomplete', | ||||
|         }, | ||||
|       }, | ||||
|       cleanProjectDir: true, | ||||
|     }, | ||||
|     async ({ context, page, homePage }) => { | ||||
|   test('Avatar text updates depending on image load success', async ({ | ||||
|     page, | ||||
|   }) => { | ||||
|     // Override beforeEach test setup | ||||
|       await context.addInitScript( | ||||
|     await page.addInitScript( | ||||
|       async ({ settingsKey, settings }) => { | ||||
|         localStorage.setItem(settingsKey, settings) | ||||
|       }, | ||||
| @ -332,8 +327,11 @@ test.describe('Onboarding tests', () => { | ||||
|       } | ||||
|     ) | ||||
|  | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|       await homePage.goToModelingScene() | ||||
|     const u = await getUtils(page) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await page.waitForURL('**/file/**', { waitUntil: 'domcontentloaded' }) | ||||
|  | ||||
|     // Test that the text in this step is correct | ||||
|     const avatarLocator = await page | ||||
| @ -361,16 +359,13 @@ test.describe('Onboarding tests', () => { | ||||
|     }) | ||||
|  | ||||
|     // 404 the CI avatar image | ||||
|       await page.route( | ||||
|         'https://lh3.googleusercontent.com/**', | ||||
|         async (route) => { | ||||
|     await page.route('https://lh3.googleusercontent.com/**', async (route) => { | ||||
|       await route.fulfill({ | ||||
|         status: 404, | ||||
|         contentType: 'text/plain', | ||||
|         body: 'Not Found!', | ||||
|       }) | ||||
|         } | ||||
|       ) | ||||
|     }) | ||||
|  | ||||
|     await page.reload({ waitUntil: 'domcontentloaded' }) | ||||
|  | ||||
| @ -378,22 +373,13 @@ test.describe('Onboarding tests', () => { | ||||
|     await expect(avatarLocator).not.toBeVisible() | ||||
|     await expect(onboardingOverlayLocator).toBeVisible() | ||||
|     await expect(onboardingOverlayLocator).toContainText('the menu button') | ||||
|     } | ||||
|   ) | ||||
|   }) | ||||
|  | ||||
|   test.fixme( | ||||
|     "Avatar text doesn't mention avatar when no avatar", | ||||
|     { | ||||
|       appSettings: { | ||||
|         app: { | ||||
|           onboardingStatus: 'incomplete', | ||||
|         }, | ||||
|       }, | ||||
|       cleanProjectDir: true, | ||||
|     }, | ||||
|     async ({ context, page, homePage }) => { | ||||
|   test("Avatar text doesn't mention avatar when no avatar", async ({ | ||||
|     page, | ||||
|   }) => { | ||||
|     // Override beforeEach test setup | ||||
|       await context.addInitScript( | ||||
|     await page.addInitScript( | ||||
|       async ({ settingsKey, settings }) => { | ||||
|         localStorage.setItem(settingsKey, settings) | ||||
|         localStorage.setItem('FORCE_NO_IMAGE', 'FORCE_NO_IMAGE') | ||||
| @ -406,8 +392,11 @@ test.describe('Onboarding tests', () => { | ||||
|       } | ||||
|     ) | ||||
|  | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|       await homePage.goToModelingScene() | ||||
|     const u = await getUtils(page) | ||||
|     await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     await page.waitForURL('**/file/**', { waitUntil: 'domcontentloaded' }) | ||||
|  | ||||
|     // Test that the text in this step is correct | ||||
|     const sidebar = page.getByTestId('user-sidebar-toggle') | ||||
| @ -433,28 +422,23 @@ test.describe('Onboarding tests', () => { | ||||
|     for (const feature of userMenuFeatures) { | ||||
|       await expect(onboardingOverlayLocator).toContainText(feature) | ||||
|     } | ||||
|     } | ||||
|   ) | ||||
|   }) | ||||
| }) | ||||
|  | ||||
| test.fixme( | ||||
| test( | ||||
|   'Restarting onboarding on desktop takes one attempt', | ||||
|   { | ||||
|     appSettings: { | ||||
|       app: { | ||||
|         onboardingStatus: 'dismissed', | ||||
|       }, | ||||
|     }, | ||||
|     cleanProjectDir: true, | ||||
|   }, | ||||
|   async ({ context, page, homePage }, testInfo) => { | ||||
|     await context.folderSetupFn(async (dir) => { | ||||
|   { tag: '@electron' }, | ||||
|   async ({ browser: _ }, testInfo) => { | ||||
|     const { electronApp, page } = await setupElectron({ | ||||
|       testInfo, | ||||
|       folderSetupFn: async (dir) => { | ||||
|         const routerTemplateDir = join(dir, 'router-template-slate') | ||||
|         await fsp.mkdir(routerTemplateDir, { recursive: true }) | ||||
|         await fsp.copyFile( | ||||
|           executorInputPath('router-template-slate.kcl'), | ||||
|           join(routerTemplateDir, 'main.kcl') | ||||
|         ) | ||||
|       }, | ||||
|     }) | ||||
|  | ||||
|     // Our constants | ||||
| @ -466,8 +450,9 @@ test.fixme( | ||||
|     const restartOnboardingButton = page.getByRole('button', { | ||||
|       name: 'Reset onboarding', | ||||
|     }) | ||||
|     const nextButton = page.getByTestId('onboarding-next') | ||||
|  | ||||
|     const restartConfirmationButton = page.getByRole('button', { | ||||
|       name: 'Make a new project', | ||||
|     }) | ||||
|     const tutorialProjectIndicator = page | ||||
|       .getByTestId('project-sidebar-toggle') | ||||
|       .filter({ hasText: 'Tutorial Project 00' }) | ||||
| @ -486,7 +471,7 @@ test.fixme( | ||||
|     }) | ||||
|  | ||||
|     await test.step('Navigate into project', async () => { | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|       await page.setViewportSize({ width: 1200, height: 1000 }) | ||||
|  | ||||
|       page.on('console', console.log) | ||||
|  | ||||
| @ -502,8 +487,8 @@ test.fixme( | ||||
|       await helpMenuButton.click() | ||||
|       await restartOnboardingButton.click() | ||||
|  | ||||
|       await nextButton.hover() | ||||
|       await nextButton.click() | ||||
|       await expect(restartConfirmationButton).toBeVisible() | ||||
|       await restartConfirmationButton.click() | ||||
|     }) | ||||
|  | ||||
|     await test.step('Confirm that the onboarding has restarted', async () => { | ||||
| @ -535,9 +520,11 @@ test.fixme( | ||||
|  | ||||
|       await restartOnboardingSettingsButton.click() | ||||
|       // Since the code is empty, we should not see the confirmation dialog | ||||
|       await expect(nextButton).not.toBeVisible() | ||||
|       await expect(restartConfirmationButton).not.toBeVisible() | ||||
|       await expect(tutorialProjectIndicator).toBeVisible() | ||||
|       await expect(tutorialModalText).toBeVisible() | ||||
|     }) | ||||
|  | ||||
|     await electronApp.close() | ||||
|   } | ||||
| ) | ||||
|  | ||||
| @ -1,190 +0,0 @@ | ||||
| import { test, expect } from './zoo-test' | ||||
|  | ||||
| /* eslint-disable jest/no-conditional-expect */ | ||||
|  | ||||
| const file = `sketch001 = startSketchOn('XZ') | ||||
| profile001 = startProfileAt([57.81, 250.51], sketch001) | ||||
|   |> line([121.13, 56.63], %, $seg02) | ||||
|   |> line([83.37, -34.61], %, $seg01) | ||||
|   |> line([19.66, -116.4], %) | ||||
|   |> line([-221.8, -41.69], %) | ||||
|   |> lineTo([profileStartX(%), profileStartY(%)], %) | ||||
|   |> close(%) | ||||
| extrude001 = extrude(200, profile001) | ||||
| sketch002 = startSketchOn('XZ') | ||||
|   |> startProfileAt([-73.64, -42.89], %) | ||||
|   |> xLine(173.71, %) | ||||
|   |> line([-22.12, -94.4], %) | ||||
|   |> xLine(-156.98, %) | ||||
|   |> lineTo([profileStartX(%), profileStartY(%)], %) | ||||
|   |> close(%) | ||||
| extrude002 = extrude(50, sketch002) | ||||
| sketch003 = startSketchOn('XY') | ||||
|   |> startProfileAt([52.92, 157.81], %) | ||||
|   |> angledLine([0, 176.4], %, $rectangleSegmentA001) | ||||
|   |> angledLine([ | ||||
|        segAng(rectangleSegmentA001) - 90, | ||||
|        53.4 | ||||
|      ], %, $rectangleSegmentB001) | ||||
|   |> angledLine([ | ||||
|        segAng(rectangleSegmentA001), | ||||
|        -segLen(rectangleSegmentA001) | ||||
|      ], %, $rectangleSegmentC001) | ||||
|   |> lineTo([profileStartX(%), profileStartY(%)], %) | ||||
|   |> close(%) | ||||
| extrude003 = extrude(20, sketch003) | ||||
| ` | ||||
|  | ||||
| test.describe('Check the happy path, for basic changing color', () => { | ||||
|   const cases = [ | ||||
|     { | ||||
|       desc: 'User accepts change', | ||||
|       shouldReject: false, | ||||
|     }, | ||||
|     { | ||||
|       desc: 'User rejects change', | ||||
|       shouldReject: true, | ||||
|     }, | ||||
|   ] as const | ||||
|   for (const { desc, shouldReject } of cases) { | ||||
|     test(`${desc}`, async ({ | ||||
|       context, | ||||
|       homePage, | ||||
|       cmdBar, | ||||
|       editor, | ||||
|       page, | ||||
|       scene, | ||||
|     }) => { | ||||
|       await context.addInitScript((file) => { | ||||
|         localStorage.setItem('persistCode', file) | ||||
|       }, file) | ||||
|       await homePage.goToModelingScene() | ||||
|  | ||||
|       const body1CapCoords = { x: 571, y: 351 } | ||||
|       const greenCheckCoords = { x: 565, y: 345 } | ||||
|       const body2WallCoords = { x: 609, y: 153 } | ||||
|       const [clickBody1Cap] = scene.makeMouseHelpers( | ||||
|         body1CapCoords.x, | ||||
|         body1CapCoords.y | ||||
|       ) | ||||
|       const yellow: [number, number, number] = [179, 179, 131] | ||||
|       const green: [number, number, number] = [108, 152, 75] | ||||
|       const notGreen: [number, number, number] = [132, 132, 132] | ||||
|       const body2NotGreen: [number, number, number] = [88, 88, 88] | ||||
|       const submittingToast = page.getByText('Submitting to Text-to-CAD API...') | ||||
|       const successToast = page.getByText('Prompt to edit successful') | ||||
|       const acceptBtn = page.getByRole('button', { name: 'checkmark Accept' }) | ||||
|       const rejectBtn = page.getByRole('button', { name: 'close Reject' }) | ||||
|  | ||||
|       await test.step('wait for scene to load select body and check selection came through', async () => { | ||||
|         await scene.expectPixelColor([134, 134, 134], body1CapCoords, 15) | ||||
|         await clickBody1Cap() | ||||
|         await scene.expectPixelColor(yellow, body1CapCoords, 20) | ||||
|         await editor.expectState({ | ||||
|           highlightedCode: '', | ||||
|           activeLines: ['|>startProfileAt([-73.64,-42.89],%)'], | ||||
|           diagnostics: [], | ||||
|         }) | ||||
|       }) | ||||
|  | ||||
|       await test.step('fire off edit prompt', async () => { | ||||
|         await cmdBar.openCmdBar('promptToEdit') | ||||
|         // being specific about the color with a hex means asserting pixel color is more stable | ||||
|         await page | ||||
|           .getByTestId('cmd-bar-arg-value') | ||||
|           .fill('make this neon green please, use #39FF14') | ||||
|         await page.waitForTimeout(100) | ||||
|         await cmdBar.progressCmdBar() | ||||
|         await expect(submittingToast).toBeVisible() | ||||
|         await expect(submittingToast).not.toBeVisible({ timeout: 2 * 60_000 }) // can take a while | ||||
|         await expect(successToast).toBeVisible() | ||||
|       }) | ||||
|  | ||||
|       await test.step('verify initial change', async () => { | ||||
|         await scene.expectPixelColor(green, greenCheckCoords, 15) | ||||
|         await scene.expectPixelColor(body2NotGreen, body2WallCoords, 15) | ||||
|         await editor.expectEditor.toContain('appearance({') | ||||
|       }) | ||||
|  | ||||
|       if (!shouldReject) { | ||||
|         await test.step('check accept works and can be "undo"ed', async () => { | ||||
|           await acceptBtn.click() | ||||
|           await expect(successToast).not.toBeVisible() | ||||
|  | ||||
|           await scene.expectPixelColor(green, greenCheckCoords, 15) | ||||
|           await editor.expectEditor.toContain('appearance({') | ||||
|  | ||||
|           // ctrl-z works after accepting | ||||
|           await page.keyboard.down('ControlOrMeta') | ||||
|           await page.keyboard.press('KeyZ') | ||||
|           await page.keyboard.up('ControlOrMeta') | ||||
|           await editor.expectEditor.not.toContain('appearance({') | ||||
|           await scene.expectPixelColor(notGreen, greenCheckCoords, 15) | ||||
|         }) | ||||
|       } else { | ||||
|         await test.step('check reject works', async () => { | ||||
|           await rejectBtn.click() | ||||
|           await expect(successToast).not.toBeVisible() | ||||
|  | ||||
|           await scene.expectPixelColor(notGreen, greenCheckCoords, 15) | ||||
|           await editor.expectEditor.not.toContain('appearance({') | ||||
|         }) | ||||
|       } | ||||
|     }) | ||||
|   } | ||||
| }) | ||||
|  | ||||
| test.describe('bad path', () => { | ||||
|   test(`bad edit prompt`, async ({ | ||||
|     context, | ||||
|     homePage, | ||||
|     cmdBar, | ||||
|     editor, | ||||
|     toolbar, | ||||
|     page, | ||||
|     scene, | ||||
|   }) => { | ||||
|     await context.addInitScript((file) => { | ||||
|       localStorage.setItem('persistCode', file) | ||||
|     }, file) | ||||
|     await homePage.goToModelingScene() | ||||
|  | ||||
|     const body1CapCoords = { x: 571, y: 351 } | ||||
|     const [clickBody1Cap] = scene.makeMouseHelpers( | ||||
|       body1CapCoords.x, | ||||
|       body1CapCoords.y | ||||
|     ) | ||||
|     const yellow: [number, number, number] = [179, 179, 131] | ||||
|     const submittingToast = page.getByText('Submitting to Text-to-CAD API...') | ||||
|     const failToast = page.getByText( | ||||
|       'Failed to edit your KCL code, please try again with a different prompt or selection' | ||||
|     ) | ||||
|  | ||||
|     await test.step('wait for scene to load and select body', async () => { | ||||
|       await scene.expectPixelColor([134, 134, 134], body1CapCoords, 15) | ||||
|  | ||||
|       await clickBody1Cap() | ||||
|       await scene.expectPixelColor(yellow, body1CapCoords, 20) | ||||
|  | ||||
|       await editor.expectState({ | ||||
|         highlightedCode: '', | ||||
|         activeLines: ['|>startProfileAt([-73.64,-42.89],%)'], | ||||
|         diagnostics: [], | ||||
|       }) | ||||
|     }) | ||||
|  | ||||
|     await test.step('fire of bad prompt', async () => { | ||||
|       await cmdBar.openCmdBar('promptToEdit') | ||||
|       await page | ||||
|         .getByTestId('cmd-bar-arg-value') | ||||
|         .fill('ansheusha asnthuatshoeuhtaoetuhthaeu laughs in dvorak') | ||||
|       await page.waitForTimeout(100) | ||||
|       await cmdBar.progressCmdBar() | ||||
|       await expect(submittingToast).toBeVisible() | ||||
|     }) | ||||
|     await test.step('check fail toast appeared', async () => { | ||||
|       await expect(submittingToast).not.toBeVisible({ timeout: 2 * 60_000 }) // can take a while | ||||
|       await expect(failToast).toBeVisible() | ||||
|     }) | ||||
|   }) | ||||
| }) | ||||
| @ -1,26 +1,36 @@ | ||||
| import { test, expect, Page } from './zoo-test' | ||||
| import path from 'path' | ||||
| import { test, expect, Page } from '@playwright/test' | ||||
| import { join } from 'path' | ||||
| import * as fsp from 'fs/promises' | ||||
| import { getUtils, executorInputPath } from './test-utils' | ||||
| import { | ||||
|   getUtils, | ||||
|   setup, | ||||
|   setupElectron, | ||||
|   tearDown, | ||||
|   executorInputPath, | ||||
| } from './test-utils' | ||||
| import { TEST_CODE_TRIGGER_ENGINE_EXPORT_ERROR } from './storageStates' | ||||
| import { bracket } from 'lib/exampleKcl' | ||||
|  | ||||
| test.beforeEach(async ({ context, page }, testInfo) => { | ||||
|   await setup(context, page, testInfo) | ||||
| }) | ||||
|  | ||||
| test.afterEach(async ({ page }, testInfo) => { | ||||
|   await tearDown(page, testInfo) | ||||
| }) | ||||
|  | ||||
| test.describe('Regression tests', () => { | ||||
|   // bugs we found that don't fit neatly into other categories | ||||
|   test('bad model has inline error #3251', async ({ | ||||
|     context, | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|   test('bad model has inline error #3251', async ({ page }) => { | ||||
|     // because the model has `line([0,0]..` it is valid code, but the model is invalid | ||||
|     // regression test for https://github.com/KittyCAD/modeling-app/issues/3251 | ||||
|     // Since the bad model also found as issue with the artifact graph, which in tern blocked the editor diognostics | ||||
|     const u = await getUtils(page) | ||||
|     await context.addInitScript(async () => { | ||||
|     await page.addInitScript(async () => { | ||||
|       localStorage.setItem( | ||||
|         'persistCode', | ||||
|         `sketch2 = startSketchOn("XY") | ||||
|   sketch001 = startSketchAt([-0, -0]) | ||||
| sketch001 = startSketchAt([-0, -0]) | ||||
|   |> line([0, 0], %) | ||||
|   |> line([-4.84, -5.29], %) | ||||
|   |> lineTo([profileStartX(%), profileStartY(%)], %) | ||||
| @ -28,10 +38,9 @@ test.describe('Regression tests', () => { | ||||
|       ) | ||||
|     }) | ||||
|  | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForPageLoad() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // error in guter | ||||
|     await expect(page.locator('.cm-lint-marker-error')).toBeVisible() | ||||
| @ -47,7 +56,6 @@ test.describe('Regression tests', () => { | ||||
|   }) | ||||
|   test('user should not have to press down twice in cmdbar', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     // because the model has `line([0,0]..` it is valid code, but the model is invalid | ||||
|     // regression test for https://github.com/KittyCAD/modeling-app/issues/3251 | ||||
| @ -56,38 +64,26 @@ test.describe('Regression tests', () => { | ||||
|     await page.addInitScript(async () => { | ||||
|       localStorage.setItem( | ||||
|         'persistCode', | ||||
|         `sketch001 = startSketchOn('XY') | ||||
|   |> startProfileAt([82.33, 238.21], %) | ||||
|   |> angledLine([0, 288.63], %, $rectangleSegmentA001) | ||||
|   |> angledLine([ | ||||
|        segAng(rectangleSegmentA001) - 90, | ||||
|        197.97 | ||||
|      ], %, $rectangleSegmentB001) | ||||
|   |> angledLine([ | ||||
|        segAng(rectangleSegmentA001), | ||||
|        -segLen(rectangleSegmentA001) | ||||
|      ], %, $rectangleSegmentC001) | ||||
|         `sketch2 = startSketchOn("XY") | ||||
| sketch001 = startSketchAt([-0, -0]) | ||||
|   |> line([0, 0], %) | ||||
|   |> line([-4.84, -5.29], %) | ||||
|   |> lineTo([profileStartX(%), profileStartY(%)], %) | ||||
|   |> close(%) | ||||
| extrude001 = extrude(50, sketch001) | ||||
| ` | ||||
|   |> close(%)` | ||||
|       ) | ||||
|     }) | ||||
|  | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await page.goto('/') | ||||
|     await u.waitForPageLoad() | ||||
|  | ||||
|     await test.step('Check arrow down works', async () => { | ||||
|       await page.getByTestId('command-bar-open-button').hover() | ||||
|       await page.getByTestId('command-bar-open-button').click() | ||||
|  | ||||
|       const floppy = page.getByRole('option', { | ||||
|         name: 'floppy disk arrow Export', | ||||
|       }) | ||||
|  | ||||
|       await floppy.click() | ||||
|       await page | ||||
|         .getByRole('option', { name: 'floppy disk arrow Export' }) | ||||
|         .click() | ||||
|  | ||||
|       // press arrow down key twice | ||||
|       await page.keyboard.press('ArrowDown') | ||||
| @ -119,7 +115,7 @@ extrude001 = extrude(50, sketch001) | ||||
|       ) | ||||
|     }) | ||||
|   }) | ||||
|   test('executes on load', async ({ page, homePage }) => { | ||||
|   test('executes on load', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.addInitScript(async () => { | ||||
|       localStorage.setItem( | ||||
| @ -131,10 +127,9 @@ extrude001 = extrude(50, sketch001) | ||||
|     |> line([-23.44, 0.52], %)` | ||||
|       ) | ||||
|     }) | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForPageLoad() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // expand variables section | ||||
|     const variablesTabButton = page.getByTestId('variables-pane-button') | ||||
| @ -153,15 +148,14 @@ extrude001 = extrude(50, sketch001) | ||||
|     ).toBeVisible() | ||||
|   }) | ||||
|  | ||||
|   test('re-executes', async ({ page, homePage }) => { | ||||
|   test('re-executes', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.addInitScript(async () => { | ||||
|       localStorage.setItem('persistCode', `myVar = 5`) | ||||
|     }) | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForPageLoad() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     const variablesTabButton = page.getByTestId('variables-pane-button') | ||||
|     await variablesTabButton.click() | ||||
| @ -180,7 +174,7 @@ extrude001 = extrude(50, sketch001) | ||||
|       page.locator('.pretty-json-container >> text=myVar:67') | ||||
|     ).toBeVisible() | ||||
|   }) | ||||
|   test('ProgramMemory can be serialised', async ({ page, homePage }) => { | ||||
|   test('ProgramMemory can be serialised', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.addInitScript(async () => { | ||||
|       localStorage.setItem( | ||||
| @ -199,14 +193,13 @@ extrude001 = extrude(50, sketch001) | ||||
|         }, %)` | ||||
|       ) | ||||
|     }) | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     const messages: string[] = [] | ||||
|  | ||||
|     // Listen for all console events and push the message text to an array | ||||
|     page.on('console', (message) => messages.push(message.text())) | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForPageLoad() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // wait for execution done | ||||
|     await u.openDebugPanel() | ||||
| @ -219,26 +212,19 @@ extrude001 = extrude(50, sketch001) | ||||
|       }) | ||||
|     }) | ||||
|   }) | ||||
|  | ||||
|   // Not relevant to us anymore, or at least for the time being. | ||||
|   test.skip('ensure the Zoo logo is not a link in browser app', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|   test('ensure the Zoo logo is not a link in browser app', async ({ page }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForPageLoad() | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     const zooLogo = page.locator('[data-testid="app-logo"]') | ||||
|     // Make sure it's not a link | ||||
|     await expect(zooLogo).not.toHaveAttribute('href') | ||||
|   }) | ||||
|  | ||||
|   test( | ||||
|     'Position _ Is Out Of Range... regression test', | ||||
|     { tag: ['@skipWin'] }, | ||||
|     async ({ context, page, homePage }) => { | ||||
|     async ({ page }) => { | ||||
|       // SKip on windows, its being weird. | ||||
|       test.skip( | ||||
|         process.platform === 'win32', | ||||
| @ -247,8 +233,8 @@ extrude001 = extrude(50, sketch001) | ||||
|  | ||||
|       const u = await getUtils(page) | ||||
|       // const PUR = 400 / 37.5 //pixeltoUnitRatio | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|       await context.addInitScript(async () => { | ||||
|       await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|       await page.addInitScript(async () => { | ||||
|         localStorage.setItem( | ||||
|           'persistCode', | ||||
|           `exampleSketch = startSketchOn("XZ") | ||||
| @ -264,9 +250,8 @@ extrude001 = extrude(50, sketch001) | ||||
|       }) | ||||
|  | ||||
|       await expect(async () => { | ||||
|         await homePage.goToModelingScene() | ||||
|         await page.goto('/') | ||||
|         await u.waitForPageLoad() | ||||
|  | ||||
|         // error in guter | ||||
|         await expect(page.locator('.cm-lint-marker-error')).toBeVisible({ | ||||
|           timeout: 1_000, | ||||
| @ -321,7 +306,6 @@ extrude001 = extrude(50, sketch001) | ||||
|  | ||||
|   test('when engine fails export we handle the failure and alert the user', async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     const u = await getUtils(page) | ||||
|     await page.addInitScript( | ||||
| @ -332,10 +316,9 @@ extrude001 = extrude(50, sketch001) | ||||
|       { code: TEST_CODE_TRIGGER_ENGINE_EXPORT_ERROR } | ||||
|     ) | ||||
|  | ||||
|     await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|     await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|     await homePage.goToModelingScene() | ||||
|     await u.waitForPageLoad() | ||||
|     await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|     // wait for execution done | ||||
|     await u.openDebugPanel() | ||||
| @ -391,6 +374,7 @@ extrude001 = extrude(50, sketch001) | ||||
|  | ||||
|     // wait for execution done | ||||
|     await u.openDebugPanel() | ||||
|     await u.clearCommandLogs() | ||||
|     await u.expectCmdLog('[data-message-type="execution-done"]') | ||||
|     await u.closeDebugPanel() | ||||
|  | ||||
| @ -424,7 +408,7 @@ extrude001 = extrude(50, sketch001) | ||||
|   test( | ||||
|     'ensure you can not export while an export is already going', | ||||
|     { tag: ['@skipLinux', '@skipWin'] }, | ||||
|     async ({ page, homePage }) => { | ||||
|     async ({ page }) => { | ||||
|       // This is being weird on ubuntu and windows. | ||||
|       test.skip( | ||||
|         // eslint-disable-next-line jest/valid-title | ||||
| @ -444,10 +428,9 @@ extrude001 = extrude(50, sketch001) | ||||
|           } | ||||
|         ) | ||||
|  | ||||
|         await page.setBodyDimensions({ width: 1000, height: 500 }) | ||||
|         await page.setViewportSize({ width: 1000, height: 500 }) | ||||
|  | ||||
|         await homePage.goToModelingScene() | ||||
|         await u.waitForPageLoad() | ||||
|         await u.waitForAuthSkipAppStart() | ||||
|  | ||||
|         // wait for execution done | ||||
|         await u.openDebugPanel() | ||||
| @ -517,17 +500,20 @@ extrude001 = extrude(50, sketch001) | ||||
|   test( | ||||
|     `Network health indicator only appears in modeling view`, | ||||
|     { tag: '@electron' }, | ||||
|     async ({ context, page }, testInfo) => { | ||||
|       await context.folderSetupFn(async (dir) => { | ||||
|         const bracketDir = path.join(dir, 'bracket') | ||||
|     async ({ browserName: _ }, testInfo) => { | ||||
|       const { electronApp, page } = await setupElectron({ | ||||
|         testInfo, | ||||
|         folderSetupFn: async (dir) => { | ||||
|           const bracketDir = join(dir, 'bracket') | ||||
|           await fsp.mkdir(bracketDir, { recursive: true }) | ||||
|           await fsp.copyFile( | ||||
|             executorInputPath('focusrite_scarlett_mounting_braket.kcl'), | ||||
|           path.join(bracketDir, 'main.kcl') | ||||
|             join(bracketDir, 'main.kcl') | ||||
|           ) | ||||
|         }, | ||||
|       }) | ||||
|  | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|       await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|       const u = await getUtils(page) | ||||
|  | ||||
|       // Locators | ||||
| @ -553,19 +539,18 @@ extrude001 = extrude(50, sketch001) | ||||
|         await u.waitForPageLoad() | ||||
|         await expect(networkHealthIndicator).toContainText('Connected') | ||||
|       }) | ||||
|  | ||||
|       await electronApp.close() | ||||
|     } | ||||
|   ) | ||||
|  | ||||
|   test(`View gizmo stays visible even when zoomed out all the way`, async ({ | ||||
|     page, | ||||
|     homePage, | ||||
|   }) => { | ||||
|     // TODO: fix this test on windows after the electron migration | ||||
|     test.skip(process.platform === 'win32', 'Skip on windows') | ||||
|     const u = await getUtils(page) | ||||
|  | ||||
|     // Constants and locators | ||||
|     const planeColor: [number, number, number] = [170, 220, 170] | ||||
|     const planeColor: [number, number, number] = [161, 220, 155] | ||||
|     const bgColor: [number, number, number] = [27, 27, 27] | ||||
|     const middlePixelIsColor = async (color: [number, number, number]) => { | ||||
|       return u.getGreatestPixDiff({ x: 600, y: 250 }, color) | ||||
| @ -576,9 +561,8 @@ extrude001 = extrude(50, sketch001) | ||||
|       await page.addInitScript(async () => { | ||||
|         localStorage.setItem('persistCode', '') | ||||
|       }) | ||||
|       await page.setBodyDimensions({ width: 1200, height: 500 }) | ||||
|       await homePage.goToModelingScene() | ||||
|       await u.waitForPageLoad() | ||||
|       await page.setViewportSize({ width: 1200, height: 500 }) | ||||
|       await u.waitForAuthSkipAppStart() | ||||
|       await u.closeKclCodePanel() | ||||
|     }) | ||||
|  | ||||
| @ -588,7 +572,7 @@ extrude001 = extrude(50, sketch001) | ||||
|           timeout: 5000, | ||||
|           message: 'Plane color is visible', | ||||
|         }) | ||||
|         .toBeLessThanOrEqual(15) | ||||
|         .toBeLessThan(15) | ||||
|  | ||||
|       let maxZoomOuts = 10 | ||||
|       let middlePixelIsBackgroundColor = | ||||
| @ -606,7 +590,7 @@ extrude001 = extrude(50, sketch001) | ||||
|       } | ||||
|  | ||||
|       expect(middlePixelIsBackgroundColor, { | ||||
|         message: 'We should not see the default planes', | ||||
|         message: 'We no longer the default planes', | ||||
|       }).toBeTruthy() | ||||
|     }) | ||||
|  | ||||
| @ -614,38 +598,6 @@ extrude001 = extrude(50, sketch001) | ||||
|       await expect(gizmo).toBeVisible() | ||||
|     }) | ||||
|   }) | ||||
|  | ||||
|   test(`Refreshing the app doesn't cause the stream to pause on long-executing files`, async ({ | ||||
|     context, | ||||
|     homePage, | ||||
|     scene, | ||||
|     toolbar, | ||||
|     viewport, | ||||
|   }) => { | ||||
|     await context.folderSetupFn(async (dir) => { | ||||
|       const legoDir = path.join(dir, 'lego') | ||||
|       await fsp.mkdir(legoDir, { recursive: true }) | ||||
|       await fsp.copyFile( | ||||
|         executorInputPath('lego.kcl'), | ||||
|         path.join(legoDir, 'main.kcl') | ||||
|       ) | ||||
|     }) | ||||
|  | ||||
|     await test.step(`Test setup`, async () => { | ||||
|       await homePage.openProject('lego') | ||||
|       await toolbar.closePane('code') | ||||
|     }) | ||||
|     await test.step(`Waiting for the loading spinner to disappear`, async () => { | ||||
|       await scene.loadingIndicator.waitFor({ state: 'detached' }) | ||||
|     }) | ||||
|     await test.step(`The part should start loading quickly, not waiting until execution is complete`, async () => { | ||||
|       await scene.expectPixelColor( | ||||
|         [143, 143, 143], | ||||
|         { x: (viewport?.width ?? 1200) / 2, y: (viewport?.height ?? 500) / 2 }, | ||||
|         15 | ||||
|       ) | ||||
|     }) | ||||
|   }) | ||||
| }) | ||||
|  | ||||
| async function clickExportButton(page: Page) { | ||||
|  | ||||
| @ -47,11 +47,7 @@ test.beforeEach(async ({ page }) => { | ||||
|  | ||||
| test.setTimeout(60_000) | ||||
|  | ||||
| // We test this end to end already - getting this to work on web just to take | ||||
| // a snapshot of it feels weird. I'd rather our regular tests fail. | ||||
| // The primary failure is doExport now relies on the filesystem. We can follow | ||||
| // up with another PR if we want this back. | ||||
| test.skip( | ||||
| test( | ||||
|   'exports of each format should work', | ||||
|   { tag: ['@snapshot', '@skipWin', '@skipMacos'] }, | ||||
|   async ({ page, context }) => { | ||||
| @ -375,7 +371,6 @@ const extrudeDefaultPlane = async (context: any, page: any, plane: string) => { | ||||
|   await u.closeKclCodePanel() | ||||
|   await expect(page).toHaveScreenshot({ | ||||
|     maxDiffPixels: 100, | ||||
|     mask: [page.getByTestId('model-state-indicator')], | ||||
|   }) | ||||
|   await u.openKclCodePanel() | ||||
| } | ||||
| @ -451,8 +446,7 @@ test( | ||||
|  | ||||
|     const startXPx = 600 | ||||
|     await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10) | ||||
|     code += ` | ||||
|   |> startProfileAt([7.19, -9.7], %)` | ||||
|     code += `profile001 = startProfileAt([7.19, -9.7], sketch001)` | ||||
|     await expect(page.locator('.cm-content')).toHaveText(code) | ||||
|     await page.waitForTimeout(100) | ||||
|  | ||||
| @ -474,6 +468,10 @@ test( | ||||
|       .getByRole('button', { name: 'arc Tangential Arc', exact: true }) | ||||
|       .click() | ||||
|  | ||||
|     // click to continue profile | ||||
|     await page.mouse.move(813, 392, { steps: 10 }) | ||||
|     await page.waitForTimeout(100) | ||||
|  | ||||
|     await page.mouse.move(startXPx + PUR * 30, 500 - PUR * 20, { steps: 10 }) | ||||
|  | ||||
|     await page.waitForTimeout(1000) | ||||
| @ -596,8 +594,7 @@ test( | ||||
|       mask: [page.getByTestId('model-state-indicator')], | ||||
|     }) | ||||
|     await expect(page.locator('.cm-content')).toHaveText( | ||||
|       `sketch001 = startSketchOn('XZ') | ||||
|   |> circle({ center = [14.44, -2.44], radius = 1 }, %)` | ||||
|       `sketch001 = startSketchOn('XZ')profile001 = circle({ center = [14.44, -2.44], radius = 1 }, sketch001)` | ||||
|     ) | ||||
|   } | ||||
| ) | ||||
| @ -641,8 +638,7 @@ test.describe( | ||||
|  | ||||
|       const startXPx = 600 | ||||
|       await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10) | ||||
|       code += ` | ||||
|   |> startProfileAt([7.19, -9.7], %)` | ||||
|       code += `profile001 = startProfileAt([7.19, -9.7], sketch001)` | ||||
|       await expect(u.codeLocator).toHaveText(code) | ||||
|       await page.waitForTimeout(100) | ||||
|  | ||||
| @ -660,6 +656,10 @@ test.describe( | ||||
|         .click() | ||||
|       await page.waitForTimeout(100) | ||||
|  | ||||
|       // click to continue profile | ||||
|       await page.mouse.click(813, 392) | ||||
|       await page.waitForTimeout(100) | ||||
|  | ||||
|       await page.mouse.click(startXPx + PUR * 30, 500 - PUR * 20) | ||||
|  | ||||
|       code += ` | ||||
| @ -746,8 +746,7 @@ test.describe( | ||||
|  | ||||
|       const startXPx = 600 | ||||
|       await page.mouse.click(startXPx + PUR * 10, 500 - PUR * 10) | ||||
|       code += ` | ||||
|   |> startProfileAt([182.59, -246.32], %)` | ||||
|       code += `profile001 = startProfileAt([182.59, -246.32], sketch001)` | ||||
|       await expect(u.codeLocator).toHaveText(code) | ||||
|       await page.waitForTimeout(100) | ||||
|  | ||||
| @ -765,6 +764,10 @@ test.describe( | ||||
|         .click() | ||||
|       await page.waitForTimeout(100) | ||||
|  | ||||
|       // click to continue profile | ||||
|       await page.mouse.click(813, 392) | ||||
|       await page.waitForTimeout(100) | ||||
|  | ||||
|       await page.mouse.click(startXPx + PUR * 30, 500 - PUR * 20) | ||||
|  | ||||
|       code += ` | ||||
|  | ||||
| Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 53 KiB | 
| After Width: | Height: | Size: 50 KiB | 
| Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 50 KiB | 
| After Width: | Height: | Size: 47 KiB | 
| Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 58 KiB | 
| After Width: | Height: | Size: 55 KiB | 
| Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 52 KiB | 
| After Width: | Height: | Size: 48 KiB | 
| Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB | 
| After Width: | Height: | Size: 45 KiB | 
| Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 45 KiB | 
| After Width: | Height: | Size: 41 KiB | 
| Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB | 
| After Width: | Height: | Size: 39 KiB | 
| Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 49 KiB | 
| After Width: | Height: | Size: 47 KiB | 
| Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 33 KiB | 
| After Width: | Height: | Size: 34 KiB | 
| Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 52 KiB | 
| Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 54 KiB | 
| Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 50 KiB | 
| After Width: | Height: | Size: 51 KiB | 
| Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB | 
| After Width: | Height: | Size: 65 KiB | 
| Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 49 KiB | 
| Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB | 
| Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 65 KiB | 
| After Width: | Height: | Size: 62 KiB | 
| Before Width: | Height: | Size: 144 KiB After Width: | Height: | Size: 144 KiB | 
| After Width: | Height: | Size: 130 KiB | 
