forked from forgejo/forgejo
[BUG] Render emojis in labels in issue info popup
- Currently emojis that are part of the label's name aren't rendered when shown in the popup that you get when you hover over issue references. - This patch fixes that by rendering the emoji. - Adds CSS to not make the emoji big in the label. - Resolves #1531
This commit is contained in:
parent
053ab13f99
commit
ddc24177dd
6 changed files with 221 additions and 13 deletions
39
web_src/js/components/ContextPopup.test.js
Normal file
39
web_src/js/components/ContextPopup.test.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
import {mount, flushPromises} from '@vue/test-utils';
|
||||
import ContextPopup from './ContextPopup.vue';
|
||||
|
||||
test('renders a issue info popup', async () => {
|
||||
const owner = 'user2';
|
||||
const repo = 'repo1';
|
||||
const index = 1;
|
||||
vi.spyOn(global, 'fetch').mockResolvedValue({
|
||||
json: vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
created_at: '2023-09-30T19:00:00Z',
|
||||
repository: {full_name: owner},
|
||||
pull_request: null,
|
||||
state: 'open',
|
||||
title: 'Normal issue',
|
||||
body: 'Lorem ipsum...',
|
||||
number: index,
|
||||
labels: [{color: 'ee0701', name: "Bug :+1: <script class='evil'>alert('Oh no!');</script>"}],
|
||||
}),
|
||||
ok: true,
|
||||
});
|
||||
|
||||
const wrapper = mount(ContextPopup);
|
||||
wrapper.vm.$el.dispatchEvent(new CustomEvent('ce-load-context-popup', {detail: {owner, repo, index}}));
|
||||
await flushPromises();
|
||||
|
||||
// Header
|
||||
expect(wrapper.get('p:nth-of-type(1)').text()).toEqual('user2 on Sep 30, 2023');
|
||||
// Title
|
||||
expect(wrapper.get('p:nth-of-type(2)').text()).toEqual('Normal issue #1');
|
||||
// Body
|
||||
expect(wrapper.get('p:nth-of-type(3)').text()).toEqual('Lorem ipsum...');
|
||||
// Check that the state is correct.
|
||||
expect(wrapper.get('svg').classes()).toContain('octicon-issue-opened');
|
||||
// Ensure that script is not an element.
|
||||
expect(() => wrapper.get('.evil')).toThrowError();
|
||||
// Check content of label
|
||||
expect(wrapper.get('.ui.label').text()).toContain("Bug 👍 <script class='evil'>alert('Oh no!');</script>");
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue