Skip to content

Conversation

@zjy2414
Copy link

@zjy2414 zjy2414 commented Aug 24, 2025

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Test coverage improvements (mocks + cases for data binding and lifecycle hooks)

Background and solution

The generator lacked targeted tests and mock data for:

  • Data binding (including two-way binding) behaviors.
  • Lifecycle hooks execution and side effects.

This gap made it hard to detect regressions when adjusting the generator logic around bindings or hook handling.

What is the current behavior?

  • Insufficient test coverage around:
    • Binding resolution (especially two-way data binding).
    • Lifecycle hook execution order and outcomes.

What is the new behavior?

  • Comprehensive tests for:
    • Data binding (one-way and two-way), ensuring bindings are generated and updated correctly.
    • Lifecycle hooks, validating correct hook invocation and expected results.
  • New mock data to support the above scenarios.

Does this PR introduce a breaking change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Added a Lifecycle page with auto-refreshing metrics and manual refresh.
    • Introduced element selection handling on the Canvas Row/Col page.
  • Improvements

    • Create VM form now uses consistent two-way bindings with centralized state; refined placeholders and label widths for better usability.
  • Routing

    • New /lifecycle route added to the app navigation.
  • Dependency Updates

    • Upgraded UI components to @opentiny/vue 3.24.0 (and icons).
    • Added TinyCard (Card) component support.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 24, 2025

Walkthrough

Adds comprehensive test suites and mock schemas for data binding and lifecycle generation in the Vue generator. Updates expected app artifacts: new LifeCyclePage, router entry, component/version bumps, and refactors to views to use nested reactive state with v-model. Extends generator mock data with new pages, state, methods, and lifecycle definitions.

Changes

Cohort / File(s) Summary
Data Binding Tests
packages/vue-generator/test/testcases/data-binding/basic.test.js, .../advanced.test.js, .../edge-case.test.js, .../form.test.js
New Vitest suites validating basic, advanced, edge, and complex-form data-binding generation, nested reactive state, component presence, and v-model counts; writes generated .vue files to result directories.
Data Binding Mock Schemas
packages/vue-generator/test/testcases/data-binding/mockData.js
Adds four exported schemas: basic, advanced, edge-case, and complex-form with componentsMap, pageSchema, JSExpression bindings to state.*, and initial reactive state.
Lifecycle Tests
packages/vue-generator/test/testcases/lifecycle/lifecycle.test.js
New tests asserting lifecycle hook generation (mounted/unmounted/updated/beforeMount, errors captured), absence of prop-based lifecycle bindings, and content checks for generated pages.
Lifecycle Mock Schemas
packages/vue-generator/test/testcases/lifecycle/mockData.js
Adds three exported schemas: basic, complex, and mixed lifecycle cases, including state, methods, and lifeCycles using JSFunction/JSExpression.
Generator Expected App: New Page & Router
packages/vue-generator/test/testcases/generator/expected/appdemo01/src/views/LifeCyclePage.vue, .../src/router/index.js
Introduces LifeCyclePage.vue with reactive metrics, interval-driven auto-refresh, visibility handling, and full lifecycle hooks; registers new route lifecycle.
Generator Expected App: View Refactors
.../src/views/createVm.vue, .../src/views/testCanvasRowCol.vue
Migrates to nested reactive state with v-model across many controls; adds TinyButton import. Updates canvas page state shape and adds handleElementClick method exposed via wrap.
Generator Mock Data & Component Map
packages/vue-generator/test/testcases/generator/mockData.js
Expands app schema: adds LifeCyclePage definition, augments page states (formData/inputValues/selectValues), introduces canvas state/method, and updates componentsMap (version bumps, adds TinyCard/Card, PortalPermissionBlock, TinyButton).
Dependency Versions
.../generator/expected/appdemo01/package.json
Bumps @opentiny/vue and @opentiny/vue-icon to 3.24.0.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Page as LifeCyclePage.vue
  participant Vue as Vue Lifecycle
  participant Doc as Document Visibility
  participant Timer as setInterval(30s)

  Vue->>Page: onBeforeMount()
  Vue->>Page: onMounted()
  Page->>Page: refreshData()
  Page->>Page: startAutoRefresh()
  Page->>Timer: start interval
  Doc-->>Page: visibilitychange (hidden)
  Page->>Page: stopAutoRefresh()
  Page->>Timer: clear interval
  Doc-->>Page: visibilitychange (visible)
  Page->>Page: startAutoRefresh()
  Page->>Timer: restart interval
  User->>Page: Click "Refresh Data"
  Page->>Page: refreshData()
  Vue->>Page: onUpdated() [state changed]
  Vue->>Page: onDeactivated()/onActivated() [keep-alive]
  Vue->>Page: onUnmounted() / onBeforeUnmount()
  Page->>Timer: clear interval
Loading
sequenceDiagram
  autonumber
  participant Tests as Vitest Suites
  participant Gen as generateApp()
  participant Schemas as Mock Schemas
  participant Files as Generated .vue

  Tests->>Schemas: load schema (basic/advanced/edge/complex/lifecycle)
  Tests->>Gen: generateApp(schema)
  Gen-->>Files: emit .vue files
  Tests->>Files: read *.vue
  Tests-->>Tests: assert v-models, state structure, hooks, imports
  Tests->>Files: write to result/* (debug)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

I thump my paws, the builds take flight,
New lifecycles dance in morning light.
v-model vines entwine the form,
State nests cozy, safe and warm.
Routes hop in, components bloom—
Ship it quick, before the moon! 🌕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added ospp ospp test test of ut/e2e... labels Aug 24, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

🧹 Nitpick comments (28)
packages/vue-generator/test/testcases/generator/expected/appdemo01/src/views/testCanvasRowCol.vue (1)

49-54: Event handler correctly mutates nested reactive state; optional ergonomic tweak.

Current pattern with wrap(function handleElementClick...) and this.state... matches existing generator conventions—keep it. Optionally, if we later favor closure style over this, we could switch to an arrow fn using the captured state.

-const handleElementClick = wrap(function handleElementClick(elementId) {
-  this.state.uiState.selectedElement = elementId
-})
+const handleElementClick = wrap(function handleElementClick(elementId) {
+  // keep "this" style to align with current wrap semantics
+  this.state.uiState.selectedElement = elementId
+})
packages/vue-generator/test/testcases/generator/expected/appdemo01/src/views/createVm.vue (1)

58-58: Solid v-model migration to centralized nested state; add keys for v-for and minor UX polish.

  • The two-way bindings mapped into state.formData, state.inputValues, and state.selectValues look consistent and testable.
  • In the “数据盘” repeater, add a stable :key to avoid Vue warnings and improve patch efficiency. You can also iterate with (disk, idx) for clarity.
-          <div v-for="() in state.dataDisk" style="margin-top: 12px; display: flex">
+          <div v-for="(disk, idx) in state.dataDisk" :key="idx" style="margin-top: 12px; display: flex">
  • Import aliases ButtonGroup as TinyButtonGroup, Button as TinyButton align with the 3.24.0 API and the rest of this PR’s expected outputs—good.

Also applies to: 92-92, 105-105, 116-116, 124-126, 217-217, 226-226, 267-267, 273-277, 299-299, 305-309, 312-312, 351-355, 399-401, 416-433

packages/vue-generator/test/testcases/lifecycle/mockData.js (2)

16-18: Unify component version declarations with fixtures (optional).

Schemas still declare '^3.10.0' while the expected fixture pins 3.24.0. Aligning these to '^3.24.0' keeps version intent coherent across tests and reduces cognitive overhead.

-      version: '^3.10.0',
+      version: '^3.24.0',

Apply to all componentsMap entries in this file.

Also applies to: 89-91, 177-186


166-260: Great coverage: mixed lifecycle + data-binding schema. Add a test to exercise it.

mixedLifecycleSchema is a useful scenario (child prop-level lifecycle + binding). It isn’t currently exercised by tests; consider adding/adjusting a spec to validate its transformation (no prop-bound onMounted=, presence of script-level vue.onMounted, and emitted method calls like focusInput()).

I can provide a test diff (see lifecycle.test.js comment) to wire this in.

packages/vue-generator/test/testcases/generator/expected/appdemo01/src/views/LifeCyclePage.vue (2)

89-93: Fix onUpdated log to reference existing state

this.state.loginCount doesn’t exist; logs will show undefined. Prefer logging relevant metrics.

Apply this diff:

-vue.onUpdated(
-  wrap(function onUpdated() {
-    console.log('页面已更新', this.state.loginCount)
-  })
-)
+vue.onUpdated(
+  wrap(function onUpdated() {
+    console.log('页面已更新', {
+      activeUsers: this.state.activeUsers,
+      systemLoad: this.state.systemLoad
+    })
+  })
+)

18-21: Drop macro imports and unused destructure for leaner SFC

  • In <script setup>, defineProps/defineEmits are compile-time macros; importing them is unnecessary and can confuse tooling.
  • t is destructured but not used.

Apply this diff:

 import { Button as TinyButton, Card as TinyCard } from '@opentiny/vue'
 import * as vue from 'vue'
-import { defineProps, defineEmits } from 'vue'
 import { I18nInjectionKey } from 'vue-i18n'
@@
-const { t, lowcodeWrap, stores } = vue.inject(I18nInjectionKey).lowcode()
+const { lowcodeWrap, stores } = vue.inject(I18nInjectionKey).lowcode()

Also applies to: 26-26

packages/vue-generator/test/testcases/generator/mockData.js (3)

1087-1091: Consistent conversion to JSExpression + model for v-model sources

All updated bindings now point to the new nested paths (state.formData/, state.inputValues/, state.selectValues/*). This should produce correct v-model generation.

Small follow-up:

  • Ensure default values match component expectations (numbers vs strings) to avoid implicit coercion when two-way binding. If Tiny components expect string values, the current string defaults are fine.

Also applies to: 1140-1144, 1182-1186, 1220-1224, 1259-1264, 1470-1473, 1492-1496, 1576-1579, 1600-1603, 1661-1664, 1685-1688, 1706-1709, 1822-1825


1252-1252: UI nit: width increased to 120px

The label width bump is fine; consider checking adjacent labels for alignment to avoid misaligned baselines in tight layouts.


2539-2545: Verify component map versions for @opentiny/vue

Most entries are pinned to 3.24.0, while TinyCard uses ^3.10.0. That resolves to 3.24.0 and won’t conflict, but aligning versions can prevent duplicate installs in other contexts.

If you want to harmonize:

-      version: '^3.10.0',
+      version: '3.24.0',

Also applies to: 2611-2617

packages/vue-generator/test/testcases/data-binding/edge-case.test.js (2)

71-79: Gate debug artifact writes behind an env switch

Avoid polluting the repo during CI and local runs by making writes opt-in.

Apply this diff:

-    const outputDir = path.resolve(__dirname, './result/edge-case')
-    fs.mkdirSync(outputDir, { recursive: true })
-
-    for (const { fileName, fileContent } of genResult) {
-      if (fileName.endsWith('.vue')) {
-        fs.writeFileSync(path.join(outputDir, fileName), fileContent)
-      }
-    }
+    if (process.env.WRITE_GEN_FIXTURES === '1') {
+      const outputDir = path.resolve(__dirname, './result/edge-case')
+      fs.mkdirSync(outputDir, { recursive: true })
+      for (const { fileName, fileContent } of genResult) {
+        if (fileName.endsWith('.vue')) {
+          fs.writeFileSync(path.join(outputDir, fileName), fileContent)
+        }
+      }
+    }

1-6: Make __dirname robust for ESM runners

Vitest often runs tests as ESM; in that case __dirname may be undefined. Provide a fallback via import.meta.url.

If your repo uses "type": "module", apply:

 import { expect, test, describe } from 'vitest'
 import path from 'path'
 import fs from 'fs'
+import { fileURLToPath } from 'url'
@@
-    const outputDir = path.resolve(__dirname, './result/edge-case')
+    const __filename = typeof __filename !== 'undefined' ? __filename : fileURLToPath(import.meta.url)
+    const __dirnameSafe = typeof __dirname !== 'undefined' ? __dirname : path.dirname(__filename)
+    const outputDir = path.resolve(__dirnameSafe, './result/edge-case')

Alternatively, confirm you’re running in CJS; if so, you can skip this change.

Also applies to: 71-73

packages/vue-generator/test/testcases/data-binding/basic.test.js (2)

60-69: Tighten the v-model regex to avoid matching modifiers/arguments

Current /v-model[^=]*="..."/ may match v-model:foo or v-model.trim. If you intend only default bindings, restrict it.

Apply this diff:

-    const vModelMatches = content.match(/v-model[^=]*="[^"]+"/g) || []
+    const vModelMatches = content.match(/(?<!:)v-model="[^"]+"/g) || []

40-49: Gate debug artifact writes behind an env switch (consistency with other tests)

Prevents stray files in CI/local runs; keeps behavior consistent with edge-case test suggestion.

Apply this diff:

-    const outputDir = path.resolve(__dirname, './result/basic')
-    fs.mkdirSync(outputDir, { recursive: true })
-
-    for (const { fileName, fileContent } of genResult) {
-      if (fileName.endsWith('.vue')) {
-        fs.writeFileSync(path.join(outputDir, fileName), fileContent)
-      }
-    }
+    if (process.env.WRITE_GEN_FIXTURES === '1') {
+      const outputDir = path.resolve(__dirname, './result/basic')
+      fs.mkdirSync(outputDir, { recursive: true })
+      for (const { fileName, fileContent } of genResult) {
+        if (fileName.endsWith('.vue')) {
+          fs.writeFileSync(path.join(outputDir, fileName), fileContent)
+        }
+      }
+    }
packages/vue-generator/test/testcases/data-binding/mockData.js (3)

282-286: Avoid empty JSExpression for modelValue in edge-case

An empty JSExpression can lead to invalid v-model like v-model="" if the transformer doesn’t guard for it. Make the intent explicit: static empty value without data-binding.

-            modelValue: {
-              type: 'JSExpression',
-              value: '' // 空字段
-            }
+            // 静态空值,无数据绑定
+            modelValue: ''

Alternatively, if you want to keep JSExpression form while ensuring it won't become v-model:

-            modelValue: {
-              type: 'JSExpression',
-              value: ''
-            }
+            modelValue: {
+              type: 'JSExpression',
+              value: "''",
+              model: false
+            }

361-372: Confirm tag expectation: schema uses

, tests assert

The schema’s root is componentName: 'form', yet form.test.js asserts <div class="complex-form">. Unless the generator normalizes form to div, this will fail.

Prefer adjusting the test to accept either <form> or <div> with the same class. See suggested test change in form.test.js comment.

If you intended a <div>, switch componentName to 'div' here to match the test.


11-26: Deduplicate componentsMap declarations

The component entries (package, version, destructuring) are repeated across schemas. Centralizing them reduces drift when versions change.

Consider exporting shared factories, e.g.,

  • makeTinyInput(), makeTinySelect(), makeTinyCheckbox(), makeTinySwitch(), makeTinyRadio()
  • or a const base = { package: '@opentiny/vue', version: '^3.10.0', destructuring: true }

Then spread and override componentName/exportName per schema.

Also applies to: 97-126, 336-358

packages/vue-generator/test/testcases/data-binding/advanced.test.js (4)

52-54: Harden file lookup and guard against undefined

Use endsWith to avoid path prefix mismatches and assert existence before dereferencing.

-    const vueFile = genResult.find((file) => file.fileName === 'AdvancedFormPage.vue')
-    const content = vueFile.fileContent
+    const vueFile = genResult.find((file) => file.fileName?.endsWith('AdvancedFormPage.vue'))
+    expect(vueFile).toBeDefined()
+    const content = vueFile.fileContent

74-76: Repeat the guard for subsequent tests

Avoid potential Cannot read properties of undefined if generation shape changes.

-    const vueFile = genResult.find((file) => file.fileName === 'AdvancedFormPage.vue')
-    const content = vueFile.fileContent
+    const vueFile = genResult.find((file) => file.fileName?.endsWith('AdvancedFormPage.vue'))
+    expect(vueFile).toBeDefined()
+    const content = vueFile.fileContent

92-94: Repeat the guard for the radio group test

Same robustness improvement as above.

-    const vueFile = genResult.find((file) => file.fileName === 'AdvancedFormPage.vue')
-    const content = vueFile.fileContent
+    const vueFile = genResult.find((file) => file.fileName?.endsWith('AdvancedFormPage.vue'))
+    expect(vueFile).toBeDefined()
+    const content = vueFile.fileContent

47-67: Optional: generate once per suite to speed up tests

You regenerate for each test. Caching genResult in beforeAll reduces runtime and IO. Keep a test that ensures idempotency if needed.

I can provide a consolidated pattern if you’d like.

packages/vue-generator/test/testcases/data-binding/form.test.js (8)

50-52: Harden file lookup and guard against undefined (test 2)

Consistent with advanced tests: avoid brittle equality and assert existence.

-    const vueFile = genResult.find((file) => file.fileName === 'ComplexFormPage.vue')
+    const vueFile = genResult.find((file) => file.fileName?.endsWith('ComplexFormPage.vue'))
+    expect(vueFile).toBeDefined()
     const content = vueFile.fileContent

68-70: Harden file lookup and guard against undefined (test 3)

-    const vueFile = genResult.find((file) => file.fileName === 'ComplexFormPage.vue')
+    const vueFile = genResult.find((file) => file.fileName?.endsWith('ComplexFormPage.vue'))
+    expect(vueFile).toBeDefined()
     const content = vueFile.fileContent

85-87: Harden file lookup and guard against undefined (test 4)

-    const vueFile = genResult.find((file) => file.fileName === 'ComplexFormPage.vue')
+    const vueFile = genResult.find((file) => file.fileName?.endsWith('ComplexFormPage.vue'))
+    expect(vueFile).toBeDefined()
     const content = vueFile.fileContent

102-104: Harden file lookup and guard against undefined (test 5)

-    const vueFile = genResult.find((file) => file.fileName === 'ComplexFormPage.vue')
+    const vueFile = genResult.find((file) => file.fileName?.endsWith('ComplexFormPage.vue'))
+    expect(vueFile).toBeDefined()
     const content = vueFile.fileContent

129-131: Harden file lookup and guard against undefined (test 6)

-    const vueFile = genResult.find((file) => file.fileName === 'ComplexFormPage.vue')
+    const vueFile = genResult.find((file) => file.fileName?.endsWith('ComplexFormPage.vue'))
+    expect(vueFile).toBeDefined()
     const content = vueFile.fileContent

133-135: Relax import assertion to tolerate formatting

Use a regex for spacing/line-break variations in the import list.

-    expect(content).toContain(
-      "import { Input as TinyInput, Select as TinySelect, Checkbox as TinyCheckbox } from '@opentiny/vue'"
-    )
+    const importRegex =
+      /import\s*{\s*Input\s+as\s+TinyInput\s*,\s*Select\s+as\s+TinySelect\s*,\s*Checkbox\s+as\s+TinyCheckbox\s*}\s*from\s*['"]@opentiny\/vue['"]/
+    expect(content).toMatch(importRegex)

113-121: Optional: gate artifact export behind an env flag

Writing files during tests can slow CI and create noisy artifacts locally. Make it opt-in.

-    // 写入测试结果
-    const outputDir = path.resolve(__dirname, './result/complex-form')
-    fs.mkdirSync(outputDir, { recursive: true })
-
-    for (const { fileName, fileContent } of genResult) {
-      if (fileName.endsWith('.vue')) {
-        fs.writeFileSync(path.join(outputDir, fileName), fileContent)
-      }
-    }
+    // 写入测试结果(可选:设置 EXPORT_GEN=1 启用)
+    if (process.env.EXPORT_GEN) {
+      const outputDir = path.resolve(__dirname, './result/complex-form')
+      fs.mkdirSync(outputDir, { recursive: true })
+      for (const { fileName, fileContent } of genResult) {
+        if (fileName.endsWith('.vue')) {
+          fs.writeFileSync(path.join(outputDir, fileName), fileContent)
+        }
+      }
+    }

7-12: Generate once per suite to reduce overhead

You can move generateApp() + generate(schema) to beforeAll and share genResult across tests; current repeated generation is unnecessary here.

I can provide a refactor sketch if you want to proceed.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 108919d and c671dd9.

📒 Files selected for processing (13)
  • packages/vue-generator/test/testcases/data-binding/advanced.test.js (1 hunks)
  • packages/vue-generator/test/testcases/data-binding/basic.test.js (1 hunks)
  • packages/vue-generator/test/testcases/data-binding/edge-case.test.js (1 hunks)
  • packages/vue-generator/test/testcases/data-binding/form.test.js (1 hunks)
  • packages/vue-generator/test/testcases/data-binding/mockData.js (1 hunks)
  • packages/vue-generator/test/testcases/generator/expected/appdemo01/package.json (1 hunks)
  • packages/vue-generator/test/testcases/generator/expected/appdemo01/src/router/index.js (1 hunks)
  • packages/vue-generator/test/testcases/generator/expected/appdemo01/src/views/LifeCyclePage.vue (1 hunks)
  • packages/vue-generator/test/testcases/generator/expected/appdemo01/src/views/createVm.vue (10 hunks)
  • packages/vue-generator/test/testcases/generator/expected/appdemo01/src/views/testCanvasRowCol.vue (1 hunks)
  • packages/vue-generator/test/testcases/generator/mockData.js (23 hunks)
  • packages/vue-generator/test/testcases/lifecycle/lifecycle.test.js (1 hunks)
  • packages/vue-generator/test/testcases/lifecycle/mockData.js (1 hunks)
🧰 Additional context used
🧠 Learnings (6)
📚 Learning: 2024-09-30T07:51:10.036Z
Learnt from: chilingling
PR: opentiny/tiny-engine#837
File: packages/vue-generator/src/plugins/genDependenciesPlugin.js:66-66
Timestamp: 2024-09-30T07:51:10.036Z
Learning: In the `tiny-engine` project, `opentiny/tiny-engine-dsl-vue` refers to the current package itself, and importing types from it may cause circular dependencies.

Applied to files:

  • packages/vue-generator/test/testcases/generator/expected/appdemo01/package.json
  • packages/vue-generator/test/testcases/generator/mockData.js
📚 Learning: 2025-01-14T06:49:00.797Z
Learnt from: gene9831
PR: opentiny/tiny-engine#1011
File: packages/configurator/src/router-select-configurator/RouterSelectConfigurator.vue:63-73
Timestamp: 2025-01-14T06:49:00.797Z
Learning: In the tiny-engine project, the SvgIcon component is globally registered and available throughout Vue components without requiring explicit imports.

Applied to files:

  • packages/vue-generator/test/testcases/generator/expected/appdemo01/package.json
  • packages/vue-generator/test/testcases/generator/expected/appdemo01/src/views/createVm.vue
📚 Learning: 2025-01-14T11:09:32.013Z
Learnt from: rhlin
PR: opentiny/tiny-engine#1011
File: packages/vue-generator/src/plugins/genRouterPlugin.js:122-125
Timestamp: 2025-01-14T11:09:32.013Z
Learning: The router configuration in Vue Generator should maintain the current structure without a catch-all route for 404 handling or modification to the root path prefix, as these are not required at this time.

Applied to files:

  • packages/vue-generator/test/testcases/generator/expected/appdemo01/src/router/index.js
📚 Learning: 2025-02-17T12:11:22.718Z
Learnt from: gene9831
PR: opentiny/tiny-engine#1117
File: packages/canvas/container/src/components/CanvasViewerSwitcher.vue:96-117
Timestamp: 2025-02-17T12:11:22.718Z
Learning: In CanvasViewerSwitcher.vue, `state.usedHoverState.element` is guaranteed to have a value when `handleClick` is called, making additional error handling unnecessary.

Applied to files:

  • packages/vue-generator/test/testcases/generator/expected/appdemo01/src/views/testCanvasRowCol.vue
📚 Learning: 2025-03-20T07:20:12.221Z
Learnt from: gene9831
PR: opentiny/tiny-engine#1233
File: packages/canvas/container/src/components/CanvasDivider.vue:184-185
Timestamp: 2025-03-20T07:20:12.221Z
Learning: In CanvasDivider.vue, even though state.verLeft and state.horizontalTop already include 'px' suffix, the CSS properties in state.dividerStyle still need to append 'px' again according to gene9831, suggesting that these state variables might be processed differently than expected when used in style binding.

Applied to files:

  • packages/vue-generator/test/testcases/generator/expected/appdemo01/src/views/testCanvasRowCol.vue
📚 Learning: 2025-01-14T06:55:59.692Z
Learnt from: gene9831
PR: opentiny/tiny-engine#1011
File: packages/configurator/src/router-select-configurator/RouterSelectConfigurator.vue:95-98
Timestamp: 2025-01-14T06:55:59.692Z
Learning: The tiny-select component from opentiny/vue library ensures selected options are valid internally, requiring no additional validation in the change handler.

Applied to files:

  • packages/vue-generator/test/testcases/generator/expected/appdemo01/src/views/createVm.vue
  • packages/vue-generator/test/testcases/generator/mockData.js
🧬 Code graph analysis (5)
packages/vue-generator/test/testcases/data-binding/advanced.test.js (2)
packages/vue-generator/src/generator/generateApp.js (1)
  • generateApp (23-82)
packages/vue-generator/test/testcases/data-binding/mockData.js (2)
  • advancedDataBindingSchema (92-247)
  • advancedDataBindingSchema (92-247)
packages/vue-generator/test/testcases/data-binding/basic.test.js (2)
packages/vue-generator/src/generator/generateApp.js (1)
  • generateApp (23-82)
packages/vue-generator/test/testcases/data-binding/mockData.js (2)
  • basicDataBindingSchema (6-89)
  • basicDataBindingSchema (6-89)
packages/vue-generator/test/testcases/lifecycle/lifecycle.test.js (2)
packages/vue-generator/src/generator/generateApp.js (1)
  • generateApp (23-82)
packages/vue-generator/test/testcases/lifecycle/mockData.js (4)
  • lifecycleTestSchema (6-76)
  • lifecycleTestSchema (6-76)
  • complexLifecycleSchema (79-164)
  • complexLifecycleSchema (79-164)
packages/vue-generator/test/testcases/data-binding/form.test.js (2)
packages/vue-generator/src/generator/generateApp.js (1)
  • generateApp (23-82)
packages/vue-generator/test/testcases/data-binding/mockData.js (2)
  • complexFormDataBindingSchema (331-451)
  • complexFormDataBindingSchema (331-451)
packages/vue-generator/test/testcases/data-binding/edge-case.test.js (2)
packages/vue-generator/src/generator/generateApp.js (1)
  • generateApp (23-82)
packages/vue-generator/test/testcases/data-binding/mockData.js (2)
  • edgeCaseDataBindingSchema (250-328)
  • edgeCaseDataBindingSchema (250-328)
🔇 Additional comments (5)
packages/vue-generator/test/testcases/generator/expected/appdemo01/src/views/testCanvasRowCol.vue (1)

43-46: Nested reactive state shape is clear and future-proof.

The canvasConfig and uiState split makes downstream bindings straightforward. Initializing selectedElement as null is appropriate for tri-state logic (unset vs. selected).

packages/vue-generator/test/testcases/lifecycle/lifecycle.test.js (1)

63-65: This expectation assumes an error identifier is present; ensure schema fix or relax assertion.

Once mockData.js is fixed to declare the error parameter, these assertions are fine. If not, consider loosening to only assert the hook registration and handler names.

-    expect(content).toContain('handleError(error)')
-    expect(content).toContain('reportError(error)')
+    expect(content).toMatch(/handleError\s*\(/)
+    expect(content).toMatch(/reportError\s*\(/)
packages/vue-generator/test/testcases/generator/expected/appdemo01/src/router/index.js (1)

31-36: Route wiring and component existence verified—Approved

The LifeCyclePage.vue component is present in packages/vue-generator/test/testcases/generator/expected/appdemo01/src/views, and its use of <script setup> is valid in Vue 3 (no export default required). The router entry in packages/vue-generator/test/testcases/generator/expected/appdemo01/src/router/index.js lines 31–36 correctly references this component by name, path, and import.

Files to confirm:

  • packages/vue-generator/test/testcases/generator/expected/appdemo01/src/router/index.js (lines 31–36)
  • packages/vue-generator/test/testcases/generator/expected/appdemo01/src/views/LifeCyclePage.vue

Route wiring for lifecycle page looks correct

  • Name/path/component align with the new view and keep the existing router shape (no catch-all, no root prefix changes), consistent with project learnings.
packages/vue-generator/test/testcases/generator/mockData.js (1)

911-941: Good shift to centralized, nested reactive state for bindings

Using formData/inputValues/selectValues clarifies ownership of fields and simplifies v-model wiring in generated pages.

packages/vue-generator/test/testcases/data-binding/advanced.test.js (1)

48-60: Alias '@' Mapping Verified
The resolve.alias block in packages/vue-generator/vite.config.js already maps '@' to ./src (lines 24–28), ensuring imports like @/generator/generateApp resolve correctly in Vitest. No further changes are needed.

@hexqi hexqi merged commit 47580f1 into opentiny:ospp-2025/source-to-dsl Oct 30, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ospp ospp test test of ut/e2e...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants