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

Standardization of "che" test automation framework classes #22184

Closed
nallikaea opened this issue Apr 28, 2023 · 1 comment · Fixed by #22466
Closed

Standardization of "che" test automation framework classes #22184

nallikaea opened this issue Apr 28, 2023 · 1 comment · Fixed by #22466
Assignees
Labels
area/qe kind/task Internal things, technical debt, and to-do tasks to be performed. severity/P2 Has a minor but important impact to the usage or development of the system.

Comments

@nallikaea
Copy link
Contributor

nallikaea commented Apr 28, 2023

Is your task related to a problem? Please describe

In "che/tests/e2e" there a lot of classes as page objects or utils. The same type of classes can have different structure, for example:

  1. Class declaration:

    • inject
    @injectable()
    export class BrowserTabsUtil {
        constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { }
    
    • regular
      export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
           constructor(_workspaceName?: string, _namespace?: string) {
               super();
           }
      
  2. Class export:

    • export class DriverHelper
    • class CheReporter...
      export = CheReporter;
      
  3. Public methods:

    • without keyword
     async switchToWindow(windowHandle: string): Promise<void> {
         Logger.debug('BrowserTabsUtil.switchToWindow');
         await this.driverHelper.getDriver().switchTo().window(windowHandle);
     }
    
    • or with
     public async maximize(): Promise<void> {
         Logger.trace('BrowserTabsUtil.maximize');
         if (TestConstants.TS_SELENIUM_LAUNCH_FULLSCREEN) {
             Logger.debug('TS_SELENIUM_LAUNCH_FULLSCREEN is set to true, maximizing window.');
             await this.driverHelper.getDriver().manage().window().maximize();
         }
    
  4. Private class fields:

    • private static readonly KUBERNETES_API_URL: string = 'api/kubernetes/namespace'
    • Static property may be useful when a property doesn't need to be recreated across each new instance of the class, but all instances of the class can point to the same value stored at the class level instead, some constants, or when it used in static methods
      readonly attempts: number = TestConstants.TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS; - can be private and static
    • private static latestWorkspace: string = ''; why static?
  5. Locators:

    • as private string -
      private static readonly RUN_BUTTON_CSS: string = '#run-workspace-button[che-button-title=\'Run\']';
    • as mechanism for locating -
      static readonly FACTORY_URL_LOCATOR: By = By.xpath(//input[@id="git-repo-url"]);
    • inbuild in function -
    async getRecentWorkspaceName(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<string> {
         Logger.debug(`Dashboard.getRecentWorkspaceName`);
    
         return await this.driverHelper.waitAndGetText(By.css('[data-testid="recent-workspace-item"]'), timeout);
     }
    
    • const in function
    async waitTitleContains(expectedText: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
         Logger.debug(`CreateWorkspace.waitTitleContains text: "${expectedText}"`);
    
         const pageTitleLocator: By = By.xpath(`//h1[contains(text(), '${expectedText}')]`);
    
         await this.driverHelper.waitVisibility(pageTitleLocator, timeout);
     }
    
    • not static -
      private readonly OPEN_SHIFT_LOGIN_LANDING_PAGE_LOCATOR: string = '//div[@class='panel-login'];'

So team/contribution conventions on using one or the other should be specified.

Describe the solution you'd like

As a sample:

import { e2eContainer } from '../../configs/inversify.config';

@injectable()
export class OcpMainPage {

    private static readonly MAIN_PAGE_HEADER_LOCATOR: By = By.id('page-main-header');
    private static readonly SELECT_ROLE_BUTTON_LOCATOR: By = By.xpath('//*[@data-test-id="perspective-switcher-toggle"]');
  
    constructor(
        @inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { }

    async waitOpenMainPage(): Promise<void> {
        Logger.debug(`${this.constructor.name}.${this.waitOpenMainPage.name}`);

        await this.driverHelper.waitVisibility(OcpMainPage.MAIN_PAGE_HEADER_LOCATOR, TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT);
    }

    private getProjectDropdownItemLocator(projectName: string): By {
        return By.xpath(`//button//*[text()="${projectName}"]`);
    }
}

Describe alternatives you've considered

No response

Additional context

No response

@nallikaea nallikaea added the kind/task Internal things, technical debt, and to-do tasks to be performed. label Apr 28, 2023
@nallikaea nallikaea changed the title Standardization of project classes Standardization of "che" test automation framework classes Apr 28, 2023
@che-bot che-bot added the status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. label Apr 28, 2023
@nallikaea
Copy link
Contributor Author

private getProjectDropdownItemLocator(projectName: string): By {
       return By.xpath('//button//*[text()="${projectName}"]');
   }

should this method be static as regular locator?
private static readonly FACTORY_URL_LOCATOR: By = By.xpath("//input[@id="git-repo-url"]);

@amisevsk amisevsk added severity/P2 Has a minor but important impact to the usage or development of the system. area/qe and removed status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. labels Apr 28, 2023
@l0rd l0rd moved this to 📋 Backlog in Eclipse Che Team B Backlog Jul 12, 2023
@nallikaea nallikaea moved this from 📋 Backlog to 🚧 In Progress in Eclipse Che Team B Backlog Aug 28, 2023
@nallikaea nallikaea linked a pull request Sep 4, 2023 that will close this issue
9 tasks
@nallikaea nallikaea moved this from 🚧 In Progress to Ready for Review in Eclipse Che Team B Backlog Sep 4, 2023
@github-project-automation github-project-automation bot moved this from Ready for Review to ✅ Done in Eclipse Che Team B Backlog Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/qe kind/task Internal things, technical debt, and to-do tasks to be performed. severity/P2 Has a minor but important impact to the usage or development of the system.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants