Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Archive Migration] x-pack..dashboard_view_mode #108503

Merged
merged 3 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this unload is actually enough in this test. This test file saves a new saved search and a new dashboard. I think we would want to clean those with something like .clean(['search', 'dashboard'[);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LeeDr Looks like the test user svc is already restoring defaults. Is there more to be done regarding test users?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not about the test user, it's about the saved objects. Currently the test does this;

  1. load some saved objects from a kbnArchive
  2. save some new SOs as a part of the test
  3. unload the SOs from step 1. This leaves the SOs that were created in step 2. The test should clean those up (delete the SOs).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the latest push addresses this boss.

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