-
-
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
* feat(#8149): respect nsfw settings on gallery list * ci(#10336): use pull_request * test(#8149): add interaction tests * test(#10336): use `waitFor` * chore: transition
- Loading branch information
1 parent
516a791
commit 3b3f683
Showing
8 changed files
with
254 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,116 @@ | ||
import type { entities } from 'misskey-js' | ||
|
||
export const userDetailed = { | ||
id: 'someuserid', | ||
username: 'miskist', | ||
host: 'misskey-hub.net', | ||
name: 'Misskey User', | ||
onlineStatus: 'unknown', | ||
avatarUrl: 'https://github.com/misskey-dev/misskey/blob/master/packages/frontend/assets/about-icon.png?raw=true', | ||
avatarBlurhash: 'eQFRshof5NWBRi},juayfPju53WB?0ofs;s*a{ofjuay^SoMEJR%ay', | ||
emojis: [], | ||
bannerBlurhash: 'eQA^IW^-MH8w9tE8I=S^o{$*R4RikXtSxutRozjEnNR.RQadoyozog', | ||
bannerColor: '#000000', | ||
bannerUrl: 'https://github.com/misskey-dev/misskey/blob/master/packages/frontend/assets/fedi.jpg?raw=true', | ||
birthday: '2014-06-20', | ||
createdAt: '2016-12-28T22:49:51.000Z', | ||
description: 'I am a cool user!', | ||
ffVisibility: 'public', | ||
fields: [ | ||
{ | ||
name: 'Website', | ||
value: 'https://misskey-hub.net', | ||
export function abuseUserReport() { | ||
return { | ||
id: 'someabusereportid', | ||
createdAt: '2016-12-28T22:49:51.000Z', | ||
comment: 'This user is a spammer!', | ||
resolved: false, | ||
reporterId: 'reporterid', | ||
targetUserId: 'targetuserid', | ||
assigneeId: 'assigneeid', | ||
reporter: userDetailed('reporterid', 'reporter', 'misskey-hub.net', 'Reporter'), | ||
targetUser: userDetailed('targetuserid', 'target', 'misskey-hub.net', 'Target'), | ||
assignee: userDetailed('assigneeid', 'assignee', 'misskey-hub.net', 'Assignee'), | ||
me: null, | ||
forwarded: false, | ||
}; | ||
} | ||
|
||
export function galleryPost(isSensitive = false) { | ||
return { | ||
id: 'somepostid', | ||
createdAt: '2016-12-28T22:49:51.000Z', | ||
updatedAt: '2016-12-28T22:49:51.000Z', | ||
userid: 'someuserid', | ||
user: userDetailed(), | ||
title: 'Some post title', | ||
description: 'Some post description', | ||
fileIds: ['somefileid'], | ||
files: [ | ||
file(isSensitive), | ||
], | ||
isSensitive, | ||
likedCount: 0, | ||
isLiked: false, | ||
} | ||
} | ||
|
||
export function file(isSensitive = false) { | ||
return { | ||
id: 'somefileid', | ||
createdAt: '2016-12-28T22:49:51.000Z', | ||
name: 'somefile.jpg', | ||
type: 'image/jpeg', | ||
md5: 'f6fc51c73dc21b1fb85ead2cdf57530a', | ||
size: 77752, | ||
isSensitive, | ||
blurhash: 'eQAmoa^-MH8w9ZIvNLSvo^$*MwRPbwtSxutRozjEiwR.RjWBoeozog', | ||
properties: { | ||
width: 1024, | ||
height: 270 | ||
}, | ||
], | ||
followersCount: 1024, | ||
followingCount: 16, | ||
hasPendingFollowRequestFromYou: false, | ||
hasPendingFollowRequestToYou: false, | ||
isAdmin: false, | ||
isBlocked: false, | ||
isBlocking: false, | ||
isBot: false, | ||
isCat: false, | ||
isFollowed: false, | ||
isFollowing: false, | ||
isLocked: false, | ||
isModerator: false, | ||
isMuted: false, | ||
isSilenced: false, | ||
isSuspended: false, | ||
lang: 'en', | ||
location: 'Fediverse', | ||
notesCount: 65536, | ||
pinnedNoteIds: [], | ||
pinnedNotes: [], | ||
pinnedPage: null, | ||
pinnedPageId: null, | ||
publicReactions: false, | ||
securityKeys: false, | ||
twoFactorEnabled: false, | ||
updatedAt: null, | ||
uri: null, | ||
url: null, | ||
} satisfies entities.UserDetailed | ||
url: 'https://github.com/misskey-dev/misskey/blob/master/packages/frontend/assets/fedi.jpg?raw=true', | ||
thumbnailUrl: 'https://github.com/misskey-dev/misskey/blob/master/packages/frontend/assets/fedi.jpg?raw=true', | ||
comment: null, | ||
folderId: null, | ||
folder: null, | ||
userId: null, | ||
user: null, | ||
}; | ||
} | ||
|
||
export function userDetailed(id = 'someuserid', username = 'miskist', host = 'misskey-hub.net', name = 'Misskey User'): entities.UserDetailed { | ||
return { | ||
id, | ||
username, | ||
host, | ||
name, | ||
onlineStatus: 'unknown', | ||
avatarUrl: 'https://github.com/misskey-dev/misskey/blob/master/packages/frontend/assets/about-icon.png?raw=true', | ||
avatarBlurhash: 'eQFRshof5NWBRi},juayfPju53WB?0ofs;s*a{ofjuay^SoMEJR%ay', | ||
emojis: [], | ||
bannerBlurhash: 'eQA^IW^-MH8w9tE8I=S^o{$*R4RikXtSxutRozjEnNR.RQadoyozog', | ||
bannerColor: '#000000', | ||
bannerUrl: 'https://github.com/misskey-dev/misskey/blob/master/packages/frontend/assets/fedi.jpg?raw=true', | ||
birthday: '2014-06-20', | ||
createdAt: '2016-12-28T22:49:51.000Z', | ||
description: 'I am a cool user!', | ||
ffVisibility: 'public', | ||
fields: [ | ||
{ | ||
name: 'Website', | ||
value: 'https://misskey-hub.net', | ||
}, | ||
], | ||
followersCount: 1024, | ||
followingCount: 16, | ||
hasPendingFollowRequestFromYou: false, | ||
hasPendingFollowRequestToYou: false, | ||
isAdmin: false, | ||
isBlocked: false, | ||
isBlocking: false, | ||
isBot: false, | ||
isCat: false, | ||
isFollowed: false, | ||
isFollowing: false, | ||
isLocked: false, | ||
isModerator: false, | ||
isMuted: false, | ||
isSilenced: false, | ||
isSuspended: false, | ||
lang: 'en', | ||
location: 'Fediverse', | ||
notesCount: 65536, | ||
pinnedNoteIds: [], | ||
pinnedNotes: [], | ||
pinnedPage: null, | ||
pinnedPageId: null, | ||
publicReactions: false, | ||
securityKeys: false, | ||
twoFactorEnabled: false, | ||
updatedAt: null, | ||
uri: null, | ||
url: null, | ||
}; | ||
} |
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
85 changes: 85 additions & 0 deletions
85
packages/frontend/src/components/MkGalleryPostPreview.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,85 @@ | ||
/* 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 { galleryPost } from '../../.storybook/fakes'; | ||
import MkGalleryPostPreview from './MkGalleryPostPreview.vue'; | ||
export const Default = { | ||
render(args) { | ||
return { | ||
components: { | ||
MkGalleryPostPreview, | ||
}, | ||
setup() { | ||
return { | ||
args, | ||
}; | ||
}, | ||
computed: { | ||
props() { | ||
return { | ||
...this.args, | ||
}; | ||
}, | ||
}, | ||
template: '<MkGalleryPostPreview v-bind="props" />', | ||
}; | ||
}, | ||
async play({ canvasElement }) { | ||
const canvas = within(canvasElement); | ||
const links = canvas.getAllByRole('link'); | ||
await expect(links).toHaveLength(2); | ||
await expect(links[0]).toHaveAttribute('href', `/gallery/${galleryPost().id}`); | ||
await expect(links[1]).toHaveAttribute('href', `/@${galleryPost().user.username}@${galleryPost().user.host}`); | ||
}, | ||
args: { | ||
post: galleryPost(), | ||
}, | ||
decorators: [ | ||
() => ({ | ||
template: '<div style="width:260px"><story /></div>', | ||
}), | ||
], | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
} satisfies StoryObj<typeof MkGalleryPostPreview>; | ||
export const Hover = { | ||
...Default, | ||
async play(context) { | ||
await Default.play(context); | ||
const canvas = within(context.canvasElement); | ||
const links = canvas.getAllByRole('link'); | ||
await waitFor(() => userEvent.hover(links[0])); | ||
}, | ||
} satisfies StoryObj<typeof MkGalleryPostPreview>; | ||
export const HoverThenUnhover = { | ||
...Default, | ||
async play(context) { | ||
await Hover.play(context); | ||
const canvas = within(context.canvasElement); | ||
const links = canvas.getAllByRole('link'); | ||
await waitFor(() => userEvent.unhover(links[0])); | ||
}, | ||
} satisfies StoryObj<typeof MkGalleryPostPreview>; | ||
export const Sensitive = { | ||
...Default, | ||
args: { | ||
...Default.args, | ||
post: galleryPost(true), | ||
}, | ||
} satisfies StoryObj<typeof MkGalleryPostPreview>; | ||
export const SensitiveHover = { | ||
...Hover, | ||
args: { | ||
...Hover.args, | ||
post: galleryPost(true), | ||
}, | ||
} satisfies StoryObj<typeof MkGalleryPostPreview>; | ||
export const SensitiveHoverThenUnhover = { | ||
...HoverThenUnhover, | ||
args: { | ||
...HoverThenUnhover.args, | ||
post: galleryPost(true), | ||
}, | ||
} satisfies StoryObj<typeof MkGalleryPostPreview>; |
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
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
Oops, something went wrong.