Skip to content
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

feat(ui): add summary #493

Merged
merged 44 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e28ae6e
feat: ui summary
userquin Jan 9, 2022
7babb57
Merge branch 'main' into userquin/feat-ui-summary
userquin Jan 9, 2022
3cb7181
feat(ui): add summary
userquin Jan 9, 2022
070ab38
Merge branch 'main' into userquin/feat-ui-summary
userquin Jan 9, 2022
593b902
chore: include running + adjust colors
userquin Jan 9, 2022
7a3e47f
chore: use v-show for graph (save state)
userquin Jan 9, 2022
ca0a1a8
fix: initial file on F5
userquin Jan 9, 2022
3aee56e
chore: add tests entry to summary
userquin Jan 9, 2022
a707146
chore: update skipped test color legend
userquin Jan 9, 2022
111ea57
chore: revert current module handling
userquin Jan 9, 2022
41d8847
chore: progress bars width changes, update logic
userquin Jan 9, 2022
0f607b7
chore: add border top to global progress bars
userquin Jan 9, 2022
d284f20
chore: update requested changes
userquin Jan 9, 2022
291351c
chore: add global time
userquin Jan 9, 2022
289dc94
chore: use total instead unref
userquin Jan 9, 2022
e2029cc
chore: use tests instead files for time
userquin Jan 9, 2022
ab39493
chore: `currentModule` was reverted
userquin Jan 9, 2022
e48bffe
chore: add navigation logic again
userquin Jan 11, 2022
b23cc2d
Merge remote-tracking branch 'origin/userquin/feat-ui-summary' into u…
userquin Jan 11, 2022
103583a
chore: adjust debounce logic
userquin Jan 11, 2022
d9f3677
chore: fix split panes layout
userquin Jan 11, 2022
3dd68ea
cleanup: remove split ref
userquin Jan 11, 2022
9b85406
chore: initialize nav and suite width equals
userquin Jan 11, 2022
0b86602
chore: make search input grow
userquin Jan 11, 2022
2fd8aa3
chore: adjust suite pane % to match nav width
userquin Jan 11, 2022
57f53df
chore: add summary icon
userquin Jan 11, 2022
112faf9
chore: add summary icon animations
userquin Jan 11, 2022
c7d9512
chore: center summary content
userquin Jan 11, 2022
a7e7f4d
chore: fix scrolls on suite panel
userquin Jan 11, 2022
4594f20
Merge branch 'main' into userquin/feat-ui-summary
antfu Jan 11, 2022
c09c678
chore: buttons title + report summary
userquin Jan 11, 2022
ab4eece
Merge remote-tracking branch 'origin/userquin/feat-ui-summary' into u…
userquin Jan 11, 2022
beb439d
chore: replace inject/provide with globals
userquin Jan 11, 2022
5e33ff8
chore: change summary with dashboard
userquin Jan 11, 2022
d475161
chore: update dashboard
userquin Jan 11, 2022
d984f55
chore: update files and tests sizes, paddings and gaps
userquin Jan 11, 2022
27bc979
chore: make progress bar always visible
userquin Jan 12, 2022
8878ea4
chore: update dark bg color on dashboard section
userquin Jan 12, 2022
e477e24
chore: fix summary dashboard layout
userquin Jan 12, 2022
59d092d
wip
antfu Jan 12, 2022
1574d01
Merge branch 'main' into userquin/feat-ui-summary
antfu Jan 12, 2022
1c59ca4
chore: update
antfu Jan 12, 2022
9cfe8b8
Merge branch 'main' into userquin/feat-ui-summary
antfu Jan 18, 2022
48c0cbd
chore: keep simple for now
antfu Jan 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/ui/client/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ declare module 'vue' {
Modal: typeof import('./components/Modal.vue')['default']
ModuleTransformResultView: typeof import('./components/ModuleTransformResultView.vue')['default']
Navigation: typeof import('./components/Navigation.vue')['default']
ProgressBar: typeof import('./components/ProgressBar.vue')['default']
ReportSummary: typeof import('./components/ReportSummary.vue')['default']
StatusIcon: typeof import('./components/StatusIcon.vue')['default']
Suites: typeof import('./components/Suites.vue')['default']
TaskItem: typeof import('./components/TaskItem.vue')['default']
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/client/components/FileDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getModuleGraph } from '~/composables/module-graph'
import type { ModuleGraphData } from '#types'

function open() {
const filePath = current.value?.filepath
const filePath = currentModule.value?.filepath
if (filePath)
fetch(`/__open-in-editor?file=${encodeURIComponent(filePath)}`)
}
Expand Down Expand Up @@ -56,7 +56,7 @@ const changeViewMode = (view: Params['view']) => {
</div>
</div>
<div flex flex-col flex-1 overflow="hidden">
<ViewModuleGraph v-if="viewMode === 'graph'" :graph="graph" class="file-details-graph" />
<ViewModuleGraph v-show="viewMode === 'graph'" :graph="graph" class="file-details-graph" />
<ViewEditor v-if="viewMode === 'editor'" :file="current" />
<ViewReport v-else-if="!viewMode" :file="current" />
</div>
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/client/components/Navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ function onItemClick(task: Task) {
/>
</div>
</template>
<template #footer>
<ReportSummary />
</template>
</TasksList>
</template>
96 changes: 96 additions & 0 deletions packages/ui/client/components/ProgressBar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<script setup lang="ts">
const props = defineProps<{ total: number; failed: number; pass: number; inProgress: boolean }>()
Copy link
Member

Choose a reason for hiding this comment

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

Why not destructure this props so you can just use the values directly inside template instead of props.value

Copy link
Member

Choose a reason for hiding this comment

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

total can be outside the computed i.e const total = unref(total) since it's been reused in multiple places

const widthPass = computed(() => {
const total = props.total
return total > 0 ? (350 * props.pass / total) : 0
})
const widthFailed = computed(() => {
const total = props.total
return total > 0 ? (350 * props.failed / total) : 0
})
const pending = computed(() => {
return props.total - props.failed - props.pass
})
const widthPending = computed(() => {
const total = props.total
return total > 0 ? (350 * pending.value / total) : 0
})
</script>

<template>
<div h-8 line-height-1 px-0 grid="~ auto-cols-max" justify-items-center>
<div h-1rem relative max-w-300px min-w-300px w-300px overflow-hidden class="px-0">
<div
absolute
left-0
top-0
h-full
line-height-1
text-right
bg-red5
:class="[{'in-progress': props.inProgress}]"
:style="`width: ${widthFailed}px;`"
>
<template v-if="!inProgress">
<div vertical-align-middle c-white text-xs m="y-0 x-5px" ws-nowrap>
{{ props.failed }}
</div>
</template>
</div>
<div
absolute
left-0
top-0
h-full
line-height-1
text-right
bg-green5
:class="[{'in-progress': props.inProgress}]"
:style="`left: ${widthFailed}px; width: ${widthPass}px;`"
>
<template v-if="!inProgress">
<div vertical-align-middle c-white text-xs m="y-0 x-5px" ws-nowrap>
{{ props.pass }}
</div>
</template>
</div>
<div
absolute
left-0
top-0
h-full
line-height-1
text-right
bg-yellow5
class="test-bg-pending"
:class="[{'in-progress': props.inProgress}]"
:style="`left: ${widthPass + widthFailed}px; width: ${widthPending}px;`"
>
<template v-if="!inProgress">
<div vertical-align-middle c-white font-size-12px m="y-0 x-5px" ws-nowrap>
&#160;
</div>
</template>
</div>
</div>
<div text-center text-xs>
<slot />
</div>
</div>
</template>

<style scoped>
.in-progress {
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
background-size: 40px 40px;
animation: in-progress-stripes 2s linear infinite;
}
@keyframes in-progress-stripes {
from {
background-position: 40px 0;
}
to {
background-position: 0 0;
}
}
</style>
56 changes: 56 additions & 0 deletions packages/ui/client/components/ReportSummary.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<script setup lang="ts">
import type { Task, Test } from 'vitest/src'
import { files, isConnected } from '~/composables/client'

const failed = computed(() => files.value.filter(f => f.result?.state === 'fail'))
const success = computed(() => files.value.filter(f => f.result?.state === 'pass'))
const ignore = computed(() => files.value.filter(f => f.mode === 'skip' || f.mode === 'todo'))
const running = computed(() => files.value.filter(f =>
!failed.value.includes(f)
&& !success.value.includes(f)
&& !ignore.value.includes(f),
))
const skipped = computed(() => ignore.value.filter(f => f.mode === 'skip'))
const todo = computed(() => ignore.value.filter(f => f.mode === 'todo'))
const finished = computed(() => {
return running.value.length === 0
})
type Nullable<T> = T | null | undefined
type Arrayable<T> = T | Array<T>
function toArray<T>(array?: Nullable<Arrayable<T>>): Array<T> {
array = array || []
if (Array.isArray(array))
return array
return [array]
}
function getTests(suite: Arrayable<Task>): Test[] {
return toArray(suite).flatMap(s => s.type === 'test' ? [s] : s.tasks.flatMap(c => c.type === 'test' ? [c] : getTests(c)))
}
const tests = computed(() => {
Copy link
Member

Choose a reason for hiding this comment

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

I think all this computed values should be before methods

return getTests(files.value)
})
const testsFailed = computed(() => {
return tests.value.filter(f => f.result?.state === 'fail')
})
const testsSuccess = computed(() => {
return tests.value.filter(f => f.result?.state === 'pass')
})
const testsIgnore = computed(() => tests.value.filter(f => f.mode === 'skip' || f.mode === 'todo'))
const testsSkipped = computed(() => testsIgnore.value.filter(f => f.mode === 'skip'))
const testsTodo = computed(() => testsIgnore.value.filter(f => f.mode === 'todo'))
const totalTests = computed(() => {
return testsFailed.value.length + testsSuccess.value.length
})
</script>

<template>
<div v-if="isConnected" flex="~ col" items-center justify-center gap-y-1 p-y-2>
<ProgressBar :total="files.length" :failed="failed.length" :pass="success.length" :in-progress="!finished">
Test Files <span text-red5>{{ failed.length }} failed</span> | <span text-green5>{{ success.length }} passed</span> | <span text-yellow5>{{ running.length }} running</span> <span c-gray op-75>({{ files.length }})</span>
</ProgressBar>
<ProgressBar :total="totalTests" :failed="testsFailed.length" :pass="testsSuccess.length" :in-progress="!finished">
Tests <span text-red5>{{ testsFailed.length }} failed</span> | <span text-green5>{{ testsSuccess.length }} passed</span> | <span text-yellow5>{{ testsSkipped.length }} skipped</span> | <span c-gray op-75>{{ testsTodo.length }} todo</span> <span c-gray op-75>({{ tests.length }})</span>
</ProgressBar>
<div>Time: </div>
</div>
</template>
3 changes: 3 additions & 0 deletions packages/ui/client/components/TasksList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,8 @@ export default {
/>
</template>
</div>
<footer v-if="$slots.footer">
<slot name="footer" />
</footer>
</div>
</template>
3 changes: 1 addition & 2 deletions packages/ui/client/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ function onResize(event: { size: number }[]) {
sizes[i] = e.size
})
}

onMounted(() => {
const width = window.innerWidth
const panelWidth = Math.min(width / 3, 300)
const panelWidth = Math.min(width / 3, 316)
const panelPercent = panelWidth / width * 100
sizes[0] = panelPercent
sizes[1] = panelPercent
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/client/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ html.dark {
}

.splitpanes--vertical > .splitpanes__splitter:before {
left: -10px;
/* make vertical scroll usable */
/*left: -10px;*/
right: -10px;
height: 100%;
}
Expand Down Expand Up @@ -163,3 +164,4 @@ html.dark {
padding-bottom: unset !important;
}


17 changes: 17 additions & 0 deletions packages/vitest/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,23 @@ Repository: [email protected]:moxystudio/node-cross-spawn.git

---------------------------------------

## detect-indent
antfu marked this conversation as resolved.
Show resolved Hide resolved
License: MIT
By: Sindre Sorhus
Repository: sindresorhus/detect-indent

> MIT License
>
> Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---------------------------------------

## diff
License: BSD-3-Clause
Repository: git:https://github.com/kpdecker/jsdiff.git
Expand Down