Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type MigrationWave end date directly into the input #1069

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading