Skip to content

Commit 87d0765

Browse files
Test downloading config in WebUI (#1545)
1 parent 8e57ed8 commit 87d0765

File tree

7 files changed

+116
-3
lines changed

7 files changed

+116
-3
lines changed

webui/cypress/integration/code-page.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('Code page', () => {
3232
cy.task('tarantool', { code: `cleanup()` });
3333
});
3434

35-
const selectAllKeys = Cypress.platform == 'darwin' ? '{cmd}a' : '{ctrl}a';
35+
const selectAllKeys = Cypress.platform === 'darwin' ? '{cmd}a' : '{ctrl}a';
3636

3737
function reload() {
3838
cy.get('.meta-test__Code__reload_idle').click({ force: true });

webui/cypress/integration/configuration-file-page.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,20 @@ describe('Configuration file page', () => {
5353
cy.get('[data-cy="test_uploadZone"]').contains('Config upload failed: uploading system section ' +
5454
'"topology" is forbidden');
5555
});
56+
57+
it('Test: download config file', () => {
58+
59+
///////////////////////////////////////////////////////////////////
60+
cy.log('Download current conf file');
61+
////////////////////////////////////////////////////////////////////
62+
cy.visit('/admin/cluster/configuration');
63+
cy.get('[data-cy="downloadButton"]').should('have.attr', 'href')
64+
.then(href => {
65+
66+
cy.downloadFile(Cypress.config('baseUrl') + href, 'cypress/downloads', 'config_downloaded.yml');
67+
cy.readFile('cypress/downloads/config_downloaded.yml').should('contain',
68+
'custom_section: []')
69+
})
70+
});
71+
5672
});

webui/cypress/plugins/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
/**
1616
* @type {Cypress.PluginConfig}
1717
*/
18+
const { downloadFile } = require('cypress-downloadfile/lib/addPlugin');
1819
const net = require('net');
1920
const yaml = require('js-yaml');
2021
const cache = {};
@@ -81,6 +82,7 @@ module.exports = (on, config) => {
8182
}
8283

8384
return resp;
84-
}
85+
},
86+
downloadFile
8587
})
8688
}

webui/cypress/support/commands.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@
2626

2727
// https://www.npmjs.com/package/cypress-file-upload
2828
import 'cypress-file-upload';
29+
require('cypress-downloadfile/lib/downloadFileCommand');

webui/package-lock.json

Lines changed: 93 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"case-sensitive-paths-webpack-plugin": "2.4.0",
3434
"chalk": "2.4.2",
3535
"css-loader": "5.2.6",
36+
"cypress-downloadfile": "^1.2.1",
3637
"cypress-file-upload": "^5.0.8",
3738
"dayjs": "^1.10.6",
3839
"dotenv": "10.0.0",

webui/src/pages/ConfigManagement/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const ConfigManagement = ({ isDemoPanelPresent }: ConfigManagementProps) => {
6666
<PageLayout
6767
heading='Configuration Management'
6868
topRightControls={[
69-
<a href={getApiEndpoint('CONFIG_ENDPOINT')}>
69+
<a href={getApiEndpoint('CONFIG_ENDPOINT')} data-cy='downloadButton'>
7070
<Button
7171
className='meta-test__DownloadBtn'
7272
icon={IconDownload}

0 commit comments

Comments
 (0)