Expand to both parking pass items
This commit is contained in:
300
test-config.js
300
test-config.js
@ -1,166 +1,168 @@
|
||||
// Test module configuration
|
||||
import { CONFIG } from './index.js';
|
||||
|
||||
// Mock API response for testing (matches real API structure)
|
||||
export const MOCK_API_RESPONSE = {
|
||||
entities: {
|
||||
bibItems: {
|
||||
"1805116|31336107103179||76": {
|
||||
"collection": "Adult - Circulation Desk",
|
||||
"callNumber": "CA STATE LIBRARY PARKS PASS HIKING BACKPACK",
|
||||
"itemId": "1805116|31336107103179||76",
|
||||
"copy": null,
|
||||
"volume": null,
|
||||
"branch": {
|
||||
"name": "Rancho Penasquitos",
|
||||
"code": "29"
|
||||
// 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
|
||||
},
|
||||
"inSiteScope": true,
|
||||
"availability": {
|
||||
"status": "AVAILABLE",
|
||||
"circulationType": "NON_CIRCULATING",
|
||||
"libraryUseOnly": false,
|
||||
"libraryStatus": "Available",
|
||||
"group": "AVAILABLE_ITEMS",
|
||||
"statusType": "AVAILABLE"
|
||||
"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
|
||||
},
|
||||
"branchName": "Rancho Penasquitos",
|
||||
"local": false,
|
||||
"requestFormUrl": null
|
||||
},
|
||||
"1805116|31336107103138||77": {
|
||||
"collection": "Adult - Circulation Desk",
|
||||
"callNumber": "CA STATE LIBRARY PARKS PASS HIKING BACKPACK",
|
||||
"itemId": "1805116|31336107103138||77",
|
||||
"copy": null,
|
||||
"volume": null,
|
||||
"branch": {
|
||||
"name": "Rancho Penasquitos",
|
||||
"code": "29"
|
||||
"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
|
||||
},
|
||||
"inSiteScope": true,
|
||||
"availability": {
|
||||
"status": "RECENTLY_RETURNED",
|
||||
"circulationType": "NON_CIRCULATING",
|
||||
"libraryUseOnly": false,
|
||||
"libraryStatus": "Recently returned",
|
||||
"group": "AVAILABLE_ITEMS",
|
||||
"statusType": "RECENTLY_RETURNED"
|
||||
"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
|
||||
},
|
||||
"branchName": "Rancho Penasquitos",
|
||||
"local": false,
|
||||
"requestFormUrl": null
|
||||
},
|
||||
"1805116|31336107103096||78": {
|
||||
"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": "Rancho Penasquitos",
|
||||
"code": "29"
|
||||
},
|
||||
"inSiteScope": true,
|
||||
"availability": {
|
||||
"status": "UNAVAILABLE",
|
||||
"circulationType": "NON_CIRCULATING",
|
||||
"libraryUseOnly": false,
|
||||
"libraryStatus": "Checked Out",
|
||||
"group": "NOT_AVAILABLE_ITEMS",
|
||||
"statusType": "UNAVAILABLE"
|
||||
},
|
||||
"branchName": "Rancho Penasquitos",
|
||||
"local": false,
|
||||
"requestFormUrl": null
|
||||
},
|
||||
"1805116|31336107103252||87": {
|
||||
"collection": "Adult - Circulation Desk",
|
||||
"callNumber": "CA STATE LIBRARY PARKS PASS HIKING BACKPACK",
|
||||
"itemId": "1805116|31336107103252||87",
|
||||
"copy": null,
|
||||
"volume": null,
|
||||
"dueDate": "2025-07-22",
|
||||
"branch": {
|
||||
"name": "Central Library",
|
||||
"code": "7"
|
||||
},
|
||||
"inSiteScope": true,
|
||||
"availability": {
|
||||
"status": "AVAILABLE",
|
||||
"circulationType": "NON_CIRCULATING",
|
||||
"libraryUseOnly": false,
|
||||
"libraryStatus": "Available",
|
||||
"group": "AVAILABLE_ITEMS",
|
||||
"statusType": "AVAILABLE"
|
||||
},
|
||||
"branchName": "Central Library",
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// Mock API response with no availability (all checked out)
|
||||
// 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: {
|
||||
"1805116|31336107103179||76": {
|
||||
"collection": "Adult - Circulation Desk",
|
||||
"callNumber": "CA STATE LIBRARY PARKS PASS HIKING BACKPACK",
|
||||
"itemId": "1805116|31336107103179||76",
|
||||
"copy": null,
|
||||
"volume": null,
|
||||
"dueDate": "2025-07-22",
|
||||
"branch": {
|
||||
"name": "Rancho Penasquitos",
|
||||
"code": "29"
|
||||
},
|
||||
"inSiteScope": true,
|
||||
"availability": {
|
||||
"status": "UNAVAILABLE",
|
||||
"circulationType": "NON_CIRCULATING",
|
||||
"libraryUseOnly": false,
|
||||
"libraryStatus": "Checked Out",
|
||||
"group": "NOT_AVAILABLE_ITEMS",
|
||||
"statusType": "UNAVAILABLE"
|
||||
},
|
||||
"branchName": "Rancho Penasquitos",
|
||||
"local": false,
|
||||
"requestFormUrl": null
|
||||
},
|
||||
"1805116|31336107103252||87": {
|
||||
"collection": "Adult - Circulation Desk",
|
||||
"callNumber": "CA STATE LIBRARY PARKS PASS HIKING BACKPACK",
|
||||
"itemId": "1805116|31336107103252||87",
|
||||
"copy": null,
|
||||
"volume": null,
|
||||
"branch": {
|
||||
"name": "Central Library",
|
||||
"code": "7"
|
||||
},
|
||||
"inSiteScope": true,
|
||||
"availability": {
|
||||
"status": "AVAILABLE",
|
||||
"circulationType": "NON_CIRCULATING",
|
||||
"libraryUseOnly": false,
|
||||
"libraryStatus": "Available",
|
||||
"group": "AVAILABLE_ITEMS",
|
||||
"statusType": "AVAILABLE"
|
||||
},
|
||||
"branchName": "Central Library",
|
||||
"local": false,
|
||||
"requestFormUrl": null
|
||||
}
|
||||
}
|
||||
bibItems: {}
|
||||
}
|
||||
};
|
||||
|
||||
// Test configuration (uses different files to avoid conflicts)
|
||||
// Test configuration
|
||||
export const TEST_CONFIG = {
|
||||
...CONFIG,
|
||||
STATE_FILE: './test_last_availability.json',
|
||||
NTFY_TOPIC: 'library-books-test'
|
||||
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)`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user