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
78 changes: 0 additions & 78 deletions .github/workflows/claude-code-review.yml

This file was deleted.

64 changes: 0 additions & 64 deletions .github/workflows/claude.yml

This file was deleted.

48 changes: 31 additions & 17 deletions tests/test_sloccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,33 @@ def test_github_repo_validation(page: Page, unused_port_server):
expect(status).to_contain_text("Invalid format")


MOCK_REPO_FILES = {
"src/hello.c": '#include <stdio.h>\n\nint main(void) {\n printf("hello\\n");\n return 0;\n}\n',
"scripts/count.py": "import sys\n\n\ndef main():\n print(len(sys.argv))\n\n\nmain()\n",
"README.md": "# Not code\n",
}


def mock_github(route):
"""Serve a tiny fake repository in place of the GitHub API and raw.githubusercontent.com,
whose unauthenticated rate limit is easily exhausted by shared CI runners."""
url = route.request.url
headers = {"access-control-allow-origin": "*"}
if url == "https://api.github.com/repos/example/tiny":
return route.fulfill(json={"default_branch": "main"}, headers=headers)
if url == "https://api.github.com/repos/example/tiny/git/trees/main?recursive=1":
tree = [{"path": path, "type": "blob"} for path in MOCK_REPO_FILES]
return route.fulfill(json={"tree": tree, "truncated": False}, headers=headers)
prefix = "https://raw.githubusercontent.com/example/tiny/main/"
if url.startswith(prefix) and url[len(prefix):] in MOCK_REPO_FILES:
return route.fulfill(body=MOCK_REPO_FILES[url[len(prefix):]], headers=headers)
route.fulfill(status=404, headers=headers)


def test_github_repo_analysis(page: Page, unused_port_server):
"""Test analyzing a small GitHub repository"""
page.route("https://api.github.com/**", mock_github)
page.route("https://raw.githubusercontent.com/**", mock_github)
unused_port_server.start(root)
page.goto(f"http://localhost:{unused_port_server.port}/sloccount.html")

Expand All @@ -258,28 +283,17 @@ def test_github_repo_analysis(page: Page, unused_port_server):
analyze_btn = page.locator("#analyze-repo-btn")
expect(analyze_btn).to_have_text("Analyze Repository", timeout=30000)

# Use a small public repository for testing
# Using the sloccount repo itself as a test
page.locator("#repo-input").fill("https://github.com/licquia/sloccount")

# Analyze (this may take a while)
page.locator("#repo-input").fill("https://github.com/example/tiny")
analyze_btn.click()

# Wait for fetch to start
status = page.locator("#status")
expect(status).to_contain_text("Fetching", timeout=5000)

# Wait for results (may take up to 60 seconds)
# Wait for results
results = page.locator("#results")
expect(results).to_have_class("visible", timeout=60000)

# Check that we got results
total_lines = page.locator("#total-lines")
expect(total_lines).not_to_have_text("0")

total_languages = page.locator("#total-languages")
# Should have at least one language
expect(total_languages).not_to_have_text("0")
# Only the C and Python files count, not the README
expect(page.locator("#total-files")).to_have_text("2")
expect(page.locator("#total-languages")).to_have_text("2")
expect(page.locator("#total-lines")).not_to_have_text("0")


def test_mobile_responsive(page: Page, unused_port_server):
Expand Down
19 changes: 12 additions & 7 deletions tests/test_video_compressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ def test_full_flow_encodes_compatible_mp4s(page: Page, unused_port_server):
expect(page.locator("#status")).to_contain_text("Done: 3 versions")
expect(page.locator("#error")).to_be_hidden()

# Playwright's Chromium has no H.264 decoder, so these details come from
# ffmpeg probing the file rather than from the <video> element.
# Older Playwright Chromium builds have no H.264 decoder, so there these details
# come from ffmpeg probing the file rather than from the <video> element.
expect(page.locator("#source-details")).to_contain_text("640×360")
expect(page.locator("#source-details")).to_contain_text("0:03")
expect(page.locator("#source-details")).to_contain_text("44100 Hz, stereo")
Expand Down Expand Up @@ -292,10 +292,13 @@ def test_filename_poster_and_embed_snippet(page: Page, unused_port_server):
expect(page.locator("#base-name-hint")).to_contain_text("test-video-medium.mp4")
expect(page.locator("#base-name-hint")).to_contain_text("test-video.jpg")

# Before anything is encoded the snippet uses the first selected version
# Before anything is encoded the snippet uses the first selected version. It only
# carries the size if this Chromium build could read the H.264 file's metadata
# (older Playwright builds have no H.264 decoder, newer ones do).
expect(page.locator("#embed-card")).to_be_visible()
snippet = page.locator("#embed-code").text_content()
assert '<video controls playsinline preload="none" poster="test-video.jpg">' in snippet
size = ' width="640" height="360"' if "640×360" in page.locator("#source-details").text_content() else ""
assert f'<video controls playsinline preload="none"{size} poster="test-video.jpg">' in snippet
assert '<source src="test-video-largest.mp4" type="video/mp4">' in snippet

# Editing the filename is reflected everywhere, and unsafe characters are cleaned up
Expand Down Expand Up @@ -631,13 +634,15 @@ def test_webp_format_switches_settings(page: Page, unused_port_server):
expect(page.locator("#custom-crf")).to_be_hidden()
expect(page.locator("#custom-audio")).to_be_hidden()

# Downloads and the embed snippet become .webp, and the snippet is an <img>
# Downloads and the embed snippet become .webp, and the snippet is an <img>. As for
# the <video> snippet, the size is only known if this Chromium can read H.264 metadata.
expect(page.locator("#base-name-hint")).to_have_text("Downloads will be named test-video-medium.webp, test-video-small.webp and so on.")
expect(page.locator("#embed-code")).to_have_text('<img src="test-video-largest.webp" alt="" loading="lazy">')
size = ' width="640" height="360"' if "640×360" in page.locator("#source-details").text_content() else ""
expect(page.locator("#embed-code")).to_have_text(f'<img src="test-video-largest.webp"{size} alt="" loading="lazy">')
expect(page.locator("#embed-image-intro")).to_be_visible()
expect(page.locator("#embed-video-intro")).to_be_hidden()
page.check("#embed-xhtml")
expect(page.locator("#embed-code")).to_have_text('<img src="test-video-largest.webp" alt="" loading="lazy" />')
expect(page.locator("#embed-code")).to_have_text(f'<img src="test-video-largest.webp"{size} alt="" loading="lazy" />')
page.uncheck("#embed-xhtml")

# Each version remembers its WebP quality and CRF separately
Expand Down
Loading