-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e78865
commit e5ddf26
Showing
11 changed files
with
208 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,74 @@ | ||
import { http, HttpResponse } from "msw"; | ||
import { format } from "date-fns"; | ||
|
||
import { urlPrefix } from "services/mocker/msw"; | ||
import { buildScenarios, urlPrefix } from "services/mocker/msw"; | ||
|
||
import { remindersElements } from "../pages"; | ||
|
||
describe("Reminders Page", () => { | ||
it("should render reminders page content", () => { | ||
it("should be able to create a reminder under a reminder group and add a due date", () => { | ||
const reminderTitle = "Learn Cypress"; | ||
|
||
cy.visit("/reminders"); | ||
|
||
remindersElements.root.should("exist"); | ||
|
||
remindersElements.createReminderGroup("Reminder group title"); | ||
|
||
remindersElements.root.findByText("Reminder group title").click(); | ||
|
||
remindersElements.reminderListTitle.should("have.text", "Reminder group title"); | ||
|
||
remindersElements.createReminder(reminderTitle); | ||
|
||
remindersElements.getReminderItemByText(reminderTitle).should("exist"); | ||
|
||
remindersElements.getReminderMenuBtnByText(reminderTitle).click(); | ||
|
||
remindersElements.reminderDueDateMenuItem.click(); | ||
|
||
const dueDate = new Date(); | ||
|
||
remindersElements.reminderDueDateDialog.findByRole("gridcell", { name: dueDate.getDate().toString() }).click(); | ||
|
||
remindersElements.reminderDueDateTimeInput.type(format(dueDate, "HH:mm")); | ||
|
||
remindersElements.saveReminderDueDateBtn.click(); | ||
|
||
remindersElements.getReminderItemByText(reminderTitle).should("not.contain", "Reminder group title"); | ||
|
||
remindersElements.getReminderItemByText(reminderTitle).contains(format(dueDate, "MMM d, yyyy, h:mm a")); | ||
}); | ||
|
||
it("should handle negative scenario for create reminder", () => { | ||
cy.interceptRequest( | ||
http.get( | ||
http.post( | ||
urlPrefix("/reminders"), | ||
() => { | ||
return HttpResponse.json(null, { status: 500 }); | ||
}, | ||
{ | ||
once: false, | ||
} | ||
{ once: true } | ||
) | ||
); | ||
|
||
cy.getMswDb().then((db) => { | ||
buildScenarios(db) | ||
.withReminders(5) | ||
.withReminderGroups({ reminderGroups: ["Personal"], remindersPerGroup: 2 }); | ||
}); | ||
|
||
cy.visit("/reminders"); | ||
|
||
remindersElements.root.should("exist"); | ||
|
||
remindersElements.getReminderGroupItemByText("Personal").findByText("Personal").click(); | ||
|
||
remindersElements.createReminder("Learn Cypress"); | ||
|
||
cy.contains("Error creating reminder"); | ||
|
||
remindersElements.createReminder("Learn Cypress"); | ||
|
||
remindersElements.getReminderItemByText("Learn Cypress").should("exist"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.