/* * Test Module: Bundle Tag Filtering * Tests scenario 6 */ 'use strict'; const utils = require('../utils.js').LinkdingSyncTests; const SCENARIO_NAME = 'Bundle Tag Filtering Tests'; // Test 7: Bundle Tag Filtering async function test7_BundleTagFiltering() { console.log('\n=== Test 7: Bundle Tag Filtering ==='); console.log('Purpose: Verify if bundle tags filter bookmarks properly'); try { utils.SessionManager.setContext( CONFIG.serverUrl, CONFIG.workApiKey, CONFIG.workUser, CONFIG.workBundle ); const testUrl = 'https://bundle-filter.example.com'; // Create with work bundle tag const bookmark = await utils.Helpers.createBookmark(testUrl, { title: 'Bundle Filter Test', path: 'Test/Path', notes: 'Work bundle tag' }); console.log(` Bookmark created: ID=${bookmark.id}`); // Query by work bundle tag const workBundleResponse = await utils.Helpers.getAllBookmarks(); console.log(` Work bundle has ${workBundleResponse.filter(b => b.testId).length} test bookmarks`); // Check if bookmark is in work bundle const workFiltered = workBundleResponse.filter(b => b.testId && b.notes?.testId); if (workFiltered.length > 0) { utils.Formatters.consoleResult('Test 7', 'PASS', 'Bundle tags filter bookmarks'); console.log(' → Work bundle has work-tagged bookmarks'); return { pass: true, filtered: true }; } else { utils.Formatters.consoleResult('Test 7', 'WARN', 'Bundle filtering unclear'); console.log(' → May need to use tags for filtering'); return { pass: null, filtered: null }; } } catch (error) { utils.Formatters.consoleResult('Test 7', 'FAIL', error.message); throw error; } } // Test 8: Bundle-Specific Sync async function test8_BundleSpecificSync() { console.log('\n=== Test 8: Bundle-Specific Sync ==='); console.log('Purpose: Verify sync behavior with different bundles'); try { utils.SessionManager.setContext( CONFIG.serverUrl, CONFIG.workApiKey, CONFIG.workUser, CONFIG.workBundle ); const workUrl = 'https://bundle-specific-work.example.com'; const personalUrl = 'https://bundle-specific-personal.example.com'; // Create work bookmark const workBookmark = await utils.Helpers.createBookmark(workUrl, { title: 'Bundle Specific - Work', path: 'Work/Bundle', notes: 'Work bundle content' }); console.log(` Work bookmark: ID=${workBookmark.id}`); // Create personal bookmark utils.SessionManager.setContext( CONFIG.serverUrl, CONFIG.personalApiKey, CONFIG.personalUser, CONFIG.personalBundle ); const personalBookmark = await utils.Helpers.createBookmark(personalUrl, { title: 'Bundle Specific - Personal', path: 'Personal/Bundle', notes: 'Personal bundle content' }); console.log(` Personal bookmark: ID=${personalBookmark.id}`); // Check via work const workList = await utils.Helpers.getAllBookmarks(); const personalList = await utils.Helpers.getAllBookmarks(); const workCount = workList.filter(b => b.testId).length; const personalCount = personalList.filter(b => b.testId).length; console.log(` Work has ${workCount} test bookmarks`); console.log(` Personal has ${personalCount} test bookmarks`); if (workCount === 1 && personalCount === 1) { utils.Formatters.consoleResult('Test 8', 'PASS', 'Bundles provide logical separation'); console.log(' → Can maintain separate sync for each bundle'); return { pass: true, workCount, personalCount }; } else { utils.Formatters.consoleResult('Test 8', 'WARN', 'Bundle counts differ from expected'); console.log(' → May need to use tags for proper isolation'); return { pass: null, workCount, personalCount }; } } catch (error) { utils.Formatters.consoleResult('Test 8', 'FAIL', error.message); throw error; } } // Run all tests async function runBundleTests() { console.log('\n' + '='.repeat(60)); console.log(' ' + SCENARIO_NAME); console.log('='.repeat(60)); const results = []; try { results[0] = await test7_BundleTagFiltering(); results[1] = await test8_BundleSpecificSync(); } catch (error) { console.error('Test suite error:', error.message); utils.Helpers.resetBookmarks(); } console.log('\n' + '='.repeat(60)); console.log(' Bundle Tests Complete'); console.log('='.repeat(60)); return results; } // Export window.LinkdingSyncTests.TestBundles = { run: runBundleTests, test7: test7_BundleTagFiltering, test8: test8_BundleSpecificSync };