From 26b3fc3ff0223b8493f07e98e9ef186e045f55bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Jaenisch?= Date: Wed, 10 Jul 2024 12:13:54 +0200 Subject: [PATCH] feat: extract MainMenuActions into component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This represents the lower part of the main menu with actions I can have on a project. Signed-off-by: André Jaenisch --- .../components/atoms/MainMenuActions.svelte | 33 +++++++++ src/lib/i18n/locales/bg.json | 5 ++ src/lib/i18n/locales/de.json | 5 ++ src/lib/i18n/locales/en.json | 5 ++ src/lib/i18n/locales/he.json | 5 ++ src/lib/i18n/locales/pl.json | 5 ++ stories/atoms/MainMenuActions.stories.ts | 26 +++++++ .../components/atoms/MainMenuActions.test.ts | 70 +++++++++++++++++++ 8 files changed, 154 insertions(+) create mode 100644 src/lib/components/atoms/MainMenuActions.svelte create mode 100644 stories/atoms/MainMenuActions.stories.ts create mode 100644 tests/components/atoms/MainMenuActions.test.ts diff --git a/src/lib/components/atoms/MainMenuActions.svelte b/src/lib/components/atoms/MainMenuActions.svelte new file mode 100644 index 0000000..85303a3 --- /dev/null +++ b/src/lib/components/atoms/MainMenuActions.svelte @@ -0,0 +1,33 @@ + + + + +
+
+ + {$_('page.profile.menu.actions.fork')} +
+
+ + {$_('page.profile.menu.actions.star')} +
+
+ + {$_('page.profile.menu.actions.watch')} + +
+
diff --git a/src/lib/i18n/locales/bg.json b/src/lib/i18n/locales/bg.json index e71a8cc..bbb6de9 100644 --- a/src/lib/i18n/locales/bg.json +++ b/src/lib/i18n/locales/bg.json @@ -91,6 +91,11 @@ "heading": "" }, "menu": { + "actions": { + "fork": "", + "star": "", + "watch": "" + }, "buttons": { "avatar": "", "issues": "", diff --git a/src/lib/i18n/locales/de.json b/src/lib/i18n/locales/de.json index addfc7e..de3dfff 100644 --- a/src/lib/i18n/locales/de.json +++ b/src/lib/i18n/locales/de.json @@ -91,6 +91,11 @@ "heading": "Aktivitäten" }, "menu": { + "actions": { + "fork": "", + "star": "", + "watch": "" + }, "buttons": { "avatar": "", "issues": "", diff --git a/src/lib/i18n/locales/en.json b/src/lib/i18n/locales/en.json index 4108365..68bcbda 100644 --- a/src/lib/i18n/locales/en.json +++ b/src/lib/i18n/locales/en.json @@ -91,6 +91,11 @@ "heading": "Activities" }, "menu": { + "actions": { + "fork": "Fork", + "star": "Star", + "watch": "Watch" + }, "buttons": { "avatar": "Menu", "issues": "{number}{blockElementOpen}{number, plural, one{ issue} other{ issues}} open{blockElementClose}", diff --git a/src/lib/i18n/locales/he.json b/src/lib/i18n/locales/he.json index 4cb4413..bf745e4 100644 --- a/src/lib/i18n/locales/he.json +++ b/src/lib/i18n/locales/he.json @@ -91,6 +91,11 @@ "heading": "פעילות" }, "menu": { + "actions": { + "fork": "", + "star": "", + "watch": "" + }, "buttons": { "avatar": "", "issues": "", diff --git a/src/lib/i18n/locales/pl.json b/src/lib/i18n/locales/pl.json index 4ea8ff3..10bd6be 100644 --- a/src/lib/i18n/locales/pl.json +++ b/src/lib/i18n/locales/pl.json @@ -91,6 +91,11 @@ "heading": "Aktywność" }, "menu": { + "actions": { + "fork": "", + "star": "", + "watch": "" + }, "buttons": { "avatar": "", "issues": "", diff --git a/stories/atoms/MainMenuActions.stories.ts b/stories/atoms/MainMenuActions.stories.ts new file mode 100644 index 0000000..472fbfe --- /dev/null +++ b/stories/atoms/MainMenuActions.stories.ts @@ -0,0 +1,26 @@ +/* Stories for MainMenuActions atom. + * Copyright (C) 2024 André Jaenisch + * SPDX-FileCopyrightText: 2024 André Jaenisch + * SPDX-License-Identifier: AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License along with this program. If not, see . + */ + +import type { Meta, StoryObj } from '@storybook/svelte'; + +import MainMenuActions from '$lib/components/atoms/MainMenuActions.svelte'; + +const meta = { + title: 'Atoms/MainMenuActions', + component: MainMenuActions, + tags: ['autodocs'] +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Plain: Story = {}; diff --git a/tests/components/atoms/MainMenuActions.test.ts b/tests/components/atoms/MainMenuActions.test.ts new file mode 100644 index 0000000..349d060 --- /dev/null +++ b/tests/components/atoms/MainMenuActions.test.ts @@ -0,0 +1,70 @@ +/* Component test for MainMenuActions atom. + * Copyright (C) 2024 André Jaenisch + * SPDX-FileCopyrightText: 2024 André Jaenisch + * SPDX-License-Identifier: AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License along with this program. If not, see . + */ + +import '@testing-library/jest-dom'; +import { render, screen } from '@testing-library/svelte'; +import { init, locale, register } from 'svelte-i18n'; + +import MainMenuActions from '../../../src/lib/components/atoms/MainMenuActions.svelte'; +import enMessages from '../../../src/lib/i18n/locales/en.json'; + +describe('MainMenuActions.svelte', () => { + beforeEach(() => { + register('en', () => import('../../../src/lib/i18n/locales/en.json')); + init({ fallbackLocale: 'en', initialLocale: 'en' }); + locale.set('en'); + }); + + it('should mount', () => { + // Arrange + // Nothing to prepare + + // Act + const { container } = render(MainMenuActions); + + // Assert + expect(container).toBeTruthy(); + }); + + it('should have a fork button', () => { + // Arrange + // Nothing to prepare + + // Act + render(MainMenuActions); + + // Assert + expect(screen.getByText(enMessages.page.profile.menu.actions.fork)).toBeInTheDocument(); + }); + + it('should have a star button', () => { + // Arrange + // Nothing to prepare + + // Act + render(MainMenuActions); + + // Assert + expect(screen.getByText(enMessages.page.profile.menu.actions.star)).toBeInTheDocument(); + }); + + it('should have a watch button', () => { + // Arrange + // Nothing to prepare + + // Act + render(MainMenuActions); + + // Assert + expect(screen.getByText(enMessages.page.profile.menu.actions.watch)).toBeInTheDocument(); + }); +});