Skip to content

Commit

Permalink
fixed failed discover app shared links tests (opensearch-project#1079)
Browse files Browse the repository at this point in the history
1. refactor so that each test case is indepent from each other
2. use decodeURI to make url consistent so that the url matches

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
  • Loading branch information
ruanyl authored and abbyhu2000 committed Feb 27, 2024
1 parent 6492d1f commit 280a0b8
Showing 1 changed file with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,19 @@ describe('shared links', () => {
cy.setAdvancedSetting({
defaultIndex: 'logstash-*',
});

miscUtils.visitPage('app/data-explorer/discover#/');
cy.waitForLoader();
cy.setTopNavDate(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME);
cy.waitForSearch();
});

describe('shared links with state in query', () => {
beforeEach(() => {
CURRENT_TENANT.newTenant = 'global';
miscUtils.visitPage('app/data-explorer/discover#/');
cy.waitForLoader();
cy.setTopNavDate(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME);
cy.waitForSearch();
});

it('should allow for copying the snapshot URL', function () {
const url = `http://localhost:5601/app/data-explorer/discover#/?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(indexPattern:'logstash-*',view:discover))&_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))&_q=(filters:!(),query:(language:kuery,query:''))`;
const url = `http://localhost:5601/app/data-explorer/discover?security_tenant=global#/?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(indexPattern:'logstash-*',view:discover))&_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:'2015-09-19T13:31:44.000Z',to:'2015-09-24T01:31:44.000Z'))&_q=(filters:!(),query:(language:kuery,query:''))`;
cy.getElementByTestId('shareTopNavButton').should('be.visible').click();
cy.getElementByTestId('copyShareUrlButton')
.invoke('attr', 'data-share-url')
Expand All @@ -64,6 +67,7 @@ describe('shared links', () => {
});

it('should allow for copying the snapshot URL as a short URL', function () {
cy.getElementByTestId('shareTopNavButton').should('be.visible').click();
cy.getElementByTestId('useShortUrl')
.should('be.visible')
.invoke('attr', 'aria-checked', 'true');
Expand All @@ -74,9 +78,11 @@ describe('shared links', () => {
});

it('should allow for copying the saved object URL', function () {
const url =
'http://localhost:5601/app/data-explorer/discover/#/view/ab12e3c0-f231-11e6-9486-733b1ac9221a?_g=%28filters%3A%21%28%29%2CrefreshInterval%3A%28pause%3A%21t%2Cvalue%3A0%29%2Ctime%3A%28from%3A%272015-09-19T13%3A31%3A44.000Z%27%2Cto%3A%272015-09-24T01%3A31%3A44.000Z%27%29%29';
const url = decodeURI(
'http://localhost:5601/app/data-explorer/discover/#/view/ab12e3c0-f231-11e6-9486-733b1ac9221a?_g=%28filters%3A%21%28%29%2CrefreshInterval%3A%28pause%3A%21t%2Cvalue%3A0%29%2Ctime%3A%28from%3A%272015-09-19T13%3A31%3A44.000Z%27%2Cto%3A%272015-09-24T01%3A31%3A44.000Z%27%29%29'
);

cy.getElementByTestId('shareTopNavButton').should('be.visible').click();
cy.getElementByTestId('exportAsSavedObject')
.get('.euiRadio__input')
.should('be.disabled');
Expand All @@ -101,7 +107,10 @@ describe('shared links', () => {
cy.setAdvancedSetting({
'state:storeInSessionStorage': true,
});
});

beforeEach(() => {
CURRENT_TENANT.newTenant = 'global';
miscUtils.visitPage('app/data-explorer/discover#/');
cy.waitForLoader();
cy.setTopNavDate(DE_DEFAULT_START_TIME, DE_DEFAULT_END_TIME);
Expand All @@ -125,6 +134,7 @@ describe('shared links', () => {
});

it('should allow for copying the snapshot URL as a short URL', function () {
cy.getElementByTestId('shareTopNavButton').should('be.visible').click();
cy.getElementByTestId('useShortUrl').should('be.visible').click();
cy.getElementByTestId('copyShareUrlButton')
.invoke('attr', 'data-share-url')
Expand All @@ -135,6 +145,7 @@ describe('shared links', () => {
});

it('should allow for copying the saved object URL', function () {
cy.getElementByTestId('shareTopNavButton').should('be.visible').click();
cy.getElementByTestId('exportAsSavedObject')
.get('.euiRadio__input')
.should('be.disabled');
Expand Down

0 comments on commit 280a0b8

Please sign in to comment.