Skip to content

Commit

Permalink
Merge branch 'main' into odigos-to-run-concurrently-with-otheragents-…
Browse files Browse the repository at this point in the history
…as-config
  • Loading branch information
tamirdavid1 authored Dec 9, 2024
2 parents d55ca19 + 4755276 commit 6ba69ac
Showing 1 changed file with 107 additions and 0 deletions.
107 changes: 107 additions & 0 deletions frontend/webapp/cypress/e2e/04-destinations.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import { ROUTES } from '../../utils/constants/routes';

// The number of CRDs that exist in the cluster before running any tests should be 0.
// Tests will fail if you have existing CRDs in the cluster.
// If you have to run tests locally, make sure to clean up the cluster before running the tests.

describe('Destinations CRUD', () => {
const namespace = 'odigos-system';
const crdName = 'destinations.odigos.io';
const noResourcesFound = `No resources found in ${namespace} namespace.`;

beforeEach(() => {
cy.intercept('/graphql').as('gql');
});

it('Should create a CRD in the cluster', () => {
cy.visit(ROUTES.OVERVIEW);

cy.exec(`kubectl get ${crdName} -n ${namespace} | awk 'NR>1 {print $1}'`).then((crdListBefore) => {
expect(crdListBefore.stderr).to.eq(noResourcesFound);
expect(crdListBefore.stdout).to.eq('');

const crdIdsBefore = crdListBefore.stdout.split('\n').filter((str) => !!str);
expect(crdIdsBefore.length).to.eq(0);

cy.get('[data-id=add-entity]').click();
cy.get('[data-id=add-destination]').click();
cy.get('[data-id=modal-Add-Destination]').should('exist');

cy.wait('@gql').then(() => {
cy.get('[data-id=destination-jaeger]').contains('Jaeger').click();
expect('[data-id=JAEGER_URL]').to.not.be.empty;
cy.get('button').contains('DONE').click();

cy.wait('@gql').then(() => {
cy.exec(`kubectl get ${crdName} -n ${namespace} | awk 'NR>1 {print $1}'`).then((crdListAfter) => {
expect(crdListAfter.stderr).to.eq('');
expect(crdListAfter.stdout).to.not.be.empty;

const crdIdsAfter = crdListAfter.stdout.split('\n').filter((str) => !!str);
expect(crdIdsAfter.length).to.eq(1);
});
});
});
});
});

it('Should update the CRD in the cluster', () => {
cy.visit(ROUTES.OVERVIEW);

const node = cy.contains('[data-id=destination-0]', 'Jaeger');
expect(node).to.exist;
node.click();

cy.get('[data-id=drawer]').should('exist');
cy.get('button[data-id=drawer-edit]').click();
cy.get('input[data-id=title]').clear().type('Cypress Test');
cy.get('button[data-id=drawer-save]').click();
cy.get('button[data-id=drawer-close]').click();

cy.wait('@gql').then(() => {
cy.exec(`kubectl get ${crdName} -n ${namespace} | awk 'NR>1 {print $1}'`).then((crdList) => {
expect(crdList.stderr).to.eq('');
expect(crdList.stdout).to.not.be.empty;

const crdIds = crdList.stdout.split('\n').filter((str) => !!str);
expect(crdIds.length).to.eq(1);

cy.exec(`kubectl get ${crdName} ${crdIds[0]} -n ${namespace} -o json`).then((crd) => {
expect(crd.stderr).to.eq('');
expect(crd.stdout).to.not.be.empty;

const parsed = JSON.parse(crd.stdout);
const { spec } = parsed?.items?.[0] || parsed || {};

expect(spec).to.not.be.empty;
expect(spec.destinationName).to.eq('Cypress Test');
});
});
});
});

it('Should delete the CRD from the cluster', () => {
cy.visit(ROUTES.OVERVIEW);

const node = cy.contains('[data-id=destination-0]', 'Jaeger');
expect(node).to.exist;
node.click();

cy.get('[data-id=drawer]').should('exist');
cy.get('button[data-id=drawer-edit]').click();
cy.get('button[data-id=drawer-delete]').click();
cy.get('[data-id=modal]').contains('Delete destination').should('exist');
cy.get('[data-id=modal]').contains("You're about to delete the last destination").should('exist');
cy.get('button[data-id=approve]').click();

cy.wait('@gql').then(() => {
cy.exec(`kubectl get ${crdName} -n ${namespace} | awk 'NR>1 {print $1}'`).then((crdList) => {
expect(crdList.stderr).to.eq(noResourcesFound);
expect(crdList.stdout).to.eq('');

const crdIds = crdList.stdout.split('\n').filter((str) => !!str);
expect(crdIds.length).to.eq(0);
});
});
});
});

0 comments on commit 6ba69ac

Please sign in to comment.