Capybara DayPickerInput selection? - capybara

Has anyone had any luck in figuring out how to use the react library https://react-day-picker.js.org/docs/input/
With Capybara/Selenium? Unfortunately it doesn't allow simply typing in the text such as MM/DD/YYYY like most date-pickers. This only allows mouse selection.
Or is specifically setting the value basically the only way to do so?

Without an example which shows the actual configuration of react-day-picker you're dealing with it's impossible to say exactly what you need to do, but the general rule is if you are testing the sites functionality then do what a user would need to do. In your case that may mean click on the forward/back month arrows until you get to the desired month, then click on the specific day element. Assuming the date you want to select is in the future (September 20, 2019) it would be something like
caption = find('.DayPicker-Caption')
until caption.has_text?('September 2019', wait: 0) do
current_month = caption.text
find('.DayPicker-NavButton--next').click
# wait for month to change
expect(caption).not_to have_text(current_month)
end
find('.DayPicker-Day', exact_text: '20').click
If you're not actually testing functionality (web scraping, etc) then you can use execute_script to call the react-day-picker JS API and set a specific date.

Related

JIRA gadget: how to disable a configuration field

Is there a way to disable a configuration field for a JIRA gadget based on the value of another field?
Example: when the user chooses 'Now' for field Foo, then the Date field is ignored. I'd like to disable the Date field. Can this be done? If so, how? I already do the ignoring part. But my only clue for the user that I am ignoring the Date field is my description for Date and Foo. It would be nicer to disable the Date field as well.
If you want to do anything other than use the built-in gadget controls with their standard behaviors, you need to implement your own gadget configuration code instead of relying on the UserPrefs directly.
This means that, in practice, that you need to omit the "configuration form" from your gadget descriptor, which is this part:
config: {
descriptor: function(){...},
args: {Function, Array}
},
After having removed that, your gadget will then need to build its own UI and decide itself whether or not it still needs to be configured, as well as call gadget.getPref() and gadget.savePref() to get/set your user's gadget configuration options in the parent container.
I should add that this is a fair amount of work. You might be able to do some hacky jQuery to override the standard controls built without doing the above, but this will not likely be portable to different parent containers (or even different versions of JIRA).

How to override the title of JQuery mobile Datebox?

I am developing a Japanese mobile site using Datebox calendar. I managed to override most of the date format and labels, but I'm not sure how to modify the title which shows the Month and Year. Instead of showing 6月2013, I want it to show 2013年6月. The two characters basically represent year and month.
I'm using Datebox version 1, and I have overriden the dateFormat and headerFormat as listed below. What am I missing here?
http://dev.jtsage.com/jQM-DateBox1/demos/api/matrix.html#matrix&ui-page=0-0
It's been a long time since I played with v1. But...
Think about upgrading the v2. Language files stay the same, but v2 is way, way more stable.
You have a couple options for headerFormat -
a. you can either mess with it in the language file (which I assume you are loading, judging by the fact that english is the default).
b. Override options..headerFormat.
c. It looks like just setting options.headerFormat is supposed to override it too... ymmv. Like I said, it's been a while.
The bad news: It is possible that the calendar mode of v1 does not in fact use headerFormat - if that is the case, look for this line, around about 1421, which looks suspiciously hard-coded to me. Which means you'll need to edit the sources directly. Sorry about that.
self.controlsInput.empty().html(o.lang[o.useLang].monthsOfYear[self.theDate.getMonth()] + " " + self.theDate.getFullYear());
Finally, if you do decide to upgrade to v2, it looks like it is also hardcoded - line 160. I'll work on making this an option instead. Edit: the option you are looking for in v2 is overrideCalHeaderFormat / calHeaderFormat.

How can I add text to a work item

We have a few bugs and change requests which have a complicated iteration path. This results in people coming over the team to ask 'Where do we raise items' a lot.
As you can't set a default value for the iteration path in TFS 2010 we think the best solution would be to add a string of text under the field which we can manually update every 7 weeks with the correct area to raise items in.
However TFS doesn't seem to allow just a line of text on its work items as a control. Is there a way to add a line of display text i.e. Not a field you edit, but just to inform those writing the items?
Please note that it needs to be visible at all times, using the tooltip 'help text' field on a control is not enough in this case.
You can use the LabelControl for this purpose.
You can not have a default in the work item for the iteration path, but what you can do is making use or the template url in web access or the work item templates in the power tools to create a work item that is prepopulated with values.
What about a custom field with a display control in read-only? You can give a default value to the field and the "read-only" control prevent other to change it.

auto_complete_for: prevent the first item from being auto-selected

The auto_complete_for dealio from script.aculo.us is great an all, but is there a way for me to selectively disable the fact that it always auto-selects the first item in the list?
The problem is that, if I want to type my own entry that is new, and novel, I don't want the first item in the list to be auto-selected. The reason is because when I TAB out of the field, it selects, and fills the text box with that first item.
I got around that, somewhat, by making the first item in the list the same as what I'm typing, but that's not perfect either, because the auto_complete list doesn't always update with every keystroke, depending on how fast I type. I've tried setting the list refresh rate to the lowest value (1 millisecond) but no go.
What I really want is an option in "auto_complete_for" that doesn't select that first item at all - the same way that Google Instant doesn't automatically select the first suggested search phrase - you have to arrow-down to select one.
Maybe I can do this via an HTML option that I'm missing?
Looking at the source, there doesn't appear to be an option for that, but I bet if you changed line 284 of controls.js to this.index = -1; it would do what you want.
Otherwise, it might be time to look for a different autocomplete widget.
If your requirements are too far away from the available plugin, then I guess there is no point in tinkering around. Its best to write your own JS code.
You might want to consider this: https://github.com/laktek/jQuery-Smart-Auto-Complete
or this : https://github.com/reinh/jquery-autocomplete
I'll add another alternative that works great with Rails 3:
http://github.com/crowdint/rails3-jquery-autocomplete
I recently implemented auto complete for more than a field for Rails 2.0.2.
The plugin I used is:- https://github.com/david-kerins/auto_complete . Not sure if it supports Rails 3.
I have also encountered issues on implementing the above scenario and have posted questions( Implementing auto complete for more than one field in Rails ; Implementing a OnClick kind of functionality and formatting wrt Rails Partial-Views ) on stackoverflow for the same, I have been lucky on getting things working for me based on my requirement.
Kindly refer to these questions, they might have relevance to your requirement.

Delphi Search Edit Component

I need a delphi component for Delphi 2007 win32 that have features like Google search text box.
** While User writing search key it should fill/refresh the list with values, and user can select one of them.
**User can go up and down list and can select one of them.
**List should contain codes and text pair, so user can select text and I can get code for database operations.
(Google can highlight the search text in List but I think it is not possible with Delphi 2007, so it is not expected.)
I tried Dev Express TcxMRUEdit, however it doesn't meet my needs
Since you have DevExpress, why don't you try the cxLookupComboBox in lsEditMode and with ImmediateDropDown = True?
Check out woll2woll components. The TLookupcombobox has done this since Delphi 3 (or earlier). This is not spam, I just use the library.
http://www.woll2woll.com/
I also had the same problem and unfortunately didn't find a suitable component. I was also inspired from google.
So it turned out to be easier for me to "simulate a component" by using an editbox and a grid placed under it. As the user types something in the editbox the query refreshes and the proper resulst are shown in the grid. I have many columns in the grid, the query results try to match all the fields (so if I type 'po', the query will return all records where any field is like 'po%'). I also added a delay of 500ms after the user types to avoid to run too many unnecessary queries (another aproach could be to kill the thread as the user strikes a new key, if the query is run in a thread).
In this way I obtained the required functionality, even if without higlighting the search text, anyway my users are delighted by this.
In every place I am using this "component" I am attaching a query at runtime so it can be used in many different forms.
I somehow was also inspired by the skype UI: when you display the lsit of contacts you can type something and the contacts will be filtered accordingly (skype uses an editbox + grid/listbox).

Resources