Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add page reload judgment #2370

Merged
merged 14 commits into from
May 6, 2022
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

context('Table Auto Jump When No Data', () => {
const selector = {
username: '#username',
page_item: '.ant-pagination-item-2',
deleteAlert: '.ant-modal-body',
notificationCloseIcon: '.ant-notification-close-icon',
notification: '.ant-notification-notice-message',
table_row: '.ant-table-row',
pluginCard: '.ant-card',
drawer: '.ant-drawer-content',
monacoScroll: '.monaco-scrollable-element',
monacoViewZones: '.view-zones',
disabledSwitcher: '#disable',
popoper: '.ant-popover',
popoprerHiden: '.ant-popover-hidden',
};

const data = {
consumerName: 'test_consumer',
createConsumerSuccess: 'Create Consumer Successfully',
deleteConsumerSuccess: 'Delete Consumer Successfully',
};

before(() => {
cy.login();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cy.login();
cy.login().then( () => { cy.requestWithToken({ method: 'PUT', payload, url: '/apisix/admin/consumers' });
});

Array.from({ length: 11 }).forEach((value, key) => {
const payload = {
username: data.consumerName + key,
plugins: {
'key-auth': {
key: 'test',
disable: false,
},
},
};
cy.requestWithToken({ method: 'PUT', payload, url: '/apisix/admin/consumers' });
});
});

it('should delete last data and jump to first page', () => {
cy.visit('/');
cy.contains('Consumer').click();
cy.get(selector.page_item).click();
cy.wait(1000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wait for 1 s?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oil-oil ping

cy.contains('Delete').click();
cy.get(selector.popoper)
.not(selector.popoprerHiden)
.contains('Confirm')
.should('be.visible')
.click();
cy.get(selector.notification).should('contain', data.deleteConsumerSuccess);
cy.get(selector.notificationCloseIcon).click();
cy.url().should('contains', '/consumer/list?page=1&pageSize=10');
cy.get(selector.table_row).should((consumer) => {
expect(consumer).to.have.length(10);
});
cy.get(`.ant-table-cell:contains(${data.consumerName})`).each((elem) => {
cy.requestWithToken({
method: 'DELETE',
url: `/apisix/admin/consumers/${elem.text()}`,
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable no-undef */

context('Create and Delete Proto', () => {
const selector = {
Expand All @@ -41,7 +40,7 @@ optional string email = 3;
}`,
createProtoSuccess: 'Create proto Successfully',
configureProtoSuccess: 'Configure proto Successfully',
deleteProtoSuccess: 'Delete Upstream Successfully',
deleteProtoSuccess: 'Delete proto Successfully',
};

beforeEach(() => {
Expand Down
67 changes: 67 additions & 0 deletions web/cypress/integration/proto/table-auto-jump-when-no-data.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

context('Batch Create Proto And Delete Proto', () => {
const selector = {
id: '#id',
content: '.view-lines',
page_item: '.ant-pagination-item-2',
draw: '.ant-drawer-content',
deleteAlert: '.ant-modal-body',
notificationCloseIcon: '.ant-notification-close-icon',
notification: '.ant-notification-notice-message',
table_row: '.ant-table-row',
};

const data = {
createProtoSuccess: 'Create proto Successfully',
deleteProtoSuccess: 'Delete proto Successfully',
};

before(() => {
cy.login();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Array.from({ length: 11 }).forEach(async (value, key) => {
const payload = {
content: 'test',
desc: '',
id: `protoId${key}`,
};
cy.requestWithToken({ method: 'POST', payload, url: '/apisix/admin/proto' });
});
});

it('should delete last data and jump to first page', () => {
cy.visit('/');
cy.contains('Protocol Buffers').click();
cy.get(selector.page_item).click();
cy.wait(1000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

cy.contains('Delete').click();
cy.contains('button', 'Confirm').click();
cy.get(selector.notification).should('contain', data.deleteProtoSuccess);
cy.get(selector.notificationCloseIcon).click();
cy.url().should('contains', '/proto/list?page=1&pageSize=10');
cy.get(selector.table_row).should((proto) => {
expect(proto).to.have.length(10);
});
cy.get('.ant-table-cell:contains(protoId)').each((elem) => {
cy.requestWithToken({
method: 'DELETE',
url: `/apisix/admin/proto/${elem.text()}`,
});
});
});
});
93 changes: 93 additions & 0 deletions web/cypress/integration/route/table-auto-jump-when-no-data.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

context('Table Auto Jump When No Data', () => {
const selector = {
name: '#name',
nodes_0_host: '#submitNodes_0_host',
page_item: '.ant-pagination-item-2',
deleteAlert: '.ant-modal-body',
notificationCloseIcon: '.ant-notification-close-icon',
notification: '.ant-notification-notice-message',
table_row: '.ant-table-row',
};

const data = {
submitSuccess: 'Submit Successfully',
deleteRouteSuccess: 'Delete Route Successfully',
};

before(() => {
cy.login();
Array.from({ length: 11 }).forEach((value, key) => {
const payload = {
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS', 'CONNECT', 'TRACE'],
priority: 0,
name: `routeName${key}`,
desc: '',
status: 1,
labels: {},
uri: '/*',
upstream: {
type: 'roundrobin',
pass_host: 'pass',
scheme: 'http',
timeout: {
connect: 6,
send: 6,
read: 6,
},
keepalive_pool: {
size: 320,
idle_timeout: 60,
requests: 1000,
},
nodes: {
'127.0.0.1': 1,
},
},
};
cy.requestWithToken({ method: 'POST', payload, url: '/apisix/admin/routes' });
});
});

it('should delete last data and jump to first page', () => {
cy.visit('/');
cy.contains('Route').click();
cy.get(selector.page_item).click();
cy.wait(1000);
cy.contains('routeName').siblings().contains('More').click();
cy.contains('Delete').click();
cy.get(selector.deleteAlert)
.should('be.visible')
.within(() => {
cy.contains('OK').click();
});
cy.get(selector.notification).should('contain', data.deleteRouteSuccess);
cy.get(selector.notificationCloseIcon).click();
cy.url().should('contains', '/routes/list?page=1&pageSize=10');
cy.get(selector.table_row).should((route) => {
expect(route).to.have.length(10);
});
cy.get('.ant-table-cell:contains(routeName)').each((elem) => {
cy.requestWithToken({
method: 'DELETE',
url: `/apisix/admin/routes/${elem.next().text()}`,
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable no-undef */

context('Table Auto Jump When No Data', () => {
const selector = {
name: '#name',
nodes_0_host: '#submitNodes_0_host',
page_item: '.ant-pagination-item-2',
deleteAlert: '.ant-modal-body',
notificationCloseIcon: '.ant-notification-close-icon',
notification: '.ant-notification-notice-message',
table_row: '.ant-table-row',
};

const data = {
createServiceSuccess: 'Create Service Successfully',
deleteServiceSuccess: 'Delete Service Successfully',
};

beforeEach(() => {
cy.login();
Array.from({ length: 11 }).forEach((value, key) => {
const payload = {
name: `serviceName${key}`,
plugins: {},
upstream: {
type: 'roundrobin',
pass_host: 'pass',
scheme: 'http',
timeout: {
connect: 6,
send: 6,
read: 6,
},
keepalive_pool: {
size: 320,
idle_timeout: 60,
requests: 1000,
},
nodes: {
'127.0.0.1': 1,
},
},
};
cy.requestWithToken({ method: 'POST', payload, url: '/apisix/admin/services' });
});
});

it('should delete last data and jump to first page', () => {
cy.visit('/');
cy.contains('Service').click();
cy.get(selector.page_item).click();
cy.wait(1000);
cy.contains('serviceName').siblings().contains('Delete').click();
cy.contains('button', 'Confirm').click();
cy.get(selector.notification).should('contain', data.deleteServiceSuccess);
cy.get(selector.notificationCloseIcon).click();
cy.url().should('contains', '/service/list?page=1&pageSize=10');
cy.get(selector.table_row).should((service) => {
expect(service).to.have.length(10);
});
cy.get('.ant-table-cell:contains(serviceName)').each((elem) => {
cy.requestWithToken({
method: 'DELETE',
url: `/apisix/admin/services/${elem.prev().text()}`,
});
});
});
});
Loading