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

Fix condition to determine if the date field's value is an array #299

Merged
merged 9 commits into from
Feb 20, 2024
Merged
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
25 changes: 13 additions & 12 deletions .cypress/integration/04-download.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,62 +11,59 @@
'/reports-dashboards'
);

cy.wait(12500);

Check failure on line 14 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods
cy.get('#landingPageOnDemandDownload').click({ force: true });
cy.get('body').then($body => {
if ($body.find('#downloadInProgressLoadingModal').length > 0) {
return;
}
else {
assert(false);
}
})
cy.get('[id="landingPageOnDemandDownload"]')

Check warning on line 15 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls
.contains('CSV')
.click({ force: true });
cy.get('.euiToastHeader__title')
.contains('Successfully downloaded report')
.should('exist');
});

it('Download pdf from in-context menu', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/dashboards#`);
cy.wait(5000);

Check failure on line 25 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods

// click first entry in dashboards page
cy.get('tr.euiTableRow:nth-child(1) > td:nth-child(2) > div:nth-child(2) > a:nth-child(1)').click({ force: true });

Check warning on line 28 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls

// click Reporting in-context menu
cy.get('#downloadReport > span:nth-child(1) > span:nth-child(1)').click({ force: true });

Check warning on line 31 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls

// download PDF
cy.get('#generatePDF > span:nth-child(1) > span:nth-child(2)').click({ force: true });

Check warning on line 34 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls

cy.get('#reportGenerationProgressModal');
});

it('Download png from in-context menu', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/dashboards#`);
cy.wait(5000);

Check failure on line 41 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods

// click first entry in dashboards page
cy.get('tr.euiTableRow:nth-child(1) > td:nth-child(2) > div:nth-child(2) > a:nth-child(1)').click({ force: true });

Check warning on line 44 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls

// click Reporting in-context menu
cy.get('#downloadReport > span:nth-child(1) > span:nth-child(1)').click({ force: true });

Check warning on line 47 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls

cy.get('#generatePNG').click({ force: true });

Check warning on line 49 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls

cy.get('#reportGenerationProgressModal');
});

it('Download csv from saved search in-context menu', () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/discover#`);
cy.wait(5000);

Check failure on line 56 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods

// open saved search list
cy.get('[data-test-subj="discoverOpenButton"]').click({ force: true });

Check warning on line 59 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls
cy.wait(5000);

Check failure on line 60 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods

// click first entry
cy.get('li.euiListGroupItem:nth-child(1) > button:nth-child(1)').click({ force: true });

Check warning on line 63 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls

// open reporting menu
cy.get('#downloadReport').click({ force: true });

Check warning on line 66 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls

cy.get('#generateCSV').click({ force: true });
});
Expand All @@ -79,16 +76,20 @@
'include',
'/reports-dashboards'
);
cy.wait(10000);

Check failure on line 79 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods

cy.get('tr.euiTableRow-isSelectable:nth-child(1) > td:nth-child(1) > div:nth-child(2) > button:nth-child(1)').first().click();

cy.url().should('include', 'report_definition_details');

cy.get('#generateReportFromDetailsButton').should('exist');
cy.wait(5000);

Check failure on line 85 in .cypress/integration/04-download.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods

cy.get('#generateReportFromDetailsFileFormat').should('exist');

cy.get('#generateReportFromDetailsButton').click({ force: true });
cy.get('#generateReportFromDetailsFileFormat').click({ force: true });

cy.get('#downloadInProgressLoadingModal');
cy.get('.euiToastHeader__title')
.contains('Successfully generated report')
.should('exist');
});
});
2 changes: 1 addition & 1 deletion .github/workflows/cypress-e2e-reporting-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ jobs:

- name: Run Cypress tests
run: |
yarn cypress:run --browser chrome --headless --spec '.cypress/integration/*'
yarn cypress:run --browser chrome --headless
Copy link
Contributor

Choose a reason for hiding this comment

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

Oops good catch on this, seems like we don't need to specify the spec for this directory setup. Thanks!

working-directory: OpenSearch-Dashboards/plugins/${{ env.PLUGIN_NAME }}

- name: Capture failure screenshots
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
cd ./OpenSearch-Dashboards/
su `id -un 1000` -c "source $NVM_DIR/nvm.sh && nvm use && node -v && yarn -v &&
cd ./plugins/${{ env.PLUGIN_NAME }} &&
whoami && yarn osd bootstrap && yarn test --coverage"
whoami && yarn osd bootstrap --single-version=loose && yarn test --coverage"
- name: Upload coverage
uses: codecov/codecov-action@v1
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
with:
timeout_minutes: 30
max_attempts: 3
command: yarn osd bootstrap
command: yarn osd bootstrap --single-version=loose

- name: Test
uses: nick-fields/retry@v1
Expand Down Expand Up @@ -171,7 +171,7 @@ jobs:
with:
timeout_minutes: 30
max_attempts: 3
command: yarn osd bootstrap
command: yarn osd bootstrap --single-version=loose

- name: Test
uses: nick-fields/retry@v1
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ another JDK installation, e.g. `RUNTIME_JAVA_HOME=/usr/lib/jvm/jdk-8`.
cd plugins
git clone https://github.com/opensearch-project/dashboards-reporting.git
```
1. Run `yarn osd bootstrap` inside `OpenSearch-Dashboards/plugins/dashboards-reporting`.
1. Run `yarn osd bootstrap --single-version=loose` inside `OpenSearch-Dashboards/plugins/dashboards-reporting`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!


Ultimately, your directory structure should look like this:

Expand Down
8 changes: 4 additions & 4 deletions server/routes/utils/dataReportHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ export const getOpenSearchData = (
if (typeof dateValue === 'string') {
data._source[keys] = moment.utc(dateValue).tz(timezone).format(dateFormat);
} else if (
fieldDateValue.length !== 0 &&
fieldDateValue instanceof Array
dateValue.length !== 0 &&
dateValue instanceof Array
) {
fieldDateValue.forEach((element, index) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for my knowledge, why whats the difference between fieldDateValue and dateValue above. Cuz I saw the change was trying to switch to dateValue .

Copy link
Member Author

Choose a reason for hiding this comment

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

Originally the variable was dateValue for this condition but was mistakenly changed in different PR which caused TypeError: Cannot create property '0' on number '1700813322772'. Reverting to fix the issue.

data._source[keys][index] = moment.utc(element).tz(timezone).format(dateFormat);
Expand All @@ -161,8 +161,8 @@ export const getOpenSearchData = (
if (typeof fieldDateValue === 'string') {
keys.push(moment.utc(fieldDateValue).tz(timezone).format(dateFormat));
} else if (
fieldDateValue.length !== 0 &&
fieldDateValue instanceof Array
dateValue.length !== 0 &&
dateValue instanceof Array
) {
let tempArray: string[] = [];
fieldDateValue.forEach((index) => {
Expand Down
20 changes: 6 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -757,13 +757,6 @@
dependencies:
undici-types "~5.26.4"

"@types/node@^18.17.5":
version "18.19.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.6.tgz#537beece2c8ad4d9abdaa3b0f428e601eb57dac8"
integrity sha512-X36s5CXMrrJOs2lQCdDF68apW4Rfx9ixYMawlepwmE4Anezv/AV2LSpKD1Ub8DAc+urp5bk0BGZ6NtmBitfnsg==
dependencies:
undici-types "~5.26.4"

"@types/parse-json@^4.0.0":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.2.tgz#5950e50960793055845e956c427fc2b0d70c5239"
Expand Down Expand Up @@ -2195,13 +2188,12 @@ cyclist@^1.0.1:
integrity sha512-0sVXIohTfLqVIW3kb/0n6IiWF3Ifj5nm2XaSrLq2DI6fKIGa2fYAZdk917rUneaeLVpYfFcyXE2ft0fe3remsA==

cypress@^13.6.0:
version "13.6.2"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.6.2.tgz#c70df09db0a45063298b3cecba2fa21109768e08"
integrity sha512-TW3bGdPU4BrfvMQYv1z3oMqj71YI4AlgJgnrycicmPZAXtvywVFZW9DAToshO65D97rCWfG/kqMFsYB6Kp91gQ==
version "13.6.4"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.6.4.tgz#42c88d3ee0342f1681abfacabf9c1f082676bc53"
integrity sha512-pYJjCfDYB+hoOoZuhysbbYhEmNW7DEDsqn+ToCLwuVowxUXppIWRr7qk4TVRIU471ksfzyZcH+mkoF0CQUKnpw==
dependencies:
"@cypress/request" "^3.0.0"
"@cypress/xvfb" "^1.2.4"
"@types/node" "^18.17.5"
"@types/sinonjs__fake-timers" "8.1.1"
"@types/sizzle" "^2.3.2"
arch "^2.2.0"
Expand Down Expand Up @@ -5343,9 +5335,9 @@ ret@~0.1.10:
integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==

rfdc@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b"
integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==
version "1.3.1"
resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.1.tgz#2b6d4df52dffe8bb346992a10ea9451f24373a8f"
integrity sha512-r5a3l5HzYlIC68TpmYKlxWjmOP6wiPJ1vWv2HeLhNsRZMrCkxeqxiHlQ21oXmQ4F3SiryXBHhAD7JZqvOJjFmg==

rgbcolor@^1.0.1:
version "1.0.1"
Expand Down
Loading