Skip to content

Commit

Permalink
chore: use relative paths in cypress (opensearch-project#9079)
Browse files Browse the repository at this point in the history
* chore: use relative paths in cypress

when we move to running tests in parallel we won't be able to use a single
hardcoded basepath as these can differ by tasks

Signed-off-by: Daniel Rowe <[email protected]>

* Changeset file for PR opensearch-project#9079 created/updated

---------

Signed-off-by: Daniel Rowe <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
d-buckner and opensearch-changeset-bot[bot] authored Jan 13, 2025
1 parent e450f4d commit 9b5ce68
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/9079.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
chore:
- Use relative paths in cypress utilities ([#9079](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9079))
20 changes: 7 additions & 13 deletions cypress/utils/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ Cypress.Commands.add('bulkUploadDocs', (fixturePath, index) => {

Cypress.Commands.add('importSavedObjects', (fixturePath, overwrite = true) => {
const sendImportRequest = (ndjson) => {
const url = `${Cypress.config().baseUrl}/api/saved_objects/_import?${
overwrite ? `overwrite=true` : ''
}`;
const url = `/api/saved_objects/_import?${overwrite ? `overwrite=true` : ''}`;

const formData = new FormData();
formData.append('file', ndjson, 'savedObject.ndjson');
Expand Down Expand Up @@ -164,7 +162,7 @@ Cypress.Commands.add('importSavedObjects', (fixturePath, overwrite = true) => {
});

Cypress.Commands.add('deleteSavedObject', (type, id, options = {}) => {
const url = `${Cypress.config().baseUrl}/api/saved_objects/${type}/${id}`;
const url = `/api/saved_objects/${type}/${id}`;

return cy.request({
method: 'DELETE',
Expand All @@ -187,9 +185,7 @@ Cypress.Commands.add('deleteSavedObjectByType', (type, search) => {
searchParams.set('search', search);
}

const url = `${
Cypress.config().baseUrl
}/api/opensearch-dashboards/management/saved_objects/_find?${searchParams.toString()}`;
const url = `/api/opensearch-dashboards/management/saved_objects/_find?${searchParams.toString()}`;

return cy.request(url).then((response) => {
console.log('response', response);
Expand All @@ -210,9 +206,7 @@ Cypress.Commands.add('ifDataSourceExists', (search) => {
searchParams.set('search', search);
}

const url = `${
Cypress.config().baseUrl
}/api/opensearch-dashboards/management/saved_objects/_find?${searchParams.toString()}`;
const url = `/api/opensearch-dashboards/management/saved_objects/_find?${searchParams.toString()}`;

return cy.request(url).then((response) => {
console.log('response', response);
Expand All @@ -221,7 +215,7 @@ Cypress.Commands.add('ifDataSourceExists', (search) => {
});

Cypress.Commands.add('createIndexPattern', (id, attributes, header = {}) => {
const url = `${Cypress.config().baseUrl}/api/saved_objects/index-pattern/${id}`;
const url = `/api/saved_objects/index-pattern/${id}`;

cy.request({
method: 'POST',
Expand All @@ -239,7 +233,7 @@ Cypress.Commands.add('createIndexPattern', (id, attributes, header = {}) => {
});

Cypress.Commands.add('createDashboard', (attributes = {}, headers = {}) => {
const url = `${Cypress.config().baseUrl}/api/saved_objects/dashboard`;
const url = '/api/saved_objects/dashboard';

cy.request({
method: 'POST',
Expand Down Expand Up @@ -275,7 +269,7 @@ Cypress.Commands.add('deleteIndexPattern', (id, options = {}) =>
);

Cypress.Commands.add('setAdvancedSetting', (changes) => {
const url = `${Cypress.config().baseUrl}/api/opensearch-dashboards/settings`;
const url = '/api/opensearch-dashboards/settings';
cy.log('setAdvancedSetting')
.request({
method: 'POST',
Expand Down

0 comments on commit 9b5ce68

Please sign in to comment.