diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-04-19 21:24:31 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-19 21:24:31 +0900 |
| commit | e1f9ab77f86f5a12091c864cdb502970715cd46e (patch) | |
| tree | 46990eae87d352e6674e43a64c3bdcd74c13119e /packages/frontend/src/components/MkSignupDialog.rules.stories.impl.ts | |
| parent | Update test-frontend.yml (diff) | |
| download | misskey-e1f9ab77f86f5a12091c864cdb502970715cd46e.tar.gz misskey-e1f9ab77f86f5a12091c864cdb502970715cd46e.tar.bz2 misskey-e1f9ab77f86f5a12091c864cdb502970715cd46e.zip | |
feat: Server rules (#10660)
* enhance(frontend): サーバールールのデザイン調整
* enhance(frontend): i18n
* enhance(frontend): 利用規約URLの設定を「モデレーション」ページへ移動
* enhance(frontend): サーバールールのデザイン調整
* Update CHANGELOG.md
* 不要な差分を削除
* fix(frontend): lint
* ui tweak
* test: add stories
* tweak
* test: bind args
* test: add interaction tests
* fix bug
* Update packages/frontend/src/pages/admin/server-rules.vue
Co-authored-by: Ebise Lutica <7106976+EbiseLutica@users.noreply.github.com>
* Update misskey-js.api.md
* chore: windowを明示
* :art:
* refactor
* :art:
* :art:
* fix e2e test
* :art:
* :art:
* fix icon
* fix e2e
---------
Co-authored-by: Ebise Lutica <7106976+EbiseLutica@users.noreply.github.com>
Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Diffstat (limited to 'packages/frontend/src/components/MkSignupDialog.rules.stories.impl.ts')
| -rw-r--r-- | packages/frontend/src/components/MkSignupDialog.rules.stories.impl.ts | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/packages/frontend/src/components/MkSignupDialog.rules.stories.impl.ts b/packages/frontend/src/components/MkSignupDialog.rules.stories.impl.ts new file mode 100644 index 0000000000..1308dfff9a --- /dev/null +++ b/packages/frontend/src/components/MkSignupDialog.rules.stories.impl.ts @@ -0,0 +1,94 @@ +/* eslint-disable @typescript-eslint/explicit-function-return-type */ +import { expect } from '@storybook/jest'; +import { userEvent, waitFor, within } from '@storybook/testing-library'; +import { StoryObj } from '@storybook/vue3'; +import { onBeforeUnmount } from 'vue'; +import MkSignupServerRules from './MkSignupDialog,rules.vue'; +import { i18n } from '@/i18n'; +import { instance } from '@/instance'; +export const Empty = { + render(args) { + return { + components: { + MkSignupServerRules, + }, + setup() { + return { + args, + }; + }, + computed: { + props() { + return { + ...this.args, + }; + }, + }, + template: '<MkSignupServerRules v-bind="props" />', + }; + }, + async play({ canvasElement }) { + const canvas = within(canvasElement); + const groups = await canvas.findAllByRole('group'); + const buttons = await canvas.findAllByRole('button'); + for (const group of groups) { + if (group.ariaExpanded === 'true') { + continue; + } + const button = await within(group).findByRole('button'); + userEvent.click(button); + await waitFor(() => expect(group).toHaveAttribute('aria-expanded', 'true')); + } + const labels = await canvas.findAllByText(i18n.ts.agree); + for (const label of labels) { + expect(buttons.at(-1)).toBeDisabled(); + await waitFor(() => userEvent.click(label)); + } + expect(buttons.at(-1)).toBeEnabled(); + }, + args: { + serverRules: [], + tosUrl: null, + }, + decorators: [ + (_, context) => ({ + setup() { + instance.serverRules = context.args.serverRules; + instance.tosUrl = context.args.tosUrl; + onBeforeUnmount(() => { + // FIXME: 呼び出されない + instance.serverRules = []; + instance.tosUrl = null; + }); + }, + template: '<story/>', + }), + ], + parameters: { + layout: 'centered', + }, +} satisfies StoryObj<typeof MkSignupServerRules>; +export const ServerRulesOnly = { + ...Empty, + args: { + ...Empty.args, + serverRules: [ + 'ルール', + ], + }, +} satisfies StoryObj<typeof MkSignupServerRules>; +export const TOSOnly = { + ...Empty, + args: { + ...Empty.args, + tosUrl: 'https://example.com/tos', + }, +} satisfies StoryObj<typeof MkSignupServerRules>; +export const ServerRulesAndTOS = { + ...Empty, + args: { + ...Empty.args, + serverRules: ServerRulesOnly.args.serverRules, + tosUrl: TOSOnly.args.tosUrl, + }, +} satisfies StoryObj<typeof MkSignupServerRules>; |