Files
compiler-explorer/test/url-serialization.ts
Matt Godbolt 53c7dd328b Configure Biome import organiser with grouped imports (#8431)
Enable Biome's `organizeImports` with groups matching the original
ESLint `import/order` configuration:

1. **Node builtins** (`node:fs`, `path`, etc.)
2. *(blank line)*
3. **Third-party packages** (`express`, `@sentry/node`, etc.)
4. *(blank line)*
5. **Local/relative imports** (`../foo.js`, `./bar.js`, aliases)

This resolves the inconsistency where Biome wasn't enforcing import
grouping, meaning new files would lose the blank-line separation that
the old ESLint config enforced.

### Impact
- **354 files** updated out of 738 checked (~48%)
- **+188 / -240 lines** (net -52) — almost entirely single blank line
additions/removals between import groups
- No import reordering; purely group separator consistency

Fixes #7373

🤖 Generated by LLM (Claude, via OpenClaw)
2026-02-01 20:50:46 -06:00

98 lines
3.4 KiB
TypeScript

import {describe, expect, it} from 'vitest';
import * as urlSerialization from '../shared/url-serialization.js';
describe('URL Serialization', () => {
it('should serialise and deserialise a simple state', () => {
const state = {
content: [
{
type: 'row',
content: [
{
type: 'component',
componentName: 'codeEditor',
componentState: {
id: 1,
lang: 'c++',
},
},
],
},
],
};
const serialized = urlSerialization.serialiseState(state);
expect(serialized).toBeTruthy();
expect(typeof serialized).toBe('string');
const deserialized = urlSerialization.deserialiseState(serialized);
expect(deserialized).toBeTruthy();
expect(deserialized.version).toBe(4);
expect(deserialized.content).toEqual(state.content);
});
it('should compress large states when beneficial', () => {
const state = {
content: [
{
type: 'row',
content: Array.from({length: 50}, (_, i) => ({
type: 'component',
componentName: 'codeEditor',
componentState: {
id: i,
lang: 'c++',
source: 'int main() { return 0; }',
},
})),
},
],
};
const serialized = urlSerialization.serialiseState(state);
// Compressed format contains {z: ...} which rison-encodes to contain 'z:'
// This test just verifies the state serializes successfully
expect(serialized).toBeTruthy();
expect(typeof serialized).toBe('string');
expect(serialized.length).toBeGreaterThan(0);
// Verify it can be deserialized
const deserialized = urlSerialization.deserialiseState(serialized);
expect(deserialized.content).toHaveLength(1);
expect(deserialized.content[0].content).toHaveLength(50);
});
it('should handle round-trip encoding correctly', () => {
const state = {
content: [
{
type: 'column',
content: [
{
type: 'stack',
content: [
{
type: 'component',
componentName: 'compiler',
componentState: {
id: 1,
compiler: 'g132',
},
},
],
},
],
},
],
};
const hash1 = urlSerialization.serialiseState(state);
const restored = urlSerialization.deserialiseState(hash1);
const hash2 = urlSerialization.serialiseState(restored);
// Round-trip should produce identical hash
expect(hash2).toBe(hash1);
});
});