wrolpi/app/cypress/e2e/domains/domains-list.cy.js
Roland e00f0439da
ui: the last of Semantic UI, in name and in dead CSS
The library has been uninstalled for some time, but the codebase still read as
though it were there: identifiers named after it, rules written against its
class names, and about 180 comments explaining a rule in terms of a thing that
is no longer installed.

Renamed, keeping the vocabulary the app actually uses: semanticUIColorMap ->
navColorHexMap, semanticColorNames -> paletteColorNames, semanticNames ->
iconNameAliases, semanticSizes -> sizeAliases, and SemanticUIColors ->
NavColors in wrolpi/schema.py, which is what validates nav_color on the way in.
ColorToSemanticHexColor had no callers at all and is gone.

The baseline ratchet has done its job -- the list reached zero, so the JSON is
deleted and the guard keeps only the checks with teeth: no package, no import,
no `className="ui "`, no toast library.  Its Theme.tsx check went with the
wrappers it was watching for.  It also asserts its own walk found files, so a
clean result cannot mean it scanned nothing.

Deleted from App.css: every rule requiring `.ui`, `.inverted`, `.segment` or
`.modal`, none of which any component has set since the stylesheet stopped
loading, plus the form skeletons, ui-alerts and progress-text rules that
nothing renders.  Two of them were doing harm rather than nothing: the drag
tints had a dark-theme variant under `.inverted` that stopped applying, leaving
15% of a fixed blue over a dark row, and now mix a token instead.

Two selectors naming markup that no longer exists were live bugs.  The file
browser's filter had `.ui.input.file-browser-filter`, so it rendered at the
browser default width on a bar laid out to give it 34em -- now qualified by its
container, because `.wrolpi-action-input` sets `width: 100%` at the same
specificity and is loaded later.  And SearchBox takes named props rather than a
rest spread, so the `id` DestinationForm hands it was dropped in silence and
the label it renders pointed at nothing; the download forms' Destination field
has had no associated label since the migration.

"Semantic roles" survives in four places, where it means what it says.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-08 18:05:54 -06:00

167 lines
6.5 KiB
JavaScript

describe('Domains List Page', () => {
beforeEach(() => {
// Mock the collections API response for domains
cy.intercept('GET', '/api/collections?kind=domain', {
statusCode: 200,
body: {
collections: [
{
id: 1,
domain: 'example.com',
archive_count: 42,
size: 1024000,
tag_name: 'News',
directory: '/media/archives/example.com',
can_be_tagged: true,
description: 'Example domain'
},
{
id: 2,
domain: 'test.org',
archive_count: 15,
size: 512000,
tag_name: null,
directory: null,
can_be_tagged: false,
description: null
}
],
totals: {collections: 2},
metadata: {
kind: 'domain',
columns: [
{key: 'domain', label: 'Domain', sortable: true},
{key: 'archive_count', label: 'Archives', sortable: true, align: 'right'},
{key: 'size', label: 'Size', sortable: true, align: 'right', format: 'bytes'},
{key: 'tag_name', label: 'Tag', sortable: true},
{key: 'actions', label: 'Manage', sortable: false, type: 'actions'}
],
fields: [
{key: 'directory', label: 'Directory', type: 'text', placeholder: 'Optional directory path'},
{key: 'tag_name', label: 'Tag', type: 'tag', placeholder: 'Select or create tag', depends_on: 'directory'},
{key: 'description', label: 'Description', type: 'textarea', placeholder: 'Optional description'}
],
routes: {
list: '/archives/domains',
edit: '/archives/domain/:id/edit',
search: '/archives'
},
messages: {
no_directory: 'Set a directory to enable tagging',
tag_will_move: 'Tagging will move files to a new directory'
}
}
}
}).as('getDomains');
// Visit the domains page
cy.visit('/archives/domains');
cy.wait('@getDomains');
});
it('displays domains page without errors', () => {
// DomainsPage doesn't have h1, check for the search input instead
cy.get('input[placeholder="Domain filter..."]').should('exist');
});
it('renders CollectionTable component', () => {
// Check that the table exists
cy.get('table').should('exist');
});
it('shows search input', () => {
cy.get('input[placeholder="Domain filter..."]').should('exist');
});
it('shows all domains from API', () => {
cy.get('table tbody tr').should('have.length', 2);
});
it('displays domain names', () => {
cy.get('table tbody tr').first().should('contain', 'example.com');
cy.get('table tbody tr').last().should('contain', 'test.org');
});
it('displays Edit buttons in Manage column', () => {
cy.get('table tbody tr').first().within(() => {
cy.get('a').contains('Edit').should('exist');
});
});
it('Edit control is a link to that domain\'s edit page', () => {
/*
* This used to assert the old `ui button secondary` classes. Framework class
* names say nothing a user can perceive and they broke the moment the button
* changed libraries, so it now checks what actually matters: the control is a real
* link, and it points at the edit route rather than relying on a click handler.
*/
cy.get('table tbody tr').first().within(() => {
cy.contains('a', 'Edit')
.should('have.attr', 'href')
.and('match', /\/archives\/domain\/\d+\/edit$/);
});
});
it('navigates to domain edit page when edit clicked', () => {
// Mock the edit page's API calls to prevent "Failed to fetch" errors
cy.intercept('GET', '/api/collections/1', {
statusCode: 200,
body: {
collection: {
id: 1,
domain: 'example.com',
directory: '/media/archives/example.com',
tag_name: 'News',
description: 'Example domain'
}
}
}).as('getDomain');
// Mock directory search to prevent errors
cy.intercept('POST', '/api/files/search_directories', {
statusCode: 200,
body: {is_dir: true, directories: [], channel_directories: [], domain_directories: []}
}).as('searchDirs');
cy.get('table tbody tr').first().within(() => {
cy.get('a').contains('Edit').click();
});
cy.url().should('include', '/archives/domain/1/edit');
});
it('filters domains with search', () => {
cy.get('input[placeholder="Domain filter..."]')
.type('example')
// Confirm the input itself stabilized before asserting downstream effects.
.should('have.value', 'example');
// The filter is driven by the URL query param; wait for the router to commit it.
cy.url().should('include', 'domain=example');
// Chain assertions so they retry together with the extended timeout
cy.get('table:visible tbody tr', {timeout: 10000})
.should('have.length', 1)
.and('contain', 'example.com');
});
it('shows empty message when no domains', () => {
cy.intercept('GET', '/api/collections?kind=domain', {
statusCode: 200,
body: {
collections: [],
totals: {collections: 0},
metadata: {
kind: 'domain',
columns: []
}
}
}).as('getEmptyDomains');
cy.visit('/archives/domains');
cy.wait('@getEmptyDomains');
cy.contains('No domains yet').should('exist');
});
it('does not show "New Domain" button (domains are auto-created)', () => {
cy.contains('button', 'New Domain').should('not.exist');
});
});