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

[OSD] Skip cypress tests for data explorer with security enabled #1120

Closed
Closed
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
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')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not a fan of this.

We could just strip the tenant from the query string and then compare. In fact, checking if the URL is identical is not a good idea; we should check if the elements we want are there, in whatever order.

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);
Copy link
Member Author

Choose a reason for hiding this comment

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

@leanneeliatra would you think this is ok?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes this looks good to me @kavilla
Have the tests been ran too, to make sure they still run okay and all is expected with this change?

// cy.waitForLoader();

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