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

[ML] Add AD job validation UI tests #179358

Merged
merged 83 commits into from
May 27, 2024

Conversation

wayneseymour
Copy link
Member

@wayneseymour wayneseymour commented Mar 25, 2024

Summary

  • Add job wizard validation suite
  • Add job wizard model change annotation recommendation callout test subject
  • Add job wizard model time picker test subject using popperProps
  • Add test subjects for two steps: Time Range and Job Details
  • Add more methods to job wizard common service

- Add job wizard validation suite
- Add job wizard model change annotation recommendation callout test subject
- Add job wizard model time picker test subject within a div, as the EUI documents are incorrect about data-test-subjs for this component
- Add test subjects for two steps: Time Range and Job Details
- Add more methods to job wizard common service
@wayneseymour wayneseymour added :ml release_note:skip Skip the PR/issue when compiling release notes test-coverage issues & PRs for improving code test coverage backport:skip This commit does not require backporting labels Mar 25, 2024
@wayneseymour wayneseymour self-assigned this Mar 25, 2024
@wayneseymour wayneseymour marked this pull request as ready for review March 25, 2024 15:16
@wayneseymour wayneseymour requested a review from a team as a code owner March 25, 2024 15:16
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

Use selectors over visible text.
Change assertions based on lessons learned from previous
code reviews.
dateFormat={dateFormat}
minDate={startMoment}
/>
<div data-test-subj="mlJobWizardDatePickerRangeEndDate">
Copy link
Contributor

Choose a reason for hiding this comment

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

https://eui.elastic.co/#/forms/date-picker supports data-test-subj, hence you do not need a wrapper.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried it, following the docs per our zoom, but it did not work. I'll try again though!

Copy link
Member Author

Choose a reason for hiding this comment

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

Screenshot 2024-04-04 at 10 38 42
@darnautov perhaps a longer timeout?

Copy link
Contributor

@darnautov darnautov Apr 5, 2024

Choose a reason for hiding this comment

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

FYI adding a div wrapper also braked styles.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

@wayneseymour you set a data-test-subj prop in the wrong place. It should be for EuiDatePickerRange, not endDateControl

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah ok, so many dates lol. Thanks @darnautov 🙉

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah I dont think either of those work, so I've switched it to a span

Copy link
Member Author

Choose a reason for hiding this comment

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

no more span!
1f9611a

Comment on lines 623 to 647
async getAnnotationSwitchCheckedState(): Promise<boolean> {
const subj = 'mlJobWizardSwitchAnnotations';
const isSelected = await testSubjects.getAttribute(subj, 'aria-checked');
return isSelected === 'true';
},

async getAnnotationsSwitchCheckedState(expectedValue: boolean) {
const actualCheckedState = await this.getAnnotationSwitchCheckedState();
expect(actualCheckedState).to.eql(
expectedValue,
`Expected annotations switch to be '${expectedValue ? 'enabled' : 'disabled'}' (got '${
actualCheckedState ? 'enabled' : 'disabled'
}')`
);
},

async toggleAnnotationSwitch(toggle: boolean) {
const subj = 'mlJobWizardSwitchAnnotations';
if ((await this.getAnnotationSwitchCheckedState()) !== toggle) {
await retry.tryForTime(5 * 1000, async () => {
await testSubjects.clickWhenNotDisabledWithoutRetry(subj);
await this.getAnnotationSwitchCheckedState();
});
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

We have a similar code snippet copy-pasted in so many places. Can you please create reusable methods in x-pack/test/functional/services/ml/common_ui.ts?

  • getSwitchChechedState(testSubj: string)
  • toggleSwitchIfNeeded(testSubj: string, targetState: boolean)

Copy link
Member Author

Choose a reason for hiding this comment

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

x-pack/test/functional/services/ml/job_wizard_common.ts Outdated Show resolved Hide resolved
x-pack/test/functional/services/ml/job_wizard_common.ts Outdated Show resolved Hide resolved
x-pack/test/functional/services/ml/job_wizard_common.ts Outdated Show resolved Hide resolved
},
];

describe('job wizard validation', function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

I reckon you should not create a dedicated test suite for that, and go through all the wizard steps again.
We already have multiple tests for job wizards. Simply add a test suite to assert job validation.

For instance in the multi-metric wizards tests:

      await ml.testExecution.logTestStep('job creation displays the validation step');
      await ml.jobWizardCommon.advanceToValidationSection();

Add your assertion after these lines

Copy link
Member Author

Choose a reason for hiding this comment

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

@darnautov One of the reasons I created this is not have a nested suite.
I'll see if I can fit these in elsewhere without a nested suite.

@wayneseymour
Copy link
Member Author

@elasticmachine merge upstream

@wayneseymour
Copy link
Member Author

@elasticmachine merge upstream

@wayneseymour
Copy link
Member Author

@elasticmachine merge upstream

Copy link
Member

@pheyos pheyos left a comment

Choose a reason for hiding this comment

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

Looks good overall, left a few suggestions.

wayneseymour and others added 10 commits May 24, 2024 13:09
…etric_job.ts

Co-authored-by: Robert Oskamp <traeluki@gmail.com>
…etric_job.ts

Co-authored-by: Robert Oskamp <traeluki@gmail.com>
…etric_job.ts

Co-authored-by: Robert Oskamp <traeluki@gmail.com>
…etric_job.ts

Co-authored-by: Robert Oskamp <traeluki@gmail.com>
…etric_job.ts

Co-authored-by: Robert Oskamp <traeluki@gmail.com>
…etric_job.ts

Co-authored-by: Robert Oskamp <traeluki@gmail.com>
Co-authored-by: Robert Oskamp <traeluki@gmail.com>
Co-authored-by: Robert Oskamp <traeluki@gmail.com>
Co-authored-by: Robert Oskamp <traeluki@gmail.com>
@wayneseymour
Copy link
Member Author

@elasticmachine merge upstream

@wayneseymour wayneseymour requested a review from pheyos May 24, 2024 17:56
@wayneseymour
Copy link
Member Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
ml 4.1MB 4.1MB +619.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @wayneseymour

Copy link
Member

@pheyos pheyos left a comment

Choose a reason for hiding this comment

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

LGTM

@wayneseymour wayneseymour merged commit dc46dfc into elastic:main May 27, 2024
19 checks passed
rshen91 pushed a commit to rshen91/kibana that referenced this pull request May 30, 2024
## Summary

- Add job wizard validation suite
- Add job wizard model change annotation recommendation callout test
subject
- Add job wizard model time picker test subject using `popperProps`
- Add test subjects for two steps: Time Range and Job Details
- Add more methods to job wizard common service

---------

Co-authored-by: Dima Arnautov <arnautov.dima@gmail.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Robert Oskamp <traeluki@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting :ml release_note:skip Skip the PR/issue when compiling release notes test-coverage issues & PRs for improving code test coverage v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants