I'm using this tutorial and this documentation to figure out integration testing for my plugin. My plugin page has an ajax call to the JIRA REST API to populate a select element with options. When I try to select an option in that dropdown via the test case, there don't appear to be any options there, as shown by the html test-report. This isn't the case with the regular JIRA instance though, everything works fine there.
This is the test case code:
@Test
public void testAdd1VersionTo1Project()
{
navigation.gotoPage(servletUrl);
text.assertTextPresent(new WebPageLocator(tester),
"Version Control - Manage Versions");
form.selectOption("projects", "Alpha");
form.selectOption("versions", "v1");
tester.clickButton("button-add");
text.assertTextPresent(new WebPageLocator(tester),
"Are you sure you want to add these versions?");
tester.clickButton("dialog-submit-button");
text.assertTextPresent(new WebPageLocator(tester),
"[Alpha - v1]: Version was created successfully.");
}
The error is:
java.lang.RuntimeException: Unable to find option Alpha for projects
Here's the ajax call:
jQuery.ajax('/jira/rest/api/2/project', {
dataType : 'json',
}).done(function(res){
var projSelect = jQuery('#projects');
jQuery.each(res, function(idx, item){
projSelect.append('<option value="' + item.id +'">' + item.name + '</option>');
});
});
Any suggestions on how to make the ajax call execute during/before the test case to populate that element?
I tried Thread.Sleep(10000), but that didn't work.
Also tried HtmlUnitTestingEngineImpl snippet, but that also didn't work presumably due to the version of jWebUnit being used by JIRA being very old, as noted in the linked tutorial.
I'll be looking into PageObjects next.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.