generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add e2e tests for call and ingress requests (#3038)
- Loading branch information
1 parent
7913488
commit 68d6ba3
Showing
10 changed files
with
136 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { expect, ftlTest } from './ftl-test' | ||
import { navigateToDecl } from './helpers' | ||
|
||
ftlTest('shows echo verb form', async ({ page }) => { | ||
await navigateToDecl(page, 'echo', 'echo') | ||
|
||
await expect(page.getByText('CALL', { exact: true })).toBeVisible() | ||
await expect(page.locator('input#request-path')).toHaveValue('echo.echo') | ||
|
||
await expect(page.getByText('Body', { exact: true })).toBeVisible() | ||
await expect(page.getByText('Verb Schema', { exact: true })).toBeVisible() | ||
await expect(page.getByText('JSONSchema', { exact: true })).toBeVisible() | ||
}) | ||
|
||
ftlTest('send echo request', async ({ page }) => { | ||
await navigateToDecl(page, 'echo', 'echo') | ||
|
||
// Check the initial value of the path input | ||
const pathInput = page.locator('#request-path') | ||
await expect(pathInput).toBeVisible() | ||
const currentValue = await pathInput.inputValue() | ||
expect(currentValue).toBe('echo.echo') | ||
|
||
const bodyEditor = page.locator('#body-editor .cm-content[contenteditable="true"]') | ||
await expect(bodyEditor).toBeVisible() | ||
await bodyEditor.fill('{\n "name": "wicket"\n}') | ||
|
||
await page.getByRole('button', { name: 'Send' }).click() | ||
|
||
const responseEditor = page.locator('#response-editor .cm-content[role="textbox"]') | ||
await expect(responseEditor).toBeVisible() | ||
|
||
const responseText = await responseEditor.textContent() | ||
const responseJson = JSON.parse(responseText.trim()) | ||
|
||
const expectedStart = 'Hello, wicket!!! It is ' | ||
expect(responseJson.message.startsWith(expectedStart)).toBe(true) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { type Page, expect } from '@playwright/test' | ||
|
||
export async function navigateToModule(page: Page, moduleName: string) { | ||
await page.getByRole('link', { name: 'Modules' }).click() | ||
|
||
// Navigate to the module page | ||
await page.locator(`#module-${moduleName}-view-icon`).click() | ||
await expect(page).toHaveURL(new RegExp(`/modules/${moduleName}`)) | ||
|
||
// Expand the module tree group | ||
await page.locator(`#module-${moduleName}-tree-group`).click() | ||
} | ||
|
||
export async function navigateToDecl(page: Page, moduleName: string, declName: string) { | ||
await navigateToModule(page, moduleName) | ||
|
||
// Navigate to the decl page | ||
await page.locator(`div#decl-${declName}`).click() | ||
await expect(page).toHaveURL(new RegExp(`/modules/${moduleName}/verb/${declName}`)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { expect, ftlTest } from './ftl-test' | ||
import { navigateToDecl } from './helpers' | ||
|
||
ftlTest('shows http ingress form', async ({ page }) => { | ||
await navigateToDecl(page, 'http', 'get') | ||
|
||
await expect(page.locator('#call-type')).toHaveText('GET') | ||
await expect(page.locator('input#request-path')).toHaveValue('http://localhost:8891/get/name') | ||
|
||
await expect(page.getByText('Body', { exact: true })).toBeVisible() | ||
await expect(page.getByText('Verb Schema', { exact: true })).toBeVisible() | ||
await expect(page.getByText('JSONSchema', { exact: true })).toBeVisible() | ||
}) | ||
|
||
ftlTest('send get request with path and query params', async ({ page }) => { | ||
await navigateToDecl(page, 'http', 'get') | ||
|
||
// Check the initial value of the path input | ||
const pathInput = page.locator('#request-path') | ||
await expect(pathInput).toBeVisible() | ||
const currentValue = await pathInput.inputValue() | ||
expect(currentValue).toBe('http://localhost:8891/get/name') | ||
|
||
// Update the path input to test path and query params | ||
await pathInput.fill('http://localhost:8891/get/wicket?age=10') | ||
await page.getByRole('button', { name: 'Send' }).click() | ||
|
||
const responseEditor = page.locator('#response-editor .cm-content[role="textbox"]') | ||
await expect(responseEditor).toBeVisible() | ||
|
||
const responseText = await responseEditor.textContent() | ||
const responseJson = JSON.parse(responseText) | ||
|
||
expect(responseJson).toEqual({ | ||
age: '10', | ||
name: 'wicket', | ||
}) | ||
}) | ||
|
||
ftlTest('send post request with body', async ({ page }) => { | ||
await navigateToDecl(page, 'http', 'post') | ||
|
||
// Check the initial value of the path input | ||
const pathInput = page.locator('#request-path') | ||
await expect(pathInput).toBeVisible() | ||
const currentValue = await pathInput.inputValue() | ||
expect(currentValue).toBe('http://localhost:8891/post') | ||
|
||
const bodyEditor = page.locator('#body-editor .cm-content[contenteditable="true"]') | ||
await expect(bodyEditor).toBeVisible() | ||
await bodyEditor.fill('{\n "age": 10,\n "name": "wicket"\n}') | ||
|
||
await page.getByRole('button', { name: 'Send' }).click() | ||
|
||
const responseEditor = page.locator('#response-editor .cm-content[role="textbox"]') | ||
await expect(responseEditor).toBeVisible() | ||
|
||
const responseText = await responseEditor.textContent() | ||
const responseJson = JSON.parse(responseText) | ||
|
||
expect(responseJson).toEqual({ | ||
age: 10, | ||
name: 'wicket', | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
import { expect, ftlTest } from './ftl-test' | ||
import { navigateToModule } from './helpers' | ||
|
||
ftlTest('shows verbs for deployment', async ({ page }) => { | ||
const modulesNavItem = page.getByRole('link', { name: 'Modules' }) | ||
await modulesNavItem.click() | ||
|
||
const moduleEchoRow = page.locator('div.cursor-pointer').getByText('echo') | ||
const moduleEcho = moduleEchoRow.locator('svg').nth(1) | ||
await moduleEcho.click() | ||
|
||
await expect(page).toHaveURL(/\/modules\/echo/) | ||
await navigateToModule(page, 'echo') | ||
|
||
await expect(page.getByText('module echo {')).toBeVisible() | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters