File size: 1,730 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { test, expect } from '@playwright/test'
import { adminSessionFile } from './lib'
import Chance from 'chance'
import { createService } from './lib/service'
const c = new Chance()
test.describe.configure({ mode: 'parallel' })
test.use({ storageState: adminSessionFile })

test('Admin', async ({ page }) => {
  const name = 'pw-service ' + c.name()
  const description = c.sentence()
  await createService(page, name, description)

  await page.goto('./admin/service-metrics')

  // wait for services to finish loading
  await expect(page.locator('.MuiDataGrid-overlay')).toHaveCount(0)

  const totalServicesLocator = page
    .locator('.MuiCardHeader-content', { hasText: 'Total Services' })
    .locator('.MuiCardHeader-title')

  // This will retry until the locator's text matches the regex (a number greater than 0)
  // or the timeout is reached.
  await expect(totalServicesLocator).toHaveText(/^[1-9]\d*$/)

  // get services missing integrations count
  const missingIntsLocator = page
    .locator('.MuiCardHeader-content', {
      hasText: 'Services With No Integrations',
    })
    .locator('.MuiCardHeader-title')
  await expect(missingIntsLocator).toHaveText(/^[1-9]\d*$/)

  // get services missing notifications count
  const missingNotifLocator = page
    .locator('.MuiCardHeader-content', {
      hasText: 'Services With Empty Escalation Policies',
    })
    .locator('.MuiCardHeader-title')
  await expect(missingNotifLocator).toHaveText('0')

  // get services reaching alert limit
  const alertLimitLocator = page
    .locator('.MuiCardHeader-content', {
      hasText: 'Services Reaching Alert Limit',
    })
    .locator('.MuiCardHeader-title')
  await expect(alertLimitLocator).toHaveText('0')
})