-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* test(storybook): add `components/Mk[D-E].*` stories * fix: mock instance name * fix: invalid `reactionAcceptance` value * style: missing trailing commas
- Loading branch information
Showing
17 changed files
with
597 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/frontend/src/components/MkDateSeparatedList.stories.impl.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import MkDateSeparatedList from './MkDateSeparatedList.vue'; | ||
void MkDateSeparatedList; |
159 changes: 159 additions & 0 deletions
159
packages/frontend/src/components/MkDialog.stories.impl.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import { action } from '@storybook/addon-actions'; | ||
import { expect, userEvent, waitFor, within } from '@storybook/test'; | ||
import { StoryObj } from '@storybook/vue3'; | ||
import { i18n } from '@/i18n.js'; | ||
import MkDialog from './MkDialog.vue'; | ||
const Base = { | ||
render(args) { | ||
return { | ||
components: { | ||
MkDialog, | ||
}, | ||
setup() { | ||
return { | ||
args, | ||
}; | ||
}, | ||
computed: { | ||
props() { | ||
return { | ||
...this.args, | ||
}; | ||
}, | ||
events() { | ||
return { | ||
done: action('done'), | ||
closed: action('closed'), | ||
}; | ||
}, | ||
}, | ||
template: '<MkDialog v-bind="props" v-on="events" />', | ||
}; | ||
}, | ||
args: { | ||
text: 'Hello, world!', | ||
}, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
} satisfies StoryObj<typeof MkDialog>; | ||
export const Success = { | ||
...Base, | ||
args: { | ||
...Base.args, | ||
type: 'success', | ||
}, | ||
} satisfies StoryObj<typeof MkDialog>; | ||
export const Error = { | ||
...Base, | ||
args: { | ||
...Base.args, | ||
type: 'error', | ||
}, | ||
} satisfies StoryObj<typeof MkDialog>; | ||
export const Warning = { | ||
...Base, | ||
args: { | ||
...Base.args, | ||
type: 'warning', | ||
}, | ||
} satisfies StoryObj<typeof MkDialog>; | ||
export const Info = { | ||
...Base, | ||
args: { | ||
...Base.args, | ||
type: 'info', | ||
}, | ||
} satisfies StoryObj<typeof MkDialog>; | ||
export const Question = { | ||
...Base, | ||
args: { | ||
...Base.args, | ||
type: 'question', | ||
}, | ||
} satisfies StoryObj<typeof MkDialog>; | ||
export const Waiting = { | ||
...Base, | ||
args: { | ||
...Base.args, | ||
type: 'waiting', | ||
}, | ||
} satisfies StoryObj<typeof MkDialog>; | ||
export const DialogWithActions = { | ||
...Question, | ||
args: { | ||
...Question.args, | ||
text: i18n.ts.areYouSure, | ||
actions: [ | ||
{ | ||
text: i18n.ts.yes, | ||
primary: true, | ||
callback() { | ||
action('YES')(); | ||
}, | ||
}, | ||
{ | ||
text: i18n.ts.no, | ||
callback() { | ||
action('NO')(); | ||
}, | ||
}, | ||
], | ||
}, | ||
} satisfies StoryObj<typeof MkDialog>; | ||
export const DialogWithDangerActions = { | ||
...Warning, | ||
args: { | ||
...Warning.args, | ||
text: i18n.ts.resetAreYouSure, | ||
actions: [ | ||
{ | ||
text: i18n.ts.yes, | ||
danger: true, | ||
primary: true, | ||
callback() { | ||
action('YES')(); | ||
}, | ||
}, | ||
{ | ||
text: i18n.ts.no, | ||
callback() { | ||
action('NO')(); | ||
}, | ||
}, | ||
], | ||
}, | ||
} satisfies StoryObj<typeof MkDialog>; | ||
export const DialogWithInput = { | ||
...Question, | ||
args: { | ||
...Question.args, | ||
title: 'Hello, world!', | ||
text: undefined, | ||
input: { | ||
placeholder: i18n.ts.inputMessageHere, | ||
type: 'text', | ||
default: null, | ||
minLength: 2, | ||
maxLength: 3, | ||
}, | ||
}, | ||
async play({ canvasElement }) { | ||
const canvas = within(canvasElement); | ||
await expect(canvasElement).toHaveTextContent(i18n.tsx._dialog.charactersBelow({ current: 0, min: 2 })); | ||
const okButton = canvas.getByRole('button', { name: i18n.ts.ok }); | ||
await expect(okButton).toBeDisabled(); | ||
const input = canvas.getByRole<HTMLInputElement>('combobox'); | ||
await waitFor(() => userEvent.hover(input)); | ||
await waitFor(() => userEvent.click(input)); | ||
await waitFor(() => userEvent.type(input, 'M')); | ||
await expect(canvasElement).toHaveTextContent(i18n.tsx._dialog.charactersBelow({ current: 1, min: 2 })); | ||
await waitFor(() => userEvent.type(input, 'i')); | ||
await expect(okButton).toBeEnabled(); | ||
}, | ||
} satisfies StoryObj<typeof MkDialog>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import MkDivider from './MkDivider.vue'; | ||
void MkDivider; |
54 changes: 54 additions & 0 deletions
54
packages/frontend/src/components/MkDonation.stories.impl.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import { action } from '@storybook/addon-actions'; | ||
import { StoryObj } from '@storybook/vue3'; | ||
import { onBeforeUnmount } from 'vue'; | ||
import MkDonation from './MkDonation.vue'; | ||
import { instance } from '@/instance.js'; | ||
export const Default = { | ||
render(args) { | ||
return { | ||
components: { | ||
MkDonation, | ||
}, | ||
setup() { | ||
return { | ||
args, | ||
}; | ||
}, | ||
computed: { | ||
props() { | ||
return { | ||
...this.args, | ||
}; | ||
}, | ||
events() { | ||
return { | ||
closed: action('closed'), | ||
}; | ||
}, | ||
}, | ||
template: '<MkDonation v-bind="props" v-on="events" />', | ||
}; | ||
}, | ||
args: { | ||
// @ts-expect-error name is used for mocking instance | ||
name: 'Misskey Hub', | ||
}, | ||
decorators: [ | ||
(_, { args }) => ({ | ||
setup() { | ||
// @ts-expect-error name is used for mocking instance | ||
instance.name = args.name; | ||
onBeforeUnmount(() => instance.name = null); | ||
}, | ||
template: '<story/>', | ||
}), | ||
], | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
} satisfies StoryObj<typeof MkDonation>; |
48 changes: 48 additions & 0 deletions
48
packages/frontend/src/components/MkDrive.file.stories.impl.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import { action } from '@storybook/addon-actions'; | ||
import { StoryObj } from '@storybook/vue3'; | ||
import MkDrive_file from './MkDrive.file.vue'; | ||
import { file } from '../../.storybook/fakes.js'; | ||
export const Default = { | ||
render(args) { | ||
return { | ||
components: { | ||
MkDrive_file, | ||
}, | ||
setup() { | ||
return { | ||
args, | ||
}; | ||
}, | ||
computed: { | ||
props() { | ||
return { | ||
...this.args, | ||
}; | ||
}, | ||
events() { | ||
return { | ||
chosen: action('chosen'), | ||
dragstart: action('dragstart'), | ||
dragend: action('dragend'), | ||
}; | ||
}, | ||
}, | ||
template: '<MkDrive_file v-bind="props" v-on="events" />', | ||
}; | ||
}, | ||
args: { | ||
file: file(), | ||
}, | ||
parameters: { | ||
chromatic: { | ||
// NOTE: ロードが終わるまで待つ | ||
delay: 3000, | ||
}, | ||
layout: 'centered', | ||
}, | ||
} satisfies StoryObj<typeof MkDrive_file>; |
Oops, something went wrong.