Skip to content

Commit

Permalink
Merge branch 'main' into update-fromid-construct
Browse files Browse the repository at this point in the history
  • Loading branch information
checklyalex authored Nov 28, 2023
2 parents a8ffeef + 1c0be73 commit 1f6264c
Show file tree
Hide file tree
Showing 50 changed files with 959 additions and 183 deletions.
4 changes: 2 additions & 2 deletions __checks__/alertChannels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { OpsgenieAlertChannel, SlackAlertChannel } from 'checkly/constructs'
import { alertChannelIds } from './defaults'

export const slackChannelOps = SlackAlertChannel.fromId(alertChannelIds.slack)
export const opsGenieChannelP1 = OpsgenieAlertChannel.fromId(alertChannelIds.opsGenieP1)
// removed temporarily for testing snapshots / visual comparisons
export const opsGenieChannelP3 = OpsgenieAlertChannel.fromId(alertChannelIds.opsGenieP3)
export const alertChannels = [slackChannelOps, opsGenieChannelP3]
export const alertChannels = [slackChannelOps]
8 changes: 8 additions & 0 deletions __checks__/docs-visual.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { test } from '@playwright/test'
import { ChecklySitePage } from './poms/ChecklySitePage'

test('homepage visual comparison', async ({ page }) => {
const checklyPage = new ChecklySitePage(page)
await checklyPage.goto('/docs')
await checklyPage.doScreenshotCompare()
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 14 additions & 3 deletions __checks__/poms/ChecklySitePage.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { BrowserContext, Page } from '@playwright/test'
import type { Page } from '@playwright/test'
import { expect } from '@playwright/test'
import { defaults } from '../defaults'

export class ChecklySitePage {
public page: Page

constructor (page) {
constructor (page: Page) {
this.page = page
}

Expand All @@ -17,7 +18,17 @@ export class ChecklySitePage {
await this.page.goto(defaults.baseURL + uri)
}

async screenshot (name) {
async screenshot (name: string) {
await this.page.screenshot({ path: `${defaults.screenshotPath}/${name}.jpg` })
}

async doScreenshotCompare () {
await expect(this.page).toHaveScreenshot({
maxDiffPixelRatio: 0.2,
mask: [
this.page.locator('.optanon-alert-box-wrapper'),
this.page.locator('#intercom-container-body')
]
})
}
}
3 changes: 2 additions & 1 deletion __checks__/site.check-group.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { CheckGroup, RetryStrategyBuilder } from 'checkly/constructs'
import { CheckGroup, RetryStrategyBuilder, Frequency } from 'checkly/constructs'
import { alertChannels } from './alertChannels'

export const checklyhqComGroup = new CheckGroup('checklyhq-docs-1', {
name: 'checklyhq.com/docs',
activated: true,
muted: false,
runtimeId: '2023.02',
frequency: Frequency.EVERY_1H,
locations: [
'us-east-1',
'us-west-1',
Expand Down
102 changes: 48 additions & 54 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
},
"devDependencies": {
"@playwright/test": "1.31.2",
"checkly": "4.1.0",
"checkly": "4.4.0",
"eslint": "7.32.0",
"eslint-config-standard": "16.0.3",
"eslint-plugin-html": "7.1.0",
Expand Down
9 changes: 7 additions & 2 deletions site/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,18 @@ disqusShortname = "checkly"
url = "/docs/heartbeat-checks/"
weight = 35

[[menu.resources]]
name = "Multistep API checks"
url = "/docs/multistep-checks/"
weight = 40

[[menu.resources]]
name = "Groups"
url = "/docs/groups/"
weight = 40
weight = 45

[[menu.resources]]
name = "Retries & Alerting"
name = "Alerting & retries"
url = "/docs/alerting/"
weight = 50

Expand Down
12 changes: 12 additions & 0 deletions site/content/_shared/runtime-env-vars.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
sitemapExclude: true
---
| variable | description | availability notes |
|-------------------|---------------------------------------------|--------------------------------------|
| `CHECK_ID` | The UUID of the check being executed. | only available after saving a check. |
| `CHECK_NAME` | The name of the check being executed. | |
| `CHECK_RESULT_ID` | The UUID where the result will be saved. | only available on scheduled runs. |
| `CHECK_RUN_ID` | The UUID of the check run execution. | only available on scheduled runs. |
| `CHECK_TYPE` | The type of the check, e.g. `BROWSER`. | |
| `REGION` | The current region, e.g. `us-west-1`. | |
| `RUNTIME_VERSION` | The version of the runtime, e.g, `2023.09`. | |
53 changes: 53 additions & 0 deletions site/content/_shared/using-the-file-system.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
sitemapExclude: true
---
Sometimes, you do want to explicitly save a file to disk. This is what you need to know.

Checkly creates a sandboxed directory for each check run. During the run you can use this directory to save or upload
artifacts. This directory is destroyed after a check is finished.

{{< tabs "Basic example" >}}
{{< tab "Typescript" >}}
```ts
import path from 'path'
import fs from 'fs'
import { test } from '@playwright/test'

test('Save file in directory', async ({ page }) => {
const image = await page.goto('https://picsum.photos/200/300')
const imagePath = path.join('example.jpg')
const buffer = await image.body()
fs.writeFileSync(imagePath, buffer)
const readFileFromDisk = fs.readFileSync(imagePath)
})
```
{{< /tab >}}
{{< tab "Javascript" >}}
```js
const path = require('path')
const fs = require('fs')
const { test } = require('@playwright/test')

test('Save file in directory', async ({ page }) => {
const image = await page.goto('https://picsum.photos/200/300')
const imagePath = path.join('example.jpg')
const buffer = await image.body()
fs.writeFileSync(imagePath, buffer)
const readFileFromDisk = fs.readFileSync(imagePath)
})
```
{{< /tab >}}
{{< /tabs >}}

Due to this sandbox, certain Node.js variables are adapted to our platform and have values we set for them. The behaviour
is slightly different when creating a browser check in the Web UI or using the Checkly CLI.

When creating a browser check in the Web UI, the variables are:

* `__dirname` will have the value of `/`
* `__filename` will have the value of `/script.js`

When creating a browser check using the Checkly CLI the variables are:

* `__dirname` will have the value of `/`
* `__filename` will have the value of the actual file in your code base, relative to the project root.
Loading

0 comments on commit 1f6264c

Please sign in to comment.