mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-07 14:08:38 +00:00
Import WSDL to collection (#5015)
* Import WSDL to bruno collection * feat(wsdl-import): remove unused code and minor refactor --------- Co-authored-by: Bijin Bruno <bijin@usebruno.com>
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
import { test, expect } from '../../../playwright';
|
||||
|
||||
test.describe('File Input Acceptance', () => {
|
||||
test('File input accepts expected file types', async ({ page }) => {
|
||||
test('File input accepts expected file types', async ({ page }) => {
|
||||
await page.getByRole('button', { name: 'Import Collection' }).click();
|
||||
|
||||
|
||||
// Check that file input exists (even if hidden)
|
||||
const fileInput = page.locator('input[type="file"]');
|
||||
await expect(fileInput).toBeAttached();
|
||||
|
||||
|
||||
// Verify it accepts the expected file types
|
||||
const acceptValue = await fileInput.getAttribute('accept');
|
||||
expect(acceptValue).toContain('.json');
|
||||
expect(acceptValue).toContain('.yaml');
|
||||
expect(acceptValue).toContain('.yml');
|
||||
|
||||
|
||||
// Cleanup: close any open modals
|
||||
await page.locator('[data-test-id="modal-close-button"]').click();
|
||||
});
|
||||
|
||||
102
tests/import/wsdl/fixtures/wsdl-bruno.json
Normal file
102
tests/import/wsdl/fixtures/wsdl-bruno.json
Normal file
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"uid": "TestServiceCollection",
|
||||
"version": "1",
|
||||
"name": "TestWSDLServiceJSON",
|
||||
"items": [
|
||||
{
|
||||
"uid": "UserServiceFolder",
|
||||
"name": "UserService",
|
||||
"type": "folder",
|
||||
"items": [
|
||||
{
|
||||
"uid": "GetUserRequest",
|
||||
"name": "GetUser",
|
||||
"type": "http-request",
|
||||
"seq": 1,
|
||||
"request": {
|
||||
"url": "http://example.com/soap/userservice",
|
||||
"method": "POST",
|
||||
"auth": {
|
||||
"mode": "none",
|
||||
"basic": null,
|
||||
"bearer": null,
|
||||
"digest": null
|
||||
},
|
||||
"headers": [
|
||||
{
|
||||
"uid": "ContentTypeHeader",
|
||||
"name": "Content-Type",
|
||||
"value": "text/xml; charset=utf-8",
|
||||
"description": "",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"uid": "SOAPActionHeader",
|
||||
"name": "SOAPAction",
|
||||
"value": "http://example.com/testservice/GetUser",
|
||||
"description": "",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"params": [],
|
||||
"body": {
|
||||
"mode": "xml",
|
||||
"json": null,
|
||||
"text": null,
|
||||
"xml": "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><GetUserRequest xmlns=\"http://example.com/testservice\"><userId>string</userId><includeDetails>true</includeDetails></GetUserRequest></soap:Body></soap:Envelope>",
|
||||
"formUrlEncoded": [],
|
||||
"multipartForm": []
|
||||
},
|
||||
"script": {
|
||||
"res": null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"uid": "CreateUserRequest",
|
||||
"name": "CreateUser",
|
||||
"type": "http-request",
|
||||
"seq": 2,
|
||||
"request": {
|
||||
"url": "http://example.com/soap/userservice",
|
||||
"method": "POST",
|
||||
"auth": {
|
||||
"mode": "none",
|
||||
"basic": null,
|
||||
"bearer": null,
|
||||
"digest": null
|
||||
},
|
||||
"headers": [
|
||||
{
|
||||
"uid": "ContentTypeHeader2",
|
||||
"name": "Content-Type",
|
||||
"value": "text/xml; charset=utf-8",
|
||||
"description": "",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"uid": "SOAPActionHeader2",
|
||||
"name": "SOAPAction",
|
||||
"value": "http://example.com/testservice/CreateUser",
|
||||
"description": "",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"params": [],
|
||||
"body": {
|
||||
"mode": "xml",
|
||||
"json": null,
|
||||
"text": null,
|
||||
"xml": "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><CreateUserRequest xmlns=\"http://example.com/testservice\"><name>string</name><email>string</email><password>string</password></CreateUserRequest></soap:Body></soap:Envelope>",
|
||||
"formUrlEncoded": [],
|
||||
"multipartForm": []
|
||||
},
|
||||
"script": {
|
||||
"res": null
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
126
tests/import/wsdl/fixtures/wsdl.xml
Normal file
126
tests/import/wsdl/fixtures/wsdl.xml
Normal file
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<wsdl:definitions
|
||||
name="TestWSDLServiceXML"
|
||||
targetNamespace="http://example.com/testservice"
|
||||
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
||||
xmlns:tns="http://example.com/testservice"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
|
||||
<wsdl:documentation>Test WSDL for Bruno import testing</wsdl:documentation>
|
||||
|
||||
<wsdl:types>
|
||||
<xsd:schema targetNamespace="http://example.com/testservice" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<xsd:element name="GetUserRequest">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="userId" type="xsd:string"/>
|
||||
<xsd:element name="includeDetails" type="xsd:boolean" minOccurs="0"/>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="GetUserResponse">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="user" type="tns:User"/>
|
||||
<xsd:element name="status" type="xsd:string"/>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:complexType name="User">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="id" type="xsd:string"/>
|
||||
<xsd:element name="name" type="xsd:string"/>
|
||||
<xsd:element name="email" type="xsd:string"/>
|
||||
<xsd:element name="active" type="xsd:boolean"/>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:element name="CreateUserRequest">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="name" type="xsd:string"/>
|
||||
<xsd:element name="email" type="xsd:string"/>
|
||||
<xsd:element name="password" type="xsd:string"/>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="CreateUserResponse">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="userId" type="xsd:string"/>
|
||||
<xsd:element name="status" type="xsd:string"/>
|
||||
<xsd:element name="message" type="xsd:string"/>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
</wsdl:types>
|
||||
|
||||
<wsdl:message name="GetUserRequestMessage">
|
||||
<wsdl:part name="parameters" element="tns:GetUserRequest"/>
|
||||
</wsdl:message>
|
||||
|
||||
<wsdl:message name="GetUserResponseMessage">
|
||||
<wsdl:part name="parameters" element="tns:GetUserResponse"/>
|
||||
</wsdl:message>
|
||||
|
||||
<wsdl:message name="CreateUserRequestMessage">
|
||||
<wsdl:part name="parameters" element="tns:CreateUserRequest"/>
|
||||
</wsdl:message>
|
||||
|
||||
<wsdl:message name="CreateUserResponseMessage">
|
||||
<wsdl:part name="parameters" element="tns:CreateUserResponse"/>
|
||||
</wsdl:message>
|
||||
|
||||
<wsdl:portType name="UserServicePortType">
|
||||
<wsdl:documentation>User management service port type</wsdl:documentation>
|
||||
|
||||
<wsdl:operation name="GetUser">
|
||||
<wsdl:documentation>Retrieve user information by ID</wsdl:documentation>
|
||||
<wsdl:input message="tns:GetUserRequestMessage"/>
|
||||
<wsdl:output message="tns:GetUserResponseMessage"/>
|
||||
</wsdl:operation>
|
||||
|
||||
<wsdl:operation name="CreateUser">
|
||||
<wsdl:documentation>Create a new user</wsdl:documentation>
|
||||
<wsdl:input message="tns:CreateUserRequestMessage"/>
|
||||
<wsdl:output message="tns:CreateUserResponseMessage"/>
|
||||
</wsdl:operation>
|
||||
</wsdl:portType>
|
||||
|
||||
<wsdl:binding name="UserServiceBinding" type="tns:UserServicePortType">
|
||||
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
|
||||
|
||||
<wsdl:operation name="GetUser">
|
||||
<soap:operation soapAction="http://example.com/testservice/GetUser"/>
|
||||
<wsdl:input>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:input>
|
||||
<wsdl:output>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
|
||||
<wsdl:operation name="CreateUser">
|
||||
<soap:operation soapAction="http://example.com/testservice/CreateUser"/>
|
||||
<wsdl:input>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:input>
|
||||
<wsdl:output>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
</wsdl:binding>
|
||||
|
||||
<wsdl:service name="UserService">
|
||||
<wsdl:documentation>User management web service</wsdl:documentation>
|
||||
<wsdl:port name="UserServicePort" binding="tns:UserServiceBinding">
|
||||
<soap:address location="http://example.com/soap/userservice"/>
|
||||
</wsdl:port>
|
||||
</wsdl:service>
|
||||
|
||||
</wsdl:definitions>
|
||||
127
tests/import/wsdl/import-wsdl.spec.ts
Normal file
127
tests/import/wsdl/import-wsdl.spec.ts
Normal file
@@ -0,0 +1,127 @@
|
||||
import { test, expect } from '../../../playwright';
|
||||
import * as path from 'path';
|
||||
import { closeAllCollections, openCollectionAndAcceptSandbox } from '../../utils/page/actions';
|
||||
|
||||
test.describe('Import WSDL Collection', () => {
|
||||
const testDataDir = path.join(__dirname, 'fixtures');
|
||||
|
||||
test.afterEach(async ({ page }) => {
|
||||
await closeAllCollections(page);
|
||||
});
|
||||
|
||||
test('Import WSDL XML file as Bruno collection', async ({ page, createTmpDir }) => {
|
||||
const wsdlFile = path.join(testDataDir, 'wsdl.xml');
|
||||
|
||||
await test.step('Open import collection modal', async () => {
|
||||
await page.getByRole('button', { name: 'Import Collection' }).click();
|
||||
|
||||
// Wait for import collection modal to be ready
|
||||
const importModal = page.getByRole('dialog');
|
||||
await importModal.waitFor({ state: 'visible' });
|
||||
});
|
||||
|
||||
await test.step('Choose WSDL XML file', async () => {
|
||||
await page.setInputFiles('input[type="file"]', wsdlFile);
|
||||
|
||||
// Wait for the loader to disappear
|
||||
await page.locator('#import-collection-loader').waitFor({ state: 'hidden' });
|
||||
});
|
||||
|
||||
await test.step('Select the location for the collection and submit to import', async () => {
|
||||
// Verify that the location selection modal is displayed to import the collection
|
||||
const locationModal = page.getByRole('dialog');
|
||||
await expect(locationModal.locator('.bruno-modal-header-title')).toContainText('Import Collection');
|
||||
|
||||
// Wait for collection to appear in the location modal
|
||||
await expect(locationModal.getByText('TestWSDLServiceXML')).toBeVisible();
|
||||
|
||||
// select a location
|
||||
await page.locator('#collection-location').fill(await createTmpDir('wsdl-xml-test'));
|
||||
await page.getByRole('button', { name: 'Import', exact: true }).click();
|
||||
});
|
||||
|
||||
await test.step('Verify that the collection was imported successfully', async () => {
|
||||
// verify the collection was imported successfully
|
||||
await expect(page.locator('#sidebar-collection-name').getByText('TestWSDLServiceXML')).toBeVisible();
|
||||
|
||||
// open the collection and accept the sandbox modal
|
||||
await openCollectionAndAcceptSandbox(page, 'TestWSDLServiceXML', 'safe');
|
||||
|
||||
// verify that all requests were imported correctly
|
||||
await expect(page.locator('#collection-testwsdlservicexml .collection-item-name')).toHaveCount(1);
|
||||
});
|
||||
|
||||
await test.step('Verify that folders and requests were imported correctly', async () => {
|
||||
await expect(page.locator('#collection-testwsdlservicexml .collection-item-name').getByText('UserService')).toBeVisible();
|
||||
// open the user service folder
|
||||
await page.locator('#collection-testwsdlservicexml .collection-item-name').getByText('UserService').click();
|
||||
|
||||
await expect(page.locator('#collection-testwsdlservicexml .collection-item-name').getByText('GetUser')).toBeVisible();
|
||||
await expect(page.locator('#collection-testwsdlservicexml .collection-item-name').getByText('CreateUser')).toBeVisible();
|
||||
});
|
||||
|
||||
await test.step('Verify the GetUser request is imported correctly', async () => {
|
||||
await page.locator('#collection-testwsdlservicexml .collection-item-name').getByText('GetUser').click();
|
||||
await expect(page.locator('.request-tab.active').getByText('GetUser')).toBeVisible();
|
||||
await expect(page.locator('#request-url').getByText('http://example.com/soap/userservice')).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test('Import WSDL JSON file as Bruno collection', async ({ page, createTmpDir }) => {
|
||||
const wsdlFile = path.join(testDataDir, 'wsdl-bruno.json');
|
||||
|
||||
await test.step('Open import collection modal', async () => {
|
||||
await page.getByRole('button', { name: 'Import Collection' }).click();
|
||||
|
||||
// Wait for import collection modal to be ready
|
||||
const importModal = page.getByRole('dialog');
|
||||
await importModal.waitFor({ state: 'visible' });
|
||||
});
|
||||
|
||||
await test.step('Choose WSDL JSON file', async () => {
|
||||
await page.setInputFiles('input[type="file"]', wsdlFile);
|
||||
|
||||
// Wait for the loader to disappear
|
||||
await page.locator('#import-collection-loader').waitFor({ state: 'hidden' });
|
||||
});
|
||||
|
||||
await test.step('Select the location for the collection and submit to import', async () => {
|
||||
// Verify that the location selection modal is displayed to import the collection
|
||||
const locationModal = page.getByRole('dialog');
|
||||
await expect(locationModal.locator('.bruno-modal-header-title')).toContainText('Import Collection');
|
||||
|
||||
// Wait for collection to appear in the location modal
|
||||
await expect(locationModal.getByText('TestWSDLServiceJSON')).toBeVisible();
|
||||
|
||||
// select a location
|
||||
await page.locator('#collection-location').fill(await createTmpDir('wsdl-json-test'));
|
||||
await page.getByRole('button', { name: 'Import', exact: true }).click();
|
||||
});
|
||||
|
||||
await test.step('Verify that the collection was imported successfully', async () => {
|
||||
// verify the collection was imported successfully
|
||||
await expect(page.locator('#sidebar-collection-name').getByText('TestWSDLServiceJSON')).toBeVisible();
|
||||
|
||||
// open the collection and accept the sandbox modal
|
||||
await openCollectionAndAcceptSandbox(page, 'TestWSDLServiceJSON', 'safe');
|
||||
|
||||
// verify that all requests were imported correctly
|
||||
await expect(page.locator('#collection-testwsdlservicejson .collection-item-name')).toHaveCount(1);
|
||||
});
|
||||
|
||||
await test.step('Verify that folders and requests were imported correctly', async () => {
|
||||
await expect(page.locator('#collection-testwsdlservicejson .collection-item-name').getByText('UserService')).toBeVisible();
|
||||
// open the user service folder
|
||||
await page.locator('#collection-testwsdlservicejson .collection-item-name').getByText('UserService').click();
|
||||
|
||||
await expect(page.locator('#collection-testwsdlservicejson .collection-item-name').getByText('GetUser')).toBeVisible();
|
||||
await expect(page.locator('#collection-testwsdlservicejson .collection-item-name').getByText('CreateUser')).toBeVisible();
|
||||
});
|
||||
|
||||
await test.step('Verify the CreateUser request is imported correctly', async () => {
|
||||
await page.locator('#collection-testwsdlservicejson .collection-item-name').getByText('CreateUser').click();
|
||||
await expect(page.locator('.request-tab.active').getByText('CreateUser')).toBeVisible();
|
||||
await expect(page.locator('#request-url').getByText('http://example.com/soap/userservice')).toBeVisible();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user