mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-16 04:11:29 +00:00
40 lines
1.8 KiB
TypeScript
40 lines
1.8 KiB
TypeScript
import { test, expect } from '../../../playwright';
|
|
import * as path from 'path';
|
|
import { closeAllCollections } from '../../utils/page';
|
|
|
|
test.describe('Import OpenAPI v3 JSON Collection', () => {
|
|
test.afterEach(async ({ page }) => {
|
|
// cleanup: close all collections
|
|
await closeAllCollections(page);
|
|
});
|
|
|
|
test('Import simple OpenAPI v3 JSON successfully', async ({ page, createTmpDir }) => {
|
|
const openApiFile = path.resolve(__dirname, 'fixtures', 'openapi-simple.json');
|
|
|
|
await page.locator('.plus-icon-button').click();
|
|
await page.locator('.tippy-box .dropdown-item').filter({ hasText: 'Import collection' }).click();
|
|
|
|
// Wait for import collection modal to be ready
|
|
const importModal = page.getByRole('dialog');
|
|
await importModal.waitFor({ state: 'visible' });
|
|
await expect(importModal.locator('.bruno-modal-header-title')).toContainText('Import Collection');
|
|
|
|
await page.setInputFiles('input[type="file"]', openApiFile);
|
|
|
|
// Wait for location modal to appear after file processing
|
|
const locationModal = page.locator('[data-testid="import-collection-location-modal"]');
|
|
await locationModal.waitFor({ state: 'visible', timeout: 10000 });
|
|
await expect(locationModal.locator('.bruno-modal-header-title')).toContainText('Import Collection');
|
|
|
|
// Wait for collection to appear in the location modal
|
|
await expect(locationModal.getByText('Simple Test API')).toBeVisible();
|
|
|
|
// Select a location and import
|
|
await page.locator('#collection-location').fill(await createTmpDir('simple-test'));
|
|
await locationModal.getByRole('button', { name: 'Import' }).click();
|
|
|
|
// Verify the collection was imported successfully
|
|
await expect(page.locator('#sidebar-collection-name').getByText('Simple Test API')).toBeVisible();
|
|
});
|
|
});
|