Skip to content
Merged
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
5 changes: 5 additions & 0 deletions aw_watcher_window/macos.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,12 @@ let researchBrowserApps = Set([
"google-chrome-unstable",
"chromium",
"chromium-browser",
"chromium.exe",
"brave browser",
"brave",
"brave-browser",
"arc",
"arc browser",
"firefox",
"firefox developer edition",
"firefox-esr",
Expand All @@ -151,6 +154,8 @@ let researchBrowserApps = Set([
"microsoft-edge-beta",
"microsoft-edge-dev",
"opera",
"vivaldi",
"vivaldi.exe",
"chrome.exe",
"brave.exe",
"firefox.exe",
Expand Down
5 changes: 5 additions & 0 deletions aw_watcher_window/research_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@
"google-chrome-unstable",
"chromium",
"chromium-browser",
"chromium.exe",
"brave browser",
"brave",
"brave-browser",
"arc",
"arc browser",
"firefox",
"firefox developer edition",
"firefox-esr",
Expand All @@ -46,6 +49,8 @@
"microsoft-edge-beta",
"microsoft-edge-dev",
"opera",
"vivaldi",
"vivaldi.exe",
"chrome.exe",
"brave.exe",
"firefox.exe",
Expand Down
24 changes: 24 additions & 0 deletions tests/test_research_filter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Tests for aw-watcher-window Research Edition filter."""

import re
import unittest
from pathlib import Path

from aw_watcher_window.research_filter import (
BROWSER_APPS,
Expand Down Expand Up @@ -41,6 +43,17 @@ def test_non_browsers(self):
for app in ("Slack", "Terminal", "iTerm2", "Code", "zoom.us", ""):
self.assertFalse(is_browser(app), f"{app!r} should not be a browser")

def test_python_and_swift_browser_aliases_match(self):
swift = (Path(__file__).parents[1] / "aw_watcher_window" / "macos.swift").read_text()
match = re.search(
r"let\s+researchBrowserApps\s*=\s*Set\s*\(\s*\[(?P<entries>.*?)\]\s*\)",
swift,
re.DOTALL,
)
self.assertIsNotNone(match)
swift_browser_apps = set(re.findall(r'"([^"]+)"', match.group("entries")))
self.assertEqual(swift_browser_apps, BROWSER_APPS)
Comment on lines +48 to +55

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Brittle Swift Source Parsing

This parity test depends on the exact whitespace and casing of the Swift source rather than its runtime behavior. Harmless changes such as placing an entry on the same line as Set([, or using a mixed-case alias that Swift normalizes with lowercased(), would fail the test even though browser recognition remains identical. Parse the declaration without depending on its layout and compare normalized values so unrelated Swift edits do not cause false failures.

Knowledge Base Used: Research-mode filtering

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!



class TestClassifyTitle(unittest.TestCase):
CATEGORY_MAP = {
Expand Down Expand Up @@ -191,6 +204,17 @@ def test_linux_browser_wm_class_title_classified(self):
self.assertEqual(result["app"], app)
self.assertEqual(result["title"], "Youtube")

def test_original_classifier_browser_aliases_are_classified(self):
for app in ("Arc", "Arc Browser", "Vivaldi", "Vivaldi.exe", "Chromium.exe"):
with self.subTest(app=app):
window = {
"app": app,
"title": "New Tab",
"url": "https://youtube.com/watch?v=private",
}
result = transform(window, self.CATEGORY_MAP)
self.assertEqual(result, {"app": app, "title": "Youtube"})

def test_input_not_mutated(self):
window = {"app": "Chrome", "title": "YouTube - Chrome"}
original = dict(window)
Expand Down
Loading