Conversation
Problem: - Tailwind utility classes (text-white, flex, etc.) were not being generated - CSS output only included custom component classes, missing core utilities Root causes: 1. @source glob pattern **/*.{html,erb} did not match .html.erb files 2. @theme directive without explicit utilities import suppressed defaults 3. @Custom-Media (CSS draft feature) caused build errors in Tailwind v4 Changes: - Fix @source patterns to properly scan template files: - **/*.{html,erb} → **/*.erb (matches .html.erb files) - Remove ./ prefix for clarity (paths are from project root) - Scope to essential directories only - Remove @theme import to restore default Tailwind utilities - Replace @Custom-Media with standard media queries: - @media (--breakpoint-lg) → @media (min-width: 1024px) - @media (--breakpoint-md) → @media (min-width: 768px) Result: - Utility classes now generated correctly (56KB → 147KB CSS) - All Tailwind build tests passing - text-white, flex, and other utilities available in views
Problem:
- Diagnostics controller returned "development" for all non-production environments
- Test assertions expected "development" even when running in test environment
- This created confusion about which environment was actually being checked
Changes:
- Update gcs_check method to return actual environment name (Rails.env.to_s)
- Update message to interpolate actual environment: "GCS not required in #{Rails.env}"
- Update test assertions to expect "test" environment values instead of "development"
Result:
- GCS diagnostics now accurately reflect the current environment
- Test environment returns "test" status and message
- Development environment returns "development" status and message
- All diagnostics controller tests passing
Updated all Playwright system tests to use semantic .spec-- class selectors
instead of HTML tag and attribute selectors for improved test stability and
maintainability.
Changes:
- admin_management_playwright_test.rb: password form fields and title
- admin_site_settings_playwright_test.rb: site settings form fields
- author_display_toggle_playwright_test.rb: site settings title
- copyright_edge_cases_playwright_test.rb: site settings title, copyright input, save button
- copyright_rewrite_bug_playwright_test.rb: site settings title, copyright input, save button
- copyright_update_playwright_test.rb: site settings title, copyright input, save button
Replaced selectors:
- h1:has-text('サイト設定') → .spec--site-settings-title
- h1:has-text('パスワード変更') → .spec--password-edit-title
- input[name='site_settings[site_title]'] → .spec--site-title-input
- input[name='site_settings[copyright]'] → .spec--copyright-input
- textarea[name='site_settings[top_page_description]'] → .spec--top-page-description-input
- input[name='admin[password]'] → .spec--password-input
- input[name='admin[password_confirmation]'] → .spec--password-confirmation-input
- input[type='submit'][value='設定を保存'] → .spec--save-button
- input[type='submit'][value='パスワードを変更'] → .spec--password-change-button
All affected tests verified to pass with new selectors.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
WalkthroughCSSのカスタムメディアクエリ変数を明示的なピクセル値に置換し、Tailwindの Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes レビューの重点項目:
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Pull Request Test Coverage Report for Build 19879444109Details
💛 - Coveralls |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
test/system/copyright_edge_cases_playwright_test.rb (1)
168-209:copyright_selector_afterが未定義で NameError になりますテスト
"copyright change with page navigation in between"の終盤で、copyright_field = @page.locator(copyright_selector_after)としていますが、
copyright_selector_afterというローカル変数はこのテスト内・クラス内どこにも定義されておらず、実行時にNameErrorでテストが必ず落ちる状態です。このケースでは直前まで
.spec--copyright-inputを前提に扱っているので、単純に同じセレクタを使う形に修正するのが安全だと思います。- copyright_field = @page.locator(copyright_selector_after) + copyright_field = @page.locator(".spec--copyright-input")または、他テスト同様に
copyright_selector変数を導入して使い回す場合は、その変数を事前に適切にセットする処理を追加してください。
🧹 Nitpick comments (3)
test/controllers/admin/diagnostics_controller_test.rb (1)
39-47: テスト名と期待値の環境表現を揃えると読みやすくなります
json["gcs_configured"]["status"]/messageの期待値を"test"/"GCS not required in test"に更新したのは、Rails.envベースの実装と整合していて良いと思います。一方でテスト名が"in development"のままなので、"in test environment"などにリネームしておくと、後から読んだときに意図がより明確になります。Based on learnings, test/**/*test.rb の命名から対象環境が分かるとメンテナンス性が上がります。
test/system/copyright_update_playwright_test.rb (1)
19-75:.spec--セレクタへの移行は妥当で、フォールバックも安全です
submit_settings_and_waitの保存ボタンや、各テストでのタイトル・著作権入力フィールドを.spec--save-button/.spec--site-settings-title/.spec--copyright-inputに揃えていて、テストの読みやすさと安定性が向上しています。COPYRIGHT_INPUTを優先しつつ、タイムアウト時に.spec--copyright-inputへフォールバックする構造も、マークアップ移行期間中の互換性という観点で合理的です。将来的にビューが完全に
.spec--クラスに統一できた段階では、COPYRIGHT_INPUTまわりのbegin/rescueを整理して.spec--copyright-inputに一本化するとテストコードがさらに簡潔になりそうです。test/system/copyright_edge_cases_playwright_test.rb (1)
18-26: エッジケース用テストの.spec--セレクタ化は妥当です複数パターン(シード値/年入り文字列/連続変更/ナビゲーション挟み/Unicode・絵文字/フッター反映)すべてで、サイト設定タイトル・著作権入力・保存ボタンを
.spec--site-settings-title/.spec--copyright-input/.spec--save-buttonに揃えていて、他のシステムテストと同じセレクタ戦略になっています。COPYRIGHT_INPUTとのフォールバックも残してあり、テンプレート移行期間中の互換性確保という意味では良い折衷に見えます。将来、ビューが完全に
.spec--クラスのみになるタイミングでは、COPYRIGHT_INPUTとの二重管理をやめて.spec--copyright-input前提に整理すると、このファイルも含めてテストコードがかなり読みやすくなりそうです。Also applies to: 37-47, 50-65, 75-87, 93-109, 119-129, 131-166, 168-209, 219-263, 273-283, 287-302
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
app/assets/tailwind/application.css(1 hunks)app/assets/tailwind/components/_action-banner.css(3 hunks)app/assets/tailwind/components/_admin-nav.css(5 hunks)app/controllers/admin/diagnostics_controller.rb(1 hunks)test/controllers/admin/diagnostics_controller_test.rb(1 hunks)test/system/admin_management_playwright_test.rb(2 hunks)test/system/admin_site_settings_playwright_test.rb(1 hunks)test/system/author_display_toggle_playwright_test.rb(2 hunks)test/system/copyright_edge_cases_playwright_test.rb(13 hunks)test/system/copyright_rewrite_bug_playwright_test.rb(5 hunks)test/system/copyright_update_playwright_test.rb(6 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.css
📄 CodeRabbit inference engine (CLAUDE.md)
Use
remunits instead of pixels in CSS, remove blank lines beyond 2 consecutive lines, and trim trailing whitespace.
Files:
app/assets/tailwind/components/_action-banner.cssapp/assets/tailwind/components/_admin-nav.cssapp/assets/tailwind/application.css
**/*.{rb,js,ts,jsx,tsx,erb,html,css}
📄 CodeRabbit inference engine (CLAUDE.md)
Ensure files end with a newline character and contain no trailing whitespace.
Files:
app/assets/tailwind/components/_action-banner.csstest/system/copyright_update_playwright_test.rbtest/system/admin_management_playwright_test.rbapp/assets/tailwind/components/_admin-nav.cssapp/controllers/admin/diagnostics_controller.rbtest/system/author_display_toggle_playwright_test.rbtest/system/copyright_rewrite_bug_playwright_test.rbtest/system/copyright_edge_cases_playwright_test.rbtest/system/admin_site_settings_playwright_test.rbapp/assets/tailwind/application.csstest/controllers/admin/diagnostics_controller_test.rb
**/*.rb
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.rb: Follow Rails Omakase RuboCop standards with 2-space indentation, snake_case naming, andAdmin::namespace convention. Runbundle exec rubocopregularly and use-a/-Aflags only when necessary.
Limit class files to 200 lines or less. Split larger classes into smaller, single-responsibility modules and extract business logic toapp/servicesorlib/.
Files:
test/system/copyright_update_playwright_test.rbtest/system/admin_management_playwright_test.rbapp/controllers/admin/diagnostics_controller.rbtest/system/author_display_toggle_playwright_test.rbtest/system/copyright_rewrite_bug_playwright_test.rbtest/system/copyright_edge_cases_playwright_test.rbtest/system/admin_site_settings_playwright_test.rbtest/controllers/admin/diagnostics_controller_test.rb
test/**/*test.rb
📄 CodeRabbit inference engine (CLAUDE.md)
Name test files by feature (e.g.,
admin_creates_article_test.rb). Include at least one failure case per new feature test, using both unit tests and system/Playwright tests.
Files:
test/system/copyright_update_playwright_test.rbtest/system/admin_management_playwright_test.rbtest/system/author_display_toggle_playwright_test.rbtest/system/copyright_rewrite_bug_playwright_test.rbtest/system/copyright_edge_cases_playwright_test.rbtest/system/admin_site_settings_playwright_test.rbtest/controllers/admin/diagnostics_controller_test.rb
test/system/**/*test.rb
📄 CodeRabbit inference engine (CLAUDE.md)
Use
.spec--selectors in system/Playwright tests to query elements. When tests fail, attach traces usingnpx playwright show-report. Reference test config fromtest/test_helper.rbTestConfigclass.
Files:
test/system/copyright_update_playwright_test.rbtest/system/admin_management_playwright_test.rbtest/system/author_display_toggle_playwright_test.rbtest/system/copyright_rewrite_bug_playwright_test.rbtest/system/copyright_edge_cases_playwright_test.rbtest/system/admin_site_settings_playwright_test.rb
app/assets/tailwind/application.css
📄 CodeRabbit inference engine (CLAUDE.md)
@sourcedirective paths must be relative to Rails.root (project root), not relative to the CSS file. Use./app/views/**/*.{html,erb}andapp/components/**/*.{rb,erb}format.
Files:
app/assets/tailwind/application.css
🧠 Learnings (12)
📓 Common learnings
Learnt from: CR
Repo: machida/mb PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T01:19:04.764Z
Learning: Applies to **/*.{erb,html} : Use `.spec--` classes exclusively for testing selectors (Playwright/MiniTest), not for CSS styling. Update `test/support/selectors.rb` when adding or modifying `.spec--` classes.
Learnt from: CR
Repo: machida/mb PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T01:19:04.764Z
Learning: Applies to **/*.{erb,html} : Use Tailwind CSS utility classes or ViewComponents for styling. Extract repeated utility patterns into `app/components` to avoid duplication.
Learnt from: CR
Repo: machida/mb PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T01:19:04.764Z
Learning: Applies to app/assets/tailwind/application.css : `source` directive paths must be relative to Rails.root (project root), not relative to the CSS file. Use `./app/views/**/*.{html,erb}` and `app/components/**/*.{rb,erb}` format.
Learnt from: CR
Repo: machida/mb PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T01:19:04.764Z
Learning: Applies to test/system/**/*test.rb : Use `.spec--` selectors in system/Playwright tests to query elements. When tests fail, attach traces using `npx playwright show-report`. Reference test config from `test/test_helper.rb` `TestConfig` class.
📚 Learning: 2025-12-03T01:19:04.764Z
Learnt from: CR
Repo: machida/mb PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T01:19:04.764Z
Learning: Applies to test/system/**/*test.rb : Use `.spec--` selectors in system/Playwright tests to query elements. When tests fail, attach traces using `npx playwright show-report`. Reference test config from `test/test_helper.rb` `TestConfig` class.
Applied to files:
test/system/copyright_update_playwright_test.rbtest/system/admin_management_playwright_test.rbtest/system/author_display_toggle_playwright_test.rbtest/system/copyright_rewrite_bug_playwright_test.rbtest/system/copyright_edge_cases_playwright_test.rbtest/system/admin_site_settings_playwright_test.rb
📚 Learning: 2025-12-03T01:19:04.764Z
Learnt from: CR
Repo: machida/mb PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T01:19:04.764Z
Learning: Applies to **/*.{erb,html} : Use `.spec--` classes exclusively for testing selectors (Playwright/MiniTest), not for CSS styling. Update `test/support/selectors.rb` when adding or modifying `.spec--` classes.
Applied to files:
test/system/copyright_update_playwright_test.rbtest/system/admin_management_playwright_test.rbtest/system/author_display_toggle_playwright_test.rbtest/system/copyright_rewrite_bug_playwright_test.rbtest/system/copyright_edge_cases_playwright_test.rbtest/system/admin_site_settings_playwright_test.rbapp/assets/tailwind/application.css
📚 Learning: 2025-12-03T01:19:04.764Z
Learnt from: CR
Repo: machida/mb PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T01:19:04.764Z
Learning: Applies to test/**/*test.rb : Name test files by feature (e.g., `admin_creates_article_test.rb`). Include at least one failure case per new feature test, using both unit tests and system/Playwright tests.
Applied to files:
test/system/copyright_update_playwright_test.rbtest/system/admin_management_playwright_test.rbtest/system/author_display_toggle_playwright_test.rbtest/system/copyright_rewrite_bug_playwright_test.rbtest/system/copyright_edge_cases_playwright_test.rbtest/system/admin_site_settings_playwright_test.rbtest/controllers/admin/diagnostics_controller_test.rb
📚 Learning: 2025-12-03T01:19:04.764Z
Learnt from: CR
Repo: machida/mb PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T01:19:04.764Z
Learning: Store GCS keys and API credentials in `rails credentials:edit`, never in `.env` or JSON files. Verify `.gitignore` includes `storage/`, `public/uploads`, and `.env`. Clearly document new credentials in PRs.
Applied to files:
app/controllers/admin/diagnostics_controller.rb
📚 Learning: 2025-12-03T01:19:04.764Z
Learnt from: CR
Repo: machida/mb PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T01:19:04.764Z
Learning: Applies to app/assets/tailwind/application.css : `source` directive paths must be relative to Rails.root (project root), not relative to the CSS file. Use `./app/views/**/*.{html,erb}` and `app/components/**/*.{rb,erb}` format.
Applied to files:
app/assets/tailwind/application.css
📚 Learning: 2025-12-03T01:19:04.764Z
Learnt from: CR
Repo: machida/mb PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T01:19:04.764Z
Learning: Applies to **/*.{erb,html} : Use Tailwind CSS utility classes or ViewComponents for styling. Extract repeated utility patterns into `app/components` to avoid duplication.
Applied to files:
app/assets/tailwind/application.css
📚 Learning: 2025-12-03T01:19:04.764Z
Learnt from: CR
Repo: machida/mb PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T01:19:04.764Z
Learning: Applies to app/components/**/*.{rb,erb} : Create reusable UI components in `app/components` for common view patterns and extract from repeated Tailwind utility usage.
Applied to files:
app/assets/tailwind/application.css
📚 Learning: 2025-12-03T01:19:04.764Z
Learnt from: CR
Repo: machida/mb PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T01:19:04.764Z
Learning: Applies to **/*.css : Use `rem` units instead of pixels in CSS, remove blank lines beyond 2 consecutive lines, and trim trailing whitespace.
Applied to files:
app/assets/tailwind/application.css
📚 Learning: 2025-12-03T01:19:04.764Z
Learnt from: CR
Repo: machida/mb PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T01:19:04.764Z
Learning: Applies to app/views/{public,admin,shared}/**/*.{erb,html} : Organize partials in `app/views/public`, `app/views/admin`, or `app/views/shared/` based on their intended usage scope.
Applied to files:
app/assets/tailwind/application.css
📚 Learning: 2025-12-03T01:19:04.764Z
Learnt from: CR
Repo: machida/mb PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T01:19:04.764Z
Learning: Applies to **/*.{rb,js,ts,jsx,tsx,erb,html,css} : Ensure files end with a newline character and contain no trailing whitespace.
Applied to files:
app/assets/tailwind/application.css
📚 Learning: 2025-12-03T01:19:04.764Z
Learnt from: CR
Repo: machida/mb PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-03T01:19:04.764Z
Learning: Applies to public/uploads/** : The `public/uploads/images` directory is used for file uploads in development only. Production uses Google Cloud Storage. Never commit uploaded files.
Applied to files:
test/controllers/admin/diagnostics_controller_test.rb
🧬 Code graph analysis (4)
test/system/copyright_update_playwright_test.rb (1)
test/system/copyright_edge_cases_playwright_test.rb (1)
submit_settings_and_wait(16-26)
test/system/author_display_toggle_playwright_test.rb (2)
app/models/site_setting.rb (1)
set(14-20)app/services/site_setting_service.rb (1)
set(11-13)
test/system/copyright_rewrite_bug_playwright_test.rb (1)
app/models/site_setting.rb (1)
copyright(49-51)
test/system/copyright_edge_cases_playwright_test.rb (1)
test/system/copyright_update_playwright_test.rb (1)
submit_settings_and_wait(19-29)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test
🔇 Additional comments (8)
app/assets/tailwind/components/_action-banner.css (1)
27-27: メディアクエリの単位をピクセルからremへの変換を検討してください。コーディングガイドラインでは「CSSではピクセルの代わりにrem単位を使用してください」と明記されています。現在のコードでは
768pxと1024pxを使用していますが、これを48rem(768px ÷ 16)と64rem(1024px ÷ 16)に変換すべきかどうか確認が必要です。Tailwindのメディアクエリではピクセルが慣例ですが、プロジェクトのガイドラインがrem単位を要求しているため、この点について検証をお願いします。Also applies to: 45-45, 57-57
app/assets/tailwind/components/_admin-nav.css (1)
13-13: メディアクエリの単位をピクセルからremへの変換について確認が必要です。
_action-banner.cssと同様に、メディアクエリで1024pxを使用していますが、コーディングガイドラインでは「CSSではピクセルの代わりにrem単位を使用してください」と明記されています。プロジェクト全体で一貫性を保つため、min-width: 64remへの変換が必要かどうか検証してください。Also applies to: 35-35, 48-48, 66-66, 92-92
app/assets/tailwind/application.css (1)
3-6: @source ディレクティブのパス形式をガイドラインと一致させてください。コーディングガイドラインでは
@sourceディレクティブについて以下の形式を指定しています:
./app/views/**/*.{html,erb}app/components/**/*.{rb,erb}現在のコードは以下のようになっています:
app/views/**/*.erb(./プレフィックスなし、{html,erb}でなく.erbのみ)app/components/**/*.rb({rb,erb}でなく.rbのみ)また、
app/helpers/**/*.rbとapp/javascript/**/*.jsが追加されていますが、これらがガイドラインで想定されていない可能性があります。Rails.rootから相対的なパスは正しいですが、グロブパターンの形式とプレフィックスについて検証が必要です。app/controllers/admin/diagnostics_controller.rb (1)
22-37: 非本番環境での動的な環境名・メッセージ化は妥当です
Rails.env.production?以外の分岐でstatus: Rails.env.to_sと"GCS not required in #{Rails.env}"を返すようにしたことで、test など他の非本番環境でも自己記述的な診断結果になっていて良いと思います。credentials の実値ではなく presence の有無(本番のみ)/false(非本番)だけを返している点も、GCS キーを漏らさないという意味でセキュアです。運用環境ごとに期待する JSON が想定どおりかだけ、手元で一度叩いて確認しておいてください。Based on learnings, GCS 資格情報は credentials に保持しつつ presence だけを公開する現状の方針と整合しています。
test/system/author_display_toggle_playwright_test.rb (1)
46-46:.spec--site-settings-titleへのセレクタ統一は良いですサイト設定ページ判定の
wait_for_selectorを 3 か所とも.spec--site-settings-titleに統一していて、他のシステムテストとの一貫性とテスト安定性が高まっています。この変更はそのままで問題なさそうです。Also applies to: 130-130, 138-138
test/system/admin_site_settings_playwright_test.rb (1)
86-94: フォーム値チェックを.spec--入力セレクタに揃えたのは適切です
site_title/top_page_description/copyrightすべて.spec--系クラスで取得し、input_valueで検証する形に揃っていて、同一ページ内の他テストとも一貫しています。ビュー側の.spec--クラス定義と対応していれば、この変更はそのままで良さそうです。test/system/admin_management_playwright_test.rb (1)
91-91: パスワード変更フローの.spec--セレクタ化は問題ありませんパスワード編集ページのタイトル確認とフォーム要素を
.spec--password-*系クラスに統一しており、他の管理画面テストと同じパターンで安定したセレクタになっています。フローやアサーションはそのままで、意図した挙動を保ったままテストの堅牢性が上がっていると思います。Also applies to: 220-226
test/system/copyright_rewrite_bug_playwright_test.rb (1)
25-77: 著作権更新系テストの.spec--セレクタ統一は良いですサイト設定タイトル、著作権入力、保存ボタンをすべて
.spec--site-settings-title/.spec--copyright-input/.spec--save-buttonに統一しつつ、フォーム表示値 → DB 値の二段階検証を維持していて、バグの再発検知に有効な形になっています。ネットワークログ取得用の@page.on('request', ...)もそのまま活かされており、デバッグ用途としても使いやすい構成だと思います。Also applies to: 86-137, 152-228
Summary by CodeRabbit
リリースノート
テスト
バグ修正
スタイル
✏️ Tip: You can customize this high-level summary in your review settings.