Skip to content

Commit

Permalink
Merge pull request #407 from freelawproject/382-fix-avoid-sending-att…
Browse files Browse the repository at this point in the history
…achment-number-0

fix(appellate): Avoids sending attachment number 0
  • Loading branch information
mlissner authored Nov 26, 2024
2 parents ab7ff58 + 17f331c commit 243b660
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Fixes:
- Ensure we call sendResponse even when notifications are disabled([405](https://github.com/freelawproject/recap-chrome/pull/405))
- Use chrome.scripting.ExecutionWorld.MAIN for firefox compatibility ([404](https://github.com/freelawproject/recap-chrome/pull/404))
- Improves getAttachmentNumberFromAnchor to accurately extract attachment numbers from tables with 5+ columns([406](https://github.com/freelawproject/recap-chrome/pull/406))
- Refines attachment handling in appellate uploads to only send attachment_number when necessary([382](https://github.com/freelawproject/recap/issues/382),[406](https://github.com/freelawproject/recap-chrome/pull/407))


For developers:
Expand Down
4 changes: 2 additions & 2 deletions spec/AppellateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('The Appellate module', function () {
);
expect(titleData.docket_number).toBe('22-11187');
expect(titleData.doc_number).toBe('49');
expect(titleData.att_number).toBe(0);
expect(titleData.att_number).toBeNull();
});

it('parses title with attachment number from download page', function () {
Expand Down Expand Up @@ -302,7 +302,7 @@ describe('The Appellate module', function () {
expect(item.dataset.pacerDlsId).toBe(documentLinks[i]['dlsId']);
expect(item.dataset.pacerCaseId).toBe('290338');
expect(item.dataset.pacerTabId).toBe('3');
expect(item.dataset.attachmentNumber).toBe('0');
expect(item.dataset.attachmentNumber).toBeUndefined();
}
});
});
Expand Down
4 changes: 2 additions & 2 deletions spec/PacerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,15 +780,15 @@ describe('The PACER module', function () {
});

describe('getAttachmentNumberFromAnchor', function () {
it('returns 0 if the table has less than four columns', function () {
it('returns null if the table has less than four columns', function () {
let tr = document.createElement('tr');
let anchor_td = document.createElement('td');
let anchor = document.createElement('a');
anchor_td.appendChild(anchor);
tr.appendChild(document.createElement('td'));
tr.appendChild(anchor_td);
tr.appendChild(document.createElement('td'));
expect(PACER.getAttachmentNumberFromAnchor(anchor)).toBe(0);
expect(PACER.getAttachmentNumberFromAnchor(anchor)).toBeNull();
});

it('returns the attachment number if the table uses checkboxes', function () {
Expand Down
7 changes: 2 additions & 5 deletions src/appellate/appellate.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ AppellateDelegate.prototype.handleAcmsDownloadPage = async function () {
att_number:
downloadData.docketEntry.documentCount > 1
? dataFromTitle.att_number
: 0,
: null,
};

// Remove element from the page to show loading message
Expand Down Expand Up @@ -1114,10 +1114,7 @@ AppellateDelegate.prototype.onDocumentViewSubmit = async function (event) {
let title = document.querySelectorAll('strong')[1].innerHTML;
let dataFromTitle = APPELLATE.parseReceiptPageTitle(title);

if (
dataFromTitle.att_number == 0 &&
this.queryParameters.get('recapAttNum')
) {
if (!dataFromTitle.att_number && this.queryParameters.get('recapAttNum')) {
dataFromTitle.att_number = this.queryParameters.get('recapAttNum');
}

Expand Down
8 changes: 3 additions & 5 deletions src/appellate/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,7 @@ let APPELLATE = {

// if an attachment number is found, it adds it to the link href
let attNumber = PACER.getAttachmentNumberFromAnchor(a);
if (attNumber != 0) {
url.searchParams.set('recapAttNum', attNumber);
}
if (attNumber) url.searchParams.set('recapAttNum', attNumber);

a.setAttribute('href', url.toString());

Expand All @@ -290,7 +288,7 @@ let APPELLATE = {
clonedNode.dataset.pacerCaseId = pacerCaseId;
clonedNode.dataset.pacerTabId = tabId;
clonedNode.dataset.documentNumber = docNum ? docNum : docId;
clonedNode.dataset.attachmentNumber = attNumber;
if (attNumber) clonedNode.dataset.attachmentNumber = attNumber;

links.push(docId);
});
Expand Down Expand Up @@ -367,7 +365,7 @@ let APPELLATE = {
[, r.docket_number, r.doc_number, r.att_number] = dataFromAttachment;
} else {
[, r.docket_number, r.doc_number] = dataFromSingleDoc;
r.att_number = 0;
r.att_number = null;
}
return r;
},
Expand Down
4 changes: 2 additions & 2 deletions src/pacer.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ let PACER = {
let row = anchor.parentNode.parentNode;
if (row.childElementCount <= 3) {
// Attachment menu pages should have more than 3 element per row.
return 0;
return null;
}

// If the attachment page uses checkboxes, each row should have five or six child nodes and the attachment
Expand All @@ -738,7 +738,7 @@ let PACER = {

let rowNumber = [5,6].includes(row.childElementCount) ? row.childNodes[1].innerHTML : row.childNodes[0].innerHTML;
let cleanNumber = this.cleanDocLinkNumber(rowNumber);
return cleanNumber ? cleanNumber : 0;
return cleanNumber ? cleanNumber : null;
},

handleDocketAvailabilityMessages: (resultCount) =>{
Expand Down

0 comments on commit 243b660

Please sign in to comment.