-
Notifications
You must be signed in to change notification settings - Fork 19
Logging-ui-plugin test using real data #305
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
base: main
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: anpingli The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
5e598ce to
74d54a2
Compare
86bc31f to
856f0b1
Compare
|
/retest |
|
@anpingli There are some errors coming from the package-lock.json file, this is from prow logs:
|
3294a38 to
cf23167
Compare
cf23167 to
cc7ed85
Compare
|
/retest-required |
cc7ed85 to
842a813
Compare
|
/retest |
a5011dc to
9a13df3
Compare
9a13df3 to
27d9043
Compare
|
@anpingli: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
@zhuje All test pass now. |
|
@jgbernalp could you talk a look my PR? |
|
LGTM |
|
|
||
| beforeEach( function() { | ||
| // Load the other page to ensure Observe-Logs in clean status | ||
| cy.get('section.pf-v6-c-nav__subnav').contains('a','Search').click(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we prefer to use test ids, so we don't depend on specific patternfly claseses. Which might change.
| const pattern = new RegExp(`${APP_NAMESPACE1}|${APP_NAMESPACE2}`); | ||
| cy.getByTestId(TestIds.LogsTable).within(() => { | ||
| // Click the first expand button | ||
| cy.get('#expand.pf-v5-c-table__td.lv-plugin__table__expand.pf-v5-c-table__toggle', { timeout: 6000 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, it seems we are mixing pf6 and pf5 selectors. A better way would be to add a test id to the logs table so we can reference it directly.
|
|
||
| it('Log Panel top elements', {tags:['@smoke','@aggr']} , () => { | ||
| //load Aggregated Logs for the first pod in APP_NAMESPACE1 | ||
| cy.get('[data-test-id="namespace-bar-dropdown"]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repeated steps like this we can make them reusable in a "utils.ts" file as a "Page Object" concept where you can pass namespace as parameter and do not hardcode it
| .first() | ||
| .find('a.co-resource-item__resource-name') | ||
| .click(); | ||
| cy.get('a[data-test-id="horizontal-link-Aggregated Logs"]').click(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as @jgbernalp had mentioned before, these data-test-id, data-id (when MaterialUI if Logging also uses), and other locators could be also be in the same /src/test-ids file in another "json object" like DataTestIds, DataIds, Classes, then according to the type you can create different selectors cy.getByDataTestId, cy.getByDataIds, cy.getByClasses and refer to them.
When handling with Classes, you can refer both pf5 and pf6. You can take a look at this file as example: https://github.com/openshift/monitoring-plugin/blob/main/web/src/components/data-test.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. Let me define similar data-test.ts for Logging.
| .click(); | ||
| cy.get('a[data-test-id="horizontal-link-Aggregated Logs"]').click(); | ||
|
|
||
| cy.getByTestId(TestIds.ToggleHistogramButton).should('exist'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an example of reusable steps would be these assertions cross different user types or cross different pages, for example Logs and Aggregated Logs probably have many common components. This way, if something breaks one of the pages by any reason, you could also detect and fix it easily in one place.
I didn't take a look at all cypress test files, but I have a feeling they are very similar in general and maybe one or another difference depending on the page (Logs or Agg Logs) and/or per user type. So, these steps could become more than reused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it would be a pain now to refactor, decouple all these steps, but I am sure it worth as a short/mid/long term, specially if you need to backport all these files of 2 Logging versions and/or upgrade patternfly from 4/5 to 6 and future ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had defined a common function in this cypress/e2e/logging/logs-common-test.cy.ts which can be called in different page.
| } | ||
| }) | ||
| cy.get('[data-test-id="perspective-switcher-toggle"]').invoke('text').then((text) => { | ||
| if (text == "Administrator" ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already in 4.21 nightly builds, you are going to see "Core platform" instead of Administrator.
Monitoring-plugin and distributed tracing repos, we have something like https://github.com/openshift/monitoring-plugin/blob/e35027e4e122dc1b70ce2584a13d1f20e5948576/web/cypress/support/commands/auth-commands.ts#L120 to pass in your test instead of hardcode in your test file.
Uh oh!
There was an error while loading. Please reload this page.