Skip to content

Commit

Permalink
Update some cypress tests to account for the removal of /api/clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
jshaughn committed May 6, 2024
1 parent 9e4bd6e commit 96ba4c8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
31 changes: 21 additions & 10 deletions frontend/cypress/integration/common/sidecar_injection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Given, Then, When } from '@badeball/cypress-cucumber-preprocessor';
import { ensureKialiFinishedLoading } from './transition';
import { MeshCluster } from '../../../src/types/Mesh';

// Most of these "Given" implementations are directly using the Kiali API
// in order to reach a well known state in the environment before performing
Expand Down Expand Up @@ -247,11 +248,13 @@ When('I override the default automatic sidecar injection policy in the namespace
cy.request('GET', '/api/status').then(response => {
expect(response.status).to.equal(200);

cy.request('/api/clusters').then(response => {
cy.request('/api/config').then(response => {
cy.wrap(response.isOkStatusCode).should('be.true');
cy.wrap(response.body).should('have.length', 1);

const cluster = response.body[0].name;
const clusters: { [key: string]: MeshCluster } = response.body.clusters;
const clusterName = Object.keys(clusters)[0];
const cluster = clusters[clusterName];

cy.getBySel('overview-type-LIST').should('be.visible').click();

Expand All @@ -273,11 +276,13 @@ When(
cy.request('GET', '/api/status').then(response => {
expect(response.status).to.equal(200);

cy.request('/api/clusters').then(response => {
cy.request('/api/config').then(response => {
cy.wrap(response.isOkStatusCode).should('be.true');
cy.wrap(response.body).should('have.length', 1);

const cluster = response.body[0].name;
const clusters: { [key: string]: MeshCluster } = response.body.clusters;
const clusterName = Object.keys(clusters)[0];
const cluster = clusters[clusterName];

cy.getBySel('overview-type-LIST').should('be.visible').click();

Expand All @@ -300,11 +305,13 @@ When('I remove override configuration for sidecar injection in the namespace', f
cy.request('GET', '/api/status').then(response => {
expect(response.status).to.equal(200);

cy.request('/api/clusters').then(response => {
cy.request('/api/config').then(response => {
cy.wrap(response.isOkStatusCode).should('be.true');
cy.wrap(response.body).should('have.length', 1);

const cluster = response.body[0].name;
const clusters: { [key: string]: MeshCluster } = response.body.clusters;
const clusterName = Object.keys(clusters)[0];
const cluster = clusters[clusterName];

cy.getBySel('overview-type-LIST').should('be.visible').click();

Expand Down Expand Up @@ -351,11 +358,13 @@ Then('I should see the override annotation for sidecar injection in the namespac

const expectation = 'exist';

cy.request('/api/clusters').then(response => {
cy.request('/api/config').then(response => {
cy.wrap(response.isOkStatusCode).should('be.true');
cy.wrap(response.body).should('have.length', 1);

const cluster = response.body[0].name;
const clusters: { [key: string]: MeshCluster } = response.body.clusters;
const clusterName = Object.keys(clusters)[0];
const cluster = clusters[clusterName];

cy.getBySel(`VirtualItem_Cluster${cluster}_${this.targetNamespace}`)
.contains(`istio-injection=${enabled}`)
Expand All @@ -368,11 +377,13 @@ Then('I should see no override annotation for sidecar injection in the namespace
cy.request('GET', '/api/status').then(response => {
expect(response.status).to.equal(200);

cy.request('/api/clusters').then(response => {
cy.request('/api/config').then(response => {
cy.wrap(response.isOkStatusCode).should('be.true');
cy.wrap(response.body).should('have.length', 1);

const cluster = response.body[0].name;
const clusters: { [key: string]: MeshCluster } = response.body.clusters;
const clusterName = Object.keys(clusters)[0];
const cluster = clusters[clusterName];

cy.getBySel(`VirtualItem_Cluster${cluster}_${this.targetNamespace}`)
.contains(`istio-injection`)
Expand Down
15 changes: 10 additions & 5 deletions frontend/cypress/integration/common/table.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Then, When } from '@badeball/cypress-cucumber-preprocessor';
import { TableDefinition } from 'cypress-cucumber-preprocessor';
import { MeshCluster } from '../../../src/types/Mesh';

enum SortOrder {
Ascending = 'ascending',
Expand Down Expand Up @@ -210,15 +211,17 @@ export const checkHealthIndicatorInTable = (
: `${targetNamespace}_${targetRowItemName}`;

// cy.getBySel(`VirtualItem_Ns${selector}]`).find('span').filter(`.icon-${healthStatus}`).should('exist');
// Fetch the cluster info from /api/clusters
// Fetch the cluster info from /api/config
// TODO: Move this somewhere else since other tests will most likely need this info as well.
// VirtualItem_Clustercluster-default_Nsbookinfo_details
// VirtualItem_Clustercluster-default_Nsbookinfo_productpage
cy.request('/api/clusters').then(response => {
cy.request('/api/config').then(response => {
cy.wrap(response.isOkStatusCode).should('be.true');
cy.wrap(response.body).should('have.length', 1);

const cluster = response.body[0].name;
const clusters: { [key: string]: MeshCluster } = response.body.clusters;
const clusterName = Object.keys(clusters)[0];
const cluster = clusters[clusterName];

cy.getBySel(`VirtualItem_Cluster${cluster}_Ns${selector}`)
.find('span')
Expand All @@ -237,11 +240,13 @@ export const checkHealthStatusInTable = (
? `${targetNamespace}_${targetType}_${targetRowItemName}`
: `${targetNamespace}_${targetRowItemName}`;

cy.request('/api/clusters').then(response => {
cy.request('/api/config').then(response => {
cy.wrap(response.isOkStatusCode).should('be.true');
cy.wrap(response.body).should('have.length', 1);

const cluster = response.body[0].name;
const clusters: { [key: string]: MeshCluster } = response.body.clusters;
const clusterName = Object.keys(clusters)[0];
const cluster = clusters[clusterName];

cy.get(
`[data-test=VirtualItem_Cluster${cluster}_Ns${selector}] td:first-child span[class=pf-v5-c-icon__content]`
Expand Down

0 comments on commit 96ba4c8

Please sign in to comment.