File tree Expand file tree Collapse file tree 10 files changed +108
-22
lines changed
Expand file tree Collapse file tree 10 files changed +108
-22
lines changed Original file line number Diff line number Diff line change @@ -40,13 +40,34 @@ jobs:
4040 with :
4141 bundler-cache : true
4242
43+ - name : 📦 Setup Playwright
44+ run : |
45+ # Setup Playwright driver
46+ APP_ROOT=${GITHUB_WORKSPACE}
47+ PLAYWRIGHT_VERSION=$(bundle exec ruby -e 'require "playwright"; puts Playwright::COMPATIBLE_PLAYWRIGHT_VERSION.strip')
48+ DRIVER_URL="https://playwright.azureedge.net/builds/driver/playwright-$PLAYWRIGHT_VERSION-linux.zip"
49+ DRIVER_DIR="$APP_ROOT/playwright-drivers"
50+ mkdir -p "$DRIVER_DIR"
51+ cd "$DRIVER_DIR"
52+ wget -q "$DRIVER_URL" -O playwright.zip
53+ unzip -o playwright.zip
54+ rm playwright.zip
55+
56+ # Install Playwright globally
57+ npm install -g playwright
58+
59+ # Install Playwright Chromium browser with dependencies
60+ playwright install --with-deps chromium
61+
4362 - name : 🧪 Prepare DB
4463 run : |
4564 bundle exec rails db:create
4665 bundle exec rails db:setup
4766
4867 - name : 🔧 Test
4968 run : bundle exec rspec spec
69+ env :
70+ PLAYWRIGHT_DRIVER_PATH : ${{ github.workspace }}/playwright-drivers/package/cli.js
5071
5172 deploy :
5273 needs : test
Original file line number Diff line number Diff line change @@ -36,3 +36,4 @@ public/assets/*
3636
3737# rspec
3838spec /examples.txt
39+ playwright-drivers
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ group :development, :test do
8787 gem 'factory_bot_rails'
8888 gem 'rspec-rails' , '~> 4.0'
8989 gem 'selenium-webdriver'
90+ gem 'capybara-playwright-driver'
9091
9192 gem 'dotenv-rails'
9293end
Original file line number Diff line number Diff line change 119119 rack-test (>= 0.6.3 )
120120 regexp_parser (>= 1.5 , < 3.0 )
121121 xpath (~> 3.2 )
122+ capybara-playwright-driver (0.5.4 )
123+ addressable
124+ capybara
125+ playwright-ruby-client (>= 1.16.0 )
122126 childprocess (5.1.0 )
123127 logger (~> 1.5 )
124128 coderay (1.1.3 )
272276 memoist (0.16.2 )
273277 memory_profiler (1.1.0 )
274278 method_source (1.1.0 )
279+ mime-types (3.6.0 )
280+ logger
281+ mime-types-data (~> 3.2015 )
282+ mime-types-data (3.2024.1203 )
275283 mini_mime (1.1.5 )
276284 mini_portile2 (2.8.8 )
277285 mini_racer (0.16.0 )
303311 ast (~> 2.4.1 )
304312 racc
305313 pg (1.5.8 )
314+ playwright-ruby-client (1.49.0 )
315+ concurrent-ruby (>= 1.1.6 )
316+ mime-types (>= 3.0 )
306317 pry (0.14.2 )
307318 coderay (~> 1.1 )
308319 method_source (~> 1.0 )
420431 ruby-mp3info (0.8.10 )
421432 ruby-progressbar (1.13.0 )
422433 ruby2_keywords (0.0.5 )
423- rubyzip (2.3.2 )
434+ rubyzip (2.4.1 )
424435 sass-rails (6.0.0 )
425436 sassc-rails (~> 2.1 , >= 2.1.1 )
426437 sassc (2.4.0 )
432443 sprockets-rails
433444 tilt
434445 secure_headers (6.7.0 )
435- selenium-webdriver (4.24 .0 )
446+ selenium-webdriver (4.27 .0 )
436447 base64 (~> 0.2 )
437448 logger (~> 1.4 )
438449 rexml (~> 3.2 , >= 3.2.5 )
@@ -506,6 +517,7 @@ DEPENDENCIES
506517 bootsnap
507518 bootstrap-sass
508519 capybara
520+ capybara-playwright-driver
509521 coffee-rails
510522 dotenv-rails
511523 factory_bot_rails
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ FileUtils.chdir APP_ROOT do
3434 system! 'gem install bundler --conservative'
3535 system ( 'bundle check' ) || system! ( 'bundle install' )
3636
37+ puts "\n == Setting up Playwright driver =="
38+ system! 'bin/setup_playwright'
39+
3740 # puts "\n== Copying sample files =="
3841 # unless File.exist?('config/database.yml')
3942 # FileUtils.cp 'config/database.yml.sample', 'config/database.yml"
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -e
3+
4+ APP_ROOT=$( dirname " $( dirname " $( readlink -f " $0 " ) " ) " )
5+ PLAYWRIGHT_VERSION=$( bundle exec ruby -e ' require "playwright"; puts Playwright::COMPATIBLE_PLAYWRIGHT_VERSION.strip' )
6+ DRIVER_URL=" https://playwright.azureedge.net/builds/driver/playwright-$PLAYWRIGHT_VERSION -linux.zip"
7+ DRIVER_DIR=" $APP_ROOT /playwright-drivers"
8+
9+ echo " == Setting up Playwright driver =="
10+
11+ mkdir -p " $DRIVER_DIR "
12+
13+ cd " $DRIVER_DIR "
14+ echo " Downloading Playwright driver from $DRIVER_URL ..."
15+ wget -q " $DRIVER_URL " -O playwright.zip
16+ echo " Extracting Playwright driver..."
17+ unzip -o playwright.zip
18+ rm playwright.zip
19+
20+ echo " Playwright driver setup completed. Driver is available in $DRIVER_DIR ."
Original file line number Diff line number Diff line change 44 describe "GET documents" do
55 scenario "Document index should be exist" do
66 visit docs_path
7- expect ( page ) . to have_http_status ( :success )
8-
9- # NOTE: 毎回 -3 などの offset を調整するのが面倒なのでテストを止めています
10- # expect(page).to have_css 'section.doc a[href]', count: (Document.all.count - 3)
7+ expect ( page ) . to have_selector ( 'h2' , text : 'CoderDojo 資料集' )
8+ expect ( page ) . to have_css ( 'section.docs a[href]' , minimum : 1 )
119 end
1210
1311 scenario "Charter should be exist" do
14- visit doc_path ( 'charter' )
15- expect ( page ) . to have_http_status ( :success )
12+ visit docs_path
13+ within ( 'section.docs' ) do
14+ expect ( page ) . to have_link 'CoderDojo 憲章' , href : "/docs/charter"
15+ click_link 'CoderDojo 憲章'
16+ end
17+ expect ( page ) . to have_selector ( 'h1' , text : 'CoderDojo 憲章' )
1618 end
1719
1820 scenario "Load doc file with absolute path" do
19- visit "#{ docs_path } /"
20- expect ( page ) . to have_http_status ( :success )
21- expect ( page ) . to have_link 'コントリビューター行動規範' , href : "/docs/code-of-conduct"
22- click_link 'コントリビューター行動規範'
23- expect ( page ) . to have_http_status ( :success )
21+ visit "/docs/code-of-conduct"
22+ expect ( page ) . to have_selector ( 'h1' , text : 'コントリビューター行動規範' )
2423 end
2524 end
2625end
Original file line number Diff line number Diff line change 77
88 describe "リンクをクリックする" do
99 scenario "統計情報に飛ぶ" do
10- all ( :link_or_button , '統計情報' ) . first . click
11- expect ( page ) . to have_selector 'h1' , text :'統計情報'
10+ find ( :link_or_button , '資料を探す' ) . hover
11+ click_link '統計情報'
12+ expect ( page ) . to have_selector 'h1' , text : '統計情報'
1213 end
1314 scenario "近日開催の道場に飛ぶ" do
1415 click_link '近日開催の道場'
15- expect ( page ) . to have_selector 'h1' , text :'📅 近日開催 '
16+ expect ( page ) . to have_selector 'h1' , text : '近日開催の道場 '
1617 end
1718 scenario "Kataに飛ぶ" do
1819 all ( :link_or_button , 'Kata' ) . first . click
19- expect ( page ) . to have_selector 'h1' , text :'📚 Kata'
20+ expect ( page ) . to have_selector 'h1' , text : / Kata/
2021 end
2122 end
2223end
Original file line number Diff line number Diff line change 44 describe 'GET documents' do
55 scenario 'Podcast index should be exist' do
66 visit '/podcasts'
7- expect ( page ) . to have_http_status ( :success )
7+ expect ( page ) . to have_selector ( 'h1' , text : 'DojoCast' )
88 end
99
1010 scenario 'Charter should be exist' do
1616
1717 visit "/podcasts/#{ @podcast . id } "
1818 target = '← Top'
19- expect ( page ) . to have_http_status ( :success )
19+ expect ( page ) . to have_selector ( '.episode h1#title' )
2020 expect ( page ) . to have_link target , href : '/podcasts'
2121 click_link target , match : :first
22- expect ( page ) . to have_http_status ( :success )
22+ expect ( page ) . to have_selector ( 'h1' , text : 'DojoCast' )
2323 end
2424
2525 scenario 'Load doc file with absolute path' do
3030
3131 visit "/podcasts/#{ @podcast . id } "
3232 target = 'DojoCast'
33- expect ( page ) . to have_http_status ( :success )
33+ expect ( page ) . to have_selector ( '.episode h1#title' )
3434 expect ( page ) . to have_link target , href : '/podcasts'
3535 click_link target , match : :first
36- expect ( page ) . to have_http_status ( :success )
36+ expect ( page ) . to have_selector ( 'h1' , text : 'DojoCast' )
3737 end
3838 end
3939end
Original file line number Diff line number Diff line change 5555 # arbitrary gems may also be filtered via:
5656 # config.filter_gems_from_backtrace("gem name")
5757 config . include FactoryBot ::Syntax ::Methods
58+
59+ # Default driver is rack_test
60+ Capybara . default_driver = :rack_test
61+
62+ # Register Selenium WebDriver driver
63+ # Capybara.register_driver :selenium do |app|
64+ # Capybara::Selenium::Driver.new(
65+ # app,
66+ # browser: :chrome,
67+ # options: Selenium::WebDriver::Chrome::Options.new(args: %w[headless disable-gpu no-sandbox])
68+ # )
69+ # end
70+
71+ # Register Playwright driver
72+ Capybara . register_driver :playwright do |app |
73+ cli_path = ENV [ 'PLAYWRIGHT_DRIVER_PATH' ] || File . expand_path ( 'playwright-drivers/package/cli.js' , Rails . root )
74+ Capybara ::Playwright ::Driver . new (
75+ app ,
76+ headless : true ,
77+ browser_type : :chromium ,
78+ playwright_cli_executable_path : cli_path
79+ )
80+ end
81+
82+ # Use Selenium driver for feature specs
83+ config . before ( :each , type : :feature ) do
84+ Capybara . current_driver = :playwright
85+ end
5886end
You can’t perform that action at this time.
0 commit comments