-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
FTR: enable ESLint mocha rules for api integration tests #191267
Conversation
it('returns 404 error on non-existing scripted field', async () => { | ||
const response1 = await supertest.get( | ||
`/api/index_patterns/index_pattern/${indexPattern.id}/scripted_field/test` | ||
); | ||
expect(response1.status).to.be(404); | ||
}); | ||
|
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.
Complete duplicate of
kibana/test/api_integration/apis/data_views/scripted_fields_crud/get_scripted_field/errors.ts
Lines 51 to 57 in 2bed553
it('returns 404 error on non-existing scripted field', async () => { | |
const response1 = await supertest.get( | |
`/api/index_patterns/index_pattern/${indexPattern.id}/scripted_field/sf` | |
); | |
expect(response1.status).to.be(404); | |
}); |
in the same file
@@ -45,15 +45,15 @@ import type { ToolingLog } from '@kbn/tooling-log'; | |||
* @returns The response from the test | |||
*/ | |||
export const retry = async <T>({ | |||
test, | |||
testFn, |
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.
test
is reserved by Mocha, renaming for convenience.
@@ -28,8 +28,6 @@ export default function ({ getService }: FtrProviderContext) { | |||
}, | |||
}; | |||
|
|||
after(async () => await deleteAllIndices()); |
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.
duplicate hook:
kibana/x-pack/test/api_integration/apis/management/index_management/mapping.ts
Lines 41 to 48 in 3b98c57
after(async () => { | |
try { | |
await deleteAllIndices(); | |
} catch (err) { | |
log.debug('[Cleanup error] Error deleting index'); | |
throw err; | |
} | |
}); |
after(async () => { | ||
await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'); | ||
await kibanaServer.savedObjects.cleanStandardList(); | ||
}); |
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.
error Unexpected use of duplicate Mocha
before hook mocha/no-sibling-hooks
Duplicating hooks is not recommended because it can lead to confusion about the order of execution and potential issues in test maintenance.
@@ -133,7 +130,7 @@ export default function (providerContext: FtrProviderContext) { | |||
expect(downloadSource.host).to.eql('https://test.co:403'); | |||
}); | |||
|
|||
it('should allow to update an existing download source', async function () { | |||
it('should allow to update is_default for existing download source', async function () { |
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.
error Test title is used multiple times in the same test suite mocha/no-identical-title
/ci |
it('should discard the shipper values when shipper is disabled', async function () { | ||
await supertest | ||
.post(`/api/fleet/outputs`) | ||
.set('kbn-xsrf', 'xxxx') | ||
.send({ | ||
name: 'default monitoring output 1', | ||
type: 'elasticsearch', | ||
hosts: ['https://test.fr'], | ||
is_default_monitoring: true, | ||
shipper: { | ||
disk_queue_enabled: true, | ||
disk_queue_path: 'path/to/disk/queue', | ||
disk_queue_encryption_enabled: true, | ||
}, | ||
}) | ||
.expect(200); | ||
const { | ||
body: { items: outputs }, | ||
} = await supertest.get(`/api/fleet/outputs`).expect(200); | ||
const defaultOutputs = outputs.filter((o: any) => o.is_default_monitoring); | ||
expect(defaultOutputs[0].shipper).to.equal(null); | ||
}); | ||
|
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.
Duplicate of
kibana/x-pack/test/fleet_api_integration/apis/outputs/crud.ts
Lines 1290 to 1311 in ffe6cf4
it('should discard the shipper values when shipper is disabled', async function () { | |
await supertest | |
.post(`/api/fleet/outputs`) | |
.set('kbn-xsrf', 'xxxx') | |
.send({ | |
name: 'default monitoring output 1', | |
type: 'elasticsearch', | |
hosts: ['https://test.fr'], | |
is_default_monitoring: true, | |
shipper: { | |
disk_queue_enabled: true, | |
disk_queue_path: 'path/to/disk/queue', | |
disk_queue_encryption_enabled: true, | |
}, | |
}) | |
.expect(200); | |
const { | |
body: { items: outputs }, | |
} = await supertest.get(`/api/fleet/outputs`).expect(200); | |
const defaultOutputs = outputs.filter((o: any) => o.is_default_monitoring); | |
expect(defaultOutputs[0].shipper).to.equal(null); | |
}); |
it('should return nothing if searched for managed policy name', async () => { | ||
const response = await supertest | ||
.get(uninstallTokensRouteService.getListPath()) | ||
.query({ | ||
search: generatedManagedPolicyArray[0].name, | ||
}) | ||
.expect(200); | ||
|
||
const body: GetUninstallTokensMetadataResponse = response.body; | ||
expect(body.total).to.equal(0); | ||
expect(body.page).to.equal(1); | ||
expect(body.perPage).to.equal(20); | ||
expect(body.items).to.eql([]); | ||
}); | ||
|
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.
Duplicate of
kibana/x-pack/test/fleet_api_integration/apis/uninstall_token/get.ts
Lines 476 to 489 in ffe6cf4
it('should return nothing if searched for managed policy name', async () => { | |
const response = await supertest | |
.get(uninstallTokensRouteService.getListPath()) | |
.query({ | |
search: generatedManagedPolicyArray[0].name, | |
}) | |
.expect(200); | |
const body: GetUninstallTokensMetadataResponse = response.body; | |
expect(body.total).to.equal(0); | |
expect(body.page).to.equal(1); | |
expect(body.perPage).to.equal(20); | |
expect(body.items).to.eql([]); | |
}); |
/ci |
/ci |
1 similar comment
/ci |
## Summary This PR refactors the `setupFleetAndAgents` helper function into a `FleetAndAgents` FTR service, which is now initialized during the config file loading. Reason: The previous implementation of `setupFleetAndAgents` wrapped a Mocha `before` hook, which is considered an anti-pattern according to the Mocha ESLint rules that the Operations and QA teams have agreed to enable in the Kibana repo. It's best practice to avoid duplicating hooks, as this can lead to inconsistent test results and make debugging difficult. Ensuring a single before and after hook sequence guarantees that the associated logic runs in a predictable and sequential manner. This change also unblocks #191267, where we plan to enforce the same recommended Mocha ESLint rules that were previously enabled for UI tests in #190690. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
1946622
to
3705654
Compare
/ci |
Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services) |
Pinging @elastic/fleet (Team:Fleet) |
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.
kibana-presentation changes LGTM
code review only
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.
ML code changes LGTM
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.
Thanks for the changes. security_solution_api_integration/edr_workflows
changes LGTM.
...ion_api_integration/test_suites/edr_workflows/artifacts/trial_license_complete_tier/index.ts
Outdated
Show resolved
Hide resolved
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.
kibana management changes lgtm
…workflows/artifacts/trial_license_complete_tier/index.ts Co-authored-by: Ash <1849116+ashokaditya@users.noreply.github.com>
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.
Fleet changes
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.
LGTM
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
Admin-merging forgoing the missing few approvals |
Summary
Follow-up to #190690
Most of API integration tests does not match the path pattern set in the original PR (thanks @pheyos for catching it) and where not updated.
This PR updates
.eslintrc.js
with explicit patterns to lint api_integration tests. Hopefully it is final change, but I rely on code owners to double check it.Most of the changes are trivial adjustments:
mocha/no-sibling-hooks
mocha/no-identical-title
mocha/no-async-describe