Skip to content

Commit

Permalink
Skip cypress tests for data explorer
Browse files Browse the repository at this point in the history
Signed-off-by: Kawika Avilla <[email protected]>
  • Loading branch information
kavilla committed Feb 22, 2024
1 parent 2784d24 commit 4fd58f7
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 62 deletions.
5 changes: 4 additions & 1 deletion cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"DATASOURCE_MANAGEMENT_ENABLED": false,
"ML_COMMONS_DASHBOARDS_ENABLED": true,
"WAIT_FOR_LOADER_BUFFER_MS": 0,
"DASHBOARDS_ASSISTANT_ENABLED": false
"DASHBOARDS_ASSISTANT_ENABLED": false,
"browserPermissions": {
"clipboard": "allow"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,51 +52,58 @@ describe('shared links', () => {
cy.waitForSearch();
});

describe('shared links with state in query', () => {
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:''))`;
cy.getElementByTestId('shareTopNavButton').should('be.visible').click();
cy.getElementByTestId('copyShareUrlButton')
.invoke('attr', 'data-share-url')
.should('eq', url)
.then((url) => {
cy.log(url);
cy.request(url).its('status').should('eq', 200);
});
});

it('should allow for copying the snapshot URL as a short URL', function () {
cy.getElementByTestId('useShortUrl')
.should('be.visible')
.invoke('attr', 'aria-checked', 'true');
cy.wait(1000);
// For some reasons, after making the toggle true, the data-share-url do not get updated in the cypress test
// Thus only testing if the button is clickable, instead of comparing the actual URL
cy.getElementByTestId('copyShareUrlButton').should('be.visible').click();
});

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';

cy.getElementByTestId('exportAsSavedObject')
.get('.euiRadio__input')
.should('be.disabled');
if (!Cypress.env('SECURITY_ENABLED')) {
describe('shared links with state in query', () => {
// Skip the test if security is enabled url adds tenancy and changes the query string making it difficult to verify the URL
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:''))`;
cy.getElementByTestId('shareTopNavButton').should('be.visible').click();
cy.getElementByTestId('copyShareUrlButton')
.invoke('attr', 'data-share-url')
.should('eq', url)
.then((url) => {
cy.log(url);
cy.request(url).its('status').should('eq', 200);
});
});

// Load a save search
cy.loadSaveSearch('A Saved Search');
it('should allow for copying the snapshot URL as a short URL', function () {
cy.getElementByTestId('useShortUrl')
.should('be.visible')
.invoke('attr', 'aria-checked', 'true');
cy.wait(1000);
// For some reasons, after making the toggle true, the data-share-url do not get updated in the cypress test
// Thus only testing if the button is clickable, instead of comparing the actual URL
cy.getElementByTestId('copyShareUrlButton')
.should('be.visible')
.click();
});

cy.getElementByTestId('shareTopNavButton').should('be.visible').click();
cy.getElementByTestId('exportAsSavedObject').should('be.visible').click();
cy.getElementByTestId('copyShareUrlButton')
.invoke('attr', 'data-share-url')
.should('eq', url)
.then((url) => {
cy.log(url);
cy.request(url).its('status').should('eq', 200);
});
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';

cy.getElementByTestId('exportAsSavedObject')
.get('.euiRadio__input')
.should('be.disabled');

// Load a save search
cy.loadSaveSearch('A Saved Search');

cy.getElementByTestId('shareTopNavButton').should('be.visible').click();
cy.getElementByTestId('exportAsSavedObject')
.should('be.visible')
.click();
cy.getElementByTestId('copyShareUrlButton')
.invoke('attr', 'data-share-url')
.should('eq', url)
.then((url) => {
cy.log(url);
cy.request(url).its('status').should('eq', 200);
});
});
});
});
}

describe('shared links with state in sessionStorage', () => {
before(() => {
Expand Down Expand Up @@ -136,22 +143,26 @@ describe('shared links', () => {
});
});

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

// Load a save search
cy.loadSaveSearch('A Saved Search');

cy.getElementByTestId('shareTopNavButton').should('be.visible').click();
cy.getElementByTestId('exportAsSavedObject').should('be.visible').click();
cy.getElementByTestId('copyShareUrlButton')
.invoke('attr', 'data-share-url')
.then((url) => {
cy.log(url);
cy.request(url).its('status').should('eq', 200);
});
});
if (!Cypress.env('SECURITY_ENABLED')) {
it('should allow for copying the saved object URL', function () {
cy.getElementByTestId('exportAsSavedObject')
.get('.euiRadio__input')
.should('be.disabled');

// Load a save search
cy.loadSaveSearch('A Saved Search');

cy.getElementByTestId('shareTopNavButton').should('be.visible').click();
cy.getElementByTestId('exportAsSavedObject')
.should('be.visible')
.click();
cy.getElementByTestId('copyShareUrlButton')
.invoke('attr', 'data-share-url')
.then((url) => {
cy.log(url);
cy.request(url).its('status').should('eq', 200);
});
});
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ if (Cypress.env('SECURITY_ENABLED')) {
// Assert that the clipboard has data
expect(clipboardData).to.have.length.greaterThan(0);

cy.visit(clipboardData);
cy.waitForLoader();
// TODO: tries to re-route with a different origin
// cy.visit(clipboardData);
// cy.waitForLoader();

// Now on copied URL page
});
Expand Down

0 comments on commit 4fd58f7

Please sign in to comment.