mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
`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.
151 lines
5.8 KiB
JavaScript
151 lines
5.8 KiB
JavaScript
import React from 'react';
|
|
import {ArchiveDownloadForm, ChannelDownloadForm, EditRSSDownloadForm} from './Download';
|
|
|
|
describe('<ArchiveDownloadForm />', () => {
|
|
beforeEach(() => {
|
|
cy.mountWithTags(<ArchiveDownloadForm/>);
|
|
});
|
|
|
|
it('displays error for invalid URL', () => {
|
|
cy.get('#urls_textarea').type('invalid-url').wait(500);
|
|
cy.get('#urls_textarea').should('have.attr', 'error');
|
|
});
|
|
|
|
it('enables download button for valid URL', () => {
|
|
cy.get('#urls_textarea').type('https://wrolpi.org').wait(500);
|
|
cy.get('#urls_textarea').should('not.have.attr', 'error');
|
|
cy.get('#download_form_download_button').should('be.visible').and('not.have.attr', 'disabled');
|
|
});
|
|
|
|
it('disables download button for invalid URL', () => {
|
|
cy.get('#urls_textarea').type('invalid-url').wait(500);
|
|
cy.get('#urls_textarea').should('have.attr', 'error');
|
|
cy.get('#download_form_download_button').should('be.visible').and('have.attr', 'disabled');
|
|
});
|
|
|
|
it('initially has download button disabled', () => {
|
|
cy.get('#download_form_download_button').should('be.visible').and('have.attr', 'disabled');
|
|
});
|
|
|
|
it('clears error when switching from invalid to valid URL', () => {
|
|
cy.get('#urls_textarea').type('invalid-url').wait(500);
|
|
cy.get('#urls_textarea').should('have.attr', 'error');
|
|
|
|
cy.get('#urls_textarea').clear();
|
|
cy.get('#urls_textarea').type('https://wrolpi.org').wait(500);
|
|
cy.get('#urls_textarea').should('not.have.attr', 'error');
|
|
});
|
|
});
|
|
|
|
describe('<ChannelDownloadForm/>', () => {
|
|
beforeEach(() => {
|
|
// Do not return directories for these tests.
|
|
cy.intercept('POST', '**/api/files/search_directories', {
|
|
statusCode: 200,
|
|
body: {
|
|
is_dir: true, channel_directories: [], domain_directories: [],
|
|
directories: [{path: "some directory", name: "some directory"}],
|
|
},
|
|
}).as('searchDirectories');
|
|
|
|
cy.mountWithTags(<ChannelDownloadForm/>);
|
|
});
|
|
|
|
it('displays error for invalid URL', () => {
|
|
cy.get('#url_input').type('invalid-url').wait(500);
|
|
cy.get('#url_input').should('have.attr', 'error');
|
|
});
|
|
|
|
it('can choose different options', () => {
|
|
cy.get('#download_frequency_selector').click()
|
|
.get('.item').contains('Once').click();
|
|
cy.get('#download_frequency_selector').click()
|
|
.get('.item').contains('Daily').click();
|
|
cy.get('#download_frequency_selector').click()
|
|
.get('.item').contains('180 Days').click();
|
|
});
|
|
});
|
|
|
|
const downloadersResponse = {
|
|
"downloaders": [{"name": "archive", "pretty_name": "Archive"}, {
|
|
"name": "video",
|
|
"pretty_name": "Videos"
|
|
}], "manager_disabled": true
|
|
};
|
|
|
|
describe('<EditRSSDownloadForm />', () => {
|
|
beforeEach(() => {
|
|
const download = {
|
|
id: 1,
|
|
destination: "destination directory",
|
|
downloader: "rss",
|
|
frequency: 604800,
|
|
next_download: "2024-11-24T16:34:21.014400+00:00",
|
|
settings: {
|
|
title_include: "included",
|
|
title_exclude: "excluded",
|
|
video_format: "mp4",
|
|
video_resolutions: [
|
|
"720p",
|
|
"480p",
|
|
"maximum"
|
|
]
|
|
},
|
|
sub_downloader: "video",
|
|
tag_names: ['Automotive'],
|
|
url: "https://www.youtube.com/feeds/videos.xml?channel_id=UC4t8bw1besFTyjW7ZBCOIrw"
|
|
};
|
|
cy.mountWithTags(<EditRSSDownloadForm download={download}/>);
|
|
cy.intercept('GET', '/api/downloaders', downloadersResponse).as('downloaders');
|
|
cy.intercept('POST', '**/api/files/search_directories', {
|
|
statusCode: 200,
|
|
body: {
|
|
is_dir: true, channel_directories: [], domain_directories: [],
|
|
directories: [{path: "some directory", name: "some directory"}],
|
|
},
|
|
}).as('searchDirectories');
|
|
|
|
});
|
|
|
|
it('can edit videos download', () => {
|
|
// Weekly frequency.
|
|
cy.get('#url_input').should('have.value',
|
|
'https://www.youtube.com/feeds/videos.xml?channel_id=UC4t8bw1besFTyjW7ZBCOIrw');
|
|
cy.get('div.divider.text').contains('Weekly');
|
|
cy.get('input[name="title_include"]').should('have.value', 'included');
|
|
cy.get('input[name="title_exclude"]').should('have.value', 'excluded');
|
|
cy.get('#destination_search_form').should('be.visible');
|
|
cy.get('div.ui.large.label').contains('Automotive').should('be.visible');
|
|
});
|
|
|
|
it('can submit videos download', () => {
|
|
cy.get('button[type="submit"]').should('be.visible');
|
|
|
|
cy.intercept('PUT', '/api/download/1', (req) => {
|
|
expect(req.body).to.deep.equal(JSON.stringify({
|
|
"destination": "destination directory",
|
|
"downloader": "rss",
|
|
"frequency": 604800,
|
|
"settings": {
|
|
"excluded_urls": null,
|
|
"title_exclude": "excluded",
|
|
"title_include": "included",
|
|
"video_resolutions": [
|
|
"720p",
|
|
"480p",
|
|
"maximum"
|
|
],
|
|
"video_format": "mp4",
|
|
"minimum_duration": null,
|
|
"maximum_duration": null
|
|
},
|
|
"sub_downloader": "video",
|
|
"tag_names": ["Automotive"],
|
|
"urls": ["https://www.youtube.com/feeds/videos.xml?channel_id=UC4t8bw1besFTyjW7ZBCOIrw"]
|
|
}));
|
|
req.reply({statusCode: 204});
|
|
}).as('downloadPut');
|
|
|
|
cy.get('button[type="submit"]').click();
|
|
});
|
|
});
|