Skip to content

Commit

Permalink
Functional test for spaces grid
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Aug 1, 2024
1 parent 47bd850 commit 473c048
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export class SpacesGridPage extends Component<Props, State> {
</EuiFlexItem>
{this.state.activeSpace?.name === rowRecord.name && (
<EuiFlexItem grow={false}>
<EuiBadge color="primary">
<EuiBadge color="primary" data-test-subj={`spacesListCurrentBadge-${rowRecord.id}`}>
{i18n.translate('xpack.spaces.management.spacesGridPage.currentSpaceMarkerText', {
defaultMessage: 'current',
})}
Expand Down
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/spaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export default function spacesApp({ loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./spaces_selection'));
loadTestFile(require.resolve('./enter_space'));
loadTestFile(require.resolve('./create_edit_space'));
loadTestFile(require.resolve('./spaces_grid'));
});
}
47 changes: 47 additions & 0 deletions x-pack/test/functional/apps/spaces/spaces_grid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function enterSpaceFunctionalTests({
getService,
getPageObjects,
}: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['security', 'spaceSelector', 'common']);
const spacesService = getService('spaces');
const testSubjects = getService('testSubjects');

const anotherSpace = {
id: 'space2',
name: 'space2',
disabledFeatures: [],
};

describe('Spaces grid', function () {
before(async () => {
await spacesService.create(anotherSpace);

await PageObjects.common.navigateToApp('spacesManagement');
await testSubjects.existOrFail('spaces-grid-page');
});

after(async () => {
await spacesService.delete('another-space');
await kibanaServer.savedObjects.cleanStandardList();
});

it('can switch to a space from the row in the grid', async () => {
// use the "current" badge confirm that Default is the current space
await testSubjects.existOrFail('spacesListCurrentBadge-default');
// click the switch button of "another space"
await PageObjects.spaceSelector.clickSwitchSpaceButton('space2');
// use the "current" badge confirm that "Another Space" is now the current space
await testSubjects.existOrFail('spacesListCurrentBadge-space2');
});
});
}
3 changes: 3 additions & 0 deletions x-pack/test/functional/config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ export default async function ({ readConfigFile }) {
snapshotRestore: {
pathname: '/app/management/data/snapshot_restore',
},
spacesManagement: {
pathname: '/app/management/kibana/spaces',
},
remoteClusters: {
pathname: '/app/management/data/remote_clusters',
},
Expand Down
12 changes: 12 additions & 0 deletions x-pack/test/functional/page_objects/space_selector_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,21 @@ export class SpaceSelectorPageObject extends FtrService {
await this.testSubjects.setValue('descriptionSpaceText', descriptionSpace);
}

async clickSwitchSpaceButton(spaceName: string) {
const collapsedButtonSelector = '[data-test-subj=euiCollapsedItemActionsButton]';
// open context menu
await this.find.clickByCssSelector(`#${spaceName}-actions ${collapsedButtonSelector}`);
// click context menu item
await this.find.clickByCssSelector(
`.euiContextMenuItem[data-test-subj="${spaceName}-switchSpace"]` // can not use testSubj: multiple elements exist with the same data-test-subj
);
}

async clickOnDeleteSpaceButton(spaceName: string) {
const collapsedButtonSelector = '[data-test-subj=euiCollapsedItemActionsButton]';
// open context menu
await this.find.clickByCssSelector(`#${spaceName}-actions ${collapsedButtonSelector}`);
// click context menu item
await this.testSubjects.click(`${spaceName}-deleteSpace`);
}

Expand Down

0 comments on commit 473c048

Please sign in to comment.