Skip to content

Commit

Permalink
Type MigrationWave end date directly into the input
Browse files Browse the repository at this point in the history
1. the original motivation no longer applies as bug MTA-706 is fixed
2. providing the end date via date picker fails repeatedly with
   PatternFly 5.2 (it seems the start date pop-up is still detected in
   the DOM tree)

Reference-Url: konveyor/tackle2-ui#1680
Signed-off-by: Radoslaw Szwajkowski <rszwajko@redhat.com>
  • Loading branch information
rszwajko committed Apr 10, 2024
1 parent 8e5a1f7 commit 62e7e6c
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions cypress/e2e/models/migration/migration-waves/migration-wave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class MigrationWave {

/**
* This method should NOT be used to do assertions, if an invalid date is passed, it'll throw an exception
* It selects the date using the picker because it can't be manually entered right now due to bug MTA-706
* It selects the date using the picker.
* @param date
*/
public fillStartDate(date: Date): void {
Expand Down Expand Up @@ -208,7 +208,6 @@ export class MigrationWave {

/**
* This method should NOT be used to do assertions, if an invalid date is passed, it'll throw an exception
* It selects the date using the picker because it can't be manually entered right now due to bug MTA-706
* @param date
*/
public fillEndDate(date: Date) {
Expand All @@ -221,14 +220,7 @@ export class MigrationWave {
).to.eq(false);
}

const currentEndDate =
this.endDate.getTime() !== date.getTime() ? this.endDate : new Date();
const currentMonth = currentEndDate.toLocaleString("en-us", { month: "long" });
cy.get(MigrationWaveView.endDateInput)
.closest(MigrationWaveView.generalDatePicker)
.find(MigrationWaveView.calendarButton)
.click();
MigrationWave.selectDateFromDatePicker(date, currentMonth);
cy.get(MigrationWaveView.endDateInput).type(MigrationWave.formatDateMMddYYYY(date));
}

private fillForm(values: Partial<MigrationWave>) {
Expand Down Expand Up @@ -268,11 +260,11 @@ export class MigrationWave {
}

static formatDateMMddYYYY(date: Date): string {
const day = String(date.getDate()).padStart(2, "0");
const month = String(date.getMonth() + 1).padStart(2, "0"); //January is 0!
const year = date.getFullYear();

return month + "/" + day + "/" + year;
return new Intl.DateTimeFormat("en-US", {
year: "numeric",
month: "2-digit",
day: "2-digit",
}).format(date);
}

public expandActionsMenu() {
Expand Down

0 comments on commit 62e7e6c

Please sign in to comment.