loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix Uint8Array comparisons and update vitest (#26805)

Compare those `Uint8Array` via conversion to Array which are properly
comparable, so that we don't have to worry about whether `TextEncoder`
and `UInt8Array` from the environment are compatible or not.

---------

Co-authored-by: delvh <dev.lh@web.de>

authored by

silverwind
delvh
and committed by
GitHub
508de3a5 7bc80cb3

+44 -39
+31 -31
package-lock.json
··· 82 82 "svgo": "3.0.2", 83 83 "updates": "14.4.0", 84 84 "vite-string-plugin": "1.1.2", 85 - "vitest": "0.34.2" 85 + "vitest": "0.34.3" 86 86 }, 87 87 "engines": { 88 88 "node": ">= 16.0.0" ··· 2043 2043 } 2044 2044 }, 2045 2045 "node_modules/@vitest/expect": { 2046 - "version": "0.34.2", 2047 - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.34.2.tgz", 2048 - "integrity": "sha512-EZm2dMNlLyIfDMha17QHSQcg2KjeAZaXd65fpPzXY5bvnfx10Lcaz3N55uEe8PhF+w4pw+hmrlHLLlRn9vkBJg==", 2046 + "version": "0.34.3", 2047 + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.34.3.tgz", 2048 + "integrity": "sha512-F8MTXZUYRBVsYL1uoIft1HHWhwDbSzwAU9Zgh8S6WFC3YgVb4AnFV2GXO3P5Em8FjEYaZtTnQYoNwwBrlOMXgg==", 2049 2049 "dev": true, 2050 2050 "dependencies": { 2051 - "@vitest/spy": "0.34.2", 2052 - "@vitest/utils": "0.34.2", 2051 + "@vitest/spy": "0.34.3", 2052 + "@vitest/utils": "0.34.3", 2053 2053 "chai": "^4.3.7" 2054 2054 }, 2055 2055 "funding": { ··· 2057 2057 } 2058 2058 }, 2059 2059 "node_modules/@vitest/runner": { 2060 - "version": "0.34.2", 2061 - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-0.34.2.tgz", 2062 - "integrity": "sha512-8ydGPACVX5tK3Dl0SUwxfdg02h+togDNeQX3iXVFYgzF5odxvaou7HnquALFZkyVuYskoaHUOqOyOLpOEj5XTA==", 2060 + "version": "0.34.3", 2061 + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-0.34.3.tgz", 2062 + "integrity": "sha512-lYNq7N3vR57VMKMPLVvmJoiN4bqwzZ1euTW+XXYH5kzr3W/+xQG3b41xJn9ChJ3AhYOSoweu974S1V3qDcFESA==", 2063 2063 "dev": true, 2064 2064 "dependencies": { 2065 - "@vitest/utils": "0.34.2", 2065 + "@vitest/utils": "0.34.3", 2066 2066 "p-limit": "^4.0.0", 2067 2067 "pathe": "^1.1.1" 2068 2068 }, ··· 2098 2098 } 2099 2099 }, 2100 2100 "node_modules/@vitest/snapshot": { 2101 - "version": "0.34.2", 2102 - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-0.34.2.tgz", 2103 - "integrity": "sha512-qhQ+xy3u4mwwLxltS4Pd4SR+XHv4EajiTPNY3jkIBLUApE6/ce72neJPSUQZ7bL3EBuKI+NhvzhGj3n5baRQUQ==", 2101 + "version": "0.34.3", 2102 + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-0.34.3.tgz", 2103 + "integrity": "sha512-QyPaE15DQwbnIBp/yNJ8lbvXTZxS00kRly0kfFgAD5EYmCbYcA+1EEyRalc93M0gosL/xHeg3lKAClIXYpmUiQ==", 2104 2104 "dev": true, 2105 2105 "dependencies": { 2106 2106 "magic-string": "^0.30.1", ··· 2124 2124 } 2125 2125 }, 2126 2126 "node_modules/@vitest/spy": { 2127 - "version": "0.34.2", 2128 - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-0.34.2.tgz", 2129 - "integrity": "sha512-yd4L9OhfH6l0Av7iK3sPb3MykhtcRN5c5K5vm1nTbuN7gYn+yvUVVsyvzpHrjqS7EWqn9WsPJb7+0c3iuY60tA==", 2127 + "version": "0.34.3", 2128 + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-0.34.3.tgz", 2129 + "integrity": "sha512-N1V0RFQ6AI7CPgzBq9kzjRdPIgThC340DGjdKdPSE8r86aUSmeliTUgkTqLSgtEwWWsGfBQ+UetZWhK0BgJmkQ==", 2130 2130 "dev": true, 2131 2131 "dependencies": { 2132 2132 "tinyspy": "^2.1.1" ··· 2136 2136 } 2137 2137 }, 2138 2138 "node_modules/@vitest/utils": { 2139 - "version": "0.34.2", 2140 - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-0.34.2.tgz", 2141 - "integrity": "sha512-Lzw+kAsTPubhoQDp1uVAOP6DhNia1GMDsI9jgB0yMn+/nDaPieYQ88lKqz/gGjSHL4zwOItvpehec9OY+rS73w==", 2139 + "version": "0.34.3", 2140 + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-0.34.3.tgz", 2141 + "integrity": "sha512-kiSnzLG6m/tiT0XEl4U2H8JDBjFtwVlaE8I3QfGiMFR0QvnRDfYfdP3YvTBWM/6iJDAyaPY6yVQiCTUc7ZzTHA==", 2142 2142 "dev": true, 2143 2143 "dependencies": { 2144 2144 "diff-sequences": "^29.4.3", ··· 10735 10735 } 10736 10736 }, 10737 10737 "node_modules/vite-node": { 10738 - "version": "0.34.2", 10739 - "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.34.2.tgz", 10740 - "integrity": "sha512-JtW249Zm3FB+F7pQfH56uWSdlltCo1IOkZW5oHBzeQo0iX4jtC7o1t9aILMGd9kVekXBP2lfJBEQt9rBh07ebA==", 10738 + "version": "0.34.3", 10739 + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.34.3.tgz", 10740 + "integrity": "sha512-+0TzJf1g0tYXj6tR2vEyiA42OPq68QkRZCu/ERSo2PtsDJfBpDyEfuKbRvLmZqi/CgC7SCBtyC+WjTGNMRIaig==", 10741 10741 "dev": true, 10742 10742 "dependencies": { 10743 10743 "cac": "^6.7.14", ··· 11172 11172 } 11173 11173 }, 11174 11174 "node_modules/vitest": { 11175 - "version": "0.34.2", 11176 - "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.34.2.tgz", 11177 - "integrity": "sha512-WgaIvBbjsSYMq/oiMlXUI7KflELmzM43BEvkdC/8b5CAod4ryAiY2z8uR6Crbi5Pjnu5oOmhKa9sy7uk6paBxQ==", 11175 + "version": "0.34.3", 11176 + "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.34.3.tgz", 11177 + "integrity": "sha512-7+VA5Iw4S3USYk+qwPxHl8plCMhA5rtfwMjgoQXMT7rO5ldWcdsdo3U1QD289JgglGK4WeOzgoLTsGFu6VISyQ==", 11178 11178 "dev": true, 11179 11179 "dependencies": { 11180 11180 "@types/chai": "^4.3.5", 11181 11181 "@types/chai-subset": "^1.3.3", 11182 11182 "@types/node": "*", 11183 - "@vitest/expect": "0.34.2", 11184 - "@vitest/runner": "0.34.2", 11185 - "@vitest/snapshot": "0.34.2", 11186 - "@vitest/spy": "0.34.2", 11187 - "@vitest/utils": "0.34.2", 11183 + "@vitest/expect": "0.34.3", 11184 + "@vitest/runner": "0.34.3", 11185 + "@vitest/snapshot": "0.34.3", 11186 + "@vitest/spy": "0.34.3", 11187 + "@vitest/utils": "0.34.3", 11188 11188 "acorn": "^8.9.0", 11189 11189 "acorn-walk": "^8.2.0", 11190 11190 "cac": "^6.7.14", ··· 11199 11199 "tinybench": "^2.5.0", 11200 11200 "tinypool": "^0.7.0", 11201 11201 "vite": "^3.0.0 || ^4.0.0", 11202 - "vite-node": "0.34.2", 11202 + "vite-node": "0.34.3", 11203 11203 "why-is-node-running": "^2.2.2" 11204 11204 }, 11205 11205 "bin": {
+1 -1
package.json
··· 81 81 "svgo": "3.0.2", 82 82 "updates": "14.4.0", 83 83 "vite-string-plugin": "1.1.2", 84 - "vitest": "0.34.2" 84 + "vitest": "0.34.3" 85 85 }, 86 86 "browserslist": [ 87 87 "defaults",
+12 -7
web_src/js/utils.test.js
··· 133 133 expect(() => toAbsoluteUrl('path')).toThrowError('unsupported'); 134 134 }); 135 135 136 - const uint8array = (s) => new TextEncoder().encode(s); 137 136 test('encodeURLEncodedBase64, decodeURLEncodedBase64', () => { 137 + // TextEncoder is Node.js API while Uint8Array is jsdom API and their outputs are not 138 + // structurally comparable, so we convert to array to compare. The conversion can be 139 + // removed once https://github.com/jsdom/jsdom/issues/2524 is resolved. 140 + const encoder = new TextEncoder(); 141 + const uint8array = encoder.encode.bind(encoder); 142 + 138 143 expect(encodeURLEncodedBase64(uint8array('AA?'))).toEqual('QUE_'); // standard base64: "QUE/" 139 144 expect(encodeURLEncodedBase64(uint8array('AA~'))).toEqual('QUF-'); // standard base64: "QUF+" 140 145 141 - expect(decodeURLEncodedBase64('QUE/')).toEqual(uint8array('AA?')); 142 - expect(decodeURLEncodedBase64('QUF+')).toEqual(uint8array('AA~')); 143 - expect(decodeURLEncodedBase64('QUE_')).toEqual(uint8array('AA?')); 144 - expect(decodeURLEncodedBase64('QUF-')).toEqual(uint8array('AA~')); 146 + expect(Array.from(decodeURLEncodedBase64('QUE/'))).toEqual(Array.from(uint8array('AA?'))); 147 + expect(Array.from(decodeURLEncodedBase64('QUF+'))).toEqual(Array.from(uint8array('AA~'))); 148 + expect(Array.from(decodeURLEncodedBase64('QUE_'))).toEqual(Array.from(uint8array('AA?'))); 149 + expect(Array.from(decodeURLEncodedBase64('QUF-'))).toEqual(Array.from(uint8array('AA~'))); 145 150 146 151 expect(encodeURLEncodedBase64(uint8array('a'))).toEqual('YQ'); // standard base64: "YQ==" 147 - expect(decodeURLEncodedBase64('YQ')).toEqual(uint8array('a')); 148 - expect(decodeURLEncodedBase64('YQ==')).toEqual(uint8array('a')); 152 + expect(Array.from(decodeURLEncodedBase64('YQ'))).toEqual(Array.from(uint8array('a'))); 153 + expect(Array.from(decodeURLEncodedBase64('YQ=='))).toEqual(Array.from(uint8array('a'))); 149 154 });