Skip to content

Commit 1a7e02d

Browse files
addressed review comments
1 parent 4a16f67 commit 1a7e02d

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/tasks/opportunity-status-processor/handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ export async function runOpportunityStatusProcessor(message, context) {
698698
+ 'The statuses above reflect data available at this moment and may be incomplete. '
699699
+ `Run \`onboard status ${siteUrl}\` to re-check once all audits have completed.`,
700700
);
701-
} else if (isRecheck) {
701+
} else if (isRecheck && onboardStartTime) {
702702
await say(
703703
env,
704704
log,

test/tasks/opportunity-status-processor/opportunity-status-processor.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ describe('Opportunity Status Processor', () => {
7575
SiteTopPage: {
7676
allBySiteIdAndSourceAndGeo: sandbox.stub().resolves([]),
7777
},
78+
Audit: {
79+
allLatestForSite: sandbox.stub().resolves([]),
80+
},
7881
})
7982
.withOverrides({
8083
s3Client: mockS3Client,
@@ -4397,5 +4400,21 @@ describe('Opportunity Status Processor', () => {
43974400
expect(disclaimer).to.include('Core Web Vitals');
43984401
expect(disclaimer).to.not.include('Scrape Top Pages');
43994402
});
4403+
4404+
it('does not send "all complete" when isRecheck=true but onboardStartTime is absent (legacy site)', async () => {
4405+
// onboardStartTime is undefined — audit completion check is skipped entirely.
4406+
// pendingAuditTypes stays [] but we must NOT send "All audits have completed"
4407+
// because no check was performed.
4408+
const testMessage = makeDisclaimerMessage(undefined, ['cwv'], true);
4409+
const testContext = makeDisclaimerContext([]);
4410+
4411+
await disclaimerHandler.runOpportunityStatusProcessor(testMessage, testContext);
4412+
4413+
// DB should not have been queried (no onboardStartTime to compare against)
4414+
expect(testContext.dataAccess.Audit.allLatestForSite).to.not.have.been.called;
4415+
const disclaimerCalls = sayStub.args.map((a) => a[3]).filter(Boolean);
4416+
expect(disclaimerCalls.some((m) => m.includes('All audits have completed'))).to.be.false;
4417+
expect(disclaimerCalls.some((m) => m.includes('may still be in progress'))).to.be.false;
4418+
});
44004419
});
44014420
});

0 commit comments

Comments
 (0)