fix(frontend): GIFバナーの復活など (#10247)
* Restore GIF banner * Add ALT banner, detect APNG too * Add vitest * Add CI for vitest * Upload coverage? * frontend
This commit is contained in:
parent
6607b39235
commit
4835f0fb43
10 changed files with 835 additions and 111 deletions
81
packages/frontend/test/note.test.ts
Normal file
81
packages/frontend/test/note.test.ts
Normal file
|
@ -0,0 +1,81 @@
|
|||
import { describe, test, assert, afterEach } from 'vitest';
|
||||
import { render, cleanup, type RenderResult } from '@testing-library/vue';
|
||||
import './init';
|
||||
import type { DriveFile } from 'misskey-js/built/entities';
|
||||
import { directives } from '@/directives';
|
||||
import MkMediaImage from '@/components/MkMediaImage.vue';
|
||||
|
||||
describe('MkMediaImage', () => {
|
||||
const renderMediaImage = (image: Partial<DriveFile>): RenderResult => {
|
||||
return render(MkMediaImage, {
|
||||
props: { image },
|
||||
global: { directives },
|
||||
});
|
||||
};
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
});
|
||||
|
||||
test('Attaching JPG should show no indicator', async () => {
|
||||
const mkMediaImage = renderMediaImage({
|
||||
type: 'image/jpeg',
|
||||
});
|
||||
const [gif, alt] = await Promise.all([
|
||||
mkMediaImage.queryByText('GIF'),
|
||||
mkMediaImage.queryByText('ALT'),
|
||||
]);
|
||||
assert.ok(!gif);
|
||||
assert.ok(!alt);
|
||||
});
|
||||
|
||||
test('Attaching GIF should show a GIF indicator', async () => {
|
||||
const mkMediaImage = renderMediaImage({
|
||||
type: 'image/gif',
|
||||
});
|
||||
const [gif, alt] = await Promise.all([
|
||||
mkMediaImage.queryByText('GIF'),
|
||||
mkMediaImage.queryByText('ALT'),
|
||||
]);
|
||||
assert.ok(gif);
|
||||
assert.ok(!alt);
|
||||
});
|
||||
|
||||
test('Attaching APNG should show a GIF indicator', async () => {
|
||||
const mkMediaImage = renderMediaImage({
|
||||
type: 'image/apng',
|
||||
});
|
||||
const [gif, alt] = await Promise.all([
|
||||
mkMediaImage.queryByText('GIF'),
|
||||
mkMediaImage.queryByText('ALT'),
|
||||
]);
|
||||
assert.ok(gif);
|
||||
assert.ok(!alt);
|
||||
});
|
||||
|
||||
test('Attaching image with an alt message should show an ALT indicator', async () => {
|
||||
const mkMediaImage = renderMediaImage({
|
||||
type: 'image/png',
|
||||
comment: 'Misskeyのロゴです',
|
||||
});
|
||||
const [gif, alt] = await Promise.all([
|
||||
mkMediaImage.queryByText('GIF'),
|
||||
mkMediaImage.queryByText('ALT'),
|
||||
]);
|
||||
assert.ok(!gif);
|
||||
assert.ok(alt);
|
||||
});
|
||||
|
||||
test('Attaching GIF image with an alt message should show a GIF and an ALT indicator', async () => {
|
||||
const mkMediaImage = renderMediaImage({
|
||||
type: 'image/gif',
|
||||
comment: 'Misskeyのロゴです',
|
||||
});
|
||||
const [gif, alt] = await Promise.all([
|
||||
mkMediaImage.queryByText('GIF'),
|
||||
mkMediaImage.queryByText('ALT'),
|
||||
]);
|
||||
assert.ok(gif);
|
||||
assert.ok(alt);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue