Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8f4a951

Browse files
committedApr 23, 2024·
Add first system testcase
1 parent d5607a9 commit 8f4a951

File tree

16 files changed

+98
-8
lines changed

16 files changed

+98
-8
lines changed
 

‎Gemfile

+5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
44
# Specify your gem's dependencies in custom_elements-rails.gemspec.
55
gemspec
66

7+
gem "importmap-rails"
8+
gem "propshaft"
9+
710
gem "puma"
811

912
gem "sqlite3", "~> 1.4"
1013

1114
# Start debugger with binding.b [https://github.com/ruby/debug]
1215
# gem "debug", ">= 1.0.0"
16+
gem "capybara"
17+
gem "selenium-webdriver"

‎Gemfile.lock

+37
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,24 @@ GEM
8181
minitest (>= 5.1)
8282
mutex_m
8383
tzinfo (~> 2.0)
84+
addressable (2.8.6)
85+
public_suffix (>= 2.0.2, < 6.0)
8486
appraisal (2.5.0)
8587
bundler
8688
rake
8789
thor (>= 0.14.0)
8890
base64 (0.2.0)
8991
bigdecimal (3.1.7)
9092
builder (3.2.4)
93+
capybara (3.40.0)
94+
addressable
95+
matrix
96+
mini_mime (>= 0.1.3)
97+
nokogiri (~> 1.11)
98+
rack (>= 1.6.0)
99+
rack-test (>= 0.6.3)
100+
regexp_parser (>= 1.5, < 3.0)
101+
xpath (~> 3.2)
91102
concurrent-ruby (1.2.3)
92103
connection_pool (2.4.1)
93104
crass (1.0.6)
@@ -98,6 +109,10 @@ GEM
98109
activesupport (>= 6.1)
99110
i18n (1.14.4)
100111
concurrent-ruby (~> 1.0)
112+
importmap-rails (2.0.1)
113+
actionpack (>= 6.0.0)
114+
activesupport (>= 6.0.0)
115+
railties (>= 6.0.0)
101116
io-console (0.7.2)
102117
irb (1.12.0)
103118
rdoc
@@ -111,6 +126,7 @@ GEM
111126
net-pop
112127
net-smtp
113128
marcel (1.0.4)
129+
matrix (0.4.2)
114130
mini_mime (1.1.5)
115131
minitest (5.22.3)
116132
mutex_m (0.2.0)
@@ -128,8 +144,14 @@ GEM
128144
racc (~> 1.4)
129145
nokogiri (1.16.4-x86_64-linux)
130146
racc (~> 1.4)
147+
propshaft (0.8.0)
148+
actionpack (>= 7.0.0)
149+
activesupport (>= 7.0.0)
150+
rack
151+
railties (>= 7.0.0)
131152
psych (5.1.2)
132153
stringio
154+
public_suffix (5.0.5)
133155
puma (6.4.2)
134156
nio4r (~> 2.0)
135157
racc (1.7.3)
@@ -173,8 +195,16 @@ GEM
173195
rake (13.2.1)
174196
rdoc (6.6.3.1)
175197
psych (>= 4.0.0)
198+
regexp_parser (2.9.0)
176199
reline (0.5.1)
177200
io-console (~> 0.5)
201+
rexml (3.2.6)
202+
rubyzip (2.3.2)
203+
selenium-webdriver (4.19.0)
204+
base64 (~> 0.2)
205+
rexml (~> 3.2, >= 3.2.5)
206+
rubyzip (>= 1.2.2, < 3.0)
207+
websocket (~> 1.0)
178208
sqlite3 (1.7.3-arm64-darwin)
179209
sqlite3 (1.7.3-x86_64-linux)
180210
stringio (3.1.0)
@@ -183,9 +213,12 @@ GEM
183213
tzinfo (2.0.6)
184214
concurrent-ruby (~> 1.0)
185215
webrick (1.8.1)
216+
websocket (1.2.10)
186217
websocket-driver (0.7.6)
187218
websocket-extensions (>= 0.1.0)
188219
websocket-extensions (0.1.5)
220+
xpath (3.2.0)
221+
nokogiri (~> 1.8)
189222
zeitwerk (2.6.13)
190223

191224
PLATFORMS
@@ -194,8 +227,12 @@ PLATFORMS
194227

195228
DEPENDENCIES
196229
appraisal
230+
capybara
197231
custom_elements-rails!
232+
importmap-rails
233+
propshaft
198234
puma
235+
selenium-webdriver
199236
sqlite3 (~> 1.4)
200237

201238
BUNDLED WITH
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require "system_helper"
2+
3+
class CustomElements::IntegrationTest < ApplicationSystemTestCase
4+
test "it has a version number" do
5+
visit elements_path
6+
7+
assert_text "connectedCallback(): hello_element.js"
8+
end
9+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class ElementsController < ApplicationController
2+
def show
3+
end
4+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ElementsHelper
2+
end
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
2+
import "custom_elements"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default class extends HTMLElement {
2+
constructor() {
3+
super()
4+
}
5+
6+
connectedCallback() {
7+
this.textContent = "connectedCallback(): hello_element.js"
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { eagerDefineCustomElementsFrom } from "custom_elements-rails"
2+
3+
eagerDefineCustomElementsFrom("custom_elements", { prefix: "app" })
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h1>Elements#show</h1>
2+
3+
<app-hello></app-hello>

‎test/dummy/app/views/layouts/application.html.erb

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<%= csp_meta_tag %>
88

99
<%= stylesheet_link_tag "application" %>
10+
<%= javascript_importmap_tags %>
1011
</head>
1112

1213
<body>

‎test/dummy/bin/importmap

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env ruby
2+
3+
require_relative "../config/application"
4+
require "importmap/commands"

‎test/dummy/config/importmap.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pin "application"
2+
pin "custom_elements-rails"
3+
pin_all_from "app/javascript/custom_elements", under: "custom_elements"

‎test/dummy/config/routes.rb

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
11
Rails.application.routes.draw do
2-
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
3-
4-
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
5-
# Can be used by load balancers and uptime monitors to verify that the app is live.
6-
get "up" => "rails/health#show", as: :rails_health_check
7-
8-
# Defines the root path route ("/")
9-
# root "posts#index"
2+
resource :elements
103
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require "test_helper"
2+
3+
class ElementsControllerTest < ActionDispatch::IntegrationTest
4+
test "should get show" do
5+
get elements_show_url
6+
assert_response :success
7+
end
8+
end

‎test/dummy/vendor/javascript/.keep

Whitespace-only changes.

‎test/system_helper.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require "test_helper"
2+
3+
Capybara.server = :puma, { Silent: true }
4+
5+
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
6+
driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400]
7+
end

0 commit comments

Comments
 (0)
Please sign in to comment.