Skip to content

Conversation

@corovcam
Copy link
Contributor

@corovcam corovcam commented Oct 3, 2025

Enhance the ESLint configuration and refactor code to improve type safety and error handling across various functions. Adjustments include removing unnecessary parameters and updating type annotations.

NOTE: Prettify-cation will be done in next PR to not bloat this one with non-important changes.

- Updated error handling in various functions to omit the error parameter in catch blocks.
- Changed type annotations from `any` to `unknown` in several interfaces and function parameters for better type safety.
- Removed unnecessary parameters from functions, such as `filename` in `uploadRandomFileAndConfirm`.
- Simplified locator functions by removing unused parameters.
- Enhanced the `FormServiceInterface` and `I18nServiceInterface` to remove generic type parameters where not needed.
- Adjusted the `uploadCompleteBar` locator to not require a filename.
- Improved the handling of translations and localization by ensuring type safety in translation-related functions.
- Updated tests to ensure they await asynchronous operations correctly and handle potential errors gracefully.
- Cleaned up ESLint disable comments for better readability and maintainability.
@corovcam corovcam changed the base branch from main to api-testing October 3, 2025 16:15
@corovcam corovcam requested a review from mesemus October 3, 2025 16:15
{
apiToken: appConfig.qase.token,
projectCode: appConfig.qase.project,
apiToken: (appConfig.qase as any).token,
Copy link
Member

Choose a reason for hiding this comment

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

Add alteast known basic typing for qase config?

Copy link
Member

Choose a reason for hiding this comment

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

* Helper method to find the appropriate method name for a field.
*/
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
private getMethod(page: any, field: string, methodPrefixes: string[]): string {
Copy link
Member

Choose a reason for hiding this comment

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

why disabling @typescript-eslint/no-explicit-any?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cause we don't know if the page is really of BasePage base type (or any type whatsover) if it doesn't have the appropriate methods we are looking for.

case 'describe':
// return a wrapper around the describe method that can skip tests
return (title: string, annotation?: any, callback?: () => void) => {
return (title: string, annotation?: unknown, callback?: () => void) => {
Copy link
Member

Choose a reason for hiding this comment

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

annotation should have some typing

}
default:
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
return (target as any)[prop];
Copy link
Member

Choose a reason for hiding this comment

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

Target type is known (extension of playwright base test

* will be marked as .skip.
*/
apply: (target, thisArg, args: any[]) => {
apply: (target, thisArg, args: unknown[]) => {
Copy link
Member

Choose a reason for hiding this comment

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

Parameters typeof target?


const page_creator = async (fixtures: any, use: UseFunction<L, T>) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const pageCreator = async (fixtures: any, use: UseFunction<L, T>) => {
Copy link
Member

Choose a reason for hiding this comment

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

Fixtures opt has type

* ```
*
* import { BasePage } from '@inveniosoftware/invenio-e2e';
* class MyPage extends BasePage&lt;MyLocators> {
Copy link
Member

Choose a reason for hiding this comment

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

Escaped bracket

…tion; enhance README with dependency details
@corovcam corovcam merged commit 6c2a462 into api-testing Oct 22, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants