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

Cypress. Dummy cloud storages. #3988

Merged
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
// Copyright (C) 2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

/// <reference types="cypress" />

const {
cloudStoragesDummyDataGoogleStorage,
cloudStoragesDummyDataAzureContainer,
cloudStoragesDummyDataAWSBucket,
} = require('../../support/dummy-data');

context('Dummy Cloud storages.', { browser: '!firefox' }, () => {
const caseId = '109';
const imageFolder = '../integration/actions_tasks3/assets/case_109';

function testCreateDummyStorage(dummyCS) {
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
cy.intercept('GET', 'api/v1/cloudstorages?page_size=12&page=1', dummyCS).as('createCS');
cy.contains('.cvat-header-button', 'Cloud Storages').should('be.visible').click();
cy.wait('@createCS').its('response.statusCode').should('eq', 200);
cy.get('.cvat-cloud-storage-item-empty-preview').should('have.length', 1);
}

function testCheckAndCloseNotification() {
// Check and close notifications
cy.get('.cvat-notification-notice-fetch-cloud-storage-status-failed').should('have.length', 1);
cy.closeNotification('.cvat-notification-notice-fetch-cloud-storage-status-failed');
cy.get('.cvat-notification-notice-fetch-cloud-storage-preview-failed').should('have.length', 1);
cy.closeNotification('.cvat-notification-notice-fetch-cloud-storage-preview-failed');
}

function testCSValues({
status, id, description, provider,
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
}) {
cy.get('.cvat-cloud-storage-item').should('have.length', 1);
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
cy.get('.cvat-cloud-storage-item')
.should('contain', `Status: ${status}`);
if (description) {
cy.get('.cvat-cloud-storage-item')
.should('contain', `#${id}: ${description}`);
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
}
if (provider) {
cy.get('.cvat-cloud-storage-item')
.should('contain', `Provider: ${provider}`);
}
if (status !== 'Error') {
cy.get('.cvat-cloud-storage-item-preview').should('exist');
}
}

function testCSSetStatusPreview(id, status, image) {
cy.intercept('GET', `api/v1/cloudstorages/${id}/status`, status).as('csStatus');
cy.intercept(
'GET',
`api/v1/cloudstorages/${id}/preview`,
{ fixture: `${imageFolder}/${image}` },
).as('csPreview');
Comment on lines +60 to +65
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to move these actions into separate commands?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then will have to go to the models page 2 times and back in order for the request to work.


cy.contains('.cvat-header-button', 'Models').should('be.visible').click();
cy.contains('.cvat-header-button', 'Cloud Storages').should('be.visible').click();

cy.wait('@csStatus').its('response.statusCode').should('eq', 200);
cy.wait('@csPreview').its('response.statusCode').should('eq', 200);
}

function testGoToCSUpdatePage() {
cy.get('.cvat-cloud-storage-item-menu-button').trigger('mousemove').trigger('mouseover');
cy.get('.ant-dropdown')
.not('.ant-dropdown-hidden')
.within(() => {
cy.contains('[role="menuitem"]', 'Update').click();
});

cy.get('.cvat-notification-update-info-cloud-storage').should('exist');

cy.get('.cvat-cloud-storage-form').should('be.visible');
}

beforeEach(() => {
cy.visit('auth/login');
cy.login();
});

afterEach(() => {
cy.logout();
});

describe(`Testing case "${caseId}"`, () => {
it('Create dummy Google cloud storage and check fields.', () => {
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
testCreateDummyStorage(cloudStoragesDummyDataGoogleStorage);
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
testCheckAndCloseNotification();
testCSValues({
status: 'Error', id: 3, description: 'Demo GCS', provider: 'GOOGLE_CLOUD_STORAGE',
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
});
testCSSetStatusPreview(3, 'NOT_FOUND', 'preview_GOOGLE_CLOUD_STORAGE.png');
testCSValues({
status: 'NOT_FOUND',
});
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
testGoToCSUpdatePage();

Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
cy.get('#display_name')
.should('be.visible')
.and('have.value', 'Demo GCS');
cy.get('#description')
.should('be.visible')
.and('have.value', 'It is first google cloud storage');
cy.get('.cvat-cloud-storage-select-provider')
.should('be.visible')
.and('have.text', 'Google Cloud Storage');
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
cy.get('[title="Key file"]').should('be.visible');
cy.get('#key_file').should('be.visible');
cy.get('[title="fakeKey.json"]').should('be.visible');
cy.get('#key_file').should('be.visible');
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
cy.get('#prefix')
.should('be.visible')
.and('have.value', '');
cy.get('#project_id')
.should('be.visible')
.and('have.value', '');
cy.get('#location').should('exist');
cy.get('[placeholder="manifest.jsonl"]')
.should('have.attr', 'value', 'manifest.jsonl');
});

it('Create dummy Azure Blob Container and check fields.', () => {
testCreateDummyStorage(cloudStoragesDummyDataAzureContainer);
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
testCheckAndCloseNotification();
testCSValues({
status: 'Error', id: 2, description: 'Demonstration container', provider: 'AZURE_CONTAINER',
});
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
testCSSetStatusPreview(2, 'AVAILABLE', 'preview_AZURE_CONTAINER.png');
testCSValues({
status: 'AVAILABLE',
});
testGoToCSUpdatePage();

cy.get('#display_name')
.should('be.visible')
.and('have.value', 'Demonstration container');
cy.get('#description')
.should('be.visible')
.and('have.value', 'It is first container');
cy.get('.cvat-cloud-storage-select-provider')
.should('be.visible')
.and('have.text', 'Azure Blob Container');
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
cy.get('#resource')
.should('be.visible')
.and('have.attr', 'value', 'container');
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
cy.get('[title="Account name and SAS token"]').should('be.visible');
cy.get('#account_name')
.should('be.visible')
.and('not.have.value', '');
cy.get('#SAS_token')
.should('be.visible')
.and('not.have.value', '');
cy.get('[placeholder="manifest.jsonl"]')
.should('have.attr', 'value', 'manifest.jsonl');
});

it('Create dummy AWS S3 and check fields.', () => {
testCreateDummyStorage(cloudStoragesDummyDataAWSBucket);
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
testCheckAndCloseNotification();
testCSValues({
status: 'Error', id: 1, description: 'Demonstration bucket', provider: 'AWS_S3_BUCKET',
});
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
testCSSetStatusPreview(1, 'FORBIDDEN', 'preview_AWS_S3_BUCKET.png');
testCSValues({
status: 'FORBIDDEN',
});
testGoToCSUpdatePage();

cy.get('#display_name')
.should('be.visible')
.and('have.value', 'Demonstration bucket');
cy.get('#description')
.should('be.visible')
.and('have.value', 'It is first bucket');
cy.get('.cvat-cloud-storage-select-provider')
.should('be.visible')
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
.and('have.text', 'AWS S3');
cy.get('#resource')
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
.should('be.visible')
.and('have.attr', 'value', 'bucket');
cy.get('[title="Key id and secret access key pair"]').should('be.visible');
cy.get('#key')
.should('be.visible')
.and('not.have.value', '');
cy.get('#secret_key')
.should('be.visible')
.and('not.have.value', '');
cy.get('#region').should('exist');
cy.get('[placeholder="manifest.jsonl"]')
.should('have.attr', 'value', 'manifest.jsonl');
});
});
});
96 changes: 96 additions & 0 deletions tests/cypress/support/dummy-data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright (C) 2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

const cloudStoragesDummyDataGoogleStorage = {
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
count: 1,
next: null,
previous: null,
results: [
{
id: 3,
owner: {
url: 'http://localhost:7000/api/v1/users/1',
id: 1,
username: 'maya',
first_name: '',
last_name: '',
},
manifests: [
'manifest.jsonl',
],
provider_type: 'GOOGLE_CLOUD_STORAGE',
resource: 'gcsbucket',
display_name: 'Demo GCS',
created_date: '2021-09-01T09:29:47.094244Z',
updated_date: '2021-09-01T09:29:47.103264Z',
credentials_type: 'KEY_FILE_PATH',
specific_attributes: '',
description: 'It is first google cloud storage',
},
],
};

const cloudStoragesDummyDataAzureContainer = {
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
count: 1,
next: null,
previous: null,
results: [
{
id: 2,
owner: {
url: 'http://localhost:7000/api/v1/users/1',
id: 1,
username: 'maya',
first_name: '',
last_name: '',
},
manifests: [
'manifest.jsonl',
],
provider_type: 'AZURE_CONTAINER',
resource: 'container',
display_name: 'Demonstration container',
created_date: '2021-09-01T09:29:47.094244Z',
updated_date: '2021-09-01T09:29:47.103264Z',
credentials_type: 'ACCOUNT_NAME_TOKEN_PAIR',
specific_attributes: '',
description: 'It is first container',
},
],
};

const cloudStoragesDummyDataAWSBucket = {
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
count: 1,
next: null,
previous: null,
results: [
{
id: 1,
owner: {
url: 'http://localhost:7000/api/v1/users/1',
id: 1,
username: 'maya',
first_name: '',
last_name: '',
},
manifests: [
'manifest.jsonl',
],
provider_type: 'AWS_S3_BUCKET',
resource: 'bucket',
display_name: 'Demonstration bucket',
created_date: '2021-08-31T09:03:09.350817Z',
updated_date: '2021-08-31T15:16:21.394773Z',
credentials_type: 'KEY_SECRET_KEY_PAIR',
specific_attributes: '',
description: 'It is first bucket',
},
],
};

module.exports = {
cloudStoragesDummyDataGoogleStorage,
cloudStoragesDummyDataAzureContainer,
cloudStoragesDummyDataAWSBucket,
Marishka17 marked this conversation as resolved.
Show resolved Hide resolved
};