2022-12-07 10:33:15 +00:00
|
|
|
import { expect, Locator } from '@playwright/test';
|
|
|
|
|
|
|
|
import { loadFixture } from '../../playwright/paths';
|
|
|
|
import { test } from '../../playwright/test';
|
|
|
|
|
|
|
|
test.describe('gRPC interactions', () => {
|
|
|
|
|
|
|
|
test.slow(process.platform === 'darwin' || process.platform === 'win32', 'Slow app start on these platforms');
|
|
|
|
let statusTag: Locator;
|
|
|
|
let responseBody: Locator;
|
|
|
|
let streamMessage: Locator;
|
|
|
|
|
|
|
|
test.beforeEach(async ({ app, page }) => {
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByRole('button', { name: 'Create in project' }).click();
|
2022-12-07 10:33:15 +00:00
|
|
|
|
|
|
|
const text = await loadFixture('grpc.yaml');
|
|
|
|
await app.evaluate(async ({ clipboard }, text) => clipboard.writeText(text), text);
|
|
|
|
|
2023-08-28 13:53:37 +00:00
|
|
|
await page.getByRole('menuitemradio', { name: 'Import' }).click();
|
2023-09-24 23:12:50 +00:00
|
|
|
await page.locator('[data-test-id="import-from-clipboard"]').click();
|
2023-03-31 10:53:22 +00:00
|
|
|
await page.getByRole('button', { name: 'Scan' }).click();
|
2023-07-05 16:51:55 +00:00
|
|
|
await page.getByRole('dialog').getByRole('button', { name: 'Import' }).click();
|
2023-06-27 15:43:51 +00:00
|
|
|
await page.getByText('CollectionPreRelease gRPCjust now').click();
|
2022-12-07 10:33:15 +00:00
|
|
|
statusTag = page.locator('[data-testid="response-status-tag"]:visible');
|
|
|
|
responseBody = page.locator('[data-testid="response-pane"] >> [data-testid="CodeEditor"]:visible', {
|
|
|
|
has: page.locator('.CodeMirror-activeline'),
|
|
|
|
});
|
|
|
|
streamMessage = page.locator('[data-testid="request-pane"] button:has-text("Stream")');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('can send unidirectional requests', async ({ page }) => {
|
2023-08-22 16:12:29 +00:00
|
|
|
await page.getByLabel('Request Collection').getByText('Unary', { exact: true }).click();
|
2022-12-07 10:33:15 +00:00
|
|
|
await page.locator('[data-testid="request-pane"] >> text=Unary').click();
|
|
|
|
await page.click('text=Send');
|
|
|
|
|
|
|
|
// Check for the single Unary response
|
|
|
|
await page.click('text=Response 1');
|
|
|
|
await expect(statusTag).toContainText('0 OK');
|
|
|
|
await expect(responseBody).toContainText('Berkshire Valley Management Area Trail');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('can send bidirectional requests', async ({ page }) => {
|
2023-11-02 14:14:26 +00:00
|
|
|
await page.getByLabel('Request Collection').getByTestId('Bidirectional Stream').press('Enter');
|
2022-12-07 10:33:15 +00:00
|
|
|
await page.locator('text=Bi-directional Streaming').click();
|
|
|
|
await page.click('text=Start');
|
|
|
|
|
|
|
|
// Stream 3 client messages
|
|
|
|
await streamMessage.click();
|
|
|
|
await streamMessage.click();
|
|
|
|
await streamMessage.click();
|
|
|
|
|
|
|
|
// Check for the 3rd stream and response
|
|
|
|
await page.locator('text=Stream 3').click();
|
|
|
|
await page.locator('text=Response 3').click();
|
|
|
|
|
|
|
|
// Finish the stream
|
|
|
|
await page.locator('text=Commit').click();
|
|
|
|
await expect(statusTag).toContainText('0 OK');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('can send client stream requests', async ({ page }) => {
|
2023-11-02 14:14:26 +00:00
|
|
|
await page.getByLabel('Request Collection').getByTestId('Client Stream').press('Enter');
|
2022-12-07 10:33:15 +00:00
|
|
|
await page.click('text=Client Streaming');
|
|
|
|
await page.click('text=Start');
|
|
|
|
|
|
|
|
// Stream 3 client messages
|
|
|
|
await streamMessage.click();
|
|
|
|
await streamMessage.click();
|
|
|
|
await streamMessage.click();
|
|
|
|
|
|
|
|
// Finish the stream and check response
|
|
|
|
await page.locator('text=Commit').click();
|
|
|
|
await page.locator('text=Stream 3').click();
|
|
|
|
await page.locator('text=Response 1').click();
|
|
|
|
await expect(statusTag).toContainText('0 OK');
|
|
|
|
await expect(responseBody).toContainText('point_count": 3');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('can send server stream requests', async ({ page }) => {
|
2023-11-02 14:14:26 +00:00
|
|
|
await page.getByLabel('Request Collection').getByTestId('Server Stream').press('Enter');
|
2022-12-07 10:33:15 +00:00
|
|
|
await page.click('text=Server Streaming');
|
|
|
|
await page.click('text=Start');
|
|
|
|
|
|
|
|
// Check response
|
|
|
|
await expect(statusTag).toContainText('0 OK');
|
|
|
|
await page.locator('text=Response 64').click();
|
|
|
|
await expect(responseBody).toContainText('3 Hasta Way');
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|