kaovilai / kaovilai/github-bot-command-palette

[daily] test: add unit tests for content.js search filter, check status, and shortcut logic

Open
#108 0 comments 0 reactions 0 assignees View on GitHub
agentic-workflows automation
Dominant language
JavaScript
Stars
1
Forks
2
Avg merge
2m
Merged PRs (30d)
15

Description

Three previously-untested logical areas of `content.js` now have unit tests in the new `tests/content-logic.test.js`, and the file is wired into `npm test`.

## Changes

### 1. `tests/content-logic.test.js` — new test file (16 tests)

**Job-picker search filter** (`renderJobs` → multi-word / quoted-phrase matching):
- Empty filter matches everything (vacuous truth — no terms → `every()` returns `true`)
- Single word matches job name as a substring
- Multiple words require ALL to match (AND logic)
- Quoted phrases match as a single substring (e.g. `"unit-test"` ≠ `"unit test"`)
- Mix of quoted and unquoted terms works correctly
- Matching is case-insensitive

**`getCheckStatus` selector coverage:**
- `octicon-x-circle-fill` present for failure detection
- `[data-conclusion="failure"]`, `[data-conclusion="timed_out"]`, `[data-conclusion="action_required"]` all present
- `octicon-dot-fill` present for pending detection
- `[data-conclusion="cancelled"]`, `[data-conclusion="stale"]` present
- The `'passed'` fallback return path is present

**`handleShortcut` combo building:**
- Modifier keys assembled in `alt → ctrl → shift → meta` order
- `+` separator used when joining combo parts
- Guard that suppresses shortcuts when a GHBCP overlay (`.ghbcp-popover`, `.ghbcp-job-picker`) is open

**`MutationObserver` own-element filter:**
- `/\bghbcp-/` class check is present to skip the extension's own DOM nodes and prevent re-injection loops

### 2. `package.json` — wire new test file into `npm test`

`tests/content-logic.test.js` is now included in the `npm test` script so the tests run on every CI invocation.

All **131 unit tests** pass.

---

> [!WARNING]
> **Protected Files — Push Permission Denied**
>
> This was originally intended as a pull request, but the patch modifies protected files. A human must create the pull request manually.
>
>
> Protected files
>
> - `package.json`
>
> The push was rejected because GitHub Actions does not have `workflows` permission to push these changes, and is never allowed to make such changes, or other authorization being used does not have this permission.
>
>

Create the pull request manually

```sh
# Download the patch from the workflow run
gh run download 26452078255 -n agent -D /tmp/agent-26452078255

# Create a new branch
git checkout -b test/content-js-unit-tests-0dac9ee487612288 main

# Apply the patch (--3way handles cross-repo patches)
git am --3way /tmp/agent-26452078255/aw-test-content-js-unit-tests.patch

# Push the branch and create the pull request
git push origin test/content-js-unit-tests-0dac9ee487612288
gh pr create --title '[daily] test: add unit tests for content.js search filter, check status, and shortcut logic' --base main --head test/content-js-unit-tests-0dac9ee487612288 --repo kaovilai/github-bot-command-palette
```

> Generated by [Daily Repository Improvement](https://github.com/kaovilai/github-bot-command-palette/actions/runs/26452078255) · ● 21.4M · [◷](https://github.com/search?q=repo%3Akaovilai%2Fgithub-bot-command-palette+%22gh-aw-workflow-id%3A+continuous-improvement%22&type=pullrequests)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.