Skip to content

Commit

Permalink
fix flaky spaces test (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzuming authored Nov 14, 2024
1 parent 1bbabc5 commit 93f6403
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 10 deletions.
10 changes: 6 additions & 4 deletions e2e-tests/cypress/e2e/Spaces.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as semver from 'semver';
import { Login } from '../support/page-objects/Login';
import { Loader } from '../support/page-objects/Loader';
import { KibanaNavigation } from '../support/page-objects/KibanaNavigation';
import { Spaces } from '../support/page-objects/Spaces';
import { getKibanaVersion } from '../support/helpers';
import { getKibanaVersion, userCredentials } from '../support/helpers';
import { kbnApiAdvancedClient } from '../support/helpers/KbnApiAdvancedClient';

describe('Spaces', () => {
beforeEach(() => {
Expand All @@ -16,6 +16,10 @@ describe('Spaces', () => {
Loader.loading();
});

afterEach(() => {
kbnApiAdvancedClient.deleteAllSpaces(userCredentials);
});

it('should successfully set feature visibility for default space', () => {
cy.log('Navigate to default space management');
cy.get('[data-test-subj=spacesNavSelector]').click();
Expand Down Expand Up @@ -81,7 +85,5 @@ describe('Spaces', () => {
KibanaNavigation.openHomepage();
KibanaNavigation.openKibanaNavigation();
KibanaNavigation.checkIfNotExists('Analytics');

Spaces.removeSpace('Test');
});
});
11 changes: 11 additions & 0 deletions e2e-tests/cypress/support/helpers/KbnApiAdvancedClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ export class KbnApiAdvancedClient extends KbnApiClient {
});
});
}

public deleteAllSpaces(credentials: string): void {
cy.log(`Delete all spaces`);
this.getAllSpaces(credentials).then(spaces => {
spaces
.filter(space => space.id !== 'default')
.forEach(space => {
this.deleteSpace(space.id, credentials);
});
});
}
}

export const kbnApiAdvancedClient = new KbnApiAdvancedClient();
25 changes: 25 additions & 0 deletions e2e-tests/cypress/support/helpers/KbnApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ export class KbnApiClient {
currentGroupHeader: group
});
}

public deleteSpace(spaceName: string, credentials: string, group?: string): void {
cy.kbnDelete({
endpoint: `api/spaces/space/${spaceName}`,
credentials,
currentGroupHeader: group
});
}

public getAllSpaces(credentials: string, group?: string): Cypress.Chainable<Space[]> {
return cy.kbnGet({
endpoint: `api/spaces/space`,
credentials,
currentGroupHeader: group
});
}
}

export const kbnApiClient = new KbnApiClient();
Expand All @@ -67,3 +83,12 @@ interface SavedObject {
export interface GetObject {
saved_objects: SavedObject[];
}

interface Space {
id: string;
name: string;
initials: string;
color: string;
disabledFeatures: string[];
imageUrl: string;
}
5 changes: 1 addition & 4 deletions e2e-tests/cypress/support/page-objects/DevTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ export class DevTools {
cy.log('Open Dev tools');
KibanaNavigation.openKibanaNavigation();
cy.contains('Dev Tools').click();
cy.findByRole('button', { name: /Dismiss/ });
cy.findByRole('dialog')
.findByRole('button', { name: /Dismiss/ })
.click();
cy.get('[data-test-subj="help-close-button"]').click();
}

static sendRequest(text: string) {
Expand Down
2 changes: 1 addition & 1 deletion environments/eck-ror/kind-cluster/ror/kbn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ spec:
env:
- name: ROR_ACTIVATION_KEY
value: "${ROR_ACTIVATION_KEY}"
- name: I_UNDERSTAND_IMPLICATION_OF_KBN_PATCHING
- name: I_UNDERSTAND_AND_ACCEPT_KBN_PATCHING
value: "yes"
2 changes: 1 addition & 1 deletion environments/elk-ror/images/kbn/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN \
exit 1; \
fi && \
INVOKE_ROR_TOOLS="$NODE_PATH /usr/share/kibana/plugins/readonlyrestkbn/ror-tools.js" && \
$INVOKE_ROR_TOOLS patch && \
$INVOKE_ROR_TOOLS patch --I_UNDERSTAND_AND_ACCEPT_KBN_PATCHING=yes && \
chown -R kibana:kibana /usr/share/kibana/config

USER kibana
Expand Down

0 comments on commit 93f6403

Please sign in to comment.