169 lines
7.0 KiB
JavaScript
169 lines
7.0 KiB
JavaScript
// Test module configuration
|
|
import { CONFIG } from './index.js';
|
|
|
|
// Helper function to get the actual branch name being used (including any overrides)
|
|
function getActualBranchName() {
|
|
return CONFIG.BRANCH_NAME; // This will include any config.js overrides
|
|
}
|
|
|
|
// Helper function to create mock API response with correct branch name
|
|
function createMockApiResponseForBranch(branchName = getActualBranchName()) {
|
|
return {
|
|
entities: {
|
|
bibItems: {
|
|
"1805116|31336107103179||76": {
|
|
"id": "S161C1805116", // Add the id field that our function looks for
|
|
"collection": "Adult - Circulation Desk",
|
|
"callNumber": "CA STATE LIBRARY PARKS PASS HIKING BACKPACK",
|
|
"itemId": "1805116|31336107103179||76",
|
|
"copy": null,
|
|
"volume": null,
|
|
"branch": {
|
|
"name": branchName,
|
|
"code": "29"
|
|
},
|
|
"inSiteScope": true,
|
|
"availability": {
|
|
"status": "AVAILABLE",
|
|
"circulationType": "NON_CIRCULATING",
|
|
"libraryUseOnly": false,
|
|
"libraryStatus": "Available",
|
|
"group": "AVAILABLE_ITEMS",
|
|
"statusType": "AVAILABLE"
|
|
},
|
|
"branchName": branchName,
|
|
"local": false,
|
|
"requestFormUrl": null
|
|
},
|
|
"1805116|31336107103138||77": {
|
|
"id": "S161C1805116", // Add the id field that our function looks for
|
|
"collection": "Adult - Circulation Desk",
|
|
"callNumber": "CA STATE LIBRARY PARKS PASS HIKING BACKPACK",
|
|
"itemId": "1805116|31336107103138||77",
|
|
"copy": null,
|
|
"volume": null,
|
|
"branch": {
|
|
"name": branchName,
|
|
"code": "29"
|
|
},
|
|
"inSiteScope": true,
|
|
"availability": {
|
|
"status": "RECENTLY_RETURNED",
|
|
"circulationType": "NON_CIRCULATING",
|
|
"libraryUseOnly": false,
|
|
"libraryStatus": "Recently returned",
|
|
"group": "AVAILABLE_ITEMS",
|
|
"statusType": "RECENTLY_RETURNED"
|
|
},
|
|
"branchName": branchName,
|
|
"local": false,
|
|
"requestFormUrl": null
|
|
},
|
|
"1805116|31336107103096||78": {
|
|
"id": "S161C1805116",
|
|
"collection": "Adult - Circulation Desk",
|
|
"callNumber": "CA STATE LIBRARY PARKS PASS HIKING BACKPACK",
|
|
"itemId": "1805116|31336107103096||78",
|
|
"copy": null,
|
|
"volume": null,
|
|
"dueDate": "2025-07-22",
|
|
"branch": {
|
|
"name": branchName,
|
|
"code": "29"
|
|
},
|
|
"inSiteScope": true,
|
|
"availability": {
|
|
"status": "UNAVAILABLE",
|
|
"circulationType": "NON_CIRCULATING",
|
|
"libraryUseOnly": false,
|
|
"libraryStatus": "Checked Out",
|
|
"group": "NOT_AVAILABLE_ITEMS",
|
|
"statusType": "UNAVAILABLE"
|
|
},
|
|
"branchName": branchName,
|
|
"local": false,
|
|
"requestFormUrl": null
|
|
},
|
|
"1805116|31336107103252||87": {
|
|
"id": "S161C1805116",
|
|
"collection": "Adult - Circulation Desk",
|
|
"callNumber": "CA STATE LIBRARY PARKS PASS HIKING BACKPACK",
|
|
"itemId": "1805116|31336107103252||87",
|
|
"copy": null,
|
|
"volume": null,
|
|
"branch": {
|
|
"name": branchName,
|
|
"code": "29"
|
|
},
|
|
"inSiteScope": true,
|
|
"availability": {
|
|
"status": "UNAVAILABLE",
|
|
"circulationType": "NON_CIRCULATING",
|
|
"libraryUseOnly": false,
|
|
"libraryStatus": "Checked Out",
|
|
"group": "NOT_AVAILABLE_ITEMS",
|
|
"statusType": "UNAVAILABLE"
|
|
},
|
|
"branchName": branchName,
|
|
"local": false,
|
|
"requestFormUrl": null
|
|
},
|
|
"1690437|31336107104321||91": {
|
|
"id": "S161C1690437", // Pure pass item
|
|
"collection": "Adult - Circulation Desk",
|
|
"callNumber": "CA STATE LIBRARY PARKS PASS PURE",
|
|
"itemId": "1690437|31336107104321||91",
|
|
"copy": null,
|
|
"volume": null,
|
|
"branch": {
|
|
"name": branchName,
|
|
"code": "29"
|
|
},
|
|
"inSiteScope": true,
|
|
"availability": {
|
|
"status": "UNAVAILABLE",
|
|
"circulationType": "NON_CIRCULATING",
|
|
"libraryUseOnly": false,
|
|
"libraryStatus": "Checked Out",
|
|
"group": "NOT_AVAILABLE_ITEMS",
|
|
"statusType": "UNAVAILABLE"
|
|
},
|
|
"branchName": branchName,
|
|
"local": false,
|
|
"requestFormUrl": null
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
// Export the mock response using the actual configured branch name
|
|
export const MOCK_API_RESPONSE = createMockApiResponseForBranch();
|
|
|
|
// Mock API response with no items (for testing empty state)
|
|
export const MOCK_API_RESPONSE_EMPTY = {
|
|
entities: {
|
|
bibItems: {}
|
|
}
|
|
};
|
|
|
|
// Test configuration
|
|
export const TEST_CONFIG = {
|
|
STATE_FILE: './test-state.json',
|
|
NTFY_URL: 'https://ntfy.sh/test-topic'
|
|
};
|
|
|
|
// Helper function to print current test configuration info
|
|
export function printTestConfig() {
|
|
console.log(`🧪 Test Configuration:`);
|
|
console.log(` Branch: ${getActualBranchName()}`);
|
|
console.log(` Mock data items: ${Object.keys(MOCK_API_RESPONSE.entities.bibItems).length}`);
|
|
|
|
const availableItems = Object.values(MOCK_API_RESPONSE.entities.bibItems).filter(item =>
|
|
(item.availability.statusType === 'AVAILABLE' ||
|
|
item.availability.statusType === 'RECENTLY_RETURNED') ||
|
|
(!item.dueDate && item.branchName.includes(getActualBranchName()))
|
|
);
|
|
console.log(` Available items in mock: ${availableItems.length} (counted by actual function logic)`);
|
|
}
|