2024-11-02 15:14:02 -06:00
|
|
|
// ***********************************************************
|
|
|
|
|
// This example support/component.js is processed and
|
|
|
|
|
// loaded automatically before your test files.
|
|
|
|
|
//
|
|
|
|
|
// This is a great place to put global configuration and
|
|
|
|
|
// behavior that modifies Cypress.
|
|
|
|
|
//
|
|
|
|
|
// You can change the location of this file or turn off
|
|
|
|
|
// automatically serving support files with the
|
|
|
|
|
// 'supportFile' configuration option.
|
|
|
|
|
//
|
|
|
|
|
// You can read more here:
|
|
|
|
|
// https://on.cypress.io/configuration
|
|
|
|
|
// ***********************************************************
|
|
|
|
|
|
|
|
|
|
import './commands'
|
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.
2026-07-30 14:50:47 -06:00
|
|
|
// Component tests mount real components, so they need the same styles the app loads.
|
|
|
|
|
import '../../src/index.css';
|
|
|
|
|
import '../../src/themes/fonts.css';
|
|
|
|
|
import '../../src/themes/tokens.css';
|
|
|
|
|
import '@mantine/core/styles.css';
|
|
|
|
|
// react-router v7 ships these directly; `react-router-dom` is not installed.
|
|
|
|
|
import {MemoryRouter, Route, Routes} from "react-router";
|
2024-11-02 15:14:02 -06:00
|
|
|
import {QueryProvider} from "../../src/hooks/customHooks";
|
|
|
|
|
import {TagsProvider} from "../../src/Tags";
|
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.
2026-07-30 14:50:47 -06:00
|
|
|
import {MantineProvider} from "@mantine/core";
|
|
|
|
|
import {cssVariablesResolver, mantineTheme} from "../../src/themes/mantine";
|
ui: a browser layer for the library, and the .media reset that never applied
The PathInput overlap could not have been caught by jest -- jsdom computes no
layout -- so the only guard was a grep for one spelling of one mistake. This
adds the layer that can actually see it, and it found a real bug immediately.
ui-layout.cy.js mounts library components in a real browser through a new
cy.mountUI(), which supplies Mantine's provider and a stamped data-theme and
nothing else. That spartan setup is the point: these components read no
ambient state, so a spec can assert what jsdom cannot compute -- real geometry,
resolved custom properties, applied filters -- across all four themes.
It reproduces the leftSectionWidth='auto' overlap on purpose and asserts it
still overlaps, because a geometry check that has never gone red is
indistinguishable from one that cannot fail.
The bug it found: the rule resetting `filter` on leaf media inside a `.media`
wrapper scored (0,2,2) against the (0,3,1) rule it was correcting, so it lost
every time and never applied to anything. Every image inside a filtered
wrapper has been through the luminance matrix twice since that rule landed --
markedly darker than its surroundings, which is exactly what it was written to
prevent. tokens.test.js asserted only that the rule's text was present, and so
stayed green throughout; it now compares the two selectors' specificity, which
is computable without a browser and goes red on the old selector.
Three guards in ui.test.js keep the library mock-free by construction rather
than by habit: no jest.mock in its own tests, no fetch in any library file, and
no useContext outside the theme controls, whose job is to read the theme. All
three were verified red against planted violations.
959 jest tests, 14 new browser tests, clean cache-busted build.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 15:31:09 -06:00
|
|
|
import {MediaFilterDefs} from "../../src/themes/MediaFilterDefs";
|
2024-11-02 15:14:02 -06:00
|
|
|
import React from "react";
|
|
|
|
|
|
2024-11-28 10:00:42 -07:00
|
|
|
Cypress.on('uncaught:exception', (err, runnable) => {
|
|
|
|
|
if (err.message.includes('ChunkLoadError')) {
|
|
|
|
|
return false; // Ignore this error which happens after CircleCI tests.
|
|
|
|
|
}
|
|
|
|
|
// Otherwise, fail like normal
|
|
|
|
|
return true;
|
|
|
|
|
});
|
2024-11-02 15:14:02 -06:00
|
|
|
|
|
|
|
|
Cypress.Commands.add('mountWithRouter', (component, options) => {
|
|
|
|
|
options = options || {};
|
|
|
|
|
const initialEntries = options?.initialEntries || ['/'];
|
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.
2026-07-30 14:50:47 -06:00
|
|
|
/*
|
|
|
|
|
* MantineProvider, configured exactly as ThemeProvider configures it. Every component
|
|
|
|
|
* in src/components/ui renders Mantine internals and throws without it -- the same
|
|
|
|
|
* thing that had to be added to test-utils.js for jest.
|
|
|
|
|
*/
|
2024-11-02 15:14:02 -06:00
|
|
|
return cy.mount(
|
|
|
|
|
<MemoryRouter initialEntries={initialEntries}>
|
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.
2026-07-30 14:50:47 -06:00
|
|
|
<MantineProvider theme={mantineTheme} cssVariablesResolver={cssVariablesResolver}>
|
2024-11-02 15:14:02 -06:00
|
|
|
<QueryProvider>
|
|
|
|
|
<Routes>
|
|
|
|
|
<Route path='/videos/channels/new' element={component}/>
|
2025-12-05 18:26:36 -07:00
|
|
|
<Route path='/videos/channel/:channelId/edit' element={component}/>
|
2024-11-02 15:14:02 -06:00
|
|
|
<Route path='/videos/channels/:channelId' element={component}/>
|
|
|
|
|
<Route path='*' element={component}/>
|
|
|
|
|
</Routes>
|
|
|
|
|
</QueryProvider>
|
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.
2026-07-30 14:50:47 -06:00
|
|
|
</MantineProvider>
|
2024-11-02 15:14:02 -06:00
|
|
|
</MemoryRouter>,
|
|
|
|
|
options
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
ui: a browser layer for the library, and the .media reset that never applied
The PathInput overlap could not have been caught by jest -- jsdom computes no
layout -- so the only guard was a grep for one spelling of one mistake. This
adds the layer that can actually see it, and it found a real bug immediately.
ui-layout.cy.js mounts library components in a real browser through a new
cy.mountUI(), which supplies Mantine's provider and a stamped data-theme and
nothing else. That spartan setup is the point: these components read no
ambient state, so a spec can assert what jsdom cannot compute -- real geometry,
resolved custom properties, applied filters -- across all four themes.
It reproduces the leftSectionWidth='auto' overlap on purpose and asserts it
still overlaps, because a geometry check that has never gone red is
indistinguishable from one that cannot fail.
The bug it found: the rule resetting `filter` on leaf media inside a `.media`
wrapper scored (0,2,2) against the (0,3,1) rule it was correcting, so it lost
every time and never applied to anything. Every image inside a filtered
wrapper has been through the luminance matrix twice since that rule landed --
markedly darker than its surroundings, which is exactly what it was written to
prevent. tokens.test.js asserted only that the rule's text was present, and so
stayed green throughout; it now compares the two selectors' specificity, which
is computable without a browser and goes red on the old selector.
Three guards in ui.test.js keep the library mock-free by construction rather
than by habit: no jest.mock in its own tests, no fetch in any library file, and
no useContext outside the theme controls, whose job is to read the theme. All
three were verified red against planted violations.
959 jest tests, 14 new browser tests, clean cache-busted build.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 15:31:09 -06:00
|
|
|
/*
|
|
|
|
|
* Mount a component from src/components/ui with nothing but Mantine's provider and the
|
|
|
|
|
* theme stamped on <html> -- no router, no query client, no tag fixtures.
|
|
|
|
|
*
|
|
|
|
|
* That spartan setup is the whole point. These components take props and read no ambient
|
|
|
|
|
* state, so a real browser can render one in isolation, which is what lets a spec assert
|
|
|
|
|
* things jsdom cannot compute: whether two boxes overlap, whether text is clipped, whether
|
|
|
|
|
* a token actually resolved. The Settings page shipped five unreadable inputs because
|
|
|
|
|
* `padding-inline-start: auto` silently became zero, and no jsdom test could have seen it --
|
|
|
|
|
* getBoundingClientRect() returns zeros there.
|
|
|
|
|
*
|
|
|
|
|
* `theme` stamps data-theme the way ThemeProvider does; `mediaFilter` stamps
|
|
|
|
|
* data-media-filter and mounts the SVG filter definitions, since a filter referenced but
|
|
|
|
|
* never defined silently does nothing.
|
|
|
|
|
*/
|
|
|
|
|
Cypress.Commands.add('mountUI', (component, options = {}) => {
|
|
|
|
|
const {theme = 'light', mediaFilter, ...mountOptions} = options;
|
|
|
|
|
|
|
|
|
|
const html = document.documentElement;
|
|
|
|
|
html.dataset.theme = theme;
|
|
|
|
|
if (mediaFilter) html.dataset.mediaFilter = mediaFilter;
|
|
|
|
|
else delete html.dataset.mediaFilter;
|
|
|
|
|
|
|
|
|
|
return cy.mount(
|
|
|
|
|
<MantineProvider theme={mantineTheme} cssVariablesResolver={cssVariablesResolver}>
|
|
|
|
|
{mediaFilter ? <MediaFilterDefs/> : null}
|
|
|
|
|
{component}
|
|
|
|
|
</MantineProvider>,
|
|
|
|
|
mountOptions
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fail unless two elements are laid out side by side.
|
|
|
|
|
*
|
|
|
|
|
* Reads real geometry, so it catches an element painted over another regardless of how the
|
|
|
|
|
* overlap came about -- an invalid length, a collapsed flex row, a stale absolute position.
|
|
|
|
|
*/
|
|
|
|
|
Cypress.Commands.add('shouldNotOverlap', {prevSubject: false}, (firstSelector, secondSelector) => {
|
|
|
|
|
cy.get(firstSelector).then(($first) => {
|
|
|
|
|
cy.get(secondSelector).then(($second) => {
|
|
|
|
|
const a = $first[0].getBoundingClientRect();
|
|
|
|
|
const b = $second[0].getBoundingClientRect();
|
ui: name the directory fields, announce their help text, let long prefixes shrink
Greptile's three findings on #590, all confirmed real before fixing, and each one
verified red against the original code afterwards.
P1, the directory fields had no accessible names. All five rendered their
visible label as a bare <label> with no htmlFor while passing no label prop, so
their inputs had a description ("/media/wrolpi/") and no name at all -- five
fields in one grid, holding similar relative paths, indistinguishable to a
screen reader. The labels now belong to the inputs, InfoPopup content and all.
This predates PathInput; the old TextInput call sites had the same gap, and
moving to a component that supports labels is what made it fixable.
P1, description and error were rendered but never referenced. aria-describedby
pointed only at the prefix, so the help text listing the variables a path
accepts, and the reason a path was rejected, were both invisible to assistive
technology. Both are now in the description, and an errored field reports
aria-invalid.
P2 was worse than reported: at `flex: none` a long prefix took the entire row
and left the input eighteen pixels wide -- not "consumes the editable area" but
a field nobody can type in. The media directory is whatever the API reports, so
its length was never ours to assume. The prefix now shrinks and ellipsises at
half the control, with the full path on `title` and in the accessible
description.
The naming fault could not have been caught where the others were. jsdom cannot
see layout, and the Settings page needs enough mocking that it had no test at
all -- which is why these five fields were uncovered when they broke. The new
e2e spec intercepts the API and lets the real page render, so it measures the
names and the geometry a user actually gets. Reverting one field to a bare
label fails it; a long prefix fails the browser spec at 18px.
962 jest, 15 browser component, 46 e2e, clean cache-busted build, tsc clean.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 15:46:54 -06:00
|
|
|
const overlapsHorizontally = (a.right > b.left + 0.5) && (b.right > a.left + 0.5);
|
|
|
|
|
const overlapsVertically = (a.bottom > b.top + 0.5) && (b.bottom > a.top + 0.5);
|
|
|
|
|
const overlaps = overlapsHorizontally && overlapsVertically;
|
ui: a browser layer for the library, and the .media reset that never applied
The PathInput overlap could not have been caught by jest -- jsdom computes no
layout -- so the only guard was a grep for one spelling of one mistake. This
adds the layer that can actually see it, and it found a real bug immediately.
ui-layout.cy.js mounts library components in a real browser through a new
cy.mountUI(), which supplies Mantine's provider and a stamped data-theme and
nothing else. That spartan setup is the point: these components read no
ambient state, so a spec can assert what jsdom cannot compute -- real geometry,
resolved custom properties, applied filters -- across all four themes.
It reproduces the leftSectionWidth='auto' overlap on purpose and asserts it
still overlaps, because a geometry check that has never gone red is
indistinguishable from one that cannot fail.
The bug it found: the rule resetting `filter` on leaf media inside a `.media`
wrapper scored (0,2,2) against the (0,3,1) rule it was correcting, so it lost
every time and never applied to anything. Every image inside a filtered
wrapper has been through the luminance matrix twice since that rule landed --
markedly darker than its surroundings, which is exactly what it was written to
prevent. tokens.test.js asserted only that the rule's text was present, and so
stayed green throughout; it now compares the two selectors' specificity, which
is computable without a browser and goes red on the old selector.
Three guards in ui.test.js keep the library mock-free by construction rather
than by habit: no jest.mock in its own tests, no fetch in any library file, and
no useContext outside the theme controls, whose job is to read the theme. All
three were verified red against planted violations.
959 jest tests, 14 new browser tests, clean cache-busted build.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 15:31:09 -06:00
|
|
|
expect(
|
|
|
|
|
overlaps,
|
|
|
|
|
`${firstSelector} [${a.left}, ${a.right}] must not overlap `
|
|
|
|
|
+ `${secondSelector} [${b.left}, ${b.right}]`,
|
|
|
|
|
).to.equal(false);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2024-11-02 15:14:02 -06:00
|
|
|
Cypress.Commands.add('mountWithTags', (component, options) => {
|
|
|
|
|
cy.fixture('tagsMock.json').then((mockTags) => {
|
|
|
|
|
cy.intercept('GET', '**/api/tag', {
|
|
|
|
|
statusCode: 200,
|
|
|
|
|
body: mockTags
|
|
|
|
|
}).as('getTags');
|
|
|
|
|
});
|
|
|
|
|
return cy.mountWithRouter(
|
|
|
|
|
<TagsProvider>
|
|
|
|
|
{component}
|
|
|
|
|
</TagsProvider>,
|
|
|
|
|
options
|
|
|
|
|
);
|
|
|
|
|
});
|