<?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 Oaish Kukreja on Medium]]></title>
        <description><![CDATA[Stories by Oaish Kukreja on Medium]]></description>
        <link>https://medium.com/@oaish08kukreja?source=rss-6558f0733d30------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*vysJb_tkSOd47JLW3W3Vmw.jpeg</url>
            <title>Stories by Oaish Kukreja on Medium</title>
            <link>https://medium.com/@oaish08kukreja?source=rss-6558f0733d30------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 16:39:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@oaish08kukreja/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[How to Host in IIS (Internet Information Services) ?]]></title>
            <link>https://oaish08kukreja.medium.com/how-to-host-in-iis-internet-information-services-ab1a6cb2b68e?source=rss-6558f0733d30------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab1a6cb2b68e</guid>
            <category><![CDATA[hosting]]></category>
            <category><![CDATA[windows]]></category>
            <dc:creator><![CDATA[Oaish Kukreja]]></dc:creator>
            <pubDate>Mon, 17 Jun 2024 11:52:40 GMT</pubDate>
            <atom:updated>2024-06-19T11:39:53.555Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Host in IIS (Internet Information Services) ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*UOiQkPl0bSk9V8wia3QWhg.png" /></figure><p>Internet Information Services, also known as IIS, is a Microsoft web server that runs on Windows operating system and is used to exchange static and dynamic web content with internet users. IIS can be used to host, deploy, and manage web applications using technologies such as ASP .NET and PHP.</p><p>Building and deploying a simple “Hello World!” website can be a great way to familiarize ourself with the basics of web development and web server management. In this tutorial, we’ll see how to build and deploy a “Hello World!” website on your Windows machine using Internet Information Services (IIS) and how can we use IIS to deploy application made from Visual Studios on .Net Core.</p><h3>Step 1 Installation of IIS and Hosting Bundle on System</h3><p>On you local Windows System</p><ul><li>Open the Control Panel and navigate to “<strong>Programs and Features</strong>”.</li><li>Click on “<strong>Turn Windows features on or off</strong>.”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mdtEyvWa6HYAkqE2Or7sqg.png" /></figure><ul><li>Scroll down and select “<strong>Internet Information Services</strong>”.</li><li>Click on “<strong>OK</strong>” to begin the installation process.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*KMDsUd1Z9VxmqFIetNIIJw.png" /></figure><p>On EC2 server instance,</p><ul><li>Open the Server Manger and navigate to <strong>“Navigate to Add roles and features“.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QzOXMeAkqb5en4FeZHHhFQ.png" /></figure><ul><li>Click Next to “<strong>Installation Type”</strong>, keep the <strong>“Role-based or feature-based installation only”.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*IQfGyQnbwoET0cXtgIm77Q.png" /></figure><ul><li>Click Next to <strong>“Server Selection“</strong>, make sure your server is selected.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*kd3V7rETPmNTgK3ZG3_nqA.png" /></figure><ul><li>Click Next to <strong>“Server Roles“</strong>, select <strong>“Web Server (IIS)“</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*hqDaSDVnskAS4Dkd79NCcw.png" /></figure><p><strong>Note:- </strong>In this server, I had already installed the IIS that’s why in image (11 of 43 installed) is coming after Web Server (IIS).</p><ul><li>Click Next to <strong>“Features“</strong>, select <strong>“IIS Hostable Web Core“</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*D3GRpoG5_ZgYDRpLQTEKbQ.png" /></figure><ul><li>Click Next to <strong>“Confirmation“ </strong>and <strong>“Result“</strong>.</li><li>After installing IIS on local windows system or aws server, install <a href="https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/hosting-bundle?view=aspnetcore-8.0">Hosting Bundle</a>.</li></ul><h3>Step 2 Create a new website in IIS</h3><ul><li>Open the <strong>“Internet Information Services (IIS) Manager”</strong> from the start menu.</li><li>In the left pane, right-click on <strong>“Sites”</strong>, select <strong>“Add Website..”</strong> and provide the site name for the website. Such as <strong>“Hello World Site”.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BFHkhkJG_m_8HaBw94eEKQ.png" /></figure><ul><li>Choose a physical path where you will store the website files.<br>Eg: <strong>“C:\inetpub\wwwroot\HelloWorldSite”</strong>.</li><li>Keep the hostname blank, since we are going to use the <strong>“localhost”</strong>.</li><li>Click on <strong>“OK”</strong> to create the website.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cXgUmAxRFX607LzroI3z3Q.png" /></figure><p><strong>Note :-</strong></p><ul><li>Give the port number available on your system or server. Port 80 and 443 are the basically used to interact with clients. Port 443 is the open port which can be used with https only.</li><li>We have used the folder <strong>“inetpub“ </strong>because this folder will have default permissions added for IIS User. We can add the any folder we want to but then we have to add IIS User to the Security. <a href="https://learn.microsoft.com/en-us/troubleshoot/developer/webapps/iis/www-authentication-authorization/default-permissions-user-rights">Default permissions and user rights in IIS — Internet Information Services</a></li></ul><h3>Step 3 Create a Hello World html file</h3><ul><li>Navigate to the physical path you specified for the application above. Eg: <strong>“C:\inetpub\wwwroot\HelloWorldSite</strong>\<strong>”</strong></li><li>Create a new HTML file named <strong>“index.html”</strong>.</li></ul><h3>Step 4 Create a Hello World html file</h3><p><em>To test the website, open your web browser and enter </em><strong><em>“</em>http://localhost:85/<em>”</em></strong><em> in the address bar.</em><br><em>TA DA.. You should see your “Hello World!” website..</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A54Vu3oVkDsUcGhMTNN3YA.png" /></figure><p>That’s it! We’ve successfully built and deployed an HTML website on your Windows machine using IIS. This is just the beginning of what you can do with IIS and web development.</p><p>Now as we have seen how to set up IIS and work with it. Let’s see how to host a ASP .NET core and to make it available on internet. Currently the Hello World Site we built was only available on local system. Also this could be possible only when you have a certified domain.</p><p>Let’s skip the part from where we will get the application to host. But let’s say we have a project create from Visual Studios which we need to host on the IIS. We have to make sure that the project must have a <strong>web.config </strong>file.</p><p>Now, <strong>Step 1 </strong>and <strong>Step 2 </strong>will remain same. We can skip <strong>Step 3</strong> as we already got the project. Now this project is available to us on <a href="http://localhost:portnumber/."><strong>http://localhost:portnumber/</strong>.</a> We have to bind this port number to 443. For which we can follow some steps</p><h3>Step 1 Get the SSL certificate</h3><ul><li>Get the SSL certificate which have a certified domain.</li><li>Save it on our server.</li></ul><h3>Step 2 Edit Binding of Website</h3><ul><li>Go to the <strong>IIS Manager</strong>, under <strong>Sites</strong> click on your Site.</li><li>On the right corner, under <strong>Actions Panel</strong>, Click on <strong>Bindings.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iuifCoWBQviE7cG7XMV65g.png" /></figure><ul><li>Click on <strong>Add, </strong>change the Type as <strong>https, </strong>the port number will change to 443.</li><li>Add the <strong>SSL Certificate</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FYl25AB8KkqeZMw_4wuh8w.png" /></figure><p>That’s it, the site is now available on your certified domain as well. With a little bit of practice and experimentation, you’ll be creating more advanced websites in no time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab1a6cb2b68e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advance Table Grid in Salesforce]]></title>
            <link>https://oaish08kukreja.medium.com/advance-table-grid-in-salesforce-aa06e04320fa?source=rss-6558f0733d30------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa06e04320fa</guid>
            <category><![CDATA[grid]]></category>
            <category><![CDATA[lwc]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[table]]></category>
            <dc:creator><![CDATA[Oaish Kukreja]]></dc:creator>
            <pubDate>Sun, 17 Oct 2021 19:23:09 GMT</pubDate>
            <atom:updated>2021-10-17T19:23:09.771Z</atom:updated>
            <content:encoded><![CDATA[<p>Today, let’s talk about some high-performance table component available to us in JavaScript, Bryntum Grid. Bryntum Grid is a powerful and potent table component capable of handling 100k+ rows while still providing a great user experience. Bryntum grid can be considered as the powered version of lightning-tree-grid and data table with so many eccentric features which can’t be found in basic lightning table components. The Bryntum grid is a pure JavaScript grid component which integrates easily with popular frameworks, where we are fortunate as it can also be used in LWC salesforce development. Bryntum Grid performs good both initially and while scrolling. Some highlighted features of grid are</p><ol><li>Fast virtual rendering</li><li>Multiple scrollable column sections</li><li>Inline cell editing</li><li>Custom cell rendering</li><li>Grouping of rows and headers</li><li>Filtering and searching</li><li>Tree grid, and many more.</li></ol><p>In this article, we will walk through how to create and integrates the bryntum grid with salesforce LWC. We also create a basic common component of bryntum grid so that you don’t have go through all the hard work again again in your development environment. I will also share the git repo for the project where I have already created the common component for all, but that component is too basic into consideration. The bryntum grid has vast varieties of grid type and usage. All the column content and data varies according to the requirement, but still I have tried to explore the grid types and brings out the most basic required grid data that I have shown in my grid repo. But still I would recommend to go through the article once you need your own customized grid.</p><h4>Bryntum Grid in Salesforce</h4><p>Salesforce Lightning allows using 3rd party JS libraries to create web applications. Bryntum Grid relies on a number of native Web APIs, some of which are modified (or completely blocked) by Lightning Locker. Salesforce recommends to always choose Lightning Web Components. With that said let’s move on to the integration part first.</p><h4>Getting Started</h4><p>Click on the <a href="https://bryntum.com/examples/grid/">link</a> and download the project demo for Salesforce, highly recommended if you want to explore all kinds of grid implementations.</p><h4>Setup</h4><ol><li>Go to your playground or create a new one, where Dev hub is enabled</li><li>Create a standard project for byrntum grid from vscode and name as bryntum grid(you can name accordingly)</li><li>Authorize the dev hub to the project</li><li>Create a Scratch org</li></ol><p>From here on first I’ll let you know how can we add the bryntum grid to our project easily, it’s not that tds task to perform. But apart from that I will show you how can we create a common byrntum grid component which can we used anywhere after a basic setup.</p><p>5. Copy static resource from examples grid folder, examples/salesforce/src/staticresources/bryntum_grid.resource-meta.xml to your directory location of static resource</p><p>6. Create folder inside static resource of your project directory name as bryntum_grid, and Copy required sources to the static resource folder, required sources are:</p><blockquote>JS bundle specific for LWC<br>CSS bundle<br>Locales<br>Fonts</blockquote><p>This resources can be found in build folder of example downloaded. You have to copy</p><blockquote>grid.lwc.module.js <br>grid.stockholm.css<br>grid.d.ts <br>locales<br>fonts</blockquote><p><em>Push this static resources to org now.</em></p><p>This have created a component that contains the bryntum grid for which we have struggled. Now the question is how many times will you go through same setup again in the js file when you want to use the bryntum grid in your project. The simple thing is we can’t do that always of course. So here’s a solution for that on a basic grid data.</p><h4>Usage</h4><ol><li>Create a LWC component name as bryntum_grid</li><li>Add events.js in the component, add two events in the file, one is for ready and other for error.</li></ol><blockquote>class ReadyEvent extends CustomEvent {<br>constructor() {<br> super(‘ready’);<br> }<br>}</blockquote><blockquote>class ErrorEvent extends CustomEvent {<br> constructor(Error) {<br> super(‘error’, {<br> detail: Error<br> });<br> }<br>}</blockquote><p>3. Add this line &lt;div lwc:dom=”manual”&gt;&lt;/div&gt; in the HTML of the component</p><p>4. In the js part, now here is the main catch for the common component to be created.</p><blockquote>a. First we look at the imports <br>import { ReadyEvent, ErrorEvent } from ‘./events’;<br>import { loadScript, loadStyle } from ‘lightning/platformResourceLoader’;<br>import GRID from ‘<a href="http://twitter.com/salesforce/resourceUrl">@salesforce/resourceUrl</a>/bryntum_grid’;</blockquote><p>Here I have imported the events, which will notify when the grid is ready to load, or it have thrown some error while loading. Also have imported the locker services which will load the styles and scripts. And finally, the GRID from static resource</p><p>b. Second if you have gone through the grid_component from the example you must have scene that the grid component is loaded after the rendered call back so I have the taken that part of code throw the ready event of error event to the parent component.</p><blockquote>renderedCallback() {<br> if (this.bryntumInitialized) {<br> return;<br> }<br> this.bryntumInitialized = true;</blockquote><blockquote>Promise.all([<br> loadScript(this, GRID + ‘/grid.lwc.module.js’),<br> loadStyle(this, GRID + ‘/grid.stockholm.css’)<br> ]).then(() =&gt; {<br> this.dispatchEvent(new ReadyEvent());<br> }).catch(error =&gt; {<br> this.dispatchEvent(<br> new ErrorEvent(‘Some Error at rendering the grid’)<br> );<br> });<br> }</blockquote><p>c. Now the main part, after handling the ready event on parent component, we will need to create the data or say initialize the grid with data, for which I have created a public method in this component,</p><blockquote><a href="http://twitter.com/api">@api</a> createGrid(initialConfig) {<br> initialConfig = { …initialConfig, appendTo: this.appendTo};<br> window.grid = new bryntum.grid.Grid(initialConfig);<br> }<br> <br>Here initialConfig is the data config for the grid.</blockquote><p>d. Last we need to append the grid to the html, so never forget to add the append to property in the initialConfig. But you can say that why didn’t we added this from the parent component. So answer is very easy, because the grid has to be created in this component and there won’t be any reference in the parent component for the child div tag. So we will add a getter in this component</p><blockquote>get appendTo() {<br> return this.template.firstChild;<br> }</blockquote><p>This is how this component is now a common byrntum initializing component. Now we have to handle the ready and error event at the parent component and pass the config in the createGrid and your BryntumGrid is ready to use. I have the added the references and the git repo, refer them for more depths of brytum grid. Also this can be used in AURA component.</p><h4>References</h4><ol><li><a href="https://github.com/Oaish08/bryntumGrid.git">Git Repo</a></li><li><a href="https://www.bryntum.com/docs/grid/">Bryntum Grid Documentation</a></li><li><a href="https://medium.com/bryntum/five-fast-javascript-data-grids-a-performance-review-22b456ba423b">Comparison between javascripts data grids</a></li><li><a href="https://madewithvuejs.com/bryntum-grid">Bryntum Grid with Vue.js</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa06e04320fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use Lighting Web Component directly as Quick Action]]></title>
            <link>https://oaish08kukreja.medium.com/use-lighting-web-component-directly-as-quick-action-5068b32c0592?source=rss-6558f0733d30------2</link>
            <guid isPermaLink="false">https://medium.com/p/5068b32c0592</guid>
            <category><![CDATA[summer-21-release]]></category>
            <category><![CDATA[lwc]]></category>
            <category><![CDATA[salesforce-summer-21]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[lightning-quick-action]]></category>
            <dc:creator><![CDATA[Oaish Kukreja]]></dc:creator>
            <pubDate>Sat, 19 Jun 2021 22:18:40 GMT</pubDate>
            <atom:updated>2021-09-12T18:20:31.951Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*skCpLJ0ep0eoxLVBqETgTA.png" /></figure><p>Quick actions are the most convenient way to do useful or any salesforce actions from the record page.</p><p>We can create a button or link which on click opens an interface where you can create the required record with the selected fields without<br>moving to another page. All this can be achieved with the help of Quick Actions. We can not only create records but also update records,<br>log calls, send emails and also call Visualforce Pages. Let’s discuss them in detail.</p><p><strong>Action:</strong><br>Each and every Action has its own layout. It contains the fields which are available for that Object. The fields available on this layout can <br>be customized according to requirements. These can be used in Salesforce Classic, Salesforce 1 and Salesforce Lightning.</p><p>This article is basically on how we can add LWC component directly to quick action on salesforce lightning mode. But we will be there shortly,<br>at first I think who are new to quick actions should also get the brief about classical way of creating quick action.</p><p>Earlier on we had to create a Aura component and exposed this Aura component as quick action on a record page. Then we had to add LWC component<br>to aura component for the use.</p><p>Guidelines for</p><blockquote>1. Create Lightning component <br>2. Add &lt;aura:component implements=”force:lightningQuickAction”&gt;<br>3. Create a LWC component<br>4. Add this LWC component to the Aura component</blockquote><p>This will enables you to add this aura component as the quick action on the record page.</p><blockquote>1. Go to the edit object page for any object which you want to add this quick action</blockquote><blockquote>2. Click on Button, Action and Links</blockquote><blockquote>3. Click Action to add this quick action</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*t16iJ6XHZdcgY2dH-JsO2Q.png" /></figure><p>This is all about the previous way.</p><p><em>With the recent Summer’21 release, we can now use the LWC component as Quick Actions directly! First, there are two types of LWC Quick Actions — Screen Actions and Headless Actions.</em></p><p><strong>Screen Actions</strong><br>Tradionally, we were using Aura component to add LWC component to quick action so that it can available on UI. Above all, Aura component is <br>only used so that it can be exposed to use it as quick action. This is exactly what you get when you are creating a Screen Action. You are <br>able to take any Lightning Web Component that you have created and expose it as a quick action.</p><p><strong>Headless Actions</strong><br>Headless actions are a new to LWC capabilities. They allow you to run JavaScript directly from the click of a button through <br>a Headless Lightning Web Component. One of the key differences between a screen action and a headless action is that you don’t need the HTML <br>file in your LWC.</p><p><em>my-action.js-meta.xml</em></p><blockquote>&lt;targets&gt;<br> &lt;target&gt;lightning__RecordAction&lt;/target&gt;<br>&lt;/targets&gt;<br>&lt;targetConfigs&gt;<br> &lt;targetConfig targets=”lightning__RecordAction”&gt;<br> &lt;actionType&gt;ScreenAction&lt;/actionType&gt;<br> &lt;/targetConfig&gt;<br>&lt;/targetConfigs&gt;</blockquote><p><em>my-action.js</em></p><blockquote>import { LightningElement, api } from ‘lwc’;<br> <br>export default class MyAction extends LightningElement {<br> <a href="http://twitter.com/api">@api</a> invoke() {<br> console.log(‘Hello, world!’);<br> }<br>}</blockquote><p><em>my-action.html</em></p><blockquote>&lt;template&gt;&lt;/template&gt;</blockquote><p><strong>Note :- Headless action won’t need to contains the html of this my-action.</strong></p><p><strong><em>LWC Quick actions are currently only available for use on Lighting Record Pages.</em></strong></p><p><strong>Lightning Quick Action Panel</strong></p><p>The screen action itself can open a blank modal on the UI which can be used to interact with data. By default, an LWC quick Action does not <br>have the header and footer that we normally see in a modal window. If we would like to create a consistent experience, there is a new base <br>lightning component for doing that, “The Lightning Quick Action Panel”. For the header, we have to give title property to this component and <br>we can provide the footer with the slot.</p><blockquote>&lt;template&gt;<br> &lt;lightning-quick-action-panel header=”Quick Action Title”&gt;<br> Body Content<br> &lt;div slot=”footer”&gt;<br> &lt;lightning-button variant=”neutral” label=”Cancel”&gt;&lt;/lightning-button&gt;<br> &lt;lightning-button variant=”brand” label=”Save”&gt;&lt;/lightning-button&gt;<br> &lt;/div&gt;<br> &lt;/lightning-quick-action-panel&gt;<br>&lt;/template&gt;</blockquote><p>This component allows you to:</p><blockquote>1. Set the title attribute of the component to render the title in the modal header</blockquote><blockquote>2. Place the content of your action in the body</blockquote><blockquote>3. Use a slot to place content in the modal footer</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*OeGGL9msuyFZCwNWL1bDAw.png" /></figure><p><strong>Close Action Screen Event</strong></p><p>When you are using screen actions, you can close the modal by importing the new CloseActionScreenEvent from ‘lightning/actions’. <br>When fired this will shut the model window if the user needs to cancel or close the quick action.</p><blockquote>import { CloseActionScreenEvent } from ‘lightning/actions’;<br> <br>handleClose(){<br> this.dispatchEvent(new CloseActionScreenEvent());<br>}</blockquote><p>This is how you can add LWC quick action</p><blockquote>1. Create LWC component</blockquote><blockquote>2. Add meta xml config for my-action to your component</blockquote><blockquote>3. Go to Object manager of your SObject</blockquote><blockquote>4. Direct to Add new Action</blockquote><blockquote>5. Add Action type to Lighting Web Component</blockquote><blockquote>6. Select the component</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ThqQSvRTTtB9LtfYykXzfQ.png" /></figure><p>The quick action can also be created by it’s meta.xml</p><blockquote>&lt;?xml version=”1.0&quot; encoding=”UTF-8&quot;?&gt;</blockquote><blockquote>&lt;QuickAction xmlns=”http://soap.sforce.com/2006/04/metadata&quot;&gt;</blockquote><blockquote>&lt;description&gt;Add Description.&lt;/description&gt;</blockquote><blockquote>&lt;actionSubtype&gt;ScreenAction&lt;/actionSubtype&gt;</blockquote><blockquote>&lt;label&gt;Clone&lt;/label&gt;</blockquote><blockquote>&lt;lightningWebComponent&gt;componentNameWithNamespace&lt;/lightningWebComponent&gt;</blockquote><blockquote>&lt;optionsCreateFeedItem&gt;false&lt;/optionsCreateFeedItem&gt;</blockquote><blockquote>&lt;type&gt;LightningWebComponent&lt;/type&gt;</blockquote><blockquote>&lt;/QuickAction&gt;</blockquote><p>This is all about using LWC component directly to salesforce quick action. This are very reliable as compared to aura technique. Sure, now <br>don’t have to create an extra component to exposed the LWC. Also this can used while using the aura component as well. It means both can<br>work together as well. Also we can now have a base lightning component to maintain the look and feel with other default action on a record page<br>like edit, create.</p><p>Here are the references :-<br><a href="https://developer.salesforce.com/blogs/2021/05/learn-moar-with-summer-21-lwc-quick-actions.html">https://developer.salesforce.com/blogs/2021/05/learn-moar-with-summer-21-lwc-quick-actions.html</a><br><a href="https://blog.bessereau.eu/assets/pdfs/actions_impl_guide.pdf">https://blog.bessereau.eu/assets/pdfs/actions_impl_guide.pdf</a><br><a href="https://trailhead.salesforce.com/en/content/learn/projects/quickstart-devzone-app/devzone-app-3">https://trailhead.salesforce.com/en/content/learn/projects/quickstart-devzone-app/devzone-app-3</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5068b32c0592" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Story on my JEST testing]]></title>
            <link>https://oaish08kukreja.medium.com/story-on-my-jest-testing-dc2809ba27d9?source=rss-6558f0733d30------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc2809ba27d9</guid>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[jest]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[lwc]]></category>
            <dc:creator><![CDATA[Oaish Kukreja]]></dc:creator>
            <pubDate>Sun, 28 Mar 2021 10:58:02 GMT</pubDate>
            <atom:updated>2021-03-28T10:58:02.518Z</atom:updated>
            <content:encoded><![CDATA[<p>Last year, My colleagues introduced me to Salesforce, and that’s how I began my adventure with Salesforce. In a short period, I was moved to LWC development. Where I came up with a new term JEST. <br>At that time, JEST testing was new to me, and also kind of challenging for me. After a gratifying journey Today, Here I am writing an article about JEST.</p><p><strong>WHY Testing!</strong><br>Testing is the process of our software development and one of the most important cost-saving approaches for our business. Testing tends to find and report errors to developers. Earlier you find the error better it is. Testing is very important when comes to expense or some danger. Some of the bugs or errors can cause monetary and human loss.<br>Most of the time errors or bugs are not produced or created on purpose. But in reality, we made some mistakes misunderstood the requirements and then the application<br>behaves in a way that was never anticipated. Testing helps us to find these kinds of errors. Earlier we debug these errors, “cheaper” it would be. Once the error,<br>hits the stages of development, even in the worse part if it includes production, more people and processes get involved to fix these errors.</p><p><strong>WHAT is JEST?</strong><br>JEST is a unit test for all the Lightning Web Components. It runs faster, as doesn’t connect to browser or org. JEST is a powerful tool to test javascript code.<br>It can mock components, data, or apex controller functions to help isolate tested from complex dependencies. For testing our LWC component code we need to have<br><a href="http://twitter.com/salesforce/sfdx-lwc-jest">@salesforce/sfdx-lwc-jest</a> Node module to be installed in our Salesforce DX project.<br>To install JEST module, run this command in your VS Code sfdx force:lightning:lwc:test:setup. It’ll end up with some vulnerabilities, but that’s fine, we are good<br>to go.</p><p>I think you might have got an idea why we are using JEST.</p><p><strong>HOW to write JEST?</strong><br>Here I have divided writing JEST into some direct points, and I am not performing JEST on some particular project so that it would be easy to find the JEST needed for<br>the right time.</p><p><strong>WHERE to start writing JEST?</strong><br>1. In your LWC component, create a _tests_ folder.<br>2. In the _tests_ folder, create a file name yourComponentName.test.js.<br>3. Open the file yourComponentName.test.js, and writes import, further we will gonna come up with different imports. We will have a different section for imports.<br>For now you have to import this,<br>import { createElement } from ‘lwc’;<br>import yourComponentName from ‘c/yourComponentName’;</p><p>We have to write JEST for API and wire properties, event handlers and dispatch events, apex calls, and some UI components. These are the main domain to<br>cover the JEST testing in our LWC component. I will cover each of them one by one. Let’s start…</p><p>But first I need to brief you about JEST components, you can skip this if you wanna the next few lines are about afterEach(), beforeEach(), describe(), and it().</p><p><em>it()</em>,<br>The innermost function in a JEST, it covers the test method.</p><p><em>describe()</em>,<br>it covers it(). describe() can inherit multiple describes(). It can also be called the test suites.</p><p><em>beforeEach()</em>,<br>lines of code required to execute before each any it(). For example, any method in connectedCallBack() of the component or any apex wire call.</p><p><em>afterEach(),</em><br>lines of code required to execute after each any it(). Usually, we use afterEach() to clear the DOM after each it().</p><blockquote>Quick note — -<br>We need to create element for the component for which we are going to write the JEST, so I use this trick to create a common const method then call this method <br>for all it().<br>const createComponent = (config) =&gt; {<br> const component = createElement(‘c-yourComponentName’, {<br> is: teamList<br> }); <br> Object.assign(component, config);<br> document.body.appendChild(component);</blockquote><blockquote>return {<br> component,<br> shadowRoot: component.shadowRoot<br> };<br>}</blockquote><p>I Hope, you have an idea about how a JEST class can look like in real. No for the best time, finally let’s see JEST in action.</p><p><em>@api</em><br>1. If the api is in the component for which you want to write a JEST,<br>In your component let’s say you have an api property with name @api accountID. We will write the test for checking if api property will be set correctly or not.</p><blockquote>it(‘should set correct projectId’, () =&gt; {<br> const mockAccountID = ‘a2i1F000000nODjQAA’;<br> const { component } = createComponent({<br> accountID: mockAccountID<br> });</blockquote><blockquote>expect(component.accountID).toBe(mockAccountID);<br>});</blockquote><p>2. If the api is in the child component and you want to write a JEST for the parent component,<br>There are 2 components in your porject. One of them is parent, parentComponent.js, and other one is child, childComponent.js. There is an api property in <br>childComponent.js name as @api recordID and an api property in parentComponent.js name as @api accountID. Here we check whether the api property on child<br>component is going to set correctly or not.</p><blockquote>it(‘should set correct projectId in childComponent’, () =&gt; {<br> const mockAccountID = ‘a2i1F000000nODjQAA’;<br> const { shadowRoot } = createComponent({<br> accountID: mockRecordID<br> }); <br> const childComponent = shadowRoot.querySelector(‘c-child-component’);</blockquote><blockquote>expect(childComponent.recordID).toBe(mockAccountID);<br>});</blockquote><p><em>Events</em><br>1. In which the event is handled by parent component which is dispatch from one it’s child<br>Say a event name error is dispatched from a childComponent.js with detail an error message. These event is handled on parentComponent.js and the message<br>is displayed in a &lt;lightning-input&gt; and set as the value of &lt;lightning-input&gt;. We are going to check where we are going to expect the detail from event correct<br>or not.</p><blockquote>it(‘should set correct error message’, () =&gt; {<br> const errorMessage = ‘Error Message’;<br> const { shadowRoot } = createComponent(); <br> const childComponent = shadowRoot.querySelector(‘c-child-component’);<br> <br> childComponent.dispatchEvent(new CustomEvent(‘error’, {<br> detail: { value : errorMessage }<br> }));<br> <br> const inputBody = shadowRoot.querySelector(‘lightning-input’);<br> expect(input.value).toBe(errorMessage)<br>});</blockquote><p>2. In which the event is dispatched by component to a parent component<br>Let’s take the same instance of an error event, but this test is for the childComponent.js to check whether the event has been dispatched or not with correct details.<br>The childComponent.js has a predefined error message which is ‘Error Message’ so whenever the event is dispatch it will be passed with the same value. Also, the error<br>event raises on &lt;lightning-button&gt; click, we are not going in deep for why the error raises. Here we are writing a test in which we will expect that how many<br>times the event is called, like here 1, and if passed the correct the details or not.</p><blockquote>it(‘should set correct error message’, () =&gt; {<br> const { component, shadowRoot } = createComponent(); <br> <br> const errorHandler = jest.fn();<br> component.addEventListener(‘error’, errorHandler);<br> <br> const buttonInput = shadowRoot.querySelector(‘lightning-button’);<br> buttonInput.dispatchEvent(new CustomEvent(‘click’)); <br> <br> expect(errorHandler).toBeCalledTimes(1);<br> expect(errorHandler.mock.calls[0][0].detail.value).toBe(‘Error Message’);<br>});</blockquote><blockquote>Before moving ahead let’s have a look at some technicalities of mocking data, wire or apex methods. First, create a _mocks_ folder in LWC component folder.<br>Inside the _mocks_ folder add a file, yourComponentName.js, place all the <a href="http://twitter.com/api">@api</a> properties, and import events. To save a mockData, inside _tests_ folder <br>Create a new folder data and add the JSON return from wire call or apex call so that you can pass this before mocking data.</blockquote><blockquote>For wire property we need following imports, I am taking example for ‘getRecord’,<br>import { registerLdsTestWireAdapter } from ‘<a href="http://twitter.com/salesforce/wire-service-jest-util">@salesforce/wire-service-jest-util</a>’;<br>import { getRecord } from ‘lightning/uiRecordApi’;</blockquote><blockquote>We can assign the registerLdsTestWireAdapter in a public const,<br>const getRecordWireAdapter = registerLdsTestWireAdapter(getRecord);</blockquote><blockquote>We are taking the same example for both of the conditions of wire property. We have a parentComponent.js calling wire property to getRecord. If get data then <br>assign the data to API property, <a href="http://twitter.com/api">@api</a> recordID, of childComponent.js and if get error show the error in UI with &lt;lightning-input&gt;</blockquote><p><a href="http://twitter.com/wire"><em>@wire</em></a><br>1. If wire emits result</p><blockquote>it(‘should correctly pass on recordID’, async () =&gt; {<br> getRecordWireAdapter.emit(‘recordID’);</blockquote><blockquote>Promise.resolve().then(() =&gt; {<br> const { shadowRoot } = createComponent();<br> const childComponent = shadowRoot.querySelector(‘c-child-component’);<br> expect(childComponent.recordID).toBe(‘recordID’);<br> });<br>});</blockquote><p>2. If wire calls error result</p><blockquote>it(‘should set correct error message’, () =&gt; {<br> const errorMessage = ‘Error Message’;<br> getRecordWireAdapter.error({ message : errorMessage }); <br> <br> Promise.resolve().then(() =&gt; {<br> const { shadowRoot } = createComponent();<br> <br> const inputBody = shadowRoot.querySelector(‘lightning-input’);<br> expect(input.value).toBe(errorMessage);<br> });<br>});</blockquote><p>For apex calls we need import and to mock the apex call, here we have an accountController with a method getAccounts() with <a href="http://twitter.com/AuraEnabled">@AuraEnabled</a>(cacheable=true), it will<br>return all accounts.<br>import getAccounts from ‘<a href="http://twitter.com/salesforce/apex">@salesforce/apex</a>/accountController.getAccounts’;<br>jest.mock(‘<a href="http://twitter.com/salesforce/apex">@salesforce/apex</a>/accountController.getAccounts’, () =&gt; {<br> () =&gt; {<br> return {<br> default: jest.fn()<br> };<br> },<br> { virtual: true }<br>});</p><p>We are taking the same example for all of the conditions of apex call. We have a calling apex to get all accounts. If get data then assign the data to <br>&lt;lightning-input&gt; and if get error show the error in UI with &lt;lightning-input&gt;.</p><p><em>Apex</em><br>1. Apex call can be imperative</p><blockquote>1.1 For resolved value, means the apex call gives positive result<br> it(‘should set correct data on UI’, () =&gt; {<br> getAccounts.mockResolvedValue(‘Account 1’);<br> const { shadowRoot } = createComponent();<br> <br> Promise.resolve().then(() =&gt; {<br> const inputBody = shadowRoot.querySelector(‘lightning-input’);<br> expect(input.value).toBe(‘Account 1’);<br> });<br> });</blockquote><blockquote>1.2 For rejected value, means the apex call gives error<br> it(‘should set correct data on UI’, () =&gt; {<br> getAccounts.mockRejectedValue(‘Error Message’);<br> const { shadowRoot } = createComponent();<br> <br> Promise.resolve().then(() =&gt; {<br> const inputBody = shadowRoot.querySelector(‘lightning-input’);<br> expect(input.value).toBe(‘Error Message’);<br> });<br> });</blockquote><p>2. Apex call as wire call<br>import { registerLdsTestWireAdapter } from ‘<a href="http://twitter.com/salesforce/wire-service-jest-util">@salesforce/wire-service-jest-util</a>’;</p><p>We can assign the registerLdsTestWireAdapter in a public const,<br>const getRecordWireAdapter = registerLdsTestWireAdapter(getAccounts);</p><p>The test will work the same as wire now like to get a positive result will emit data and to throw error we should call error method, above two lines will be extra in <br>the code to achieve the JEST for the apex as wire property.</p><p>Okay, so that’s a long journey of mine of JEST understanding. Please find few references below.</p><p>1. <a href="https://trailhead.salesforce.com/content/learn/modules/test-lightning-web-components/set-up-jest-testing-framework">https://trailhead.salesforce.com/content/learn/modules/test-lightning-web-components/set-up-jest-testing-framework</a><br>2. <a href="https://developer.salesforce.com/docs/component-library/documentation/en/lwc/testing">https://developer.salesforce.com/docs/component-library/documentation/en/lwc/testing</a><br>3.<a href="https://lwc.dev/guide/test"> https://lwc.dev/guide/test</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc2809ba27d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>