Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/shared/src/utils/bot-detection/__tests__/detector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,21 @@ describe("detectBot", () => {
expect(custom.action).toBe(BotAction.BLOCK);
});
});

describe("Generic isBot() fallback — config should still apply", () => {
it("respects trackOnlyCategories for bots only caught by ua-parser-js's generic isBot()", () => {
Comment on lines +266 to +267

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.

P2 Correct inverted test indentation

The new describe is indented more deeply than its child it, which visually misrepresents the test hierarchy and makes the structure harder to follow.

Suggested change
describe("Generic isBot() fallback — config should still apply", () => {
it("respects trackOnlyCategories for bots only caught by ua-parser-js's generic isBot()", () => {
describe("Generic isBot() fallback — config should still apply", () => {
it("respects trackOnlyCategories for bots only caught by ua-parser-js's generic isBot()", () => {

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

const genericBotUA = "PowerShell/7.1.0";

const result = detectBot(genericBotUA, {
trackOnlyCategories: [BotCategory.UNKNOWN_BOT],
});

expect(result.isBot).toBe(true);
expect(result.category).toBe(BotCategory.UNKNOWN_BOT);
expect(result.reason).toBe("general_bot_pattern");
expect(result.action).toBe(BotAction.TRACK_ONLY);
});
});
});

describe("matchCategory", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/utils/bot-detection/detector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function detect(
isBot: true,
category: BotCategory.UNKNOWN_BOT,
name,
action: BotAction.BLOCK,
action: getAction(BotCategory.UNKNOWN_BOT, config),
confidence: 70,
reason: "general_bot_pattern",
};
Expand Down