Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkav committed Apr 2, 2024
1 parent 922cbbc commit c09f5f2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
17 changes: 5 additions & 12 deletions packages/insomnia-smoke-test/tests/smoke/mock.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import { loadFixture } from '../../playwright/paths';
import { test } from '../../playwright/test';

test('can make a mock route', async ({ app, page }) => {
test('can make a mock route', async ({ page }) => {
test.slow(process.platform === 'darwin' || process.platform === 'win32', 'Slow app start on these platforms');
const text = await loadFixture('smoke-test-collection.yaml');
await app.evaluate(async ({ clipboard }, text) => clipboard.writeText(text), text);

await page.getByRole('button', { name: 'Create in project' }).click();
await page.getByRole('menuitemradio', { name: 'Import' }).click();
await page.locator('[data-test-id="import-from-clipboard"]').click();
await page.getByRole('button', { name: 'Scan' }).click();
await page.getByRole('dialog').getByRole('button', { name: 'Import' }).click();

await page.getByLabel('New Mock Server').click();
await page.getByRole('button', { name: 'Create', exact: true }).click();
await page.getByRole('button', { name: 'New Mock Route' }).click();
await page.getByText('GET/').click();
await page.getByTestId('CodeEditor').getByRole('textbox').fill('123');
await page.getByLabel('Project Actions').click();
await page.getByText('Rename').click();
await page.locator('#prompt-input').fill('/123');
await page.getByRole('button', { name: 'Rename' }).click();

await page.getByRole('button', { name: 'Test' }).click();
await page.getByText('No body returned for response').click();
Expand Down
8 changes: 4 additions & 4 deletions packages/insomnia/src/ui/routes/mock-route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ export const MockRouteRoute = () => {
});

const upsertMockbinHar = async (pathInput?: string) => {
const hasRouteInServer = mockRoutes.find(m => m.name === pathInput);
const hasRouteInServer = mockRoutes.filter(m => m._id !== mockRoute._id).find(m => m.name === pathInput);
if (hasRouteInServer) {
showModal(AlertModal, {
title: 'Error',
message: 'Route name must be unique. Please enter a different name.',
message: `Path "${pathInput}" must be unique. Please enter a different name.`,
});

return;
Expand All @@ -176,11 +176,11 @@ export const MockRouteRoute = () => {
});
};
const onSend = async (pathInput: string) => {
const hasRouteInServer = mockRoutes.find(m => m.name === pathInput);
const hasRouteInServer = mockRoutes.filter(m => m._id !== mockRoute._id).find(m => m.name === pathInput);
if (hasRouteInServer) {
showModal(AlertModal, {
title: 'Error',
message: 'Route name must be unique. Please enter a different name.',
message: `Path "${pathInput}" must be unique. Please enter a different name.`,
});

return;
Expand Down
8 changes: 4 additions & 4 deletions packages/insomnia/src/ui/routes/mock-server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ const MockServerRoute = () => {
defaultValue: mockRoutes.find(s => s._id === id)?.name,
submitName: 'Rename',
onComplete: name => {
const hasRouteInServer = mockRoutes.find(s => s.name === name);
const hasRouteInServer = mockRoutes.filter(m => m._id !== id).find(m => m.name === name);
if (hasRouteInServer) {
showModal(AlertModal, {
title: 'Error',
message: 'Route name must be unique. Please enter a different name.',
message: `Path "${name}" must be unique. Please enter a different name.`,
});
return;
};
Expand Down Expand Up @@ -204,11 +204,11 @@ const MockServerRoute = () => {
});
}}
onSubmit={name => {
const hasRouteInServer = mockRoutes.find(s => s.name === name);
const hasRouteInServer = mockRoutes.filter(m => m._id !== item._id).find(m => m.name === name);
if (hasRouteInServer) {
showModal(AlertModal, {
title: 'Error',
message: 'Route name must be unique. Please enter a different name.',
message: `Path "${name}" must be unique. Please enter a different name.`,
});
return;
};
Expand Down

0 comments on commit c09f5f2

Please sign in to comment.