Skip to content

[AI Improvement] [Task] Await chai-as-promised assertions in 6 spec files that never run today (lint: no-floating-promises, spec slice) - #11469

Open
joehan wants to merge 1 commit into
mainfrom
ai-improve-582885987-task-await-chai-as-promised-asserti
Open

joehan wants to merge 1 commit into
mainfrom
ai-improve-582885987-task-await-chai-as-promised-asserti

Conversation

@joehan

@joehan joehan commented Nov 6, 2026

Copy link
Copy Markdown
Member

Description

Resolves Buganizer b/582885987 (parent goal b/565072516).

Fixes all 13 @typescript-eslint/no-floating-promises warnings across 6 spec files so that async chai-as-promised assertions and helper calls are properly awaited or handled:

  • src/deploy/functions/validate.spec.ts: Converted 5 synchronous it callbacks calling expect(validate.secretsAreValid(...)).to.(not.)be.rejected(With) to async and awaited each assertion.
  • src/deploy/extensions/planner.spec.ts: Converted the parameterized it callback in resolveSemver to async and awaited both expect(planner.resolveVersion(...)).to.eventually... branches.
  • src/throttler/throttler.spec.ts: Converted it("should return the result of task") to async and awaited both expect(q.run(...)).to.eventually.to.equal(...) assertions.
  • src/deploy/functions/remoteSource.spec.ts: Attached .catch(reject) to archive.finalize() inside createZipBuffer.
  • src/emulator/workQueue.spec.ts: Marked queue.start() calls in beforeEach hooks with void and explanatory comments since start() loops until afterEach calls stop().
  • src/database/fakeRemoveRemote.spec.ts: Made FakeRemoveRemote.deleteSubPath async, awaited this.deletePath(...) in the loop, and returned boolean literals directly.

Scenarios Tested

  • npx eslint --config .eslintrc.js --rule '@typescript-eslint/no-floating-promises: error' on all 6 modified spec files (0 errors).
  • npx prettier --check on all 6 modified spec files.
  • npm run test:compile (0 errors).
  • npm run build (0 errors).
  • npm run lint:quiet (0 errors).
  • npx mocha src/deploy/functions/validate.spec.ts src/deploy/extensions/planner.spec.ts src/throttler/throttler.spec.ts src/deploy/functions/remoteSource.spec.ts src/emulator/workQueue.spec.ts src/database/remove.spec.ts (184 passing, 3 pending).
  • Full npm run mocha suite (5934 passing, 11 pending; only failure was unrelated local port 52672 EADDRINUSE in src/apiv2.spec.ts proxy hook).

Sample Commands

N/A

@joehan joehan self-assigned this Nov 6, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors several test files to properly handle asynchronous operations, converting test cases to async, awaiting expectations, and handling floating promises. The review feedback suggests adding defensive checks in fakeRemoveRemote.spec.ts to safely handle potentially undefined paths, and removing a redundant .to in the assertion chain within throttler.spec.ts.

Comment on lines +32 to 37
async deleteSubPath(path: string, subPaths: string[]): Promise<boolean> {
const d = this._dataAtpath(path);
let size = 0;
for (const p of subPaths) {
size += this._size(d[p]);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If d is null/undefined, or if a subpath does not exist in d (making d[p] undefined), accessing properties or calling _size will throw a TypeError. Adding defensive checks ensures the fake database helper is robust against non-existent paths.

  async deleteSubPath(path: string, subPaths: string[]): Promise<boolean> {
    const d = this._dataAtpath(path);
    if (!d) {
      return true;
    }
    let size = 0;
    for (const p of subPaths) {
      if (d[p] !== undefined) {
        size += this._size(d[p]);
      }
    }
References
  1. Use strict null checks and handle undefined/null explicitly. (link)

Comment on lines +247 to +248
await expect(q.run(2)).to.eventually.to.equal("result: 2");
await expect(q.run(3)).to.eventually.to.equal("result: 3");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The assertion chain contains a redundant .to after .eventually. It should be simplified to .to.eventually.equal for better readability and consistency with other assertions in the codebase.

Suggested change
await expect(q.run(2)).to.eventually.to.equal("result: 2");
await expect(q.run(3)).to.eventually.to.equal("result: 3");
await expect(q.run(2)).to.eventually.equal("result: 2");
await expect(q.run(3)).to.eventually.equal("result: 3");

@joehan
joehan marked this pull request as ready for review November 7, 2026 00:01
@joehan
joehan requested a review from bkendall November 7, 2026 00:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant