Creating a new Collection model for use in organizing FileGroups.

Replacing Channels and Domains with Collection.

Moving downloading relationships from Channel to Collection.

Created domains.yaml config to manage tagged domain collections.

Adding turn-key upgrade solution in the UI.
This commit is contained in:
Roland 2025-10-29 22:16:33 -06:00
parent 1f7b1c8744
commit 4fae4ae1b4
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
115 changed files with 13309 additions and 986 deletions

View file

@ -0,0 +1,270 @@
describe('Domain Editing Workflow', () => {
beforeEach(() => {
// Suppress uncaught exceptions from the application (API errors are thrown as unhandled rejections)
cy.on('uncaught:exception', (err) => {
// Return false to prevent Cypress from failing the test
// These are expected API errors in error handling tests
return false;
});
// Mock directory search endpoint - DirectorySearch component makes this call automatically
cy.intercept('POST', '/api/files/search_directories', {
statusCode: 200,
body: {is_dir: true, directories: [], channel_directories: [], domain_directories: []}
}).as('searchDirectories');
// Mock tags endpoint - needed for TagsSelector component
cy.intercept('GET', '/api/tags', {
statusCode: 200,
body: {
tags: [
{id: 1, name: 'News', color: '#ff0000'},
{id: 2, name: 'Tech', color: '#00ff00'}
]
}
}).as('getTags');
// Mock the collections list 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: null,
directory: null,
can_be_tagged: false,
description: 'Example domain'
}
],
totals: {collections: 1},
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: '/archive/domains',
edit: '/archive/domain/:id/edit',
search: '/archive',
},
}
}
}).as('getDomains');
});
it('completes full edit workflow: add directory and tag', () => {
// Mock collection details endpoint BEFORE navigation
cy.intercept('GET', '/api/collections/1', {
statusCode: 200,
body: {
collection: {
id: 1,
domain: 'example.com',
directory: '',
tag_name: null,
description: '',
can_be_tagged: false,
archive_count: 42,
size: 1024000
}
}
}).as('getDomain');
// Start at domains list
cy.visit('/archive/domains');
cy.wait('@getDomains');
// Click edit on first domain
cy.get('table tbody tr').first().within(() => {
cy.contains('Edit').click();
});
// Should navigate to edit page
cy.url().should('include', '/archive/domain/1/edit');
cy.wait('@getDomain');
// Page should load with domain name
cy.contains('h1', 'example.com').should('exist');
// Set directory - DirectorySearch component uses input inside field
cy.contains('label', 'Directory').parent().find('input').clear().type('archive/example.com');
// Set description - Semantic UI TextArea
cy.contains('label', 'Description').parent().find('textarea').clear().type('Updated example domain');
// Mock tags endpoint
cy.intercept('GET', '/api/tags', {
statusCode: 200,
body: {
tags: [
{id: 1, name: 'News', color: '#ff0000'},
{id: 2, name: 'Tech', color: '#00ff00'}
]
}
}).as('getTags');
// Tag selector should now be enabled (because directory is set)
// This depends on the actual implementation of CollectionEditForm
// Mock update endpoint
cy.intercept('PUT', '/api/collections/1', {
statusCode: 200,
body: {
success: true,
collection: {
id: 1,
name: 'example.com',
directory: 'archive/example.com',
tag_name: null,
description: 'Updated example domain',
can_be_tagged: true,
}
}
}).as('updateDomain');
// Save changes
cy.contains('button', 'Save').click();
cy.wait('@updateDomain');
// Should show success toast and stay on edit page (page refreshes data after save)
cy.contains('Domain Updated').should('be.visible');
cy.url().should('include', '/archive/domain/1/edit');
});
it('shows validation errors for invalid data', () => {
// Mock domain details
cy.intercept('GET', '/api/collections/1', {
statusCode: 200,
body: {
collection: {
id: 1,
domain: 'example.com',
directory: 'archive/example.com',
tag_name: null,
description: 'Example domain',
can_be_tagged: true,
archive_count: 42,
size: 1024000
}
}
}).as('getDomain');
cy.visit('/archive/domain/1/edit');
cy.wait('@getDomain');
// Try to save with invalid directory
cy.intercept('PUT', '/api/collections/1', {
statusCode: 400,
body: {
error: 'Invalid directory path',
cause: {
code: 'INVALID_DIRECTORY'
}
}
}).as('invalidUpdate');
cy.contains('label', 'Directory').parent().find('input').clear().type('/invalid/absolute/path');
cy.contains('button', 'Save').click();
cy.wait('@invalidUpdate');
// Should show error message
cy.contains('Invalid directory path').should('be.visible');
// Should stay on edit page
cy.url().should('include', '/edit');
});
it('allows navigating back without saving using Back button', () => {
cy.intercept('GET', '/api/collections/1', {
statusCode: 200,
body: {
collection: {
id: 1,
domain: 'example.com',
directory: '',
tag_name: null,
description: 'Example domain',
can_be_tagged: false,
archive_count: 42,
size: 1024000
}
}
}).as('getDomain');
// Mock PUT endpoint but don't expect it to be called
cy.intercept('PUT', '/api/collections/1', {
statusCode: 200,
body: {success: true, domain: {}}
}).as('updateDomain');
cy.visit('/archive/domain/1/edit');
cy.wait('@getDomain');
// Make some changes
cy.contains('label', 'Description').parent().find('textarea').clear().type('Changed description');
// Click Back button (the page uses BackButton, not Cancel)
cy.contains('button', 'Back').click();
// Should navigate back without saving
// Note: Since we don't have browser history in test, we just verify no save was made
cy.get('@updateDomain.all').should('have.length', 0);
});
it('shows form after domain data loads', () => {
cy.intercept('GET', '/api/collections/1', {
statusCode: 200,
body: {
collection: {
id: 1,
domain: 'example.com',
directory: null,
tag_name: null,
description: 'Example domain',
can_be_tagged: false
}
}
}).as('getDomain');
cy.visit('/archive/domain/1/edit');
cy.wait('@getDomain');
// Form should be visible with domain name in title
cy.contains('h1', 'example.com').should('exist');
// Form fields should be present
cy.contains('label', 'Directory').should('exist');
cy.contains('label', 'Description').should('exist');
});
it('handles 404 when domain not found', () => {
cy.intercept('GET', '/api/collections/999', {
statusCode: 404,
body: {
error: 'Domain collection with ID 999 not found'
}
}).as('domainNotFound');
cy.visit('/archive/domain/999/edit');
cy.wait('@domainNotFound');
// Should show error message
cy.contains('not found').should('be.visible');
});
});

View file

@ -0,0 +1,154 @@
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: '/archive/domains',
edit: '/archive/domain/:id/edit',
search: '/archive'
},
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('/archive/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 button has correct styling', () => {
cy.get('table tbody tr').first().within(() => {
cy.get('a').contains('Edit').should('have.class', 'ui');
cy.get('a').contains('Edit').should('have.class', 'button');
cy.get('a').contains('Edit').should('have.class', 'secondary');
});
});
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', '/archive/domain/1/edit');
});
it('filters domains with search', () => {
cy.get('input[placeholder="Domain filter..."]').type('example');
cy.get('table tbody tr').should('have.length', 1);
cy.get('table tbody tr').should('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('/archive/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');
});
});

View file

@ -0,0 +1,299 @@
describe('DirectorySearch Integration Tests', () => {
const mockSearchResponse = {
is_dir: false,
directories: [
{path: 'videos/nature'},
{path: 'videos/tech'},
{path: 'videos/cooking'}
],
channel_directories: [
{path: 'videos/channels/news', name: 'News Channel'},
{path: 'videos/channels/tech', name: 'Tech Reviews'}
],
domain_directories: [
{path: 'archive/example.com', domain: 'example.com'},
{path: 'archive/test.org', domain: 'test.org'}
]
};
const mockEmptyResponse = {
is_dir: false,
directories: [],
channel_directories: [],
domain_directories: []
};
const mockExistingDirResponse = {
is_dir: true,
directories: [
{path: 'videos/nature/wildlife'},
{path: 'videos/nature/ocean'}
],
channel_directories: [],
domain_directories: []
};
beforeEach(() => {
// Mock the directory search API
cy.intercept('POST', '/api/files/search_directories', (req) => {
const {path} = req.body;
if (path === 'videos') {
req.reply({statusCode: 200, body: mockSearchResponse});
} else if (path === 'empty') {
req.reply({statusCode: 200, body: mockEmptyResponse});
} else if (path === 'videos/nature') {
req.reply({statusCode: 200, body: mockExistingDirResponse});
} else {
req.reply({statusCode: 200, body: mockSearchResponse});
}
}).as('searchDirectories');
});
context('Standalone DirectorySearch Behavior', () => {
beforeEach(() => {
// Visit a page with DirectorySearch (using domain edit as example)
cy.intercept('GET', '/api/collections/1', {
statusCode: 200,
body: {
collection: {
id: 1,
name: 'example.com',
kind: 'domain',
directory: '',
description: '',
tag_name: null
}
}
}).as('getDomain');
cy.intercept('GET', '/api/collections?kind=domain', {
statusCode: 200,
body: {
collections: [],
totals: {collections: 0},
metadata: {
kind: 'domain',
columns: [],
fields: [
{key: 'directory', label: 'Directory', type: 'text', required: false}
],
routes: {},
messages: {}
}
}
}).as('getMetadata');
cy.visit('/archive/domain/1/edit');
cy.wait('@getDomain');
cy.wait('@getMetadata');
});
it('types in search box and sees results', () => {
// Find the directory input
cy.contains('label', 'Directory')
.parent()
.find('input')
.type('videos');
cy.wait('@searchDirectories');
// Should see results in dropdown
cy.contains('videos/nature').should('be.visible');
cy.contains('videos/tech').should('be.visible');
});
it('clicks result and value updates', () => {
cy.contains('label', 'Directory')
.parent()
.find('input')
.type('videos');
cy.wait('@searchDirectories');
// Click a result
cy.contains('videos/nature').click();
// Input should show selected value
cy.contains('label', 'Directory')
.parent()
.find('input')
.should('have.value', 'videos/nature');
});
it('categories are visually distinct', () => {
cy.contains('label', 'Directory')
.parent()
.find('input')
.type('videos');
cy.wait('@searchDirectories');
// Check that categories exist
cy.contains('Directories').should('be.visible');
cy.contains('Channels').should('be.visible');
cy.contains('Domains').should('be.visible');
});
it('result descriptions appear correctly', () => {
cy.contains('label', 'Directory')
.parent()
.find('input')
.type('videos');
cy.wait('@searchDirectories');
// Channel should show name as description
cy.contains('News Channel').should('be.visible');
// Domain should show domain as description
cy.contains('example.com').should('be.visible');
});
it('shows "New Directory" for new paths', () => {
cy.contains('label', 'Directory')
.parent()
.find('input')
.type('empty');
cy.wait('@searchDirectories');
// Should show "New Directory" option
cy.contains('New Directory').should('be.visible');
});
});
context('DestinationForm Workflow', () => {
beforeEach(() => {
// Set up domain edit page as a form with DestinationForm
cy.intercept('GET', '/api/collections/2', {
statusCode: 200,
body: {
collection: {
id: 2,
name: 'test.com',
kind: 'domain',
directory: 'archive/test.com',
description: '',
tag_name: null
}
}
}).as('getDomain');
cy.intercept('GET', '/api/collections?kind=domain', {
statusCode: 200,
body: {
collections: [],
totals: {collections: 0},
metadata: {
kind: 'domain',
columns: [],
fields: [
{key: 'directory', label: 'Directory', type: 'text', required: true}
],
routes: {},
messages: {}
}
}
}).as('getMetadata');
cy.visit('/archive/domain/2/edit');
cy.wait('@getDomain');
cy.wait('@getMetadata');
});
it('starts with existing directory value', () => {
cy.contains('label', 'Directory')
.parent()
.find('input')
.should('have.value', 'archive/test.com');
});
it('types partial path and sees suggestions', () => {
cy.contains('label', 'Directory')
.parent()
.find('input')
.clear()
.type('videos');
cy.wait('@searchDirectories');
// Should see suggestions
cy.contains('videos/nature').should('be.visible');
});
it('selects channel directory and form updates', () => {
cy.contains('label', 'Directory')
.parent()
.find('input')
.clear()
.type('videos');
cy.wait('@searchDirectories');
// Select a channel directory
cy.contains('News Channel').click();
// Form should update
cy.contains('label', 'Directory')
.parent()
.find('input')
.should('have.value', 'videos/channels/news');
});
});
context('Real-World Scenarios', () => {
it('handles API returning empty results', () => {
cy.intercept('GET', '/api/collections/3', {
statusCode: 200,
body: {
collection: {
id: 3,
name: 'empty.com',
kind: 'domain',
directory: '',
description: '',
tag_name: null
}
}
}).as('getDomain');
cy.intercept('GET', '/api/collections?kind=domain', {
statusCode: 200,
body: {
collections: [],
totals: {collections: 0},
metadata: {
kind: 'domain',
columns: [],
fields: [
{key: 'directory', label: 'Directory', type: 'text', required: false}
],
routes: {},
messages: {}
}
}
}).as('getMetadata');
cy.visit('/archive/domain/3/edit');
cy.wait('@getDomain');
cy.wait('@getMetadata');
// Type path that returns empty results
cy.contains('label', 'Directory')
.parent()
.find('input')
.type('empty');
cy.wait('@searchDirectories');
// Should show "New Directory" option
cy.contains('New Directory').should('be.visible');
});
});
});

View file

@ -0,0 +1,63 @@
{
"collections": [
{
"id": 1,
"name": "My Tech Channel",
"video_count": 100,
"size": 5000000000,
"tag_name": "Tech",
"directory": "videos/channels/tech",
"download_frequency": "daily",
"url": "https://youtube.com/c/tech",
"rss_url": "https://youtube.com/feeds/tech"
},
{
"id": 2,
"name": "News Channel",
"video_count": 50,
"size": 2500000000,
"tag_name": "News",
"directory": "videos/channels/news",
"download_frequency": "weekly",
"url": "https://youtube.com/c/news",
"rss_url": null
},
{
"id": 3,
"name": "Science Channel",
"video_count": 75,
"size": 3750000000,
"tag_name": null,
"directory": "videos/channels/science",
"download_frequency": null,
"url": null,
"rss_url": null
}
],
"totals": {
"channels": 3
},
"metadata": {
"kind": "channel",
"columns": [
{"key": "name", "label": "Name", "sortable": true},
{"key": "tag_name", "label": "Tag", "sortable": true},
{"key": "video_count", "label": "Videos", "sortable": true},
{"key": "download_frequency", "label": "Download Frequency", "sortable": true},
{"key": "size", "label": "Size", "sortable": true, "format": "bytes"},
{"key": "actions", "label": "Manage", "sortable": false, "type": "actions"}
],
"fields": [
{"key": "name", "label": "Channel Name", "type": "text", "required": true},
{"key": "directory", "label": "Directory", "type": "path", "required": true},
{"key": "url", "label": "URL", "type": "url", "optional": true},
{"key": "tag_name", "label": "Tag", "type": "tag", "optional": true},
{"key": "download_missing_data", "label": "Download Missing Data", "type": "boolean", "optional": true}
],
"routes": {
"list": "/videos/channels",
"edit": "/videos/channel/:id/edit",
"search": "/videos/channel/:id/video"
}
}
}

View file

@ -0,0 +1,62 @@
{
"collections": [
{
"id": 1,
"domain": "example.com",
"archive_count": 42,
"size": 1024000,
"tag_name": "News",
"directory": "archive/example.com",
"can_be_tagged": true,
"description": "News from Example.com"
},
{
"id": 2,
"domain": "test.org",
"archive_count": 15,
"size": 512000,
"tag_name": null,
"directory": null,
"can_be_tagged": false,
"description": "Test archives"
},
{
"id": 3,
"domain": "demo.net",
"archive_count": 8,
"size": 256000,
"tag_name": "Tech",
"directory": "archive/demo.net",
"can_be_tagged": true,
"description": "Tech demos"
}
],
"totals": {
"domains": 3
},
"metadata": {
"kind": "domain",
"columns": [
{"key": "domain", "label": "Domain", "sortable": true},
{"key": "archive_count", "label": "URLs", "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": "/archive/domains",
"edit": "/archive/domain/:id/edit",
"search": "/archive",
"searchParam": "domain"
},
"messages": {
"no_directory": "Set a directory to enable tagging",
"tag_will_move": "Tagging will move files to a new directory"
}
}
}

View file

@ -0,0 +1,9 @@
// ***********************************************************
// This file is used to load the support and commands for e2e tests
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')