insomnia/packages/insomnia-smoke-test/tests/critical/app-start.test.ts

34 lines
1.7 KiB
TypeScript
Raw Normal View History

import { expect } from '@playwright/test';
import { loadFixture } from '../../playwright/paths';
import { test } from '../../playwright/test';
test('can send requests', async ({ app, page }) => {
const statusTag = page.locator('[data-testid="response-status-tag"]:visible');
const responseBody = page.locator('[data-testid="CodeEditor"]:visible', {
has: page.locator('.CodeMirror-activeline'),
});
await page.getByRole('button', { name: 'Create' }).click();
const text = await loadFixture('smoke-test-collection.yaml');
await app.evaluate(async ({ clipboard }, text) => clipboard.writeText(text), text);
await page.getByRole('menuitem', { name: 'Import' }).click();
await page.getByText('Clipboard').click();
await page.getByRole('button', { name: 'Scan' }).click();
await page.getByRole('dialog').getByRole('button', { name: 'Import' }).click();
await page.getByText('CollectionSmoke testsjust now').click();
await page.getByRole('button', { name: 'send JSON request' }).click();
await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click();
await expect(statusTag).toContainText('200 OK');
await expect(responseBody).toContainText('"id": "1"');
await page.getByRole('button', { name: 'Preview' }).click();
await page.getByRole('menuitem', { name: 'Raw Data' }).click();
await expect(responseBody).toContainText('{"id":"1"}');
await page.getByRole('button', { name: 'send JSON request' }).click();
await page.locator('[data-testid="Dropdown-send-JSON-request"]').click();
await page.getByRole('menuitem', { name: 'Generate Code' }).click();
await page.getByText('curl --request GET \\').click();
await page.getByRole('button', { name: 'Done' }).click();
});