kibana/x-pack/test/functional/apps/spaces/spaces_grid.ts
Kibana Machine b9c29e9bfa
[8.x] Assign Roles to Space from Spaces Management (#191795) (#193787)
# Backport

This will backport the following commits from `main` to `8.x`:
- [Assign Roles to Space from Spaces Management
(#191795)](https://github.com/elastic/kibana/pull/191795)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Tim
Sullivan","email":"tsullivan@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-09-23T19:13:56Z","message":"Assign
Roles to Space from Spaces Management (#191795)\n\n##
Summary\r\n\r\nEpic link:
https://github.com/elastic/kibana-team/issues/785\r\n\r\nThis changes
bring a new design to the management of Spaces in Stack\r\nManagement /
Security. We have a new page to view the details of the\r\nSpace, and
new UX to assign Roles to a Space.\r\n\r\n### Release Note\r\nAdded
several UX improvements to the management of Spaces in
**Stack\r\nManagement > Spaces**, including the ability to assign Roles
to an\r\nexisting Space.\r\n\r\n### Checklist\r\n\r\nDelete any items
that are not applicable to this PR.\r\n\r\n- [x] Use flaky test runner
on changed functional
tests:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/6953\r\n-
[x] Create test for the ability to change space avatar from
`initials`\r\nto `image` and vice versa\r\n- [x] Any text added follows
[EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n-
[x] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Eyo
Okon Eyo <eyo.eyo@elastic.co>\r\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>\r\nCo-authored-by: Aleh
Zasypkin
<aleh.zasypkin@elastic.co>","sha":"fb9700caa097dbdac310f8fd3a387b8d218a7428","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Team:Security","v9.0.0","ci:cloud-deploy","v8.16.0","backport:version"],"title":"Assign
Roles to Space from Spaces
Management","number":191795,"url":"https://github.com/elastic/kibana/pull/191795","mergeCommit":{"message":"Assign
Roles to Space from Spaces Management (#191795)\n\n##
Summary\r\n\r\nEpic link:
https://github.com/elastic/kibana-team/issues/785\r\n\r\nThis changes
bring a new design to the management of Spaces in Stack\r\nManagement /
Security. We have a new page to view the details of the\r\nSpace, and
new UX to assign Roles to a Space.\r\n\r\n### Release Note\r\nAdded
several UX improvements to the management of Spaces in
**Stack\r\nManagement > Spaces**, including the ability to assign Roles
to an\r\nexisting Space.\r\n\r\n### Checklist\r\n\r\nDelete any items
that are not applicable to this PR.\r\n\r\n- [x] Use flaky test runner
on changed functional
tests:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/6953\r\n-
[x] Create test for the ability to change space avatar from
`initials`\r\nto `image` and vice versa\r\n- [x] Any text added follows
[EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n-
[x] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Eyo
Okon Eyo <eyo.eyo@elastic.co>\r\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>\r\nCo-authored-by: Aleh
Zasypkin
<aleh.zasypkin@elastic.co>","sha":"fb9700caa097dbdac310f8fd3a387b8d218a7428"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/191795","number":191795,"mergeCommit":{"message":"Assign
Roles to Space from Spaces Management (#191795)\n\n##
Summary\r\n\r\nEpic link:
https://github.com/elastic/kibana-team/issues/785\r\n\r\nThis changes
bring a new design to the management of Spaces in Stack\r\nManagement /
Security. We have a new page to view the details of the\r\nSpace, and
new UX to assign Roles to a Space.\r\n\r\n### Release Note\r\nAdded
several UX improvements to the management of Spaces in
**Stack\r\nManagement > Spaces**, including the ability to assign Roles
to an\r\nexisting Space.\r\n\r\n### Checklist\r\n\r\nDelete any items
that are not applicable to this PR.\r\n\r\n- [x] Use flaky test runner
on changed functional
tests:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/6953\r\n-
[x] Create test for the ability to change space avatar from
`initials`\r\nto `image` and vice versa\r\n- [x] Any text added follows
[EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] Any UI
touched in this PR is usable by keyboard only (learn more\r\nabout
[keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n-
[x] Any UI touched in this PR does not create any new axe
failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Eyo
Okon Eyo <eyo.eyo@elastic.co>\r\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>\r\nCo-authored-by: Aleh
Zasypkin
<aleh.zasypkin@elastic.co>","sha":"fb9700caa097dbdac310f8fd3a387b8d218a7428"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Tim Sullivan <tsullivan@users.noreply.github.com>
2024-09-23 15:56:38 -05:00

124 lines
4.3 KiB
TypeScript

/*
* 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 crypto from 'crypto';
import expect from '@kbn/expect';
import { type FtrProviderContext } from '../../ftr_provider_context';
export default function spaceDetailsViewFunctionalTests({
getService,
getPageObjects,
}: FtrProviderContext) {
const PageObjects = getPageObjects(['common', 'settings', 'spaceSelector']);
const spacesService = getService('spaces');
const testSubjects = getService('testSubjects');
const retry = getService('retry');
const testSpacesIds = [
'odyssey',
// this number is chosen intentionally to not exceed the default 10 items displayed by spaces table
...Array.from(new Array(5)).map((_) => `space-${crypto.randomUUID()}`),
];
describe('Spaces Management: List of Spaces', function () {
before(async () => {
for (const testSpaceId of testSpacesIds) {
await spacesService.create({ id: testSpaceId, name: `${testSpaceId}-name` });
}
await PageObjects.settings.navigateTo();
await testSubjects.existOrFail('spaces');
});
beforeEach(async () => {
await PageObjects.common.navigateToUrl('management', 'kibana/spaces', {
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
shouldUseHashForSubUrl: false,
});
await testSubjects.existOrFail('spaces-grid-page');
});
after(async () => {
for (const testSpaceId of testSpacesIds) {
await spacesService.delete(testSpaceId);
}
});
it('should list all the spaces populated', async () => {
const renderedSpaceRow = await testSubjects.findAll('*spacesListTableRow-');
expect(renderedSpaceRow.length).to.equal(testSpacesIds.length + 1);
});
it('does not display the space switcher button when viewing the details page for the current selected space', async () => {
const currentSpaceTitle = (
await PageObjects.spaceSelector.currentSelectedSpaceTitle()
)?.toLowerCase();
expect(currentSpaceTitle).to.equal('default');
await testSubjects.click('default-hyperlink');
await testSubjects.existOrFail('space-view-page-details-header');
expect(
(await testSubjects.getVisibleText('space-view-page-details-header'))
.toLowerCase()
.includes('default')
).to.be(true);
await testSubjects.missingOrFail('spaces-view-page-switcher-button');
});
it("displays the space switcher button when viewing the details page of the space that's not the current selected one", async () => {
const testSpaceId = testSpacesIds[Math.floor(Math.random() * testSpacesIds.length)];
const currentSpaceTitle = (
await PageObjects.spaceSelector.currentSelectedSpaceTitle()
)?.toLowerCase();
expect(currentSpaceTitle).to.equal('default');
await testSubjects.click(`${testSpaceId}-hyperlink`);
await testSubjects.existOrFail('space-view-page-details-header');
expect(
(await testSubjects.getVisibleText('space-view-page-details-header'))
.toLowerCase()
.includes(`${testSpaceId}-name`)
).to.be(true);
await testSubjects.existOrFail('spaces-view-page-switcher-button');
});
it('switches to a new space using the space switcher button', async () => {
const currentSpaceTitle = (
await PageObjects.spaceSelector.currentSelectedSpaceTitle()
)?.toLowerCase();
expect(currentSpaceTitle).to.equal('default');
const testSpaceId = testSpacesIds[Math.floor(Math.random() * testSpacesIds.length)];
await testSubjects.click(`${testSpaceId}-hyperlink`);
await testSubjects.click('spaces-view-page-switcher-button');
await retry.try(async () => {
const detailsTitle = (
await testSubjects.getVisibleText('space-view-page-details-header')
).toLowerCase();
const currentSwitchSpaceTitle = (
await PageObjects.spaceSelector.currentSelectedSpaceTitle()
)?.toLocaleLowerCase();
return (
currentSwitchSpaceTitle &&
currentSwitchSpaceTitle === `${testSpaceId}-name` &&
detailsTitle.includes(currentSwitchSpaceTitle)
);
});
});
});
}