Skip to content

Commit

Permalink
[Security Solution] Re-enable the timelines url state test (elastic#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
lgestc authored Dec 20, 2023
1 parent f2ad024 commit ff0df59
Showing 1 changed file with 20 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,65 +4,53 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { encode } from '@kbn/rison';

import { encode } from '@kbn/rison';
import { getTimeline } from '../../../objects/timeline';

import { TIMELINE_HEADER } from '../../../screens/timeline';

import { createTimeline } from '../../../tasks/api_calls/timelines';

import { ALERTS_URL } from '../../../urls/navigation';
import { createRule } from '../../../tasks/api_calls/rules';
import { waitForAlertsToPopulate } from '../../../tasks/create_new_rule';
import { getNewRule } from '../../../objects/rule';

import { login } from '../../../tasks/login';
import { visit, visitWithTimeRange } from '../../../tasks/navigation';

import { TIMELINES_URL } from '../../../urls/navigation';
import { deleteTimelines } from '../../../tasks/api_calls/common';

// FLAKY: https://github.com/elastic/kibana/issues/172503
describe.skip('Open timeline', { tags: ['@serverless', '@ess'] }, () => {
describe('Open timeline', { tags: ['@serverless', '@ess'] }, () => {
let timelineSavedObjectId: string | null = null;
before(function () {
beforeEach(function () {
login();
deleteTimelines();
visit(TIMELINES_URL);

createTimeline(getTimeline()).then((response) => {
timelineSavedObjectId = response.body.data.persistTimeline.timeline.savedObjectId;
return response.body.data.persistTimeline.timeline.savedObjectId;
});

createRule(getNewRule());
visitWithTimeRange(ALERTS_URL);
waitForAlertsToPopulate();
});

beforeEach(() => {
login();
it('should open a timeline via url alone without a saved object id', () => {
const urlWithoutSavedObjectId = `${ALERTS_URL}?timeline=(activeTab:query,isOpen:!t)`;
visit(urlWithoutSavedObjectId);
cy.get(TIMELINE_HEADER).should('be.visible');
});

describe('open timeline from url exclusively', () => {
it('should open a timeline via url alone without a saved object id', () => {
const urlWithoutSavedObjectId = `${ALERTS_URL}?timeline=(activeTab:query,isOpen:!t)`;
visit(urlWithoutSavedObjectId);
cy.get(TIMELINE_HEADER).should('be.visible');
});

it('should also support opening with a saved object id', () => {
cy.location('search').then((search) => {
const params = new URLSearchParams(search);
const timelineParams = encode({
activeTab: 'query',
isOpen: true,
id: timelineSavedObjectId,
});
params.set('timeline', timelineParams);
const urlWithSavedObjectId = `${ALERTS_URL}?${params.toString()}`;
visit(urlWithSavedObjectId);
cy.get(TIMELINE_HEADER).should('be.visible');
it('should also support opening with a saved object id', () => {
cy.location('search').then((search) => {
const params = new URLSearchParams(search);
const timelineParams = encode({
activeTab: 'query',
isOpen: true,
id: timelineSavedObjectId,
});
params.set('timeline', timelineParams);
const urlWithSavedObjectId = `${ALERTS_URL}?${params.toString()}`;
visit(urlWithSavedObjectId);
cy.get(TIMELINE_HEADER).should('be.visible');
});
});
});

0 comments on commit ff0df59

Please sign in to comment.