ATF: How to deal with service catalog calendar/date field that only accept today or later, not past(Old pre-selected date)?

bbf3562
Kilo Guru

I tested ATF on March 5th and I selected the date on March 5th, the test passed. Until today I retest it and it failed because the date I selected is March 5th and the catalog item validation do not accept any date that is before today. It only allows today or later dates. The problem for the long term is that I don't want to modify the date if it expired. I have tried javascript:gs.daysAgo(-3) in the field so that it will automate put 3 days ahead from today. Apparently, the test step can read and convert to date in the test step description. Here a screenshot example,

find_real_file.png

find_real_file.png

But when I execute this test, it looks like a catalog item date variable wasn't able to read javascript:gs.daysAgo(-3) that cause test failed.

find_real_file.png

The only approach I can think of is to pre-select the date that is like 5 years later that eventually will need to update when its time or there is a better way?

3 REPLIES 3

Harsh Vardhan
Giga Patron

I have tried using an example from your link that Chuck provided(I use 3 days later from today),

var myDatePicker = Class.create();
myDatePicker.prototype = {
    initialize: function() {
    },

	// Pass in year and month as numbers
	test : function() {
		//var first = 15; // the soonest that the 3rd Sunday can be
		//var last = 21; // the latest that the 3rd Sunday can be
		
		var startDate = gs.nowDateTime();
		
		var gdt = new GlideDateTime();
		gdt.setDisplayValue(startDate);
		gdt.addSeconds(259200); // 3 days later
		//gdt.setYearLocalTime(year);
		//gdt.setMonthLocalTime(month);

		/*for (var day = first; day < last; day++) { 
			gdt.setDayOfMonthLocalTime(day);
			if (gdt.getDayOfWeekLocalTime() == 7) {
				return day;
			}
		}*/
		
		return gdt;
		//return gdt.getDate();
	},

    type: 'myDatePicker'
};

 

Then I put in date/time field in ATF, javascript:new myDatePicker().test();.

But it still doesn't work and here a screenshot error of unreadable javascript input,

find_real_file.png

I think here you need to create your own custom step, this way you can validate the dynamic date or date/time values on catalog item date or date/time variables.

 

adding doc link here. 

 

Create custom step configuration