From ec5b6bb8ff236cb10cea850590bb7dea96cd8f69 Mon Sep 17 00:00:00 2001 From: Tonya Date: Mon, 28 Oct 2024 19:47:00 +0000 Subject: [PATCH] Get front end tests passing (#299) * chore: get front end tests passing * chore: add @vue/runtime-core to fix types for $t * chore: sort lockfile * Discard changes to frontend/pnpm-lock.yaml * chore: sort lockfile * chore: fix some type errors * chore: switch from nuxi typecheck to vue-tsc to force a known good version * chore: linting * chore: update pnpm version in frontend test * feat: add proper pagination type (need to sort why it still doesn't work) * chore: format imports and initialize totalPrice in label page to null when no label is present * chore: update pnpm to v9.12.2, merge ItemSummaryPaginationResult with PaginationResult, and handle error in label generator more gracefully * chore: lint --------- Co-authored-by: Matt Kilgore --- .github/workflows/partial-frontend.yaml | 4 +- frontend/assets/css/main.css | 58 ++++++++++++++++++++ frontend/components/Base/SectionHeader.vue | 1 - frontend/components/Form/Autocomplete2.vue | 15 +++-- frontend/components/Form/TextArea.vue | 13 ++--- frontend/components/Form/TextField.vue | 10 ++-- frontend/components/Item/Card.vue | 2 +- frontend/components/Item/CreateModal.vue | 8 ++- frontend/components/Item/View/Table.vue | 24 ++++---- frontend/components/Label/CreateModal.vue | 6 +- frontend/components/Location/CreateModal.vue | 8 ++- frontend/components/Location/Selector.vue | 8 ++- frontend/components/Location/Tree/Root.vue | 1 + frontend/components/Maintenance/ListView.vue | 10 ++-- frontend/components/global/Markdown.vue | 50 +---------------- frontend/composables/use-formatters.ts | 23 ++------ frontend/composables/use-preferences.ts | 2 +- frontend/layouts/default.vue | 18 +++--- frontend/lib/api/__test__/user/items.test.ts | 4 +- frontend/lib/api/classes/items.ts | 4 +- frontend/lib/api/types/non-generated.ts | 4 ++ frontend/package.json | 3 +- frontend/pages/item/[id]/index.vue | 11 +--- frontend/pages/item/[id]/index/edit.vue | 8 +-- frontend/pages/label/[id].vue | 18 ++++-- frontend/pages/location/[id].vue | 16 +++++- frontend/pages/profile.vue | 15 +++-- frontend/pages/reports/label-generator.vue | 11 +++- frontend/pages/tools.vue | 4 ++ frontend/pnpm-lock.yaml | 37 ++++++++++--- frontend/test/vitest.config.ts | 1 + 31 files changed, 237 insertions(+), 160 deletions(-) diff --git a/.github/workflows/partial-frontend.yaml b/.github/workflows/partial-frontend.yaml index f84940644..c793c62aa 100644 --- a/.github/workflows/partial-frontend.yaml +++ b/.github/workflows/partial-frontend.yaml @@ -15,7 +15,7 @@ jobs: - uses: pnpm/action-setup@v3.0.0 with: - version: 6.0.2 + version: 9.12.2 - name: Install dependencies run: pnpm install --shamefully-hoist @@ -54,7 +54,7 @@ jobs: - uses: pnpm/action-setup@v3.0.0 with: - version: 6.0.2 + version: 9.12.2 - name: Install dependencies run: pnpm install diff --git a/frontend/assets/css/main.css b/frontend/assets/css/main.css index 8a9d8fa72..185c47f5f 100644 --- a/frontend/assets/css/main.css +++ b/frontend/assets/css/main.css @@ -28,3 +28,61 @@ ::-webkit-scrollbar-thumb:hover { background-color: #9B9B9B; } + +.scroll-bg::-webkit-scrollbar { + width: 0.5rem; +} + +.scroll-bg::-webkit-scrollbar-thumb { + border-radius: 0.25rem; + @apply bg-base-300; +} + +.markdown > :first-child { + margin-top: 0px !important; +} + +.markdown :where(p, ul, ol, dl, blockquote, h1, h2, h3, h4, h5, h6) { + margin-top: var(--y-gap); + margin-bottom: var(--y-gap); +} + +.markdown :where(ul) { + list-style: disc; + margin-left: 2rem; +} + +.markdown :where(ol) { + list-style: decimal; + margin-left: 2rem; +} +/* Heading Styles */ +.markdown :where(h1) { + font-size: 2rem; + font-weight: 700; +} + +.markdown :where(h2) { + font-size: 1.5rem; + font-weight: 700; +} + +.markdown :where(h3) { + font-size: 1.25rem; + font-weight: 700; +} + +.markdown :where(h4) { + font-size: 1rem; + font-weight: 700; +} + +.markdown :where(h5) { + font-size: 0.875rem; + font-weight: 700; +} + +.markdown :where(h6) { + font-size: 0.75rem; + font-weight: 700; +} diff --git a/frontend/components/Base/SectionHeader.vue b/frontend/components/Base/SectionHeader.vue index 387d160fc..9f1a86f25 100644 --- a/frontend/components/Base/SectionHeader.vue +++ b/frontend/components/Base/SectionHeader.vue @@ -4,7 +4,6 @@ class="flex items-center text-3xl font-bold tracking-tight" :class="{ 'text-neutral-content': dark, - 'text-content': !dark, }" > diff --git a/frontend/components/Form/Autocomplete2.vue b/frontend/components/Form/Autocomplete2.vue index 92fef222a..552c5da5c 100644 --- a/frontend/components/Form/Autocomplete2.vue +++ b/frontend/components/Form/Autocomplete2.vue @@ -85,7 +85,10 @@ type Props = { label: string; modelValue: SupportValues | null | undefined; - items: string[] | object[]; + items: { + id: string; + treeString: string; + }[]; display?: string; multiple?: boolean; }; @@ -156,7 +159,7 @@ const matches = index.value.search("*" + search.value + "*"); - let resultIDs = [] + const resultIDs = []; for (let i = 0; i < matches.length; i++) { const match = matches[i]; const item = props.items[parseInt(match.ref)]; @@ -170,9 +173,11 @@ * Resolve the issue of language not being supported */ for (let i = 0; i < props.items.length; i++) { - const item = props.items[i] - if(resultIDs.find(item_ => item_ === item.id) != undefined){continue} - if(item.treeString.indexOf(search.value) > -1){ + const item = props.items[i]; + if (resultIDs.find(item_ => item_ === item.id) !== undefined) { + continue; + } + if (item.treeString.includes(search.value)) { const display = extractDisplay(item); list.push({ id: i, display, value: item }); } diff --git a/frontend/components/Form/TextArea.vue b/frontend/components/Form/TextArea.vue index f208b3274..87207415a 100644 --- a/frontend/components/Form/TextArea.vue +++ b/frontend/components/Form/TextArea.vue @@ -6,10 +6,10 @@ :class="{ 'text-red-600': typeof value === 'string' && - ((maxLength && value.length > maxLength) || (minLength && value.length < minLength)), + ((maxLength !== -1 && value.length > maxLength) || (minLength !== -1 && value.length < minLength)), }" > - {{ typeof value === "string" && (maxLength || minLength) ? `${value.length}/${maxLength}` : "" }} + {{ typeof value === "string" && (maxLength !== -1 || minLength !== -1) ? `${value.length}/${maxLength}` : "" }}