forked from nning/svelte-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·49 lines (33 loc) · 1.06 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
set -xe
export DISABLE_SPRING=true
# nvm use --delete-prefix v14.5.0
rails new svelte-rails-test --webpack=svelte
cd svelte-rails-test
echo "gem 'svelte-rails', path: '..'" >> Gemfile
bundle
yes | rails svelte:install
sed -i 's/svelte_ujs_ng.*$/svelte_ujs_ng": "..",/g' package.json
yarn
# TODO This does not work in shell context, yet
rails g controller greetings show
cat <<EOF > app/views/greetings/show.html.erb
<%= svelte_component :Hello, {name: 'Test'}, {prerender: true} %>
EOF
# rails s -d
# xdg-open http://localhost:3000/greetings/show
# kill `cat tmp/pids/server.pid`
rails db:migrate
rails assets:precompile
cat <<EOF > test/system/features_test.rb
require 'application_system_test_case'
class FeaturesTest < ApplicationSystemTestCase
test 'SSR from view and update by hydration' do
visit greetings_show_url
assert_selector 'h1', text: 'Hello Test! ❤'
assert !find('code').text.nil?
end
end
EOF
sed -i 's/driven_by :selenium.*$/driven_by :selenium, using: :headless_chrome/g' test/application_system_test_case.rb
rails test:system