<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by nando on Medium]]></title>
        <description><![CDATA[Stories by nando on Medium]]></description>
        <link>https://medium.com/@nando_chistaco?source=rss-852619621057------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QcGKOZV5XNJ7yFh4t5z1KA.jpeg</url>
            <title>Stories by nando on Medium</title>
            <link>https://medium.com/@nando_chistaco?source=rss-852619621057------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 22:46:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nando_chistaco/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Component visual testing with ViewCompontents and Appraise.qa]]></title>
            <link>https://medium.com/@nando_chistaco/component-visual-testing-with-viewcompontents-and-appraise-qa-ca864654f267?source=rss-852619621057------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca864654f267</guid>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[storybook]]></category>
            <category><![CDATA[viewcomponents]]></category>
            <category><![CDATA[visual-testing]]></category>
            <dc:creator><![CDATA[nando]]></dc:creator>
            <pubDate>Sun, 16 Jan 2022 17:40:17 GMT</pubDate>
            <atom:updated>2022-01-20T06:51:04.835Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OLnim_vNWFKT7Z_f" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>Component-driven (UI) Development</em> is gaining track influenced by, among other things, the growing relevance of <em>Design Systems</em> and the increase of the complexity and number of the use cases any application has to be able to manage “looking right”. <em>Storybook</em> has emerged into development teams as one of the favourite <em>Open Source</em> tools to make it possible. In this post i’ll talk about <em>RailsStorybookAppraise</em> (or <em>RSA</em> xD), a <em>Proof of Concept</em> of <em>Visual</em> “component” <em>Testing</em> using <em>Appraise.qa</em>, <em>Storybook</em>, and the <em>ViewComponent Rails</em> engine.</p><h3>Having a Design System lets us be recognized…</h3><p>And every growing company finally need one for, among other things, ensure the maximum return on its advertising investment. In front of a new development project <a href="https://storybook.js.org/"><strong><em>Storybook</em></strong></a><strong> is one of the available tools to document and discuss internally the components</strong> between the different teams involved in their implementation:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fp-LFh5Y89eM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dp-LFh5Y89eM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fp-LFh5Y89eM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbf37edece297cc5327a7bcbc22baf4b/href">https://medium.com/media/dbf37edece297cc5327a7bcbc22baf4b/href</a></iframe><p><a href="https://storybook.js.org/cdb19b23da5e96c112ff3b8fded28a82/storybook-hero-video-optimized-lg.mp4">https://storybook.js.org/cdb19b23da5e96c112ff3b8fded28a82/storybook-hero-video-optimized-lg.mp4</a></p><p>Considering that <a href="https://storybook.js.org/blog/the-storybook-story/"><strong><em>Storybook</em> is an <em>Open Source</em> community-driven project</strong></a> that already supports most <em>JS</em> existing <em>frameworks</em>…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/198/1*hNNvtu3B3-qvP6z859zVqg.png" /></figure><p>…it is no wonder that <strong><em>Storybook</em> is becoming the de facto standard to do that work</strong>. And <strong><em>Component-driven (User Interface) Development</em></strong> (<a href="http://componentdriven.org/"><em>componentdriven.org</em></a>) the philosophy that comes behind it…</p><h3>Visual Testing as a sentinel of our identity</h3><p><em>Visual</em> (regression or approval) <em>Testing</em> cares about what we are finally showing to those who are watching our app. <strong>It assumes that everything underneath is working</strong> (and hopefully being tested) correctly so that the image in question looks as desired.</p><p>This “carelessness” IMHO is very appropriate because for those pixels to be there are <strong>many “things” that have to be</strong> in their place. <strong>Very many in fact</strong>. That is the main reason why, when explaining a bug, we often start by saying something like “it was foolish” (“era una tontería”). The very name we give it, <em>bug</em> (insecto), already captures the essence of what I mean.</p><p>Therefore focusing on what we will finally show <strong>as if we were in a vacuum chamber</strong> to which no bug has access seems ideal to me. There are many good posts that have already been written on the subject, three of which I particularly liked and leave here for future reference:</p><ul><li><a href="https://betterprogramming.pub/visual-regression-testing-is-awesome-a6ac081ce58f"><strong>Visual Regression Testing Is Awesome</strong></a> (by <em>José Granja</em>)</li><li><a href="https://sparkbox.com/foundry/visual_regression_testing_with_backstopjs_applitools_webdriverio_wraith_percy_chromatic"><strong>Visual Regression Testing: Comparing SaaS tools and DIY tools</strong></a> (by <em>Patrick Fulton</em>)</li><li><a href="https://medium.com/loftbr/visual-regression-testing-eb74050f3366"><strong>Visual Regression Testing: what, why and how</strong></a> (by <em>Leonardo Giroto</em>)</li></ul><p>Finally I’d like to add two more links: the first one, <strong><em>Happo.io</em></strong>, for being the first SaaS I tried when <em>Mark Villacampa</em> told me about it after Zeitwerk’s MadridRB (of <strong>the awesome </strong><a href="http://applitools.com/"><strong><em>Applitools</em></strong></a><strong> and </strong><a href="http://percy.io/"><strong><em>Percy</em></strong></a> already speak amply any of the three posts I put above), and the last link for being <strong>the <em>Awesome List</em> that has helped me to discover </strong>many other interesting resources on the subject:</p><ul><li><a href="http://happo.io/"><strong><em>Happo.io</em></strong></a> (pioneer SaaS used by <em>Airbnb</em>, thanks Mark!!)</li><li><a href="https://github.com/mojoaxel/awesome-regression-testing"><strong>Awesome Visual Regression Testing</strong></a> (“curated list” in <em>GitHub</em>)</li></ul><p>For visual testing of components (not full pages) “the king” in the house is <a href="http://chromatic.com/"><em>Chromatic.com</em></a>, created and used by the <em>Storybook</em> team for <em>Storybook</em>’s own development, <strong>being </strong><a href="https://github.com/storybookjs/storybook/tree/master/addons/storyshots"><strong><em>StoryShots</em></strong></a><strong> and </strong><a href="https://loki.js.org/"><strong><em>Loki</em></strong></a><strong> the alternatives related with this <em>Proof of Concept</em> using only <em>Node</em></strong>.</p><h3>Appraise.qa: painless Visual Testing</h3><p>Painless visual testing (<em>dixit</em>) especially thanks to :</p><ul><li>Start the build from <strong>sketches/drawings</strong> if needed,</li><li>Self-documented<strong> tests written in <em>markdown</em></strong> in a free structure for its files and directories,</li><li><strong>Two commands</strong>: <strong><em>test</em></strong> (our app) <strong>and <em>approve</em></strong> (example/test).</li></ul><p>Let’s see an example to better understand what i mean:</p><ul><li><strong><em>First</em></strong> (optional step): we can draw our awesome homepage and take a picture of it (which we save e.g. in <em>test/examples/home.jpg</em>):</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hwH4YptPO6-acIc9bpyk1g.jpeg" /></figure><ul><li><strong><em>Second</em></strong>: wrote our first test in <em>markdown </em>(which we save e.g. in <em>test/examples/home.md</em>):</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*eVRt9-igEOTwKBNT8Q0vaA.png" /></figure><p>When in next step we launch the build <em>Appraise</em> will extract from our <em>.md</em> files its “<strong><em>~~~yaml</em></strong>” fragments with attributes <strong><em>example</em></strong> (test name) and <strong><em>fixture</em></strong> (<em>JS</em> function), and will execute the test in three stages:</p><ol><li>Executes the <em>JS</em> function defined in the fixture file passing as parameter an object with the keys/values defined in the block (in our example it’ll call the <strong><em>url.js</em></strong> function passing <strong><em>{ path: “/” }</em></strong><em> </em>as parameter).</li><li>That function should return anything that a browser is able to render (like for example an <em>URL</em>). <em>Appraise</em> will pass that value to the browser (by default a headless <em>Chrome</em> driven by <em>Puppeteer</em>) and will save the image rendered by the browser.</li><li>Finally <em>Appraise</em> compares that image with the “desired” one (the one in our “base line”), and determines whether or not it is valid (we can set a couple of parameters such as the tolerance for considering a pixel to be distinct, and the total number of distinct pixels allowed).</li></ol><ul><li><strong><em>Third</em></strong>: we launch our <em>test</em>… unsurprisingly <em>Appraise</em> tell us the images don’t match (or that no expected result has been defined yet).</li><li><strong><em>And fourth</em></strong>: as soon as our app is rendering something that we consider valid we approve the example, making that image the first one generated by our app, our first real “base line”.</li></ul><h3>ViewComponent: ours Rails way</h3><p><em>ViewComponent</em> is a <em>Rails engine</em> that, as its own definition at <a href="http://viewcomponent.org/">viewcomponent.org</a>, allows us to define <em>Ruby</em> objects with its presentation logic encapsulated. It’s an <strong>evolution of the<em> Presenter design pattern</em> inspired by <em>React</em></strong>.</p><p>Was created by <em>GitHub</em> to refactor its huge amount of <em>Ruby</em> and <em>Rails</em> code, and are currently being used by some of the “big players” using <em>Rails</em>. Many of those publish the components definitions of their design systems making them available for the community, like for example the <a href="https://design-system.service.gov.uk/components/"><em>UK’S Department of Education</em></a>, or <a href="https://primer.style/view-components/"><em>GitHub itself</em></a><em>.</em></p><p>In <a href="https://www.railsconf.com/info"><em>RailsConf 2021</em></a><em> Joel Hawksley</em> (<em>GitHub</em>) finished <a href="https://www.youtube.com/watch?v=QoetqsBCsbE">his talk about <em>ViewComponent</em></a><em> </em>calling on the <em>Rails</em> community to keep the <em>framework</em> relevant:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UnzrQJNlZBlGLyRS" /></figure><p>Shortly before that Joel referred to the need to innovate and explore potentially disruptive roads, such as the technology he had just presented.</p><p>One of the main advantages of using <em>ViewComponent</em> is the possibility of having <em>unit</em> tests, which are several orders of magnitude faster than <em>integration</em> or <em>acceptance</em> tests (e2e).</p><p>Although full page <em>visual (regression or approval) testing</em> are closer to the latter (and its scary slowness), component visual testing would be closer to the former, unit tests, <strong>making it IMHO a very attractive road to be explored</strong> by the community.</p><p>I owe the <em>Rails</em> community a lot, much more than just this (lousy xD) little post (and talk!!), but <strong>this <em>Proof of Concept</em> is my small grain of sand</strong> to explore that road. 🧐</p><h3>RailsStorybookAppraise (RSA): a PoC</h3><p><a href="http://github.com/nando/RSA"><em>RSA</em></a><em> </em>(github.com/nando/RSA) is a <em>Proof of Concept</em> of components visual testing using <em>Rails</em>’ <a href="http://viewcomponent.org/"><em>ViewComponents</em></a> an <a href="http://appraise.qa/"><em>Appraise.qa</em></a>.</p><p>To perform this <em>PoC</em> locally <strong>we need to have <em>Rails</em>, <em>Node</em>, and <em>Yarn</em> installed</strong>. Although the fastest way to do it is to clone <a href="http://github.com/nando/RSA">the <em>RSA</em> repo</a>, we can also do it step by step by following, in reverse, their self-explanatory commit messages (they use the <a href="https://gitmoji.dev/"><em>gitmoji</em></a> convention and, when needed, have an extra description of what they add to the project):</p><p><a href="https://github.com/nando/RSA/commit/ef8e01661f46c1acb55871de189a6ab8dd630275">🔧 Run “rails new RSA” and complete .gitignore</a> …</p><p>We create our <em>Rails</em> application with “<em>rails new AwesomeSite</em>” and add to .gitignore the files we know we don’t want to have in the repository (<em>*/**/*.stories.json</em>, <em>node_modules</em>, <em>public/storybook/</em> y <em>test/appraise/results/</em>).</p><p><a href="https://github.com/nando/RSA/commit/b1ecd525afc51cf41083eccbf6d3c0b0559b6236">➕ $ bundle add view_component view_component_storybook</a></p><p><a href="https://github.com/nando/RSA/commit/baedf22c66e81f5ef5a263df757459aafd55f941">➕ $ yarn add storybook/server — dev…</a></p><p>In this commit we made <strong>three changes to incorporate <em>Storybook</em> </strong>into the Node project:</p><ul><li>We add two of its packages (<em>server</em> and <em>addon-controls</em>):</li></ul><pre>$ yarn add @storybook/server @storybook/addon-controls --dev</pre><ul><li>We add two scripts in our <em>package.json</em>: one to run <em>Storybook</em> server in the development environment, and the other to generate it with static files in <em>public/storybook</em>:</li></ul><pre>{ <br>  &quot;scripts&quot;: {<br>    &quot;storybook&quot;: &quot;start-storybook&quot;,<br>    &quot;storybook:build&quot;: &quot;build-storybook -o public/storybook&quot;<br>  },<br>  [...]  <br>}</pre><ul><li>We add the <em>.storybook</em> folder with its first two files: <em>main.js</em> (to tell <em>Storybook</em> where we have the definition of our stories), and <em>preview.js</em> (to tell it where is the server to which it can request the referenced components)..</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*h3VxRIW5YWXFNgO5YO3ytA.png" /></figure><p><a href="https://github.com/nando/RSA/commit/c19d459753037cb1fe83e6844d0bf3b4ff9d281c">➕ $ bundle install rack-cors</a></p><p><a href="https://github.com/nando/RSA/commit/ae2f362ae016b6cf6d0b00989b8d61c6b0affc1a">🔧 Require storybook/engine &amp; rack-cors cfg.</a> …</p><p>We add the <em>Storybook</em> engine in our <em>config/application.rb</em> file:</p><pre>[...]<br>require &quot;rails/all&quot;<br>require &quot;view_component/storybook/engine&quot;<br>[...]</pre><p>In <em>config/environments/development.rb</em> we add the location of the assets server and a basic <em>CORS</em> configuration:</p><pre>[...]<br>  config.action_controller.asset_host =  &#39;<a href="http://localhost:3000&#39;">http://localhost:3000&#39;</a><br>  config.middleware.insert_before 0, Rack::Cors do<br>    allow do<br>      origins &#39;*&#39;<br>        resource &#39;/rails/stories/*&#39;,<br>                 :headers =&gt; :any,<br>                 :methods =&gt; [:get]<br>    end<br>  end<br>[...]</pre><p><a href="https://github.com/nando/RSA/commit/ef6348a6126b10395d5710fc69e564c067e9334d">✨ Our button component first two stories are (almost) here!!</a> …</p><p>This commit code was generated by our first component, with:</p><pre>$ rails generate component Button title --sidecar<br>      create  app/components/button_component.rb<br>      invoke  test_unit<br>      create    test/components/button_component_test.rb<br>      invoke  erb<br>      create    app/components/button_component/button_component.html.erb<br>$</pre><p>And replacing its empty test with the first two stories of our button that will be visually tested soon…</p><pre>class ButtonComponentStories &lt; ViewComponent::Storybook::Stories<br>  story(:with_short_text) do<br>    constructor(title: &quot;Title&quot;)<br>  end</pre><pre>story(:with_long_text) do<br>    constructor(title: &quot;THE REALLY BIG BUTTON THAT DOESN&#39;T DO ANYTHING&quot;)<br>  end<br>end</pre><p>Finally to give some colour to our buttons we are going to add some minimal styling (courtesy of <a href="http://w3schools.com/"><em>w3schools.com</em></a>, thanks!) to our <em>application.css</em> file:</p><pre>button {<br> background-color: #4CAF50; /* Green */<br> border: none;<br> color: white;<br> padding: 15px 32px;<br> text-align: center;<br> text-decoration: none;<br> display: inline-block;<br> font-size: 16px;<br>}</pre><p>To view <em>Storybook </em>in our development environment we first need to generate our component stories in its JSON format (running the <em>view_component_storybook:write_stories_json Rake</em> task) and start the <em>Rails</em> server:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*LSNGtFJ8oHzP4HCx1QsZ6A.png" /></figure><p>At this point we can, either raise a local<em> Storybook </em>server by launching “<em>npm run storybook</em>”, or deploy it with static files in <em>public/storybook</em> using its <em>storybook:build </em>script instead:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I8M9bZwN-HAS-y_VNzj5Kg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TE5AGrGLBfnYV6Db9tXJPA.png" /></figure><p>Whether we do the latter and visit <em>http://localhost:3000/storybook/</em>, or do the former and launch <em>Storybook</em> locally, we should see the first two stories on our brand new button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*VeXpxvxnhCC7L8RfmsS22A.png" /></figure><p>And without further ado let’s add the visual tests (or “examples”, as <em>Appraise</em> calls them) of our first two stories to our project…</p><p><a href="https://github.com/nando/RSA/commit/00cefa75bb7ddafe47e0a14ae4511e1761af257e">➕ $ yarn add appraise — dev (+ npm scripts)</a> …</p><p>We add the <em>Appraise</em> dependency:</p><pre>$ yarn add appraise --dev</pre><p>And we edit again the <em>package.json</em> file to add the two scripts needed to launch and approve the examples:</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;examples&quot;: &quot;./node_modules/.bin/<strong>appraise run</strong> [...]&quot;,<br>    &quot;approve&quot;: &quot;./node_modules/.bin/<strong>appraise approve</strong> [...]&quot;,<br>    [...]<br>  },<br>  [...]<br>}</pre><p><a href="https://github.com/nando/RSA/commit/d04f783dd1b605605d3b82febdd95f02cd1601e8">🧪 Add the first two “examples” (aka tests) of our button</a></p><pre># My Awesome Components Examples</pre><pre>Here we talk about our components awesomeness (if needed!! xDDD).</pre><pre>## Button component</pre><pre>### With short text<br>~~~yaml example=&quot;Button w short text&quot; fixture=&quot;url.js&quot;<br>path: /rails/stories/button_component/with_short_text<br>~~~</pre><pre>### With long text<br>~~~yaml example=&quot;Button w long text&quot; fixture=&quot;url.js&quot;<br>path: /rails/stories/button_component/with_long_text<br>~~~</pre><p>We launch the application tests by running our “<em>examples</em>” script and <em>Appraise</em> tells us that it has no images to compare the result of the executions with (i.e. it has no “<em>base line</em>”):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y52Gb0zWkvNPVoc2YnXXLg.png" /></figure><p>If we go to the folder where Appraise generates the results of its execution (<em>tests/appraise/results</em>) we can navigate to see the images of the two buttons that our component is returning at this time:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m33drktFEICXiTHzEStbEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NypFOLtkEzXMGnwLTQoN8Q.png" /></figure><p>In the pages with the results, when these are negative, <em>Appraise</em> offers us the command that we should execute if we want the image/s obtained by the last execution to become our “base line” for the “example/s” (as our scripts use <em>npm</em> to make these commands work we have to add “<em>npm run</em>” in front of them, and two dashes in front of the parameters).</p><p>In the previous page we can see that <em>Appraise</em> offers us the command to approve all the images of the component, but instead of approving all of them we will approve only the first one (we can navigate to that particular failure to <em>copy&amp;paste</em> its approval parameters):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rffxw2IaKKr749QmsO3Wgw.png" /><figcaption>Tras aprobar la imagen el test/ejemplo pasa a ser válido.</figcaption></figure><p>For the second button we have other plans…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/0*6WqbuHT7OQcBmQSU" /></figure><p><strong>¡¡We want the second button image to look like the one in </strong><a href="https://krystalrose.com/rosewood/library/BigButton.htm"><strong><em>TRBBTDDA</em></strong></a><strong>!!</strong></p><p>To achieve our goal we download <a href="https://github.com/nando/RSA/blob/7c355399d8ded0aa4699f93610ab7de28d739056/app/assets/images/button-that-doesnt-do-anything.png">the <em>TRBBTDDA</em><strong><em> </em></strong>button image</a> and put it in the folder <em>test/appraise/examples</em> where we have, on one side<strong> the <em>markdown</em> with the definition</strong> of our unique example, and <strong>now also the image of the button that we have just validated</strong> that <em>Appraise</em> stored next to it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*r5cmld9eMryCldbDOyVnrg.png" /><figcaption>Along with the definition of our tests/examples Appraise adds its “base line”.</figcaption></figure><p>Let’s open <em>my_awesome_components.md</em> to see what <em>Appraise</em> has added to it when we approve the short text button example:</p><pre># My Awesome Components Examples</pre><pre>Here we talk about our components awesomeness (if needed!! xDDD).</pre><pre>## Button component</pre><pre>### With short text<br>~~~yaml example=&quot;Button w short text&quot; fixture=&quot;url.js&quot;<br>path: /rails/stories/button_component/with_short_text<br>~~~</pre><pre>### With long text<br>~~~yaml example=&quot;Button w long text&quot; fixture=&quot;url.js&quot;<br>path: /rails/stories/button_component/with_long_text<br>~~~</pre><pre>## Button w short text</pre><pre>![Button w short text](Buttonwshorttext-ae761028-977e-43f8-809c-956fedde8669.png)</pre><pre>(generated: 8/1/2022 16:53:09)</pre><p>It has added a new section with the name of the example we have just validated in which it stores the name of the associated image and the date it was generated. To add the <em>TRBBTDDA</em> image, we duplicate this section and then modify its name and the name of its associated image:</p><pre>[...]</pre><pre>## Button w long text</pre><pre>![Button w long text](button-that-doesnt-do-anything.png)</pre><p>Now when we launch the tests <em>Appraise</em> tells us that the images have different dimensions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X9v70ZAIm2qi-vXzaxWXVQ.png" /></figure><p>And in the results of the story of the button with long text we can see the current situation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xe86sNm-9kE_vaANObhIlQ.png" /></figure><p>We copy <em>button-that-doesnt-do-anything.png</em> in <em>app/assets/images</em> and modify our view code to show it if the title is long:</p><pre>&lt;div data-controller=&quot;button-component--button-component&quot;&gt;<br>&lt;%- if title.length &gt; 30 -%&gt;<br>  &lt;%= image_tag(&quot;button-that-doesnt-do-anything.png&quot;,<br>        onclick: &quot;alert(&#39;Hi there!! Nothing here!!&#39;);&quot;) %&gt;<br>&lt;%- else -%&gt;<br>  &lt;%= button_to title %&gt;<br>&lt;%- end -%&gt;<br>&lt;/div&gt;</pre><p>Now, if we go to our <em>Storybook</em> and click on the button of his second story… <strong>DOES NOTHING!!</strong> xDDD</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*OGb4YODcp_lgUHmceAK-LQ.png" /></figure><p>Let’s see what happen when we launch our visual test:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*DbUjfQevFLNoq9uDLrrjWw.png" /></figure><p><em>Appraise</em> it continues failing because the dimensions of the original button in our “base line” (<em>320x200px</em>) do not match those of the one generated by the browser when rederderized as part of a webpage (<em>1024x220px</em>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*dLQNXebIlJ7NCgvxm_fUkA.png" /></figure><p>The width of the image generated by the browser can be set using the <strong><em>initial_width</em></strong> parameter of <em>Appraise.</em> In our case we have it set in the definition of our “<em>examples</em>” script to <em>1024px</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OE8rJJueAgmxjFpJj2E-hg.png" /></figure><p>As a matter of fact,<strong> for our visual validation requirements </strong>(that to say, a <em>Proof of Concept</em> of a “Chromatic DIY tool”) the image generated from Rails for our button <strong>is perfectly valid</strong>. And if we approve this exampleee… we will have created<strong> our first real “base line”!!!</strong> <strong><em>¡¡chispas!!*</em> </strong>✨</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*xmuMWN2mNBzHRU8gg7LE0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nLxzLCYC-Ve4wh2AGVFUdg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*X3wpm5yFw0Un9DTsMdBVuQ.png" /></figure><p>(*) “<em>Sparks!!</em>” is a classic joke for first time achievements that comes from a funny teenage perfume commercial on Spanish TV. By the way, this could also be my first talk in <em>Madrid-rb</em>!! ✨✨✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca864654f267" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>