github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/public/src/__tests__/e2e/courseUtilityLinks.test.tsx (about)

     1  import { By, until } from 'selenium-webdriver'
     2  import { isOverlapping, setupDrivers } from '../TestHelpers'
     3  
     4  
     5  describe("Course utility elements should not overlap", () => {
     6  
     7      const overlapTests: { width: number, height: number, want: boolean }[] = [
     8          // Resolutions to test
     9          { width: 1920, height: 1080, want: false }, // Desktop
    10          { width: 360, height: 740, want: false },   // More common phones
    11          { width: 360, height: 640, want: false },   // Older phones
    12          { width: 412, height: 914, want: false }    // Bigger phones
    13      ]
    14  
    15      const drivers = setupDrivers("/course/1")
    16  
    17      drivers.forEach(driver => {
    18          overlapTests.forEach(test => {
    19              it(`Should not overlap on split screen ${test.width}x${test.height}`, async () => {
    20                  await driver.manage().window().setRect({ width: test.width, height: test.height })
    21                  if (await driver.findElement(By.className("closeButton")).isDisplayed()) {
    22                      driver.findElement(By.className("closeButton")).click()
    23                  }
    24                  const switchStudent = driver.findElement(By.className("clickable"))
    25                  await driver.wait(until.elementIsVisible(switchStudent), 100)
    26                  await switchStudent.click()
    27  
    28                  const labs = await driver.findElement(By.className("col-md-9"))
    29                  await driver.wait(until.elementIsVisible(labs), 5000)
    30  
    31                  const utility = await driver.findElement(By.className("list-group width-resize"))
    32                  await driver.wait(until.elementIsVisible(utility), 5000)
    33                  const rect = await utility.getRect()
    34                  const rect2 = await labs.getRect()
    35  
    36                  const overlap = isOverlapping(rect, rect2)
    37  
    38                  expect(overlap).toBe(test.want)
    39  
    40                  // Refresh the page to reset the state
    41                  await driver.navigate().refresh()
    42              }, 50000)
    43          })
    44      })
    45  })