mirror of
https://github.com/lana-k/sqliteviz.git
synced 2026-11-04 00:39:24 +08:00
Compare commits
6
Commits
8cace0586a
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e3057908f | ||
|
|
381f33b9e2 | ||
|
|
a68f799fdf | ||
|
|
835a88cbbb | ||
|
|
a210e77f51 | ||
|
|
df6ba00f2b |
+1
-1
@@ -108,7 +108,7 @@ module.exports = function (config) {
|
|||||||
},
|
},
|
||||||
// start these browsers
|
// start these browsers
|
||||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||||
browsers: ['ChromiumHeadlessWebGL' /*, 'FirefoxHeadlessTouch'*/],
|
browsers: ['ChromiumHeadlessWebGL', 'FirefoxHeadlessTouch'],
|
||||||
|
|
||||||
// Continuous Integration mode
|
// Continuous Integration mode
|
||||||
// if true, Karma captures browsers, runs the tests and exits
|
// if true, Karma captures browsers, runs the tests and exits
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sqliteviz",
|
"name": "sqliteviz",
|
||||||
"version": "0.32.0",
|
"version": "0.32.1",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -10,4 +10,5 @@
|
|||||||
border-radius: var(--border-radius-medium);
|
border-radius: var(--border-radius-medium);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
:iconSize="20"
|
:iconSize="20"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div :class="['text-field-container', { disabled }]">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
@@ -24,6 +25,17 @@
|
|||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
@input="$emit('update:modelValue', $event.target.value)"
|
@input="$emit('update:modelValue', $event.target.value)"
|
||||||
/>
|
/>
|
||||||
|
<button
|
||||||
|
v-if="showClearButton"
|
||||||
|
type="button"
|
||||||
|
:disabled="disabled"
|
||||||
|
class="clear-btn"
|
||||||
|
@click="$emit('update:modelValue', '')"
|
||||||
|
>
|
||||||
|
<i class="myicon myicon-clear" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-show="errorMsg" class="text-field-error">{{ errorMsg }}</div>
|
<div v-show="errorMsg" class="text-field-error">{{ errorMsg }}</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -42,22 +54,40 @@ export default {
|
|||||||
width: String,
|
width: String,
|
||||||
hint: String,
|
hint: String,
|
||||||
maxHintWidth: { type: String, default: '149px' },
|
maxHintWidth: { type: String, default: '149px' },
|
||||||
disabled: Boolean
|
disabled: Boolean,
|
||||||
|
showClearButton: Boolean
|
||||||
},
|
},
|
||||||
emits: ['update:modelValue']
|
emits: ['update:modelValue']
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
input {
|
.text-field-container {
|
||||||
background: var(--color-white);
|
background: var(--color-white);
|
||||||
border: 1px solid var(--color-border);
|
border: 1px solid var(--color-border);
|
||||||
color: var(--color-text-base);
|
|
||||||
border-radius: var(--border-radius-medium-2);
|
border-radius: var(--border-radius-medium-2);
|
||||||
height: 36px;
|
height: 36px;
|
||||||
padding: 0 8px;
|
padding: 0 8px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-field-container.disabled {
|
||||||
|
background: var(--color-bg-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-field-container.error {
|
||||||
|
border-color: var(--color-text-error);
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
background: inherit;
|
||||||
|
border: none;
|
||||||
|
color: var(--color-text-base);
|
||||||
|
height: 100%;
|
||||||
|
padding: 0;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,15 +100,10 @@ input:focus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
input:disabled {
|
input:disabled {
|
||||||
background: var(--color-bg-light);
|
|
||||||
color: var(--color-text-light-2);
|
color: var(--color-text-light-2);
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
input.error {
|
|
||||||
border-color: var(--color-text-error);
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-field-label {
|
.text-field-label {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: var(--color-text-base);
|
color: var(--color-text-base);
|
||||||
@@ -121,4 +146,22 @@ input.error {
|
|||||||
padding: 6px;
|
padding: 6px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.clear-btn {
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
padding: 0;
|
||||||
|
height: 20px;
|
||||||
|
width: 20px;
|
||||||
|
color: var(--color-border);
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear-btn i {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear-btn:not(:disabled):hover {
|
||||||
|
color: var(--color-danger);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
width="250px"
|
width="250px"
|
||||||
placeholder="Search nodes..."
|
placeholder="Search nodes..."
|
||||||
:errorMsg="regExpIsValid ? '' : 'Invalid regular expression'"
|
:errorMsg="regExpIsValid ? '' : 'Invalid regular expression'"
|
||||||
|
showClearButton
|
||||||
class="query-input"
|
class="query-input"
|
||||||
@keydown.enter.prevent="search"
|
@keydown.enter.prevent="search"
|
||||||
@update:model-value="onSearchInput"
|
@update:model-value="onSearchInput"
|
||||||
@@ -199,6 +200,7 @@ export default {
|
|||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-color: var(--color-border-light);
|
border-color: var(--color-border-light);
|
||||||
border-radius: 0 0 0 4px;
|
border-radius: 0 0 0 4px;
|
||||||
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.graph-search-panel--search-controls {
|
.graph-search-panel--search-controls {
|
||||||
@@ -213,7 +215,7 @@ export default {
|
|||||||
.close-search-panel :deep(i) {
|
.close-search-panel :deep(i) {
|
||||||
transform: scaleX(-1);
|
transform: scaleX(-1);
|
||||||
}
|
}
|
||||||
.query-input :deep(input) {
|
.query-input :deep(.text-field-container) {
|
||||||
height: 26px;
|
height: 26px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -3,7 +3,8 @@ export default {
|
|||||||
return {
|
return {
|
||||||
tooltipStyle: {
|
tooltipStyle: {
|
||||||
visibility: 'hidden'
|
visibility: 'hidden'
|
||||||
}
|
},
|
||||||
|
showTooltipTimeout: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -13,6 +14,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showTooltip(e, tooltipPosition) {
|
showTooltip(e, tooltipPosition) {
|
||||||
|
this.showTooltipTimeout = setTimeout(() => {
|
||||||
const position = tooltipPosition
|
const position = tooltipPosition
|
||||||
? tooltipPosition.split('-')
|
? tooltipPosition.split('-')
|
||||||
: ['top', 'right']
|
: ['top', 'right']
|
||||||
@@ -32,8 +34,10 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.tooltipStyle.visibility = 'visible'
|
this.tooltipStyle.visibility = 'visible'
|
||||||
|
}, 500)
|
||||||
},
|
},
|
||||||
hideTooltip() {
|
hideTooltip() {
|
||||||
|
this.showTooltipTimeout && clearTimeout(this.showTooltipTimeout)
|
||||||
this.tooltipStyle.visibility = 'hidden'
|
this.tooltipStyle.visibility = 'hidden'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
import { expect } from 'chai'
|
||||||
|
import { mount } from '@vue/test-utils'
|
||||||
|
import TextField from '@/components/Common/TextField'
|
||||||
|
|
||||||
|
describe('TextField.vue', () => {
|
||||||
|
it('renders the model value, placeholder, and configured width', () => {
|
||||||
|
const wrapper = mount(TextField, {
|
||||||
|
props: {
|
||||||
|
modelValue: 'initial value',
|
||||||
|
placeholder: 'Enter a value',
|
||||||
|
width: '240px'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const input = wrapper.find('input')
|
||||||
|
|
||||||
|
expect(input.element.value).to.equal('initial value')
|
||||||
|
expect(input.attributes('placeholder')).to.equal('Enter a value')
|
||||||
|
expect(input.element.style.width).to.equal('240px')
|
||||||
|
expect(wrapper.find('.text-field-label').exists()).to.equal(false)
|
||||||
|
expect(wrapper.find('.clear-btn').exists()).to.equal(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('emits update:modelValue when the input changes', async () => {
|
||||||
|
const wrapper = mount(TextField, {
|
||||||
|
props: { modelValue: 'before' }
|
||||||
|
})
|
||||||
|
|
||||||
|
await wrapper.find('input').setValue('after')
|
||||||
|
|
||||||
|
expect(wrapper.emitted('update:modelValue')).to.eql([['after']])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('renders label and hint with the configured tooltip width', () => {
|
||||||
|
const wrapper = mount(TextField, {
|
||||||
|
props: {
|
||||||
|
label: 'Name',
|
||||||
|
hint: 'A helpful hint',
|
||||||
|
maxHintWidth: '200px'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(wrapper.find('.text-field-label').text()).to.include('Name')
|
||||||
|
expect(wrapper.find('.icon-tooltip').text()).to.equal('A helpful hint')
|
||||||
|
expect(wrapper.find('.icon-tooltip').element.style.maxWidth).to.equal(
|
||||||
|
'200px'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('shows the error message and applies error classes', () => {
|
||||||
|
const wrapper = mount(TextField, {
|
||||||
|
props: {
|
||||||
|
label: 'Name',
|
||||||
|
errorMsg: 'A value is required'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(wrapper.find('.text-field-label').classes()).to.include('error')
|
||||||
|
expect(wrapper.find('input').classes()).to.include('error')
|
||||||
|
expect(wrapper.find('.text-field-error').isVisible()).to.equal(true)
|
||||||
|
expect(wrapper.find('.text-field-error').text()).to.equal(
|
||||||
|
'A value is required'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('hides the error message when there is no error', () => {
|
||||||
|
const wrapper = mount(TextField)
|
||||||
|
|
||||||
|
expect(wrapper.find('.text-field-error').element.style.display).to.equal(
|
||||||
|
'none'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('emits an empty value when the clear button is clicked', async () => {
|
||||||
|
const wrapper = mount(TextField, {
|
||||||
|
props: { modelValue: 'to clear', showClearButton: true }
|
||||||
|
})
|
||||||
|
|
||||||
|
await wrapper.find('.clear-btn').trigger('click')
|
||||||
|
|
||||||
|
expect(wrapper.emitted('update:modelValue')).to.eql([['']])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('disables the input and clear button', () => {
|
||||||
|
const wrapper = mount(TextField, {
|
||||||
|
props: {
|
||||||
|
disabled: true,
|
||||||
|
label: 'Name',
|
||||||
|
showClearButton: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(wrapper.find('input').element.disabled).to.equal(true)
|
||||||
|
expect(wrapper.find('.clear-btn').element.disabled).to.equal(true)
|
||||||
|
expect(wrapper.find('.text-field-container').classes()).to.include(
|
||||||
|
'disabled'
|
||||||
|
)
|
||||||
|
expect(wrapper.find('.text-field-label').classes()).to.include('disabled')
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import { mount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
import tooltipMixin from '@/tooltipMixin'
|
import tooltipMixin from '@/tooltipMixin'
|
||||||
|
import sinon from 'sinon'
|
||||||
|
|
||||||
describe('tooltipMixin.js', () => {
|
describe('tooltipMixin.js', () => {
|
||||||
let container
|
let container
|
||||||
@@ -23,6 +24,7 @@ describe('tooltipMixin.js', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('tooltipStyle is correct when showTooltip: top-right', async () => {
|
it('tooltipStyle is correct when showTooltip: top-right', async () => {
|
||||||
|
const clock = sinon.useFakeTimers()
|
||||||
const component = {
|
const component = {
|
||||||
template:
|
template:
|
||||||
'<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
'<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
||||||
@@ -38,15 +40,18 @@ describe('tooltipMixin.js', () => {
|
|||||||
clientY: 20
|
clientY: 20
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
await clock.tick(500)
|
||||||
expect(wrapper.vm.tooltipStyle).to.eql({
|
expect(wrapper.vm.tooltipStyle).to.eql({
|
||||||
visibility: 'visible',
|
visibility: 'visible',
|
||||||
top: '8px',
|
top: '8px',
|
||||||
left: '22px'
|
left: '22px'
|
||||||
})
|
})
|
||||||
expect(wrapper.find('div').isVisible()).to.equal(true)
|
expect(wrapper.find('div').isVisible()).to.equal(true)
|
||||||
|
clock.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('tooltipStyle is correct when showTooltip: top-left', async () => {
|
it('tooltipStyle is correct when showTooltip: top-left', async () => {
|
||||||
|
const clock = sinon.useFakeTimers()
|
||||||
const component = {
|
const component = {
|
||||||
template:
|
template:
|
||||||
'<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
'<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
||||||
@@ -61,6 +66,7 @@ describe('tooltipMixin.js', () => {
|
|||||||
}),
|
}),
|
||||||
'top-left'
|
'top-left'
|
||||||
)
|
)
|
||||||
|
await clock.tick(500)
|
||||||
|
|
||||||
expect(wrapper.vm.tooltipStyle).to.eql({
|
expect(wrapper.vm.tooltipStyle).to.eql({
|
||||||
visibility: 'visible',
|
visibility: 'visible',
|
||||||
@@ -69,9 +75,11 @@ describe('tooltipMixin.js', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(wrapper.find('div').isVisible()).to.equal(true)
|
expect(wrapper.find('div').isVisible()).to.equal(true)
|
||||||
|
clock.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('tooltipStyle is correct when showTooltip: bottom-right', async () => {
|
it('tooltipStyle is correct when showTooltip: bottom-right', async () => {
|
||||||
|
const clock = sinon.useFakeTimers()
|
||||||
const component = {
|
const component = {
|
||||||
template:
|
template:
|
||||||
'<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
'<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
||||||
@@ -86,15 +94,18 @@ describe('tooltipMixin.js', () => {
|
|||||||
}),
|
}),
|
||||||
'bottom-right'
|
'bottom-right'
|
||||||
)
|
)
|
||||||
|
await clock.tick(500)
|
||||||
expect(wrapper.vm.tooltipStyle).to.eql({
|
expect(wrapper.vm.tooltipStyle).to.eql({
|
||||||
visibility: 'visible',
|
visibility: 'visible',
|
||||||
top: '32px',
|
top: '32px',
|
||||||
left: '22px'
|
left: '22px'
|
||||||
})
|
})
|
||||||
expect(wrapper.find('div').isVisible()).to.equal(true)
|
expect(wrapper.find('div').isVisible()).to.equal(true)
|
||||||
|
clock.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('tooltipStyle is correct when showTooltip: bottom-left', async () => {
|
it('tooltipStyle is correct when showTooltip: bottom-left', async () => {
|
||||||
|
const clock = sinon.useFakeTimers()
|
||||||
const component = {
|
const component = {
|
||||||
template:
|
template:
|
||||||
'<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
'<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
||||||
@@ -109,6 +120,7 @@ describe('tooltipMixin.js', () => {
|
|||||||
}),
|
}),
|
||||||
'bottom-left'
|
'bottom-left'
|
||||||
)
|
)
|
||||||
|
await clock.tick(500)
|
||||||
|
|
||||||
expect(wrapper.vm.tooltipStyle).to.eql({
|
expect(wrapper.vm.tooltipStyle).to.eql({
|
||||||
visibility: 'visible',
|
visibility: 'visible',
|
||||||
@@ -116,9 +128,11 @@ describe('tooltipMixin.js', () => {
|
|||||||
left: '100px'
|
left: '100px'
|
||||||
})
|
})
|
||||||
expect(wrapper.find('div').isVisible()).to.equal(true)
|
expect(wrapper.find('div').isVisible()).to.equal(true)
|
||||||
|
clock.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('tooltip is not visible after hideTooltip', async () => {
|
it('tooltip is not visible after hideTooltip', async () => {
|
||||||
|
const clock = sinon.useFakeTimers()
|
||||||
const component = {
|
const component = {
|
||||||
template: '<div :style="tooltipStyle"></div>',
|
template: '<div :style="tooltipStyle"></div>',
|
||||||
mixins: [tooltipMixin]
|
mixins: [tooltipMixin]
|
||||||
@@ -131,6 +145,8 @@ describe('tooltipMixin.js', () => {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
await wrapper.vm.hideTooltip()
|
await wrapper.vm.hideTooltip()
|
||||||
|
await clock.tick(500)
|
||||||
expect(wrapper.find('div').isVisible()).to.equal(false)
|
expect(wrapper.find('div').isVisible()).to.equal(false)
|
||||||
|
clock.restore()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user