Skip to content

Commit 682d7d4

Browse files
authored
Merge pull request #466 from matestack/next-release
1.0.1 Release
2 parents 50ed0b3 + 86882e6 commit 682d7d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+302
-341
lines changed

Diff for: CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## v1.0.1 Release
4+
5+
This release contains bugfixes.
6+
7+
### Bugfixes
8+
9+
* Fixed javascript automatic scroll top on page transition for short pages #462
10+
* Enable async components on app level, only usable in pages and components before #458
11+
* Fixed duplicate directory error when using matestack-ui-core with webpacker #460
12+
13+
314
## v1.0.0 Release
415

516
Please note that this release contains breaking changes and soft deprecations. To make things easy for users of the current `v0.7.*` version, we have provided **Migration TODOs** at the end of each chapter.

Diff for: Dockerfile.dev

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ruby:2.6.5-alpine3.9
1+
FROM ruby:2.7.2-alpine3.12
22

33
RUN gem install bundler:2.1.4
44

Diff for: Dockerfile.test

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ruby:2.6.5-alpine3.9
1+
FROM ruby:2.7.2-alpine3.12
22

33
RUN gem install bundler:2.1.4
44

@@ -20,14 +20,14 @@ RUN apk update && apk upgrade \
2020
&& echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories \
2121
&& echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories \
2222
&& apk add --no-cache \
23-
chromium@edge=72.0.3626.121-r0 \
23+
chromium@edge \
2424
nss@edge \
2525
&& rm -rf /var/lib/apt/lists/* \
2626
/var/cache/apk/* \
2727
/usr/share/man \
2828
/tmp/*
2929

30-
RUN apk add chromium-chromedriver@edge=72.0.3626.121-r0
30+
RUN apk add chromium-chromedriver@edge
3131

3232
ENV CHROME_BIN=/usr/bin/chromium-browser \
3333
CHROME_PATH=/usr/lib/chromium/

Diff for: Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ group :development, :test do
2020
gem 'capybara'
2121
gem 'webpacker', '~> 4.0'
2222
gem 'pg', '>= 0.18', '< 2.0'
23-
gem 'selenium-webdriver', '~> 3.142', '>= 3.142.7'
23+
gem 'selenium-webdriver'
2424
gem 'puma'
2525
gem 'simplecov', require: false, group: :test
2626
gem 'byebug'

Diff for: Gemfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ GEM
197197
rspec-support (3.9.2)
198198
rspec-wait (0.0.9)
199199
rspec (>= 3, < 4)
200-
rubyzip (2.2.0)
200+
rubyzip (2.3.0)
201201
safe_yaml (1.0.5)
202202
selenium-webdriver (3.142.7)
203203
childprocess (>= 0.5, < 4.0)
@@ -257,7 +257,7 @@ DEPENDENCIES
257257
rspec-rails (~> 3.8)
258258
rspec-retry
259259
rspec-wait (~> 0.0.9)
260-
selenium-webdriver (~> 3.142, >= 3.142.7)
260+
selenium-webdriver
261261
simplecov
262262
trailblazer-cells
263263
turbolinks

Diff for: app/concepts/matestack/ui/core/app/store.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ const store = new Vuex.Store({
4040
return getScrollParent(node.parentNode)
4141
}
4242
}
43-
getScrollParent(document.getElementsByClassName("matestack-page-root")[0]).scrollTop = 0
43+
var scrollParent = getScrollParent(document.getElementsByClassName("matestack-page-root")[0])
44+
if(scrollParent){
45+
scrollParent.scrollTop = 0;
46+
}
47+
// getScrollParent(document.getElementsByClassName("matestack-page-root")[0]).scrollTop = 0
4448
}
4549
},
4650
actions: {

Diff for: app/lib/matestack/ui/core/rendering/main_renderer.rb

+7-6
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ def render(controller_instance, page_class, options)
2121
render_matestack_object(controller_instance, page_instance)
2222
elsif (params[:component_key].present? && params[:component_class].blank?)
2323
# async component rerendering from non isolated context
24+
app_instance = app_class.new(page_class, controller_instance, context)
2425
component_key = params[:component_key]
2526
page_instance = page_class.new(controller_instance: controller_instance, context: context)
26-
render_component(component_key, page_instance, controller_instance, context)
27+
render_component(component_key, app_instance, controller_instance, context)
2728
elsif (params[:component_class].present? && params[:component_key].blank?)
2829
# isolated component rendering
2930
component_class = params[:component_class]
@@ -75,15 +76,15 @@ def render_matestack_object(controller_instance, object, opts = {}, render_metho
7576
controller_instance.render rendering_options
7677
end
7778

78-
def render_component(component_key, page_instance, controller_instance, context)
79+
def render_component(component_key, app_or_page_instance, controller_instance, context)
7980
matched_component = nil
8081

81-
page_instance.matestack_set_skip_defer(false)
82+
app_or_page_instance.matestack_set_skip_defer(false)
8283

83-
page_instance.prepare
84-
page_instance.response
84+
app_or_page_instance.prepare
85+
app_or_page_instance.response
8586

86-
matched_component = dig_for_component(component_key, page_instance)
87+
matched_component = dig_for_component(component_key, app_or_page_instance)
8788

8889
unless matched_component.nil?
8990
render_matestack_object(controller_instance, matched_component, {}, :render_content)

Diff for: builder/Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
source 'https://rubygems.org'
22
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
33

4-
ruby '2.6.5'
4+
ruby '2.7.2'
55

66
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
77
gem 'rails', '~> 5.2.0'

Diff for: builder/Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ DEPENDENCIES
177177
webpacker
178178

179179
RUBY VERSION
180-
ruby 2.6.5p114
180+
ruby 2.7.2p137
181181

182182
BUNDLED WITH
183183
2.1.4

Diff for: docs/guides/000-installation/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Rails 6+ apps use webpacker by default. Rails 5 and below apps use the asset pip
2727
Add 'matestack-ui-core' to your `package.json` by running:
2828

2929
```
30-
$ yarn add https://github.com/matestack/matestack-ui-core#v1.0.0
30+
$ yarn add https://github.com/matestack/matestack-ui-core#v1.0.1
3131
$ yarn install
3232
```
3333

@@ -127,11 +127,11 @@ For further reading check out the [basic building blocks](/docs/guides/200-basic
127127

128128
## Usage
129129

130-
There are two ways to use matestack.
130+
There are two ways to use matestack.
131131

132132
### Full matestack
133133

134-
First, as we call it, _full matestack_, enabling all features and developing with all benefits. Learn more about the _full matestack_ approach by following the [tutorial](/docs/guides/100-tutorial/README.md) or reading about matestacks [basic building blocks](/docs/guides/200-basic_building_blocks/README.md).
134+
First, as we call it, _full matestack_, enabling all features and developing with all benefits. Learn more about the _full matestack_ approach by following the [tutorial](/docs/guides/100-tutorial/README.md) or reading about matestacks [basic building blocks](/docs/guides/200-basic_building_blocks/README.md).
135135

136136
### Integration in existing projects
137137

Diff for: lib/matestack/ui/core/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Matestack
22
module Ui
33
module Core
4-
VERSION = '1.0.0'
4+
VERSION = '1.0.1'
55
end
66
end
77
end

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "matestack-ui-core",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"main": "app/javascript/matestack-ui-core",
55
"private": true,
66
"dependencies": {

Diff for: spec/dummy/vendor/matestack-ui-core

-1
This file was deleted.

Diff for: spec/rails_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This file is copied to spec/ when you run 'rails generate rspec:install'
22
require 'spec_helper'
33
ENV['RAILS_ENV'] ||= 'test'
4-
require File.expand_path('../../config/environment', __FILE__)
4+
# require File.expand_path('../../config/environment', __dir__)
55
# Prevent database truncation if the environment is production
66
abort("The Rails environment is running in production mode!") if Rails.env.production?
77
require 'rspec/rails'

Diff for: spec/spec_helper.rb

+10
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,14 @@
140140
# as the one that triggered the failure.
141141
Kernel.srand config.seed
142142
=end
143+
144+
config.before :all, type: :feature do
145+
unless Rails.application.routes.url_helpers.method_defined?(:matestack_components_test_path)
146+
Rails.application.routes.append do
147+
get '/matestack_components_test', to: 'matestack_components#matestack_components_test', as: :matestack_components_test
148+
end
149+
Rails.application.reload_routes!
150+
end
151+
end
152+
143153
end

Diff for: spec/test/base/xss_spec.rb

+18-6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ def response
1212
end
1313

1414
visit "/example"
15-
static_output = page.html
16-
expect(static_output).to include("<h1>#{XSS::ESCAPED_EVIL_SCRIPT}</h1>")
15+
expect(page).to have_selector('h1', text: XSS::EVIL_SCRIPT)
16+
expect_alert false
1717
end
1818

1919
it "does not escape when we specifically say #html_safe" do
@@ -26,10 +26,8 @@ def response
2626
# gotta accept our injected alert
2727
accept_alert do
2828
visit "/example"
29+
expect_alert true
2930
end
30-
31-
# for reasons beyond me Chrome seems to remove our injected script tag,
32-
# but since we accepted an alert to get here this test should be fine
3331
end
3432

3533
# note that `heading do "string" end` doesn't work and you
@@ -47,6 +45,7 @@ def response
4745
end
4846

4947
visit "/example"
48+
expect_alert false
5049
static_output = page.html
5150
expect(static_output).not_to include("alert(")
5251
end
@@ -59,7 +58,20 @@ def response
5958
end
6059

6160
visit "/example"
62-
expect(page.html).to include("id=\"something-&quot;&gt;&lt;script&gt;alert('hello');&lt;/script&gt;")
61+
expect_alert false
62+
# expect(page.html).to include("id=\"something-&quot;&gt;&lt;script&gt;alert('hello');&lt;/script&gt;")
63+
end
64+
end
65+
66+
67+
68+
def expect_alert(alert)
69+
@alert = true
70+
begin
71+
page.driver.browser.switch_to.alert
72+
rescue
73+
@alert = false
6374
end
75+
expect(@alert).to be(alert)
6476
end
6577
end

Diff for: spec/test/components/area_spec.rb

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
require_relative "../support/utils"
2-
include Utils
1+
require 'rails_helper'
32

43
describe "Address Component", type: :feature, js: true do
4+
include Utils
5+
56
it "Example 1 - yield a given block" do
7+
matestack_render do
8+
area shape: :rect, coords: [1,2,3,4], href: '#', hreflang: 'de',
9+
media: "screen", rel: 'nofollow', target: :_blank
10+
end
611

7-
class ExamplePage < Matestack::Ui::Page
8-
def response
9-
area shape: :rect, coords: [1,2,3,4], href: '#', hreflang: 'de', media: "screen", rel: 'nofollow', target: :_blank
10-
end
11-
end
12-
13-
visit "/example"
14-
static_output = page.html
15-
expected_static_output = <<~HTML
16-
<area coords="1,2,3,4" href="#" hreflang="de" media="screen" rel="nofollow" shape="rect" target="_blank" />
17-
HTML
18-
expect(stripped(static_output)).to include(stripped(expected_static_output))
12+
expect(page).to have_selector(
13+
"area[shape='rect'][coords='1,2,3,4'][href='#'][hreflang='de'][media='screen'][rel='nofollow'][target='_blank']",
14+
visible: false
15+
)
1916
end
2017
end

Diff for: spec/test/components/br_spec.rb

+6-37
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,14 @@
1-
require_relative '../support/utils'
2-
include Utils
1+
require 'rails_helper'
32

43
describe 'Br Component', type: :feature, js: true do
4+
include Utils
55

66
it 'Example 1' do
7-
8-
class ExamplePage < Matestack::Ui::Page
9-
def response
10-
# simple br tag
11-
plain 'hello'
12-
br
13-
plain 'world!'
14-
# multiple br tags
15-
plain 'hello'
16-
br times: 5
17-
plain 'world!'
18-
# br tag with id and class
19-
plain 'hello'
20-
br id: 'my-br', class: 'fancy-br-class'
21-
plain 'world!'
22-
end
7+
matestack_render do
8+
br
9+
br
2310
end
24-
25-
visit "/example"
26-
static_output = page.html
27-
expected_static_output = <<~HTML
28-
hello
29-
<br/>
30-
world!
31-
hello
32-
<br/>
33-
<br/>
34-
<br/>
35-
<br/>
36-
<br/>
37-
world!
38-
hello
39-
<br id="my-br" class="fancy-br-class"/>
40-
world!
41-
HTML
42-
expect(stripped(static_output)).to ( include(stripped(expected_static_output)) )
11+
expect(page).to have_selector('br', count: 2, visible: false)
4312
end
4413

4514
end

Diff for: spec/test/components/dynamic/async/app_level_spec.rb

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
require 'rails_helper'
2+
3+
describe "Async Component", type: :feature, js: true do
4+
include Utils
5+
6+
it 'works on page level' do
7+
matestack_render do
8+
async id: 'async', rerender_on: 'update' do
9+
plain 'Time now: '
10+
paragraph text: DateTime.now.strftime("%Q")
11+
end
12+
end
13+
14+
expect(page).to have_content('Time now:')
15+
initial_timestamp = page.find("p").text # initial page load
16+
page.execute_script('MatestackUiCore.matestackEventHub.$emit("update")')
17+
expect(page).to have_content('Time now:')
18+
expect(page).not_to have_content(initial_timestamp)
19+
end
20+
21+
it 'should work on app level' do
22+
matestack_app do
23+
async id: 'async', rerender_on: 'update' do
24+
plain 'Time now: '
25+
paragraph text: DateTime.now.strftime("%Q")
26+
end
27+
yield_page
28+
end
29+
matestack_render reset_app: false do
30+
plain 'A page inside the app'
31+
end
32+
33+
expect(page).to have_content('A page inside the app')
34+
expect(page).to have_content('Time now:')
35+
initial_timestamp = page.find("p").text # initial page load
36+
page.execute_script('MatestackUiCore.matestackEventHub.$emit("update")')
37+
expect(page).to have_content('Time now:')
38+
expect(page).not_to have_content(initial_timestamp)
39+
reset_matestack_app
40+
end
41+
42+
end

0 commit comments

Comments
 (0)