|
96 | 96 | * so this file mirrors exactly what the gallery host registers, in the same |
97 | 97 | * order — several packages claim the same bare keyword (`chart`, `calendar`) |
98 | 98 | * and the last registration wins, so a reordered mirror would not be a mirror. |
99 | | - * The last case in this file reads the host and fails if the two lists drift. |
| 99 | + * The last case in this file read the host and failed if the two lists drifted. |
| 100 | + * |
| 101 | + * ⛔ objectstack#27145 deleted that host with the docs site (its |
| 102 | + * `registerCatalogBlocks.ts`, `SchemaThumbnail.tsx`, `InteractiveDemo.tsx` and |
| 103 | + * `galleryDataSource.ts`), and every host-parity case went with it. Where a |
| 104 | + * docblock below still says "the parity case", it is describing history: the |
| 105 | + * registration list and the fixture in this file are now the only copies. |
100 | 106 | * |
101 | 107 | * ## What is asserted, per entry |
102 | 108 | * |
|
128 | 134 | import { describe, it, expect, vi, beforeEach, afterEach, afterAll } from 'vitest'; |
129 | 135 | import { render, waitFor, cleanup } from '@testing-library/react'; |
130 | 136 | import '@object-ui/components'; |
131 | | -// Mirrors apps/site/app/components/registerCatalogBlocks.ts, in its order. |
| 137 | +// Mirrors the docs-site gallery host's registration list, in its order. The host |
| 138 | +// (`registerCatalogBlocks.ts`) was deleted with the site by objectstack#27145; |
| 139 | +// `HOST_PACKAGES` below is now the only copy. |
132 | 140 | import '@object-ui/plugin-dashboard'; |
133 | 141 | import '@object-ui/plugin-charts'; |
134 | 142 | import '@object-ui/plugin-calendar'; |
@@ -220,7 +228,11 @@ const ALL_DIAGNOSTICS = [UNKNOWN_COMPONENT, FAILED_TO_RENDER, DATASOURCE_REQUIRE |
220 | 228 | */ |
221 | 229 | const FORM_LOADING = 'Loading form…'; |
222 | 230 |
|
223 | | -/** The packages the gallery host must load, in the host's own order. */ |
| 231 | +/** |
| 232 | + * The packages the gallery host loaded, in the host's own order. The host left |
| 233 | + * the tree with the docs site (objectstack#27145), so its parity cases are gone |
| 234 | + * and this list is what the imports above are held to. |
| 235 | + */ |
224 | 236 | const HOST_PACKAGES = [ |
225 | 237 | '@object-ui/plugin-dashboard', |
226 | 238 | '@object-ui/plugin-charts', |
@@ -411,17 +423,6 @@ const galleryDataSource = { |
411 | 423 | delete: async () => true, |
412 | 424 | }; |
413 | 425 |
|
414 | | -/** The method names the host fixture must expose for the mirror to be one. */ |
415 | | -const GALLERY_DATA_SOURCE_METHODS = [ |
416 | | - 'queryDataset', |
417 | | - 'getObjectSchema', |
418 | | - 'find', |
419 | | - 'findOne', |
420 | | - 'create', |
421 | | - 'update', |
422 | | - 'delete', |
423 | | -]; |
424 | | - |
425 | 426 | /** The two wrapper elements this harness adds around the entry's own root. */ |
426 | 427 | const WRAPPER_ELEMENTS = 2; |
427 | 428 |
|
@@ -754,49 +755,6 @@ describe('objectui#4616 — every catalog entry renders in the docs gallery', () |
754 | 755 | }); |
755 | 756 | }, 120000); |
756 | 757 |
|
757 | | - /** |
758 | | - * HOST PARITY (source-text guard, deliberately not behavioural). |
759 | | - * |
760 | | - * Everything above mirrors the gallery: the same registration set, in the |
761 | | - * same order, with the same dataset-capable `dataSource`. It cannot mirror it |
762 | | - * by construction — `apps/**` is outside every root Vitest project — so |
763 | | - * deleting a package from the host would leave this file green while |
764 | | - * `/docs/guide/schema-catalog` went back to painting red panels. This case |
765 | | - * reads the host and pins what the sweep assumes about it. |
766 | | - */ |
767 | | - describe('the docs-site gallery host registers the same set', () => { |
768 | | - // Rooted at this file, never at the cwd — see `REPO_ROOT` above. |
769 | | - const siteDir = path.join(REPO_ROOT, 'apps/site/app/components'); |
770 | | - const read = (f: string) => fs.readFileSync(path.join(siteDir, f), 'utf8'); |
771 | | - |
772 | | - it('loads every package this pin loads, in this pin’s order', () => { |
773 | | - const source = read('registerCatalogBlocks.ts'); |
774 | | - const imported = [...source.matchAll(/^import\s+'(@object-ui\/[^']+)';$/gm)].map( |
775 | | - (m) => m[1], |
776 | | - ); |
777 | | - expect(imported).toEqual(HOST_PACKAGES); |
778 | | - }); |
779 | | - |
780 | | - it('is imported by the gallery thumbnail host', () => { |
781 | | - expect(read('SchemaThumbnail.tsx')).toMatch( |
782 | | - /^import\s+'\.\/registerCatalogBlocks';$/m, |
783 | | - ); |
784 | | - }); |
785 | | - |
786 | | - /** |
787 | | - * The objectui#4600 separation, restated because objectui#4616 is exactly |
788 | | - * the change that would tempt someone to collapse it: the per-page demo |
789 | | - * hosts opt into their plugins through `PluginLoader`, and importing this |
790 | | - * module from them would make every docs page carrying a demo load every |
791 | | - * graph in that list eagerly. |
792 | | - */ |
793 | | - it.each(['InteractiveDemo.tsx', 'LiveSplitDemo.tsx'])( |
794 | | - '%s still does NOT import it (PluginLoader stays lazy there)', |
795 | | - (host) => { |
796 | | - expect(read(host)).not.toContain('registerCatalogBlocks'); |
797 | | - }, |
798 | | - ); |
799 | | - }); |
800 | 758 | }); |
801 | 759 |
|
802 | 760 | /** |
@@ -1358,39 +1316,11 @@ describe('objectui#6025 — the gallery DECLARES the packages its entries need', |
1358 | 1316 | 'these packages register the types their own category’s entries author, and the ' + |
1359 | 1317 | 'gallery host does not name them. Whether the types resolve anyway through some ' + |
1360 | 1318 | 'other package’s component import is a different question and not this one — add ' + |
1361 | | - 'the side-effect import to `apps/site/app/components/registerCatalogBlocks.ts` and ' + |
1362 | | - 'mirror it in `HOST_PACKAGES`.', |
| 1319 | + 'the side-effect import at the top of this file and name it in `HOST_PACKAGES`.', |
1363 | 1320 | ).toEqual([]); |
1364 | 1321 | }); |
1365 | 1322 | }); |
1366 | 1323 |
|
1367 | | -/** |
1368 | | - * HOST PARITY for the fixture, same technique and same reason as the |
1369 | | - * registration-set parity above: the mirror at the top of this file is what |
1370 | | - * the assertions run against, so a host fixture that lost `find` would leave |
1371 | | - * this file green while the docs page went back to an empty view. |
1372 | | - */ |
1373 | | -describe('objectui#5113 — the docs-site hosts supply the same fixture', () => { |
1374 | | - const siteDir = path.join(REPO_ROOT, 'apps/site/app/components'); |
1375 | | - const read = (f: string) => fs.readFileSync(path.join(siteDir, f), 'utf8'); |
1376 | | - |
1377 | | - it('the host fixture exposes every method this mirror implements', () => { |
1378 | | - const source = read('galleryDataSource.ts'); |
1379 | | - const missing = GALLERY_DATA_SOURCE_METHODS.filter( |
1380 | | - (method) => !new RegExp(`\\basync ${method}\\s*\\(`).test(source), |
1381 | | - ); |
1382 | | - expect(missing).toEqual([]); |
1383 | | - }); |
1384 | | - |
1385 | | - it.each(['SchemaThumbnail.tsx', 'InteractiveDemo.tsx'])( |
1386 | | - '%s hands it to the renderer', |
1387 | | - (host) => { |
1388 | | - expect(read(host)).toMatch(/^import \{ galleryDataSource \} from '\.\/galleryDataSource';$/m); |
1389 | | - expect(read(host)).toContain('dataSource: galleryDataSource'); |
1390 | | - }, |
1391 | | - ); |
1392 | | -}); |
1393 | | - |
1394 | 1324 | /** |
1395 | 1325 | * objectui#6317 — every `select` field in the fixture declares the options its |
1396 | 1326 | * own rows use, and this mirror declares exactly what the host declares. |
@@ -1448,50 +1378,6 @@ function distinctRowValues(field: string): Set<string> { |
1448 | 1378 | return seen; |
1449 | 1379 | } |
1450 | 1380 |
|
1451 | | -/** |
1452 | | - * The host's `USERS_SCHEMA`, read off its source. `apps/**` is outside every |
1453 | | - * root Vitest project, which is the same constraint that makes this file a |
1454 | | - * mirror in the first place. Brace-matched rather than pattern-matched and then |
1455 | | - * JSON-ified, so an extraction that stops working fails LOUDLY here rather than |
1456 | | - * quietly comparing less than it claims to. |
1457 | | - */ |
1458 | | -function readHostUsersFields(source: string): Record<string, UsersFieldDecl> { |
1459 | | - const start = source.indexOf('const USERS_SCHEMA = {'); |
1460 | | - expect(start, 'the host fixture no longer declares `const USERS_SCHEMA = {`').toBeGreaterThan(-1); |
1461 | | - const open = source.indexOf('{', start); |
1462 | | - let depth = 0; |
1463 | | - let end = -1; |
1464 | | - for (let i = open; i < source.length; i++) { |
1465 | | - if (source[i] === '{') depth += 1; |
1466 | | - else if (source[i] === '}') { |
1467 | | - depth -= 1; |
1468 | | - if (depth === 0) { |
1469 | | - end = i; |
1470 | | - break; |
1471 | | - } |
1472 | | - } |
1473 | | - } |
1474 | | - expect(end, 'the host `USERS_SCHEMA` literal has unbalanced braces').toBeGreaterThan(-1); |
1475 | | - const json = source |
1476 | | - .slice(open, end + 1) |
1477 | | - .replace(/'/g, '"') |
1478 | | - .replace(/([{,[]\s*)([A-Za-z_$][A-Za-z0-9_$]*)\s*:/g, '$1"$2":') |
1479 | | - .replace(/,(\s*[}\]])/g, '$1'); |
1480 | | - let parsed: { fields?: Record<string, UsersFieldDecl> }; |
1481 | | - try { |
1482 | | - parsed = JSON.parse(json) as { fields?: Record<string, UsersFieldDecl> }; |
1483 | | - } catch (error) { |
1484 | | - throw new Error( |
1485 | | - 'the host `USERS_SCHEMA` is no longer a plain single-quoted literal, so this ' + |
1486 | | - 'parity case can no longer read it — a comment inside the literal, or an ' + |
1487 | | - 'apostrophe inside a string, would each do it. Fix the reader, not the pin.', |
1488 | | - { cause: error }, |
1489 | | - ); |
1490 | | - } |
1491 | | - expect(parsed.fields, 'the host `USERS_SCHEMA` declares no `fields`').toBeTruthy(); |
1492 | | - return parsed.fields as Record<string, UsersFieldDecl>; |
1493 | | -} |
1494 | | - |
1495 | 1381 | describe('objectui#6317 — a `select` field declares the options its rows use', () => { |
1496 | 1382 | const mirrorFields = USERS_SCHEMA.fields as Record<string, UsersFieldDecl>; |
1497 | 1383 | const selectFields = Object.entries(mirrorFields) |
@@ -1523,19 +1409,6 @@ describe('objectui#6317 — a `select` field declares the options its rows use', |
1523 | 1409 | ).toEqual([]); |
1524 | 1410 | }); |
1525 | 1411 |
|
1526 | | - it('the host fixture declares the SAME field surface, options included', () => { |
1527 | | - const hostSource = fs.readFileSync( |
1528 | | - path.join(REPO_ROOT, 'apps/site/app/components/galleryDataSource.ts'), |
1529 | | - 'utf8', |
1530 | | - ); |
1531 | | - expect( |
1532 | | - readHostUsersFields(hostSource), |
1533 | | - 'the host fixture and this mirror declare different `users` field surfaces. They ' + |
1534 | | - 'are ONE fixture in two files and have to move together: the host gained its ' + |
1535 | | - '`role` / `status` options in 4b0b12630 and this mirror did not follow for 330 ' + |
1536 | | - 'commits, with every case in this file green the whole time.', |
1537 | | - ).toEqual(mirrorFields); |
1538 | | - }); |
1539 | 1412 | }); |
1540 | 1413 |
|
1541 | 1414 | /** |
|
0 commit comments