-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP]:feat(numeric): [numeric] add props of numeric #2546
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,31 @@ | ||
<template> | ||
<tiny-numeric v-model="value" :step="step"></tiny-numeric> | ||
<div class="m-layout"> | ||
<div class="m-b10"> | ||
<div class="m-b10">1、step-restore 用法</div> | ||
<tiny-numeric v-model="value" :step="step" step-restore></tiny-numeric> | ||
</div> | ||
<div> | ||
<div class="m-b10">2、step-strictly 用法</div> | ||
<tiny-numeric v-model="valueStep" :step="step" step-strictly></tiny-numeric> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import { TinyNumeric } from '@opentiny/vue' | ||
|
||
const value = ref(0) | ||
const step = ref(2) | ||
const step = ref(5) | ||
const valueStep = ref(0) | ||
</script> | ||
|
||
<style scoped> | ||
.m-layout { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
.m-b10 { | ||
margin-bottom: 10px; | ||
} | ||
</style> | ||
Comment on lines
1
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Documentation and test coverage needed for step features The verification reveals that:
Action items:
🔗 Analysis chainVerify documentation and test coverage While this example demonstrates the new 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check for presence of test files and documentation
echo "Checking for test coverage..."
fd "numeric.*spec" --type f
echo "Checking for documentation..."
fd "numeric.*md" --type f
Length of output: 622 Script: #!/bin/bash
# Check if step-restore and step-strictly features are documented
echo "Checking documentation content for step features..."
rg -i "step-restore|step-strictly" examples/sites/demos/pc/app/numeric/webdoc/numeric.*.md
echo "Checking test coverage for step features..."
rg -i "step-restore|step-strictly" examples/sites/demos/pc/app/numeric/numeric-size.spec.ts
Length of output: 454 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,23 @@ test('步长', async ({ page }) => { | |
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('numeric#about-step') | ||
|
||
const input = page.getByRole('spinbutton') | ||
const increaseBtn = page.locator('.tiny-numeric__increase') | ||
const decreaseBtn = page.locator('.tiny-numeric__decrease') | ||
const value = Number(await input.inputValue()) | ||
const step = 2 | ||
await decreaseBtn.click() | ||
const decreasedVal = Number(await input.inputValue()) | ||
expect(value).toEqual(decreasedVal + step) | ||
await increaseBtn.click() | ||
const increasedVal = Number(await input.inputValue()) | ||
expect(decreasedVal).toEqual(increasedVal - step) | ||
await page.getByRole('button').nth(1).click() | ||
await page.getByRole('spinbutton').first().fill('56') | ||
await page | ||
.locator('div') | ||
.filter({ hasText: /step-restore/ }) | ||
.first() | ||
.click() | ||
const inputValue = await page.locator('.tiny-numeric__input-inner').first().inputValue() | ||
expect(inputValue).toEqual('5') | ||
Comment on lines
+7
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance test clarity and coverage for step-restore feature The test implementation could be improved in several ways:
Consider refactoring like this: + // Test step-restore feature:
+ // When input value is not a multiple of step (step = 5),
+ // it should restore to the nearest valid value
await page.getByRole('button').nth(1).click()
await page.getByRole('spinbutton').first().fill('56')
await page
.locator('div')
.filter({ hasText: /step-restore/ })
.first()
.click()
- const inputValue = await page.locator('.tiny-numeric__input-inner').first().inputValue()
+ const inputValue = await page.getByTestId('numeric-input').first().inputValue()
expect(inputValue).toEqual('5')
+ // Add edge cases
+ await page.getByRole('spinbutton').first().fill('4.9')
+ await page.getByTestId('step-restore').click()
+ expect(await page.getByTestId('numeric-input').first().inputValue()).toEqual('5')
|
||
|
||
await page.getByRole('button').nth(3).click() | ||
await page.getByRole('spinbutton').nth(1).fill('56') | ||
await page | ||
.locator('div') | ||
.filter({ hasText: /step-strictly/ }) | ||
.first() | ||
.click() | ||
const input = await page.locator('.tiny-numeric__input-inner').nth(1).inputValue() | ||
expect(input).toEqual('55') | ||
Comment on lines
+17
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve test structure and coverage for step-strictly feature Similar to the previous test segment, this implementation needs improvements:
Consider refactoring like this: + // Test step-strictly feature:
+ // When input value is not a multiple of step (step = 5),
+ // it should round to the nearest multiple
+ const testStrictStep = async (input: string, expected: string) => {
+ await page.getByTestId('numeric-input').nth(1).fill(input)
+ await page.getByTestId('step-strictly').click()
+ expect(await page.getByTestId('numeric-input').nth(1).inputValue())
+ .toEqual(expected)
+ }
await page.getByRole('button').nth(3).click()
- await page.getByRole('spinbutton').nth(1).fill('56')
- await page
- .locator('div')
- .filter({ hasText: /step-strictly/ })
- .first()
- .click()
- const input = await page.locator('.tiny-numeric__input-inner').nth(1).inputValue()
- expect(input).toEqual('55')
+ await testStrictStep('56', '55') // Rounds down to nearest multiple of 5
+ await testStrictStep('53', '55') // Rounds up to nearest multiple of 5
+ await testStrictStep('50', '50') // Already a multiple of 5
|
||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
<template> | ||
<tiny-numeric v-model="value" :step="step"></tiny-numeric> | ||
<div class="m-layout"> | ||
<div class="m-b10"> | ||
<div class="m-b10">1、step-restore 用法</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Externalize UI text for internationalization The Chinese text should be moved to translation files to support internationalization. - <div class="m-b10">1、step-restore 用法</div>
+ <div class="m-b10">{{ t('numeric.stepRestore.title') }}</div> - <div class="m-b10">2、step-strictly 用法</div>
+ <div class="m-b10">{{ t('numeric.stepStrictly.title') }}</div> Also applies to: 8-8 |
||
<tiny-numeric v-model="value" :step="step" step-restore></tiny-numeric> | ||
</div> | ||
<div> | ||
<div class="m-b10">2、step-strictly 用法</div> | ||
<tiny-numeric v-model="valueStep" :step="step" step-strictly></tiny-numeric> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
|
@@ -12,8 +21,19 @@ export default { | |
data() { | ||
return { | ||
value: 0, | ||
step: 2 | ||
valueStep: 0, | ||
step: 5 | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.m-layout { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
.m-b10 { | ||
margin-bottom: 10px; | ||
} | ||
</style> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -35,8 +35,10 @@ export default { | |||||||||||||||||
'en-US': 'Step' | ||||||||||||||||||
}, | ||||||||||||||||||
desc: { | ||||||||||||||||||
'zh-CN': '可通过<code>step</code>属性设置计数器的加减数值。', | ||||||||||||||||||
'en-US': 'Set the addition and subtraction values of the counter through the<code>step</code>attribute.' | ||||||||||||||||||
'zh-CN': | ||||||||||||||||||
'可通过<code>step</code>属性设置计数器的加减数值,<code>step-restore</code>属性设置是否还原上一个值,<code>step-strictly</code>属性设置只能输入 step 的倍数', | ||||||||||||||||||
'en-US': | ||||||||||||||||||
'Set the addition and subtraction values of the counter through the<code>step</code>attribute,<code>step-restore</code>property setting whether to restore the previous value,<code>step restricted</code>The attribute setting can only input multiples of step' | ||||||||||||||||||
Comment on lines
+38
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve English translation and formatting The English description has several issues that should be addressed for better clarity and consistency: 'zh-CN':
'可通过<code>step</code>属性设置计数器的加减数值,<code>step-restore</code>属性设置是否还原上一个值,<code>step-strictly</code>属性设置只能输入 step 的倍数',
'en-US':
- 'Set the addition and subtraction values of the counter through the<code>step</code>attribute,<code>step-restore</code>property setting whether to restore the previous value,<code>step restricted</code>The attribute setting can only input multiples of step'
+ 'Set the increment/decrement value through the <code>step</code> attribute, use the <code>step-restore</code> attribute to control whether to restore the previous value, and the <code>step-strictly</code> attribute to restrict input to multiples of the step value' 📝 Committable suggestion
Suggested change
|
||||||||||||||||||
}, | ||||||||||||||||||
codeFiles: ['about-step.vue'] | ||||||||||||||||||
}, | ||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Replace hardcoded Chinese text with i18n keys
The demo labels should use internationalization for better maintainability and global accessibility.
Also applies to: 8-8