mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-20 15:06:19 -05:00
build: uninstall Semantic UI
`semantic-ui-react`, `react-semantic-toasts-2` and `semantic-ui-offline` are
gone from package.json, the lockfile and node_modules -- 19 MB of dependencies
that nothing had imported since the migration finished.
Four things still referenced them and would have broken on uninstall. None was
caught by a build or by jest:
Four test files still ran `jest.mock('react-semantic-toasts-2', ...)` for
components that no longer use it. A jest.mock of a module that does not exist
throws, so the packages could not have come out without this.
`src/components/Download.cy.js` and `cypress/support/component.js` both
imported semantic.min.css. The support file now loads what the app loads --
index.css, the font and token stylesheets, and Mantine's.
The ratchet changes job rather than being deleted. An import of a missing module
fails loudly now, but three quieter mistakes would not: a `className="ui button"`
that styles nothing, a file reaching back through Theme.tsx, and someone
reinstalling a package to "just use one Semantic component". It asserts all
three, plus that package.json names nothing matching /semantic/i.
Two pre-existing problems in the cypress component harness surfaced while
checking the uninstall had not broken it, both fixed because that file had to be
edited anyway:
It imported `react-router-dom`, which is not installed -- this app is on
react-router v7. Dates to 5621d473, so the component suite has been
un-runnable since well before this migration.
Its mount helper supplied no MantineProvider, so every library component threw
-- the same gap test-utils.js had for jest.
The component specs now load and four pass; eleven assertions are still written
against markup from before they stopped running. Repairing those is its own
piece of work, deliberately not bundled in here. The e2e suite is unaffected:
43/43.
This commit is contained in:
parent
3c82291db3
commit
8ba73e64cd
9 changed files with 48 additions and 322 deletions
|
|
@ -1,6 +1,5 @@
|
|||
import React from 'react';
|
||||
import {ArchiveDownloadForm, ChannelDownloadForm, EditRSSDownloadForm} from './Download';
|
||||
import 'semantic-ui-offline/semantic.min.css';
|
||||
|
||||
describe('<ArchiveDownloadForm />', () => {
|
||||
beforeEach(() => {
|
||||
|
|
|
|||
|
|
@ -11,10 +11,6 @@ jest.mock('../../api', () => ({
|
|||
getBatchReorganizationStatus: jest.fn(),
|
||||
}));
|
||||
|
||||
// Mock react-semantic-toasts-2
|
||||
jest.mock('react-semantic-toasts-2', () => ({
|
||||
toast: jest.fn(),
|
||||
}));
|
||||
|
||||
// Mock the FileWorkerStatusContext
|
||||
jest.mock('../../contexts/FileWorkerStatusContext', () => ({
|
||||
|
|
|
|||
|
|
@ -11,10 +11,6 @@ jest.mock('../../api', () => ({
|
|||
getReorganizationStatus: jest.fn(),
|
||||
}));
|
||||
|
||||
// Mock react-semantic-toasts-2
|
||||
jest.mock('react-semantic-toasts-2', () => ({
|
||||
toast: jest.fn(),
|
||||
}));
|
||||
|
||||
// Mock the FileWorkerStatusContext - default mock returns inactive state
|
||||
jest.mock('../../contexts/FileWorkerStatusContext', () => ({
|
||||
|
|
|
|||
|
|
@ -9,10 +9,6 @@ jest.mock('../../api', () => ({
|
|||
deleteFileGroups: jest.fn(),
|
||||
}));
|
||||
|
||||
// Mock react-semantic-toasts-2
|
||||
jest.mock('react-semantic-toasts-2', () => ({
|
||||
toast: jest.fn(),
|
||||
}));
|
||||
|
||||
describe('ConflictResolutionModal', () => {
|
||||
const mockConflicts = [
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ jest.mock('../api/controller', () => ({
|
|||
getControllerStats: jest.fn().mockResolvedValue({}),
|
||||
}));
|
||||
|
||||
jest.mock('react-semantic-toasts-2', () => ({toast: jest.fn()}));
|
||||
|
||||
const controllerApi = require('../api/controller');
|
||||
|
||||
|
|
|
|||
|
|
@ -3,20 +3,20 @@ import path from 'path';
|
|||
import baseline from './semantic-baseline.json';
|
||||
|
||||
/*
|
||||
* A ratchet for the Semantic UI removal.
|
||||
* Semantic UI is gone, and this keeps it gone.
|
||||
*
|
||||
* semantic-baseline.json lists every file that still imports Semantic UI (or the
|
||||
* Semantic-based toast library). This test fails if a file not on that list
|
||||
* starts importing them, and asks for the list to shrink when a file stops.
|
||||
* It began as a ratchet: semantic-baseline.json listed the 75 files still importing
|
||||
* Semantic UI, the list only shrank, and adding a file to it failed the build. The list
|
||||
* reached zero, the three packages are uninstalled, and the baseline is now an empty
|
||||
* array kept only so a reintroduction has to delete a file rather than edit one.
|
||||
*
|
||||
* It replaces an ESLint rule deliberately: `no-restricted-imports` would either
|
||||
* print 75 warnings on every dev rebuild, or fail the build outright, and CI
|
||||
* already unsets CI= for the build step so warnings there guard nothing.
|
||||
* The assertions below are cheap and each one caught something real during the migration,
|
||||
* so they stay: an import would now fail to resolve, but a `className="ui button"` or a
|
||||
* reach back through Theme.tsx would not, and neither would reinstalling a package.
|
||||
*
|
||||
* The list has reached zero. The test stays as a guard rather than being deleted: it now
|
||||
* asserts that nothing imports Semantic UI, nothing calls its toast library, nothing leans
|
||||
* on its stylesheet, and no migrated file reaches back through Theme.tsx. It can go when
|
||||
* the packages themselves are uninstalled.
|
||||
* It is a test rather than an ESLint rule deliberately: `no-restricted-imports` would
|
||||
* either print dozens of warnings on every dev rebuild or fail the build outright, and CI
|
||||
* unsets CI= for its build step, so warnings there guard nothing.
|
||||
*/
|
||||
|
||||
const SRC = path.join(__dirname);
|
||||
|
|
@ -109,10 +109,26 @@ describe('Semantic UI removal', () => {
|
|||
expect(leaks).toEqual([]);
|
||||
});
|
||||
|
||||
it('reports how much of the migration is left', () => {
|
||||
// Not an assertion so much as a progress readout in the test output.
|
||||
const remaining = importers().length;
|
||||
expect(remaining).toBeLessThanOrEqual(baseline.length);
|
||||
console.log(`Semantic UI: ${remaining} files remaining to migrate.`);
|
||||
it('has no Semantic package installed', () => {
|
||||
/*
|
||||
* The three packages are uninstalled. An import of a missing module fails loudly,
|
||||
* so this guards the quieter mistake: someone reinstalling one -- to "just use a
|
||||
* Semantic component for this one thing" -- which would drag the whole library and
|
||||
* its 300kB stylesheet back into the bundle.
|
||||
*/
|
||||
const pkg = JSON.parse(
|
||||
fs.readFileSync(path.join(SRC, '..', 'package.json'), 'utf8'));
|
||||
const named = [...Object.keys(pkg.dependencies || {}),
|
||||
...Object.keys(pkg.devDependencies || {})]
|
||||
.filter(name => /semantic/i.test(name));
|
||||
|
||||
expect(named).toEqual([]);
|
||||
});
|
||||
|
||||
it('keeps the baseline empty', () => {
|
||||
// The migration is finished; the file stays as an empty list so that putting a
|
||||
// name back requires a deliberate edit.
|
||||
expect(baseline).toEqual([]);
|
||||
expect(importers()).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue