Skip to content

Commit

Permalink
support service spec
Browse files Browse the repository at this point in the history
  • Loading branch information
chirag-madlani committed Dec 19, 2023
1 parent eb1242c commit 879c6c9
Show file tree
Hide file tree
Showing 14 changed files with 701 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const restoreEntity = () => {
// cy.get(`[data-testid="entity-header-display-name"]`)
// .contains(entityName)
// .click();
cy.reload();
cy.get('[data-testid="deleted-badge"]').should('be.visible');
cy.get('[data-testid="manage-button"]').click();
cy.get('[data-testid="restore-button"]').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,17 @@ export const visitServiceDetailsPage = (service, verifyHeader = true) => {
// Services page
interceptURL('GET', '/api/v1/services/*', 'getServices');

cy.get('.ant-menu-title-content')
.contains(service.type)
.should('be.visible')
.click();
cy.get('.ant-menu-title-content').contains(service.type).click();

cy.wait('@getServices');

searchServiceFromSettingPage(service.name);

// click on created service
cy.get(`[data-testid="service-name-${service.name}"]`)
.should('exist')
.should('be.visible')
.click();
cy.get(`[data-testid="service-name-${service.name}"]`).click();

if (verifyHeader) {
cy.get(`[data-testid="entity-header-display-name"]`)
.should('exist')
.should('be.visible')
.invoke('text')
.then((text) => {
expect(text).to.equal(service.displayName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const entities = [
new TopicClass(),
new MlModelClass(),
new ContainerClass(),
// TODO: add tests for metadata service tests
// new MetadataServiceClass(),
];
const domainDetails1 = {
name: `cypress-domain-${uuid()}`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/*
* Copyright 2023 Collate.
* Licensed 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.
*/

import { uuid } from '../common/common';
import {
createEntityViaREST,
deleteEntityViaREST,
} from '../common/Utils/Entity';
import DashboardServiceClass from './base/DashboardServiceClass';
import DatabaseServiceClass from './base/DatabaseServiceClass';
import { EntityType } from './base/EntityClass';
import MessagingServiceClass from './base/MessagingServiceClass';
import MlModelServiceClass from './base/MlModelServiceClass';
import PipelineServiceClass from './base/PipelineServiceClass';
import SearchServiceClass from './base/SearchServiceClass';
import StorageServiceClass from './base/StorageServiceClass';

const entities = [
new DatabaseServiceClass(),
new MessagingServiceClass(),
new DashboardServiceClass(),
new PipelineServiceClass(),
new MlModelServiceClass(),
new StorageServiceClass(),
new SearchServiceClass(),
// TODO: add tests for metadata service tests
// new MetadataServiceClass(),
];
const domainDetails1 = {
name: `cypress-domain-${uuid()}`,
displayName: 'Cypress Domain',
description: 'Cypress domain description',
domainType: 'Aggregate',
experts: [],
style: {},
};

const domainDetails2 = {
name: `cypress-domain-${uuid()}`,
displayName: 'Cypress Domain 2',
description: 'Cypress domain description',
domainType: 'Aggregate',
experts: [],
style: {},
};

const OWNER1 = 'Aaron Johnson';
const OWNER2 = 'Cynthia Meyer';

const TEAM_OWNER_1 = 'Marketplace';
const TEAM_OWNER_2 = 'DevOps';

entities.forEach((entity) => {
describe(`${entity.name} page`, () => {
before(() => {
cy.login();
entity.createEntity();

// Create domain
cy.getAllLocalStorage().then((data) => {
const token = Object.values(data)[0].oidcIdToken;

createEntityViaREST({
token,
body: domainDetails1,
endPoint: EntityType.Domain,
});

createEntityViaREST({
token,
body: domainDetails2,
endPoint: EntityType.Domain,
});
});
});

after(() => {
cy.login();

// Delete domain
cy.getAllLocalStorage().then((data) => {
const token = Object.values(data)[0].oidcIdToken;

// Domain 1 to test
deleteEntityViaREST({
token,
entityName: domainDetails1.name,
endPoint: EntityType.Domain,
});

// Domain 2 to test
deleteEntityViaREST({
token,
entityName: domainDetails2.name,
endPoint: EntityType.Domain,
});
});
});

beforeEach(() => {
cy.login();
entity.visitEntity();
});

it(`Assign domain`, () => {
entity.assignDomain(domainDetails1.displayName);
});

it(`Update domain`, () => {
entity.updateDomain(domainDetails2.displayName);
});

it(`Remove domain`, () => {
entity.removeDomain(domainDetails2.displayName);
});

it(`Assign user Owner`, () => {
entity.assignOwner(OWNER1);
});

it(`Update user Owner`, () => {
entity.updateOwner(OWNER2);
});

it(`Remove user Owner`, () => {
entity.removeOwner(OWNER2);
});

it(`Assign team as Owner`, () => {
entity.assignTeamOwner(TEAM_OWNER_1);
});

it(`Update team as Owner`, () => {
entity.updateTeamOwner(TEAM_OWNER_2);
});

it(`Remove team as Owner`, () => {
entity.removeTeamOwner(TEAM_OWNER_2);
});

it(`Assign tier`, () => {
entity.assignTier('Tier1');
});

it(`Update tier`, () => {
entity.updateTier('Tier5');
});

it(`Remove tier`, () => {
entity.removeTier();
});

it(`Update description`, () => {
entity.updateDescription();
});

it(`Assign tags`, () => {
entity.assignTags();
});

it(`Update Tags`, () => {
entity.updateTags();
});

it(`Remove Tags`, () => {
entity.removeTags();
});

it(`Assign GlossaryTerm`, () => {
entity.assignGlossary();
});

it(`Update GlossaryTerm`, () => {
entity.updateGlossary();
});

it(`Remove GlossaryTerm`, () => {
entity.removeGlossary();
});

it(`Update displayName`, () => {
entity.renameEntity();
});

it(`Create annoucement`, () => {
entity.createAnnouncement();
});

it(`Remove annoucement`, () => {
entity.removeAnnouncement();
});

it(`Create inactive annoucement`, () => {
entity.createInactiveAnnouncement();
});

it(`Remove inactive annoucement`, () => {
entity.removeInactiveAnnouncement();
});

it(`Soft delete`, () => {
entity.softDeleteEntity();
entity.restoreEntity();
});

it(`Hard delete`, () => {
entity.hardDeleteEntity();
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2023 Collate.
* Licensed 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.
*/

import { createSingleLevelEntity } from '../../common/EntityUtils';
import { visitServiceDetailsPage } from '../../common/serviceUtils';
import { SERVICE_TYPE } from '../../constants/constants';
import { DASHBOARD_SERVICE } from '../../constants/EntityConstant';
import EntityClass, { EntityType } from './EntityClass';

class DashboardServiceClass extends EntityClass {
dashboardName: string;

constructor() {
const dashboardName = `cypress-dashboard-service-${Date.now()}`;
super(dashboardName, DASHBOARD_SERVICE.entity, EntityType.DashboardService);

this.dashboardName = dashboardName;
this.name = 'Dashboard Service';
}

visitEntity() {
visitServiceDetailsPage(
{
name: this.dashboardName,
type: SERVICE_TYPE.Dashboard,
},
false
);
}

// Creation

createEntity() {
// Handle creation here

cy.getAllLocalStorage().then((data) => {
const token = Object.values(data)[0].oidcIdToken as string;

createSingleLevelEntity({
...DASHBOARD_SERVICE,
service: { ...DASHBOARD_SERVICE.service, name: this.dashboardName },
entity: {
...DASHBOARD_SERVICE.entity,
service: this.dashboardName,
},
token,
});
});
}
}

export default DashboardServiceClass;
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2023 Collate.
* Licensed 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.
*/

import { createEntityTable } from '../../common/EntityUtils';
import { visitServiceDetailsPage } from '../../common/serviceUtils';
import { SERVICE_TYPE } from '../../constants/constants';
import { DATABASE_SERVICE } from '../../constants/EntityConstant';
import EntityClass, { EntityType } from './EntityClass';

class DatabaseServiceClass extends EntityClass {
databaseName: string;

constructor() {
const databaseName = `cypress-database-service-${Date.now()}`;
super(databaseName, DATABASE_SERVICE.entity, EntityType.DatabaseService);

this.databaseName = databaseName;
this.name = 'Database Service';
}

visitEntity() {
visitServiceDetailsPage(
{
name: this.databaseName,
type: SERVICE_TYPE.Database,
},
false
);
}

// Creation

createEntity() {
// Handle creation here

cy.getAllLocalStorage().then((data) => {
const token = Object.values(data)[0].oidcIdToken as string;

createEntityTable({
...DATABASE_SERVICE,
service: { ...DATABASE_SERVICE.service, name: this.databaseName },
database: { ...DATABASE_SERVICE.database, service: this.databaseName },
schema: {
...DATABASE_SERVICE.schema,
database: `${this.databaseName}.${DATABASE_SERVICE.database.name}`,
},
tables: [
{
...DATABASE_SERVICE.entity,
databaseSchema: `${this.databaseName}.${DATABASE_SERVICE.database.name}.${DATABASE_SERVICE.schema.name}`,
},
],
token,
});
});
}
}

export default DatabaseServiceClass;
Loading

0 comments on commit 879c6c9

Please sign in to comment.