test: Update image e2e case

1. Add cypress download file
2. Create image by downloaded file

Change-Id: Id14ac0e360197f6cb52d39527dec977206f411f5
This commit is contained in:
Jingwei.Zhang 2021-09-28 17:55:57 +08:00
parent e43612a39a
commit 505e31418e
5 changed files with 45 additions and 2 deletions

View File

@ -109,6 +109,7 @@
"cross-env": "^7.0.3",
"css-loader": "^0.28.11",
"cypress": "6.8.0",
"cypress-downloadfile": "^1.2.1",
"cypress-file-upload": "^5.0.6",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",

View File

@ -24,13 +24,18 @@ describe('The Image Page', () => {
const name = `e2e-image-${uuid}`;
const sharedImage = `e2e-image-shared-${uuid}`;
const newname = `${name}-1`;
const filename = 'cirros-0.4.0-x86_64-disk.qcow2';
const filename = `cirros-disk-${uuid}.qcow2`;
const volumeName = `e2e-volume-by-image-${uuid}`;
const downloadUrl = Cypress.env('imageDownloadUrl');
beforeEach(() => {
cy.login(listUrl);
});
it('successfully download image', () => {
cy.downloadFile(downloadUrl, 'test/e2e/fixtures', filename);
});
it('successfully list', () => {
cy.clickTab('Public Image', 'public').clickTab('Shared Image', 'shared');
});
@ -133,6 +138,9 @@ describe('The Image Page', () => {
it('successfully delete', () => {
cy.tableSearchText(newname).clickConfirmActionInMore('Delete');
cy.tableSearchText(sharedImage).clickConfirmActionInMore('Delete');
cy.loginAdmin()
.visitPage(imageListUrlAdmin)
.tableSearchText(sharedImage)
.clickConfirmActionInMore('Delete');
});
});

View File

@ -13,6 +13,7 @@
// limitations under the License.
// / <reference types="cypress" />
const { downloadFile } = require('cypress-downloadfile/lib/addPlugin');
const { getConfig } = require('../utils');
/**
@ -36,6 +37,7 @@ module.exports = (on, config) => {
...env,
};
on('task', { downloadFile });
// eslint-disable-next-line global-require
require('@cypress/code-coverage/task')(on, config);
// eslint-disable-next-line global-require

View File

@ -34,6 +34,9 @@ import './table-commands';
import './detail-commands';
import './commands';
import './resource-commands';
import 'cypress-file-upload';
require('cypress-downloadfile/lib/downloadFileCommand');
Cypress.Cookies.defaults({
preserve: ['session', 'X-Auth-Token'],

View File

@ -4431,6 +4431,13 @@ cross-env@^7.0.3:
dependencies:
cross-spawn "^7.0.1"
cross-fetch@^3.1.4:
version "3.1.4"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.4.tgz#9723f3a3a247bf8b89039f3a380a9244e8fa2f39"
integrity sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==
dependencies:
node-fetch "2.6.1"
cross-spawn@^6.0.0, cross-spawn@^6.0.5:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
@ -4624,6 +4631,14 @@ cyclist@^1.0.1:
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk=
cypress-downloadfile@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/cypress-downloadfile/-/cypress-downloadfile-1.2.1.tgz#5dfa66bca323eb7c1df9c04d99ec0d92104e6679"
integrity sha512-6JXnlI3AMVntapsg5U8yfaKUDkpXUtpuE7GMIEKD/q/QsKvFbRW9elmMEn4xsfZODos1NDAlI7z5bmj52UI47w==
dependencies:
cross-fetch "^3.1.4"
fs-extra "^10.0.0"
cypress-file-upload@^5.0.6:
version "5.0.7"
resolved "https://registry.yarnpkg.com/cypress-file-upload/-/cypress-file-upload-5.0.7.tgz#acf24fe08a92b2d0c892a58b56811fb933d34ea9"
@ -6460,6 +6475,15 @@ fs-extra@9.0.0:
jsonfile "^6.0.1"
universalify "^1.0.0"
fs-extra@^10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.0.0.tgz#9ff61b655dde53fb34a82df84bb214ce802e17c1"
integrity sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==
dependencies:
graceful-fs "^4.2.0"
jsonfile "^6.0.1"
universalify "^2.0.0"
fs-extra@^7.0.0, fs-extra@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
@ -9895,6 +9919,11 @@ no-case@^2.2.0:
dependencies:
lower-case "^1.1.1"
node-fetch@2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
node-forge@^0.10.0:
version "0.10.0"
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.10.0.tgz#32dea2afb3e9926f02ee5ce8794902691a676bf3"