mirror of
https://github.com/go-gitea/gitea.git
synced 2026-01-27 17:59:41 +01:00
1. Upgrade to [jQuery
4.0](https://blog.jquery.com/2026/01/17/jquery-4-0-0/). Two of the
removed APIs are in use by fomantic, but there are [polyfills
present](a3a3e581aa/web_src/fomantic/build/components/dropdown.js (L15-L17))
so it continues to work.
2. Remove manual naming of webpack chunks. I was running into below
webpack error and I see no reason for this manual chunk naming which is
prone to naming collisions. Also, the webpack build now shows all output
assets. This change will result in longer asset filenames, but webpack
should now be able to guarentee that the names are without collisions.
````
ERROR in SplitChunksPlugin
Cache group "defaultVendors" conflicts with existing chunk.
Both have the same name "--------" and existing chunk is not a parent of
the selected modules.
Use a different name for the cache group or make sure that the existing
chunk is a parent (e. g. via dependOn).
HINT: You can omit "name" to automatically create a name.
BREAKING CHANGE: webpack < 5 used to allow to use an entrypoint as
splitChunk. This is no longer allowed when the entrypoint is not a
parent of the selected modules.
Remove this entrypoint and add modules to cache group's 'test' instead.
If you need modules to be evaluated on startup, add them to the existing
entrypoints (make them arrays). See migration guide of more info.
3. Fix test issue related to `p > div` which is invalid as per HTML spec
because `div` is not [phrasing
content](https://html.spec.whatwg.org/multipage/dom.html#phrasing-content-2)
and therefor can not be a descendant of `p`. This is related to
https://github.com/capricorn86/happy-dom/pull/2007.
4. Add webpack globals
5. Remove obsolete docs glob
6. fix security issue for `seroval` package
7. disable [vitest isolate](https://vitest.dev/config/isolate.html) for
30% faster JS tests, which are all pure.
55 lines
2.4 KiB
TypeScript
55 lines
2.4 KiB
TypeScript
import {
|
|
createElementFromAttrs,
|
|
createElementFromHTML,
|
|
queryElemChildren,
|
|
querySingleVisibleElem,
|
|
toggleElem,
|
|
} from './dom.ts';
|
|
|
|
test('createElementFromHTML', () => {
|
|
expect(createElementFromHTML('<a>foo<span>bar</span></a>').outerHTML).toEqual('<a>foo<span>bar</span></a>');
|
|
expect(createElementFromHTML('<tr data-x="1"><td>foo</td></tr>').outerHTML).toEqual('<tr data-x="1"><td>foo</td></tr>');
|
|
});
|
|
|
|
test('createElementFromAttrs', () => {
|
|
const el = createElementFromAttrs('button', {
|
|
id: 'the-id',
|
|
class: 'cls-1 cls-2',
|
|
disabled: true,
|
|
checked: false,
|
|
required: null,
|
|
tabindex: 0,
|
|
'data-foo': 'the-data',
|
|
}, 'txt', createElementFromHTML('<span>inner</span>'));
|
|
expect(el.outerHTML).toEqual('<button id="the-id" class="cls-1 cls-2" disabled="" tabindex="0" data-foo="the-data">txt<span>inner</span></button>');
|
|
});
|
|
|
|
test('querySingleVisibleElem', () => {
|
|
let el = createElementFromHTML('<div></div>');
|
|
expect(querySingleVisibleElem(el, 'span')).toBeNull();
|
|
el = createElementFromHTML('<div><span>foo</span></div>');
|
|
expect(querySingleVisibleElem(el, 'span')!.textContent).toEqual('foo');
|
|
el = createElementFromHTML('<div><span style="display: none;">foo</span><span>bar</span></div>');
|
|
expect(querySingleVisibleElem(el, 'span')!.textContent).toEqual('bar');
|
|
el = createElementFromHTML('<div><span class="some-class tw-hidden">foo</span><span>bar</span></div>');
|
|
expect(querySingleVisibleElem(el, 'span')!.textContent).toEqual('bar');
|
|
el = createElementFromHTML('<div><span>foo</span><span>bar</span></div>');
|
|
expect(() => querySingleVisibleElem(el, 'span')).toThrowError('Expected exactly one visible element');
|
|
});
|
|
|
|
test('queryElemChildren', () => {
|
|
const el = createElementFromHTML('<div><span class="a">a</span><span class="b">b</span></div>');
|
|
const children = queryElemChildren(el, '.a');
|
|
expect(children.length).toEqual(1);
|
|
});
|
|
|
|
test('toggleElem', () => {
|
|
const el = createElementFromHTML('<div><div>a</div><div class="tw-hidden">b</div></div>');
|
|
toggleElem(el.children);
|
|
expect(el.outerHTML).toEqual('<div><div class="tw-hidden">a</div><div class="">b</div></div>');
|
|
toggleElem(el.children, false);
|
|
expect(el.outerHTML).toEqual('<div><div class="tw-hidden">a</div><div class="tw-hidden">b</div></div>');
|
|
toggleElem(el.children, true);
|
|
expect(el.outerHTML).toEqual('<div><div class="">a</div><div class="">b</div></div>');
|
|
});
|