Untitled

 avatar
unknown
plain_text
2 years ago
28 kB
3
Indexable

import { ACCOUNTS } from '../../data/accounts'
import { getFormattedDate } from '../../utils/date_helper'
import bookingsPage from '../../pages/bookings.page'
import { cleanupBookings } from '../../utils/bookings_cleanup'
import pages from '../../utils/pages'

Feature('Editing booked desk')

Before(async ({ I, loginPage }) => {

  I.amOnPage('/')
  loginPage.sendForm(ACCOUNTS.USER_ROLE!.email, ACCOUNTS.USER_ROLE!.password)

  await cleanupBookings()

})

Scenario(
  '@861mz422k As a user I am able to edit the date of booked desk via "Bookings" tab',
  async ({ I, bookPage, mainPage }) => {
    const nextDate = getFormattedDate(1)

    // ('----------------------------------')
    // ('Creating a desk booking')
    // ('----------------------------------')

    // Navigates to book tab and filters the areas by Meeting rooms. Selects 1st Floor and first room
    I.amOnPage(pages.goto.bookTab)
    I.see('Book a space')
    I.click(bookPage.buttons.fullDayOption)
    I.waitForElement(bookPage.fields.areaSelector)
    I.click(bookPage.fields.areaSelector)
    I.click(bookPage.areaTypes('Desk areas'))
    I.click(bookPage.floorAndRoomSelect (1, 1))

    // Grabs the booking office name, floor, and room numbers from the title header
    const bookingDetails = await I.grabTextFrom(bookPage.headers.deskBookingTitle)
    const officeName = bookingDetails.split('·')[0].trim()
    const floorNumber = bookingDetails.split('·')[1].trim()
    const roomNumber = bookingDetails.split('·')[2].trim()

    // Grabs the desk name from the booking specification container
    const deskName = await I.grabTextFrom(bookPage.fields.deskName)

    // Grabs the date from the booking specification container and converts it to mount long and day numeric (June 23)
    const dateStr = await I.grabTextFrom(bookPage.headers.dateContainer)
    const date = new Date(dateStr)
    const formatter = new Intl.DateTimeFormat('en-US', { day: 'numeric', month: 'long' })
    const formattedDate = formatter.format(date)

    // Adds one additional day to the format from above
    const nextDayDate = new Date(date)

    nextDayDate.setDate(nextDayDate.getDate() + 1)
    const formattedNextDay = formatter.format(nextDayDate)

    // Formats the date to day numeric, month short, year numeric (23 Jun 2023)
    const formatterDateStr = new Intl.DateTimeFormat('en-DE', { day: 'numeric', month: 'short', year: 'numeric' })
    const formattedNextDayDateStr = formatterDateStr.format(nextDayDate)

    const formattedDayDateStr = formatterDateStr.format(date)

    // Grabs the start and end booking time from the booking specification container
    const startTime = await I.grabTextFrom(bookPage.fields.startTime)
    const endTime = await I.grabTextFrom(bookPage.fields.endTime)

    // Confirms the booking and waits for the booking confirmation popup
    I.click(bookPage.buttons.confirmBooking)
    I.waitForElement(bookPage.fields.bookingConfirmationModal)

    within(bookPage.fields.bookingConfirmationModal, () => {
      I.see(bookingDetails.trim())
      I.see(deskName.trim())
      I.see(formattedDate)
      I.see(startTime)
      I.see(endTime)
    })

    // Completes the booking and waits for the upcomingBooking element
    I.click(bookPage.buttons.done)
    I.waitForElement(bookPage.fields.upcomingBooking)

    within(bookPage.fields.upcomingBooking, () => {
      I.see(deskName.trim())
      I.seeTextEquals('Booked', bookPage.headers.bookedIcon)
      I.see('Full day')
    })

    // Enters into the booking placeholder from the upcoming booking element
    I.click(bookPage.fields.upcomingBooking)
    I.waitForElement(bookPage.fields.upcomingBookingInfo)

    within(bookPage.fields.upcomingBookingInfo, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(deskName.trim())
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(formattedDayDateStr)
      I.see(startTime)
      I.see(endTime)
    })

    // Navigates to schedule tab and waits for the booking placeholder element
    I.amOnPage(pages.goto.scheduleTab)
    I.waitForElement(mainPage.fields.viewBooking)

    within(mainPage.fields.viewBooking, () => {
      I.see(deskName.trim())
      I.seeTextEquals('Booked', mainPage.headers.bookedIcon)
      I.see('Full day')
    })

    // Navigates to bookingsTab and checks information from the info container
    I.amOnPage(pages.goto.bookingsTab)

    within(bookingsPage.fields.bookingInfoContainer, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(deskName.trim())
      I.see(ACCOUNTS.USER_ROLE!.email)
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(formattedDayDateStr)
      I.see(startTime)
      I.see(endTime)
    })

    // ('----------------------------------')
    // ('Editing the booked desk')
    // ('----------------------------------')

    // Clicks on the edit button from the bookings tab and changes the desk booking date
    I.click(bookingsPage.buttons.editBooking)
    I.click(bookingsPage.fields.editCalendar)
    I.click(bookPage.dateSelector(nextDate))

    // Confirms the edited booking and waits for the booking confirmation popup
    I.click(bookPage.buttons.confirmBooking)
    I.waitForElement(bookPage.fields.bookingConfirmationModal)

    within(bookPage.fields.bookingConfirmationModal, () => {
      I.see(bookingDetails.trim())
      I.see(deskName.trim())
      I.see(formattedNextDay)
      I.see(startTime)
      I.see(endTime)
    })

    // Confirms the edit and checks the information in the booking info container
    I.click(bookPage.buttons.done)
    I.waitForElement(bookingsPage.fields.bookingInfoContainer)

    within(bookingsPage.fields.bookingInfoContainer, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(deskName.trim())
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(formattedNextDayDateStr)
      I.see(startTime)
      I.see(endTime)
    })

    // Navigates to the book tab and checks that there are no bookings for the current date
    I.amOnPage(pages.goto.bookTab)
    I.waitForElement(bookPage.fields.emptyBookingContainer)

    within(bookPage.fields.emptyBookingContainer, () => {
      I.see('No bookings on this day')
    })

    // Chooses the next day and confirms the edited booking
    I.click(bookPage.buttons.calendarDropDown)
    I.click(bookPage.calendarDatePicker(1))

    I.waitForElement(bookPage.fields.upcomingBooking)

    within(bookPage.fields.upcomingBooking, () => {
      I.see(deskName.trim())
      I.seeTextEquals('Booked', bookPage.headers.bookedIcon)
      I.see('Full day')
    })

    // Clicks on the booking placeholder and checks information
    I.click(bookPage.fields.upcomingBooking)
    I.waitForElement(bookPage.fields.upcomingBookingInfo)

    within(bookPage.fields.upcomingBookingInfo, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(deskName.trim())
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(formattedNextDayDateStr)
      I.see(startTime)
      I.see(endTime)
    })

    // Verification in the Schedule tab of Desk name and that only one booking is made
    // *This can run from Sunday to Thursday because of weekend logic
    I.amOnPage(pages.goto.scheduleTab)
    I.waitForElement(mainPage.fields.viewBooking)

    within(mainPage.fields.viewBooking, () => {
      I.waitForText(deskName.trim())
      I.seeTextEquals('Booked', mainPage.headers.bookedIcon)
      I.see('Full day')
    })
  },
).tag('@deskbird').tag('@book').tag('@deskBooking').tag('update').tag('regression')

Scenario(
  '@861mz9rwp As a user I am able to edit the desk number of booked desk via "Bookings" tab',
  async ({ I, bookPage, mainPage }) => {

    // ('----------------------------------')
    // ('Creating a desk booking')
    // ('----------------------------------')

    // Navigates to book tab and filters the areas by Meeting rooms. Selects 1st Floor and first room
    I.amOnPage(pages.goto.bookTab)
    I.see('Book a space')
    I.click(bookPage.buttons.fullDayOption)
    I.waitForElement(bookPage.fields.areaSelector)
    I.click(bookPage.fields.areaSelector)
    I.click(bookPage.areaTypes('Desk areas'))
    I.click(bookPage.floorAndRoomSelect (1, 1))

    // Grabs the booking office name, floor, and room numbers from the title
    const bookingDetails = await I.grabTextFrom(bookPage.headers.deskBookingTitle)
    const officeName = bookingDetails.split('·')[0].trim()
    const floorNumber = bookingDetails.split('·')[1].trim()
    const roomNumber = bookingDetails.split('·')[2].trim()

    // Grabs the desk name from the booking specification container
    const deskName = await I.grabTextFrom(bookPage.fields.deskName)

    // Grabs the date from the booking specification container and converts it to month long and day numeric (June 23)
    const dateStr = await I.grabTextFrom(bookPage.headers.dateContainer)
    const date = new Date(dateStr)
    const formatter = new Intl.DateTimeFormat('en-US', { day: 'numeric', month: 'long' })
    const formattedDate = formatter.format(date)

    // Formats the date to day numeric, month short, year numeric (23 Jun 2023)
    const formatterDateStr = new Intl.DateTimeFormat('en-DE', { day: 'numeric', month: 'short', year: 'numeric' })

    const formattedDayDateStr = formatterDateStr.format(date)

    // Grabs the start and end booking time from the booking specification container
    const startTime = await I.grabTextFrom(bookPage.fields.startTime)
    const endTime = await I.grabTextFrom(bookPage.fields.endTime)

    // Confirms the booking and waits for the booking confirmation popup
    I.click(bookPage.buttons.confirmBooking)
    I.waitForElement(bookPage.fields.bookingConfirmationModal)

    within(bookPage.fields.bookingConfirmationModal, () => {
      I.see(bookingDetails.trim())
      I.see(deskName.trim())
      I.see(formattedDate)
      I.see(startTime)
      I.see(endTime)
    })

    // Completes the booking and waits for the upcomingBooking element
    I.click(bookPage.buttons.done)
    I.waitForElement(bookPage.fields.upcomingBooking)

    within(bookPage.fields.upcomingBooking, () => {
      I.see(deskName.trim())
      I.seeTextEquals('Booked', bookPage.headers.bookedIcon)
      I.see('Full day')
    })

    // Enters into the booking placeholder from the upcoming booking element
    I.click(bookPage.fields.upcomingBooking)
    I.waitForElement(bookPage.fields.upcomingBookingInfo)

    within(bookPage.fields.upcomingBookingInfo, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(deskName.trim())
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(formattedDayDateStr)
      I.see(startTime)
      I.see(endTime)
    })

    // Navigates to schedule tab and waits for the booking placeholder element
    I.amOnPage(pages.goto.scheduleTab)
    I.waitForElement(mainPage.fields.viewBooking)

    within(mainPage.fields.viewBooking, () => {
      I.see(deskName.trim())
      I.seeTextEquals('Booked', mainPage.headers.bookedIcon)
      I.see('Full day')
    })

    // Navigates to bookingsTab and checks information from the info container
    I.amOnPage(pages.goto.bookingsTab)

    within(bookingsPage.fields.bookingInfoContainer, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(deskName.trim())
      I.see(ACCOUNTS.USER_ROLE!.email)
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(formattedDayDateStr)
      I.see(startTime)
      I.see(endTime)
    })

    // ('----------------------------------')
    // ('Editing the booked desk')
    // ('----------------------------------')

    // Clicks on the edit button from the bookings tab and changes the desk number
    I.click(bookingsPage.buttons.editBooking)

    I.waitForElement(bookPage.deskNumberSelect('Desk 2'))
    I.click(bookPage.deskNumberSelect('Desk 2'))

    // Grabs the new desk name from the booking specification container
    const newDeskName = await I.grabTextFrom(bookPage.fields.deskName)

    // Confirms the edited booking and waits for the booking confirmation popup
    I.click(bookPage.buttons.confirmBooking)
    I.waitForElement(bookPage.fields.bookingConfirmationModal)

    within(bookPage.fields.bookingConfirmationModal, () => {
      I.see(bookingDetails.trim())
      // I.see(newDeskName.trim()) // BLOCKED BECAUSE OF A BUG
      I.see(formattedDate)
      I.see(startTime)
      I.see(endTime)
    })

    // Confirms the edit and checks the information in the booking info container
    I.click(bookPage.buttons.done)
    I.waitForElement(bookingsPage.fields.bookingInfoContainer)

    within(bookingsPage.fields.bookingInfoContainer, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(newDeskName.trim())
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(dateStr.trim())
      I.see(startTime)
      I.see(endTime)
    })

    // Navigates to the book tab and checks that there are no bookings for the current date
    I.amOnPage(pages.goto.bookTab)
    I.waitForElement(bookPage.fields.upcomingBooking)

    within(bookPage.fields.upcomingBooking, () => {
      I.see(newDeskName.trim())
      I.seeTextEquals('Booked', bookPage.headers.bookedIcon)
      I.see('Full day')
    })

    // Clicks on the booking placeholder and checks information
    I.click(bookPage.fields.upcomingBooking)
    I.waitForElement(bookPage.fields.upcomingBookingInfo)

    within(bookPage.fields.upcomingBookingInfo, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(newDeskName.trim())
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(dateStr.trim())
      I.see(startTime)
      I.see(endTime)
    })

    // Verification in the Schedule tab of Desk name and that only one booking is made
    // *This can run from Sunday to Thursday because of weekend logic
    I.amOnPage(pages.goto.scheduleTab)
    I.waitForElement(mainPage.fields.viewBooking)

    within(mainPage.fields.viewBooking, () => {
      I.waitForText(newDeskName.trim())
      I.seeTextEquals('Booked', mainPage.headers.bookedIcon)
      I.see('Full day')
    })

  },
).tag('@deskbird').tag('@book').tag('@deskBooking').tag('update').tag('regression')

Scenario(
  '@861mz9fhd As a user I am able to edit the time of booked desk via "Bookings" tab',
  async ({ I, bookPage, mainPage }) => {

    // ('----------------------------------')
    // ('Creating a desk booking')
    // ('----------------------------------')

    // Navigates to book tab and filters the areas by Meeting rooms. Selects 1st Floor and first room
    I.amOnPage(pages.goto.bookTab)
    I.see('Book a space')
    I.click(bookPage.buttons.fullDayOption)
    I.waitForElement(bookPage.fields.areaSelector)
    I.click(bookPage.fields.areaSelector)
    I.click(bookPage.areaTypes('Desk areas'))
    I.click(bookPage.floorAndRoomSelect (1, 1))

    // Grabs the booking office name, floor, and room numbers from the title
    const bookingDetails = await I.grabTextFrom(bookPage.headers.deskBookingTitle)
    const officeName = bookingDetails.split('·')[0].trim()
    const floorNumber = bookingDetails.split('·')[1].trim()
    const roomNumber = bookingDetails.split('·')[2].trim()

    // Grabs the desk name from the booking specification container
    const deskName = await I.grabTextFrom(bookPage.fields.deskName)

    // Grabs the date from the booking specification container and converts it to month long and day numeric (June 23)
    const dateStr = await I.grabTextFrom(bookPage.headers.dateContainer)
    const date = new Date(dateStr)
    const formatter = new Intl.DateTimeFormat('en-US', { day: 'numeric', month: 'long' })
    const formattedDate = formatter.format(date)

    // Formats the date to day numeric, month short, year numeric (23 Jun 2023)
    const formatterDateStr = new Intl.DateTimeFormat('en-DE', { day: 'numeric', month: 'short', year: 'numeric' })

    const formattedDayDateStr = formatterDateStr.format(date)

    // Grabs the start and end booking time from the booking specification container
    const startTime = await I.grabTextFrom(bookPage.fields.startTime)
    const endTime = await I.grabTextFrom(bookPage.fields.endTime)

    // Confirms the booking and waits for the booking confirmation popup
    I.click(bookPage.buttons.confirmBooking)
    I.waitForElement(bookPage.fields.bookingConfirmationModal)

    within(bookPage.fields.bookingConfirmationModal, () => {
      I.see(bookingDetails.trim())
      I.see(deskName.trim())
      I.see(formattedDate)
      I.see(startTime)
      I.see(endTime)
    })

    // Completes the booking and waits for the upcomingBooking element
    I.click(bookPage.buttons.done)
    I.waitForElement(bookPage.fields.upcomingBooking)

    within(bookPage.fields.upcomingBooking, () => {
      I.see(deskName.trim())
      I.seeTextEquals('Booked', bookPage.headers.bookedIcon)
      I.see('Full day')
    })

    // Enters into the booking placeholder from the upcoming booking element
    I.click(bookPage.fields.upcomingBooking)
    I.waitForElement(bookPage.fields.upcomingBookingInfo)

    within(bookPage.fields.upcomingBookingInfo, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(deskName.trim())
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(formattedDayDateStr)
      I.see(startTime)
      I.see(endTime)
    })

    // Navigates to schedule tab and waits for the booking placeholder element
    I.amOnPage(pages.goto.scheduleTab)
    I.waitForElement(mainPage.fields.viewBooking)

    within(mainPage.fields.viewBooking, () => {
      I.see(deskName.trim())
      I.seeTextEquals('Booked', mainPage.headers.bookedIcon)
      I.see('Full day')
    })

    // Navigates to bookingsTab and checks information from the info container
    I.amOnPage(pages.goto.bookingsTab)

    within(bookingsPage.fields.bookingInfoContainer, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(deskName.trim())
      I.see(ACCOUNTS.USER_ROLE!.email)
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(formattedDayDateStr)
      I.see(startTime)
      I.see(endTime)
    })

    // ('----------------------------------')
    // ('Editing the booked desk')
    // ('----------------------------------')

    // Clicks on the edit button from the bookings tab and changes the start and end times
    I.click(bookingsPage.buttons.editBooking)

    I.click(bookPage.fields.editStartTime)
    I.click(bookPage.timeSelector('10:00 PM'))

    I.click(bookPage.fields.editEndTime)
    I.click(bookPage.timeSelector('10:30 PM'))

    const editedStartTime = await I.grabTextFrom(bookPage.fields.editStartTime)
    const editedEndTime = await I.grabTextFrom(bookPage.fields.editEndTime)

    // Confirms the edited booking and waits for the booking confirmation popup
    I.click(bookPage.buttons.confirmBooking)
    I.waitForElement(bookPage.fields.bookingConfirmationModal)

    within(bookPage.fields.bookingConfirmationModal, () => {
      I.see(bookingDetails.trim())
      I.see(deskName.trim())
      I.see(formattedDate)
      I.see(editedStartTime)
      I.see(editedEndTime)
    })

    // Confirms the edit and checks the information in the booking info container
    I.click(bookPage.buttons.done)
    I.waitForElement(bookingsPage.fields.bookingInfoContainer)

    within(bookingsPage.fields.bookingInfoContainer, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(deskName.trim())
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(dateStr.trim())
      I.see(editedStartTime)
      I.see(editedEndTime)
    })

    // Navigates to the book tab and checks that there are no bookings for the current date
    I.amOnPage(pages.goto.bookTab)
    I.waitForElement(bookPage.fields.upcomingBooking)

    within(bookPage.fields.upcomingBooking, () => {
      I.see(deskName.trim())
      I.seeTextEquals('Booked', bookPage.headers.bookedIcon)
      I.see(editedStartTime)
      I.see(editedEndTime)
    })

    // Enters into the booking placeholder from the upcoming booking element
    I.click(bookPage.fields.upcomingBooking)
    I.waitForElement(bookPage.fields.upcomingBookingInfo)

    within(bookPage.fields.upcomingBookingInfo, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(deskName.trim())
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(formattedDayDateStr)
      I.see(editedStartTime)
      I.see(editedEndTime)
    })

    // Verification in the Schedule tab of Desk name and that only one booking is made
    // *This can run from Sunday to Thursday because of weekend logic
    I.amOnPage(pages.goto.scheduleTab)
    I.waitForElement(mainPage.fields.viewBooking)

    within(mainPage.fields.viewBooking, () => {
      I.waitForText(deskName.trim())
      I.seeTextEquals('Booked', mainPage.headers.bookedIcon)
      I.see(editedStartTime)
      I.see(editedEndTime)
    })

  },
).tag('@deskbird').tag('@book').tag('@deskBooking').tag('update').tag('regression')

Scenario(
  '@861n362mh As a user I am able to edit the desk number of booked desk via the widget in "Book" tab',
  async ({ I, bookPage, mainPage }) => {

    // ('----------------------------------')
    // ('Creating a desk booking')
    // ('----------------------------------')

    // Navigates to book tab and filters the areas by Meeting rooms. Selects 1st Floor and first room
    I.amOnPage(pages.goto.bookTab)
    I.see('Book a space')
    I.click(bookPage.buttons.fullDayOption)
    I.waitForElement(bookPage.fields.areaSelector)
    I.click(bookPage.fields.areaSelector)
    I.click(bookPage.areaTypes('Desk areas'))
    I.click(bookPage.floorAndRoomSelect (1, 1))

    // Grabs the booking office name, floor, and room numbers from the title
    const bookingDetails = await I.grabTextFrom(bookPage.headers.deskBookingTitle)
    const officeName = bookingDetails.split('·')[0].trim()
    const floorNumber = bookingDetails.split('·')[1].trim()
    const roomNumber = bookingDetails.split('·')[2].trim()

    // Grabs the desk name from the booking specification container
    const deskName = await I.grabTextFrom(bookPage.fields.deskName)

    // Grabs the date from the booking specification container and converts it to month long and day numeric (June 23)
    const dateStr = await I.grabTextFrom(bookPage.headers.dateContainer)
    const date = new Date(dateStr)
    const formatter = new Intl.DateTimeFormat('en-US', { day: 'numeric', month: 'long' })
    const formattedDate = formatter.format(date)

    // Formats the date to day numeric, month short, year numeric (23 Jun 2023)
    const formatterDateStr = new Intl.DateTimeFormat('en-DE', { day: 'numeric', month: 'short', year: 'numeric' })

    const formattedDayDateStr = formatterDateStr.format(date)

    // Grabs the start and end booking time from the booking specification container
    const startTime = await I.grabTextFrom(bookPage.fields.startTime)
    const endTime = await I.grabTextFrom(bookPage.fields.endTime)

    // Confirms the booking and waits for the booking confirmation popup
    I.click(bookPage.buttons.confirmBooking)
    I.waitForElement(bookPage.fields.bookingConfirmationModal)

    within(bookPage.fields.bookingConfirmationModal, () => {
      I.see(bookingDetails.trim())
      I.see(deskName.trim())
      I.see(formattedDate)
      I.see(startTime)
      I.see(endTime)
    })

    // Completes the booking and waits for the upcomingBooking element
    I.click(bookPage.buttons.done)
    I.waitForElement(bookPage.fields.upcomingBooking)

    within(bookPage.fields.upcomingBooking, () => {
      I.see(deskName.trim())
      I.seeTextEquals('Booked', bookPage.headers.bookedIcon)
      I.see('Full day')
    })

    // Enters into the booking placeholder from the upcoming booking element
    I.click(bookPage.fields.upcomingBooking)
    I.waitForElement(bookPage.fields.upcomingBookingInfo)

    within(bookPage.fields.upcomingBookingInfo, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(deskName.trim())
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(formattedDayDateStr)
      I.see(startTime)
      I.see(endTime)
    })

    // Navigates to schedule tab and waits for the booking placeholder element
    I.amOnPage(pages.goto.scheduleTab)
    I.waitForElement(mainPage.fields.viewBooking)

    within(mainPage.fields.viewBooking, () => {
      I.see(deskName.trim())
      I.seeTextEquals('Booked', mainPage.headers.bookedIcon)
      I.see('Full day')
    })

    // Navigates to bookingsTab and checks information from the info container
    I.amOnPage(pages.goto.bookingsTab)

    within(bookingsPage.fields.bookingInfoContainer, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(deskName.trim())
      I.see(ACCOUNTS.USER_ROLE!.email)
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(formattedDayDateStr)
      I.see(startTime)
      I.see(endTime)
    })

    // ('----------------------------------')
    // ('Editing the booked desk')
    // ('----------------------------------')

    // Clicks on the edit button from the book tab and changes the desk number
    I.amOnPage(pages.goto.bookTab)

    I.waitForElement(bookPage.fields.upcomingBooking)
    I.click(bookPage.fields.upcomingBooking)

    I.click(bookPage.buttons.editBooking)

    I.waitForElement(bookPage.deskNumberSelect('Desk 2'))
    I.click(bookPage.deskNumberSelect('Desk 2'))

    // Grabs the new desk name from the booking specification container
    const newDeskName = await I.grabTextFrom(bookPage.fields.deskName)

    // Confirms the edited booking and waits for the booking confirmation popup
    I.click(bookPage.buttons.confirmBooking)
    I.waitForElement(bookPage.fields.bookingConfirmationModal)

    within(bookPage.fields.bookingConfirmationModal, () => {
      I.see(bookingDetails.trim())
      // I.see(newDeskName.trim()) // BLOCKED BECAUSE OF A BUG
      I.see(formattedDate)
      I.see(startTime)
      I.see(endTime)
    })

    // Confirms the edit and checks the information in the booking info container
    I.click(bookPage.buttons.done)
    I.waitForElement(bookingsPage.fields.bookingInfoContainer)

    within(bookingsPage.fields.bookingInfoContainer, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(newDeskName.trim())
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(dateStr.trim())
      I.see(startTime)
      I.see(endTime)
    })

    // Navigates to the book tab and checks that there are no bookings for the current date
    I.amOnPage(pages.goto.bookTab)
    I.waitForElement(bookPage.fields.upcomingBooking)

    within(bookPage.fields.upcomingBooking, () => {
      I.see(newDeskName.trim())
      I.seeTextEquals('Booked', bookPage.headers.bookedIcon)
      I.see('Full day')
    })

    // Clicks on the booking placeholder and checks information
    I.click(bookPage.fields.upcomingBooking)
    I.waitForElement(bookPage.fields.upcomingBookingInfo)

    within(bookPage.fields.upcomingBookingInfo, () => {
      I.see(officeName)
      I.see(floorNumber)
      I.see(roomNumber)
      I.see(newDeskName.trim())
      I.seeTextEquals('Booked', bookingsPage.headers.bookedIcon)
      I.see(dateStr.trim())
      I.see(startTime)
      I.see(endTime)
    })

    // Verification in the Schedule tab of Desk name and that only one booking is made
    // *This can run from Sunday to Thursday because of weekend logic
    I.amOnPage(pages.goto.scheduleTab)
    I.waitForElement(mainPage.fields.viewBooking)

    within(mainPage.fields.viewBooking, () => {
      I.waitForText(newDeskName.trim())
      I.seeTextEquals('Booked', mainPage.headers.bookedIcon)
      I.see('Full day')
    })

  },
).tag('@deskbird').tag('@book').tag('@deskBooking').tag('update').tag('regression')

After(async ({ I }) => {
  I.amOnPage(pages.goto.scheduleTab)
  await cleanupBookings()
})
Editor is loading...