Skip to content

Commit

Permalink
test: add e2e test for /api/v0/version endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed Oct 25, 2023
1 parent 26cb74a commit 01ac9cc
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions e2e-tests/version-response.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { test, expect } from '@playwright/test'
import { PORT } from '../src/constants.js'

function validateResponse (content: string): void {
expect(() => JSON.parse(content)).not.toThrow()
const versionObj = JSON.parse(content)

expect(versionObj).toHaveProperty('Version')
expect(versionObj).toHaveProperty('Commit')
}

test('GET /api/v0/version', async ({ page }) => {
const result = await page.goto(`http://localhost:${PORT}/api/v0/version`)
expect(result?.status()).toBe(200)

const maybeContent = await result?.text()
expect(maybeContent).not.toBe(undefined)
validateResponse(maybeContent as string)
})

test('POST /api/v0/version', async ({ page }) => {
const result = await page.request.post(`http://localhost:${PORT}/api/v0/version`)
expect(result?.status()).toBe(200)

const maybeContent = await result?.text()
expect(maybeContent).not.toBe(undefined)
validateResponse(maybeContent)
})

0 comments on commit 01ac9cc

Please sign in to comment.