From 2019e0d6c3dbb6116c73d83c3d67a33a28e4a98c Mon Sep 17 00:00:00 2001 From: zysim <9867871+zysim@users.noreply.github.com> Date: Sat, 16 Mar 2024 15:07:51 +0800 Subject: [PATCH 01/25] Use type imports in lib/api --- lib/api/Account.ts | 5 +++-- lib/api/AccountRoute.ts | 2 +- lib/api/Categories.ts | 5 +++-- lib/api/CategoriesRoute.ts | 2 +- lib/api/Leaderboards.ts | 5 +++-- lib/api/LeaderboardsRoute.ts | 2 +- lib/api/Runs.ts | 5 +++-- lib/api/RunsRoute.ts | 2 +- lib/api/Users.ts | 5 +++-- lib/api/UsersRoute.ts | 2 +- 10 files changed, 20 insertions(+), 15 deletions(-) diff --git a/lib/api/Account.ts b/lib/api/Account.ts index 8568d7f3..630ba8fa 100644 --- a/lib/api/Account.ts +++ b/lib/api/Account.ts @@ -9,7 +9,7 @@ * --------------------------------------------------------------- */ -import { +import type { ChangePasswordRequest, LoginRequest, LoginResponse, @@ -19,7 +19,8 @@ import { UserViewModel, ValidationProblemDetails, } from './data-contracts' -import { ContentType, HttpClient, RequestParams } from './http-client' +import type { RequestParams } from './http-client' +import { ContentType, HttpClient } from './http-client' export class Account< SecurityDataType = unknown, diff --git a/lib/api/AccountRoute.ts b/lib/api/AccountRoute.ts index f27622b8..1f2f3c21 100644 --- a/lib/api/AccountRoute.ts +++ b/lib/api/AccountRoute.ts @@ -9,7 +9,7 @@ * --------------------------------------------------------------- */ -import { +import type { ChangePasswordRequest, LoginRequest, LoginResponse, diff --git a/lib/api/Categories.ts b/lib/api/Categories.ts index fdbead3c..47f00144 100644 --- a/lib/api/Categories.ts +++ b/lib/api/Categories.ts @@ -9,13 +9,14 @@ * --------------------------------------------------------------- */ -import { +import type { CategoryViewModel, CreateCategoryRequest, ProblemDetails, ValidationProblemDetails, } from './data-contracts' -import { ContentType, HttpClient, RequestParams } from './http-client' +import type { RequestParams } from './http-client' +import { ContentType, HttpClient } from './http-client' export class Categories< SecurityDataType = unknown, diff --git a/lib/api/CategoriesRoute.ts b/lib/api/CategoriesRoute.ts index 5129b183..0f49fd56 100644 --- a/lib/api/CategoriesRoute.ts +++ b/lib/api/CategoriesRoute.ts @@ -9,7 +9,7 @@ * --------------------------------------------------------------- */ -import { CategoryViewModel, CreateCategoryRequest } from './data-contracts' +import type { CategoryViewModel, CreateCategoryRequest } from './data-contracts' export namespace Categories { /** diff --git a/lib/api/Leaderboards.ts b/lib/api/Leaderboards.ts index 9474c30c..d007ff94 100644 --- a/lib/api/Leaderboards.ts +++ b/lib/api/Leaderboards.ts @@ -9,14 +9,15 @@ * --------------------------------------------------------------- */ -import { +import type { CreateLeaderboardRequest, LeaderboardViewModel, LeaderboardsListParams, ProblemDetails, ValidationProblemDetails, } from './data-contracts' -import { ContentType, HttpClient, RequestParams } from './http-client' +import type { RequestParams } from './http-client' +import { ContentType, HttpClient } from './http-client' export class Leaderboards< SecurityDataType = unknown, diff --git a/lib/api/LeaderboardsRoute.ts b/lib/api/LeaderboardsRoute.ts index f9b9e4cd..9b043987 100644 --- a/lib/api/LeaderboardsRoute.ts +++ b/lib/api/LeaderboardsRoute.ts @@ -9,7 +9,7 @@ * --------------------------------------------------------------- */ -import { +import type { CreateLeaderboardRequest, LeaderboardViewModel, } from './data-contracts' diff --git a/lib/api/Runs.ts b/lib/api/Runs.ts index 66b18c43..ef614e8b 100644 --- a/lib/api/Runs.ts +++ b/lib/api/Runs.ts @@ -9,14 +9,15 @@ * --------------------------------------------------------------- */ -import { +import type { CategoryViewModel, CreateRunRequest, ProblemDetails, RunViewModel, ValidationProblemDetails, } from './data-contracts' -import { ContentType, HttpClient, RequestParams } from './http-client' +import type { RequestParams } from './http-client' +import { ContentType, HttpClient } from './http-client' export class Runs< SecurityDataType = unknown, diff --git a/lib/api/RunsRoute.ts b/lib/api/RunsRoute.ts index 7527347e..de244e2b 100644 --- a/lib/api/RunsRoute.ts +++ b/lib/api/RunsRoute.ts @@ -9,7 +9,7 @@ * --------------------------------------------------------------- */ -import { +import type { CategoryViewModel, CreateRunRequest, RunViewModel, diff --git a/lib/api/Users.ts b/lib/api/Users.ts index 4ccf98cb..40498df8 100644 --- a/lib/api/Users.ts +++ b/lib/api/Users.ts @@ -9,8 +9,9 @@ * --------------------------------------------------------------- */ -import { ProblemDetails, UserViewModel } from './data-contracts' -import { HttpClient, RequestParams } from './http-client' +import type { ProblemDetails, UserViewModel } from './data-contracts' +import type { RequestParams } from './http-client' +import { HttpClient } from './http-client' export class Users< SecurityDataType = unknown, diff --git a/lib/api/UsersRoute.ts b/lib/api/UsersRoute.ts index e5afa2c3..c603334a 100644 --- a/lib/api/UsersRoute.ts +++ b/lib/api/UsersRoute.ts @@ -9,7 +9,7 @@ * --------------------------------------------------------------- */ -import { UserViewModel } from './data-contracts' +import type { UserViewModel } from './data-contracts' export namespace Users { /** From ac91ae43e5b23e529f4111af7ab49a97d6c6f960 Mon Sep 17 00:00:00 2001 From: zysim <9867871+zysim@users.noreply.github.com> Date: Sun, 17 Mar 2024 00:58:54 +0800 Subject: [PATCH 02/25] Add compoments, elements, and most of the styles --- .../LeaderboardDetails/LeaderboardDetails.vue | 108 ++++++++++++++++++ .../LeaderboardDetails/PlatformTags.vue | 22 ++++ components/elements/tags/Tag/Tag.vue | 13 +++ .../api/useGetLeaderboardDetail/index.ts | 3 +- composables/useApi/index.ts | 1 + pages/board/[slug].vue | 11 +- 6 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 components/blocks/LeaderboardDetails/LeaderboardDetails.vue create mode 100644 components/blocks/LeaderboardDetails/PlatformTags.vue create mode 100644 components/elements/tags/Tag/Tag.vue diff --git a/components/blocks/LeaderboardDetails/LeaderboardDetails.vue b/components/blocks/LeaderboardDetails/LeaderboardDetails.vue new file mode 100644 index 00000000..53a20f89 --- /dev/null +++ b/components/blocks/LeaderboardDetails/LeaderboardDetails.vue @@ -0,0 +1,108 @@ + + + + + diff --git a/components/blocks/LeaderboardDetails/PlatformTags.vue b/components/blocks/LeaderboardDetails/PlatformTags.vue new file mode 100644 index 00000000..df5d7b75 --- /dev/null +++ b/components/blocks/LeaderboardDetails/PlatformTags.vue @@ -0,0 +1,22 @@ + + + + + diff --git a/components/elements/tags/Tag/Tag.vue b/components/elements/tags/Tag/Tag.vue new file mode 100644 index 00000000..b9f8de17 --- /dev/null +++ b/components/elements/tags/Tag/Tag.vue @@ -0,0 +1,13 @@ + + + + + diff --git a/composables/api/useGetLeaderboardDetail/index.ts b/composables/api/useGetLeaderboardDetail/index.ts index ef1dd406..124c2de2 100644 --- a/composables/api/useGetLeaderboardDetail/index.ts +++ b/composables/api/useGetLeaderboardDetail/index.ts @@ -1,6 +1,7 @@ import { ref } from 'vue' -import { ApiResponse, optionalParameters, useApi } from 'composables/useApi' +import { useApi } from 'composables/useApi' import { Leaderboards } from 'lib/api/Leaderboards' +import type { ApiResponse, optionalParameters } from 'composables/useApi' import type { LeaderboardViewModel } from 'lib/api/data-contracts' export async function useGetLeaderboardDetail( diff --git a/composables/useApi/index.ts b/composables/useApi/index.ts index 6607764e..7c0dd341 100644 --- a/composables/useApi/index.ts +++ b/composables/useApi/index.ts @@ -9,6 +9,7 @@ import type { HttpResponse } from 'lib/api/http-client' /** * @property {T} [data] * @property {ProblemDetails | null} error + * @property {ValidationProblemDetails | null} errors * @property {boolean} loading */ export interface ApiResponse { diff --git a/pages/board/[slug].vue b/pages/board/[slug].vue index 175aad71..b9ffad25 100644 --- a/pages/board/[slug].vue +++ b/pages/board/[slug].vue @@ -1,4 +1,6 @@ + From 8da1217fbce0a3adf5169b1baa873db464b1e6cb Mon Sep 17 00:00:00 2001 From: zysim <9867871+zysim@users.noreply.github.com> Date: Mon, 25 Mar 2024 23:47:22 +0800 Subject: [PATCH 03/25] Update vitest recommended extension --- .vscode/extensions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index ffa80745..5d14fc65 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -6,6 +6,6 @@ "bradlc.vscode-tailwindcss", // Tooling for Tailwind "csstools.postcss", // PostCSS as Tailwind is built on top of it "Vue.volar", // Vue 3 Language support for VSC https://github.com/johnsoncodehk/volar - "ZixuanChen.vitest-explorer" // Vitest extension to run tests inside of VSCode + "vitest.explorer" // Vitest extension to run tests inside of VSCode ] } From 109fdaace14a854762739b53d88052793422a1b4 Mon Sep 17 00:00:00 2001 From: zysim <9867871+zysim@users.noreply.github.com> Date: Mon, 25 Mar 2024 23:58:50 +0800 Subject: [PATCH 04/25] REBASE: Add components --- .../LeaderboardDetails.test.ts | 56 +++++++++++++++++++ .../LeaderboardDetails/LeaderboardDetails.vue | 40 ++++++++----- .../PlatformTags/PlatformTags.test.ts | 14 +++++ .../{ => PlatformTags}/PlatformTags.vue | 2 +- .../buttons/DropDown/DropDown.test.ts | 9 +++ .../elements/buttons/DropDown/DropDown.vue | 37 ++++++++++++ .../buttons/DropDown/DropDownContent.vue | 17 ++++++ .../buttons/DropDown/DropDownItem.vue | 13 +++++ pages/board/[slug].vue | 3 +- 9 files changed, 175 insertions(+), 16 deletions(-) create mode 100644 components/blocks/LeaderboardDetails/LeaderboardDetails.test.ts create mode 100644 components/blocks/LeaderboardDetails/PlatformTags/PlatformTags.test.ts rename components/blocks/LeaderboardDetails/{ => PlatformTags}/PlatformTags.vue (88%) create mode 100644 components/elements/buttons/DropDown/DropDown.test.ts create mode 100644 components/elements/buttons/DropDown/DropDown.vue create mode 100644 components/elements/buttons/DropDown/DropDownContent.vue create mode 100644 components/elements/buttons/DropDown/DropDownItem.vue diff --git a/components/blocks/LeaderboardDetails/LeaderboardDetails.test.ts b/components/blocks/LeaderboardDetails/LeaderboardDetails.test.ts new file mode 100644 index 00000000..75782379 --- /dev/null +++ b/components/blocks/LeaderboardDetails/LeaderboardDetails.test.ts @@ -0,0 +1,56 @@ +import { enableAutoUnmount, mount } from '@vue/test-utils' +import { getByTestId } from 'root/testUtils' +import LeaderboardDetails from './LeaderboardDetails.vue' + +describe.skip('', () => { + function getLeaderboardDetailsWrapper() { + return mount(LeaderboardDetails, { + props: { + leaderboardDetail: { + categories: [], + id: 1, + name: 'Stuck in the Train Simulator 2', + slug: 'stuck-in-the-train-sim-2', + socials: [ + { + icon: 'disc', + name: 'discord', + url: 'https://discord.gg/leaderboards.gg', + }, + { + icon: 'youtube', + name: 'Socials', + url: 'https://youtube.com', + }, + { + icon: 'twit', + name: 'twitter', + url: 'https://twitter.com/bestofdyingtwit', + }, + ], + }, + }, + }) + } + + afterEach(() => { + vi.restoreAllMocks() + }) + + enableAutoUnmount(afterEach) + + it('should render without crashing', () => { + const wrapper = getLeaderboardDetailsWrapper() + expect(wrapper.isVisible()).toBe(true) + }) + + it('should trigger follow button', async () => { + const wrapper = getLeaderboardDetailsWrapper() + await getByTestId(wrapper, 'middle__follow').trigger('click') + expect(wrapper.emitted().follow?.[0]).toEqual([1]) + }) + + it('should trigger', () => { + // + }) +}) diff --git a/components/blocks/LeaderboardDetails/LeaderboardDetails.vue b/components/blocks/LeaderboardDetails/LeaderboardDetails.vue index 53a20f89..b8c8be86 100644 --- a/components/blocks/LeaderboardDetails/LeaderboardDetails.vue +++ b/components/blocks/LeaderboardDetails/LeaderboardDetails.vue @@ -1,24 +1,25 @@ + + + + diff --git a/components/elements/buttons/DropDown/DropDownContent.vue b/components/elements/buttons/DropDown/DropDownContent.vue new file mode 100644 index 00000000..98e14893 --- /dev/null +++ b/components/elements/buttons/DropDown/DropDownContent.vue @@ -0,0 +1,17 @@ + + + + + diff --git a/components/elements/buttons/DropDown/DropDownItem.vue b/components/elements/buttons/DropDown/DropDownItem.vue new file mode 100644 index 00000000..502191e4 --- /dev/null +++ b/components/elements/buttons/DropDown/DropDownItem.vue @@ -0,0 +1,13 @@ + -