Skip to content

Commit

Permalink
test: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
guoqqqi committed Jun 10, 2022
1 parent 654751e commit 3bf98f2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions web/cypress/fixtures/plugin-dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
"shouldValid": true,
"data": {
"break_response_code": 502,
"break_response_body": "{\"message\":\"breaker opened.\"}",
"break_response_headers": [
{ "key": "Content-Type", "value": "application/json" },
{ "key": "Content-Type", "value": "application/json+v1" }
],
"unhealthy": {
"http_statuses": [500],
"failures": 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
context('Create and delete consumer with api-breaker plugin form', () => {
const selector = {
break_response_code: '#break_response_code',
break_response_body: '#break_response_body',
break_response_headers_0_key: '#break_response_headers_0_key',
break_response_headers_0_value: '#break_response_headers_0_value',
empty: '.ant-empty-normal',
username: '#username',
description: '#desc',
Expand All @@ -31,6 +34,9 @@ context('Create and delete consumer with api-breaker plugin form', () => {

const data = {
break_response_code: 200,
break_response_body: 'breaker opened',
break_response_headers_0_key: 'Content-Type',
break_response_headers_0_value: 'application/json',
consumerName: 'test_consumer',
description: 'desc_by_autotest',
createConsumerSuccess: 'Create Consumer Successfully',
Expand Down Expand Up @@ -82,8 +88,13 @@ context('Create and delete consumer with api-breaker plugin form', () => {
});
});
cy.get(selector.notification).should('contain', 'Invalid plugin data');

cy.contains('.ant-form-item', 'break_response_headers').within(() => {
cy.contains('button', 'Create').click();
});
cy.get(selector.break_response_code).type(data.break_response_code);
cy.get(selector.break_response_body).type(data.break_response_body);
cy.get(selector.break_response_headers_0_key).type(data.break_response_headers_0_key);
cy.get(selector.break_response_headers_0_value).type(data.break_response_headers_0_value);
cy.get(selector.disabledSwitcher).click();
cy.get(selector.drawer).within(() => {
cy.contains('Submit').click({
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/Plugin/UI/api-breaker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const FORM_ITEM_LAYOUT = {
span: 7,
},
wrapperCol: {
span: 7,
span: 12,
},
};

Expand Down Expand Up @@ -136,7 +136,7 @@ const ApiBreaker: React.FC<Props> = ({ form, schema }) => {
add();
}}
>
<PlusOutlined /> {formatMessage({ id: 'component.global.add' })}
<PlusOutlined /> {formatMessage({ id: 'component.global.create' })}
</Button>
</Form.Item>
</div>
Expand Down

0 comments on commit 3bf98f2

Please sign in to comment.