Jenkins test harness not loading JS files in dependencies of plugin under test

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Jenkins test harness not loading JS files in dependencies of plugin under test

Ulli Hafner
I’m trying to write UI tests with Jenkins test harness (based on HTMLUnit). When one of my jelly files under test uses a JS library that is part of another plugin (i.e. in a maven dependency) then the JS file seems to be not exposed and Jenkins reports a 404. The same jelly file works fine when deployed to a real Jenkins instance.  

Is this a known limitation of the test harness? Or is this a bug I can try to fix in the test harness (or is this the epic in https://issues.jenkins-ci.org/browse/JENKINS-41827)? 
Or do I need to bundle or reference the dependencies in a different way? 

My Jelly looks like:

<l:main-panel>

<st:adjunct includes="io.jenkins.plugins.bootstrap4"/>
<st:adjunct includes="io.jenkins.plugins.data-tables"/>
<st:adjunct includes="io.jenkins.plugins.font-awesome"/>

<div class="fluid-container">

<h3>${it.displayName}</h3>

<div class="row py-3">

<div class="col">
<div id="statistics">
<bs:card title="${%Details}" fontAwesomeIcon="fa-chart-bar">
<dt:table model="${it.getTableModel('forensics')}"/>
</bs:card>
</div>
</div>

</div>

</div>

</l:main-panel>
The JS files are located in the webjars folder of the dependencies (not part of the WEB-INF/lib jar file anymore). They are resolved to something like
and so on. 

In a real Jenkins instance the same URL will return the JS file, in the tests a 404.



--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/2C8F6B1E-0A4B-4EDD-A19D-A9675616B605%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Jenkins test harness not loading JS files in dependencies of plugin under test

Jesse Glick-4
On Wed, Nov 20, 2019 at 5:37 PM Ullrich Hafner <[hidden email]> wrote:
> Is this a known limitation of the test harness? Or is this a bug I can try to fix in the test harness

Since you are probably the first to encounter the issue, I would guess
it is a bug. Whether it is fixable, I have no idea offhand.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2iJdgEEppzRKTwfYYWzUHMnPJKFp5QcRKLe1teCYy5JA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Adjunct library vs. JS plugin: Was: Re: Jenkins test harness not loading JS files in dependencies of plugin under test

Ulli Hafner
Ok, I found the problem (but still have no solution on how to proceed):

In the adjunct jelly file I load the JS files in using commands like:
<script type="text/javascript" src="${resURL}/plugin/jquery3-api/webjars/jquery.min.js“/>

The part ${resURL} is correctly evaluated in Jenkins but not in the test harness (where „jenkins“ is used as context root). Actually ${resURL} is empty in the adjunct. So I think if Jenkins will use a different context root it will not work there as well.

Then I realized that other adjuncts use something like:
<script src="${it.packageUrl}/timeline_js/timeline-bundle.js" type="text/javascript" />

After changing that in my plugins the path is correctly expanded to something like

However the resources are not found, they are rather exposed as 

After some more digging I realized that the adjuncts are actually libraries and no plugins. So this seems to be not compatible. 

What is the right way to tackle this problem?
Should I locate JS libraries like bootstrap in a Jenkins plugin or in a library (jar) that I am depending on?
Should I refer to the JS files using something like <st:adjunct includes="io.jenkins.plugins.bootstrap4“/> or should I better define a tag lib that includes the JS files using simple script tags?
Or is there even another way that makes sense?

Am 21.11.2019 um 01:35 schrieb Jesse Glick <[hidden email]>:

On Wed, Nov 20, 2019 at 5:37 PM Ullrich Hafner <[hidden email]> wrote:
Is this a known limitation of the test harness? Or is this a bug I can try to fix in the test harness

Since you are probably the first to encounter the issue, I would guess
it is a bug. Whether it is fixable, I have no idea offhand.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2iJdgEEppzRKTwfYYWzUHMnPJKFp5QcRKLe1teCYy5JA%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/A66C8411-84D1-4C61-BC9D-2AFE950942AF%40gmail.com.