From 2178d337de116f34140aec51f73c758873638587 Mon Sep 17 00:00:00 2001 From: William Volin Date: Mon, 4 Nov 2024 20:22:54 -0700 Subject: [PATCH] feat: add new leaderboard view scaffold - shows game name as header - shows toggle-able info dropdown showing Leaderboard.Info - if api returns a 404, renders the nuxt 404 page - This must be implemented globally and is out of scope of this PR --- .../LeaderboardInfo/Desktop/Desktop.test.ts | 33 ---- .../LeaderboardInfo/Desktop/Desktop.vue | 141 ------------------ .../LeaderboardInfo/LeaderboardInfo.test.ts | 47 ------ .../LeaderboardInfo/LeaderboardInfo.vue | 57 ++----- .../LeaderboardInfoAccordion.vue | 30 ++++ .../LeaderboardInfo/Mobile/Mobile.test.ts | 33 ---- .../blocks/LeaderboardInfo/Mobile/Mobile.vue | 84 ----------- .../PlatformTags/PlatformTags.test.ts | 23 --- .../PlatformTags/PlatformTags.vue | 22 --- i18n/en/index.ts | 1 + i18n/language.ts | 1 + pages/game/[slug].vue | 18 ++- 12 files changed, 54 insertions(+), 436 deletions(-) delete mode 100644 components/blocks/LeaderboardInfo/Desktop/Desktop.test.ts delete mode 100644 components/blocks/LeaderboardInfo/Desktop/Desktop.vue delete mode 100644 components/blocks/LeaderboardInfo/LeaderboardInfo.test.ts create mode 100644 components/blocks/LeaderboardInfo/LeaderboardInfoAccordion.vue delete mode 100644 components/blocks/LeaderboardInfo/Mobile/Mobile.test.ts delete mode 100644 components/blocks/LeaderboardInfo/Mobile/Mobile.vue delete mode 100644 components/blocks/LeaderboardInfo/PlatformTags/PlatformTags.test.ts delete mode 100644 components/blocks/LeaderboardInfo/PlatformTags/PlatformTags.vue diff --git a/components/blocks/LeaderboardInfo/Desktop/Desktop.test.ts b/components/blocks/LeaderboardInfo/Desktop/Desktop.test.ts deleted file mode 100644 index 5c841c62..00000000 --- a/components/blocks/LeaderboardInfo/Desktop/Desktop.test.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { mountSuspended } from '@nuxt/test-utils/runtime' -import { getByTestId } from 'root/testUtils' -import Desktop from './Desktop.vue' - -describe('', () => { - async function getDesktopWrapper() { - return await mountSuspended(Desktop, { - props: { - leaderboard: { - categories: [{ id: 1, name: 'Any%', slug: 'any' }], - id: 1, - name: 'Stuck in the Train Simulator 2', - slug: 'stuck-in-the-train-sim-2', - }, - todoPlatforms: ['XBox', 'PC'], - }, - }) - } - - afterEach(() => { - vi.restoreAllMocks() - }) - - it('should render without crashing', async () => { - const wrapper = await getDesktopWrapper() - expect(wrapper.isVisible()).toBe(true) - - expect(getByTestId(wrapper, 'title').text()).toBe( - 'Stuck in the Train Simulator 2', - ) - expect(getByTestId(wrapper, 'tag').text()).toBe('Any%') - }) -}) diff --git a/components/blocks/LeaderboardInfo/Desktop/Desktop.vue b/components/blocks/LeaderboardInfo/Desktop/Desktop.vue deleted file mode 100644 index dae18f2d..00000000 --- a/components/blocks/LeaderboardInfo/Desktop/Desktop.vue +++ /dev/null @@ -1,141 +0,0 @@ - - - - - -elements/buttons/Dropdown/Dropdown.vueelements/buttons/Dropdown/DropdownItem.vue diff --git a/components/blocks/LeaderboardInfo/LeaderboardInfo.test.ts b/components/blocks/LeaderboardInfo/LeaderboardInfo.test.ts deleted file mode 100644 index 897899e1..00000000 --- a/components/blocks/LeaderboardInfo/LeaderboardInfo.test.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { mountSuspended } from '@nuxt/test-utils/runtime' -import { getByTestId } from 'root/testUtils' -import LeaderboardInfo from './LeaderboardInfo.vue' - -describe('', () => { - async function getLeaderboardInfoWrapper() { - return await mountSuspended(LeaderboardInfo, { - props: { - leaderboard: { - categories: [], - id: 1, - name: 'Stuck in the Train Simulator 2', - slug: 'stuck-in-the-train-sim-2', - }, - }, - }) - } - - afterEach(() => { - vi.restoreAllMocks() - vi.unstubAllGlobals() - }) - - it('should render without crashing', async () => { - const wrapper = await getLeaderboardInfoWrapper() - expect(wrapper.isVisible()).toBe(true) - }) - - it('should render if device width is large', async () => { - vi.stubGlobal('innerWidth', 1980) - const wrapper = await getLeaderboardInfoWrapper() - expect(wrapper.html()).toContain('Guides') - }) - - it('should render if device width is small', async () => { - vi.stubGlobal('innerWidth', 600) - const wrapper = await getLeaderboardInfoWrapper() - expect(wrapper.html()).toContain('Submit Run') - }) - - // TODO: The follow event doesn't trigger in the test, somehow - it.skip('should emit event when the Follow Button is triggered', async () => { - const wrapper = await getLeaderboardInfoWrapper() - await getByTestId(wrapper, 'child').trigger('follow') - expect(wrapper.emitted().follow).toBeTruthy() - }) -}) diff --git a/components/blocks/LeaderboardInfo/LeaderboardInfo.vue b/components/blocks/LeaderboardInfo/LeaderboardInfo.vue index c9395469..fcee55a5 100644 --- a/components/blocks/LeaderboardInfo/LeaderboardInfo.vue +++ b/components/blocks/LeaderboardInfo/LeaderboardInfo.vue @@ -1,55 +1,18 @@ - - - diff --git a/components/blocks/LeaderboardInfo/LeaderboardInfoAccordion.vue b/components/blocks/LeaderboardInfo/LeaderboardInfoAccordion.vue new file mode 100644 index 00000000..de5fa052 --- /dev/null +++ b/components/blocks/LeaderboardInfo/LeaderboardInfoAccordion.vue @@ -0,0 +1,30 @@ + + + diff --git a/components/blocks/LeaderboardInfo/Mobile/Mobile.test.ts b/components/blocks/LeaderboardInfo/Mobile/Mobile.test.ts deleted file mode 100644 index fce62d74..00000000 --- a/components/blocks/LeaderboardInfo/Mobile/Mobile.test.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { mountSuspended } from '@nuxt/test-utils/runtime' -import { getByTestId } from 'root/testUtils' -import Mobile from './Mobile.vue' - -describe('', () => { - async function getMobileWrapper() { - return await mountSuspended(Mobile, { - props: { - leaderboard: { - categories: [{ id: 1, name: 'Any%', slug: 'any' }], - id: 1, - name: 'Stuck in the Train Simulator 2', - slug: 'stuck-in-the-train-sim-2', - }, - todoPlatforms: ['XBox', 'PC'], - }, - }) - } - - afterEach(() => { - vi.restoreAllMocks() - }) - - it('should render without crashing', async () => { - const wrapper = await getMobileWrapper() - expect(wrapper.isVisible()).toBe(true) - - expect(getByTestId(wrapper, 'title').text()).toBe( - 'Stuck in the Train Simulator 2', - ) - expect(getByTestId(wrapper, 'tag').text()).toBe('Any%') - }) -}) diff --git a/components/blocks/LeaderboardInfo/Mobile/Mobile.vue b/components/blocks/LeaderboardInfo/Mobile/Mobile.vue deleted file mode 100644 index 99c16642..00000000 --- a/components/blocks/LeaderboardInfo/Mobile/Mobile.vue +++ /dev/null @@ -1,84 +0,0 @@ - - - - - diff --git a/components/blocks/LeaderboardInfo/PlatformTags/PlatformTags.test.ts b/components/blocks/LeaderboardInfo/PlatformTags/PlatformTags.test.ts deleted file mode 100644 index 1331bded..00000000 --- a/components/blocks/LeaderboardInfo/PlatformTags/PlatformTags.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { mountSuspended } from '@nuxt/test-utils/runtime' -import PlatformTags from './PlatformTags.vue' - -describe('', () => { - const tags = ['XBox', 'PS4', 'Amiga DS'] - - it('should render without crashing', async () => { - const wrapper = await mountSuspended(PlatformTags, { - props: { - tags, - }, - }) - - expect(wrapper.isVisible()).toBe(true) - - wrapper - .getComponent('div.platform-tags') - .findAllComponents('div') - .forEach((c, i) => { - expect(c.text()).toBe(tags[i]) - }) - }) -}) diff --git a/components/blocks/LeaderboardInfo/PlatformTags/PlatformTags.vue b/components/blocks/LeaderboardInfo/PlatformTags/PlatformTags.vue deleted file mode 100644 index ae069c42..00000000 --- a/components/blocks/LeaderboardInfo/PlatformTags/PlatformTags.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - - - diff --git a/i18n/en/index.ts b/i18n/en/index.ts index ee03553b..4e78d8b8 100644 --- a/i18n/en/index.ts +++ b/i18n/en/index.ts @@ -12,4 +12,5 @@ export const English = { 'Something went wrong. Reach out to support if the problem persists.', signup: 'Sign Up', welcome: 'Welcome', + info: 'Info', } satisfies LanguageIndexFile diff --git a/i18n/language.ts b/i18n/language.ts index bcabde6d..8aef93e2 100644 --- a/i18n/language.ts +++ b/i18n/language.ts @@ -8,4 +8,5 @@ export interface LanguageIndexFile { confirmationReceived?: string confirmationReceivedText?: string signup?: string + info?: string } diff --git a/pages/game/[slug].vue b/pages/game/[slug].vue index 588a1d58..a0b7012d 100644 --- a/pages/game/[slug].vue +++ b/pages/game/[slug].vue @@ -1,21 +1,27 @@