Skip to content

Commit

Permalink
[Archive Migration] x-pack..dashboard_view_mode (#108503)
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneseymour authored Aug 19, 2021
1 parent cfd5dad commit 7f68ff2
Show file tree
Hide file tree
Showing 4 changed files with 323 additions and 373 deletions.
85 changes: 20 additions & 65 deletions x-pack/test/functional/apps/dashboard_mode/dashboard_view_mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default function ({ getService, getPageObjects }) {
const pieChart = getService('pieChart');
const security = getService('security');
const testSubjects = getService('testSubjects');
const dashboardAddPanel = getService('dashboardAddPanel');
const dashboardPanelActions = getService('dashboardPanelActions');
const appsMenu = getService('appsMenu');
const filterBar = getService('filterBar');
Expand All @@ -30,91 +29,47 @@ export default function ({ getService, getPageObjects }) {
'share',
]);
const dashboardName = 'Dashboard View Mode Test Dashboard';
const savedSearchName = 'Saved search for dashboard';

describe('Dashboard View Mode', function () {
this.tags(['skipFirefox']);

before('initialize tests', async () => {
log.debug('Dashboard View Mode:initTests');
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional');
await esArchiver.load('x-pack/test/functional/es_archives/dashboard_view_mode');
await kibanaServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/dashboard_view_mode'
);
await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' });
await browser.setWindowSize(1600, 1000);

await PageObjects.common.navigateToApp('discover');
await PageObjects.timePicker.setHistoricalDataRange();
await PageObjects.discover.saveSearch(savedSearchName);

await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.clickNewDashboard();
await dashboardAddPanel.addSavedSearch(savedSearchName);
await PageObjects.dashboard.addVisualizations(
PageObjects.dashboard.getTestVisualizationNames()
});

after(async () => {
await kibanaServer.importExport.unload(
'x-pack/test/functional/fixtures/kbn_archiver/dashboard_view_mode'
);
await PageObjects.dashboard.saveDashboard(dashboardName);
const types = [
'search',
'dashboard',
'visualization',
'search-session',
'core-usage-stats',
'event_loop_delays_daily',
'search-telemetry',
'core-usage-stats',
];
await kibanaServer.savedObjects.clean({ types });
});

describe('Dashboard viewer', () => {
before('Create logstash data role', async () => {
await PageObjects.settings.navigateTo();
await testSubjects.click('roles');
await PageObjects.security.clickCreateNewRole();

await testSubjects.setValue('roleFormNameInput', 'logstash-data');
await PageObjects.security.addIndexToRole('logstash-*');
await PageObjects.security.addPrivilegeToRole('read');
await PageObjects.security.clickSaveEditRole();
});

before('Create dashboard only mode user', async () => {
await PageObjects.settings.navigateTo();
await PageObjects.security.createUser({
username: 'dashuser',
password: '123456',
confirm_password: '123456',
email: '[email protected]',
full_name: 'dashuser',
roles: ['kibana_dashboard_only_user', 'logstash-data'],
});
});

before('Create user with mixes roles', async () => {
await PageObjects.security.createUser({
username: 'mixeduser',
password: '123456',
confirm_password: '123456',
email: '[email protected]',
full_name: 'mixeduser',
roles: ['kibana_dashboard_only_user', 'kibana_admin', 'logstash-data'],
});
});

before('Create user with dashboard and superuser role', async () => {
await PageObjects.security.createUser({
username: 'mysuperuser',
password: '123456',
confirm_password: '123456',
email: '[email protected]',
full_name: 'mixeduser',
roles: ['kibana_dashboard_only_user', 'superuser'],
});
});

after(async () => {
await security.testUser.restoreDefaults();
});

it('shows only the dashboard app link', async () => {
await security.testUser.setRoles(
['test_logstash_reader', 'kibana_dashboard_only_user'],
false
);

await security.testUser.setRoles(['test_logstash_reader', 'kibana_dashboard_only_user']);
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.security.forceLogout();
await PageObjects.security.login('test_user', 'changeme');

const appLinks = await appsMenu.readLinks();
expect(appLinks).to.have.length(1);
expect(appLinks[0]).to.have.property('text', 'Dashboard');
Expand Down
Binary file not shown.
Loading

0 comments on commit 7f68ff2

Please sign in to comment.