github.com/argoproj/argo-cd/v3@v3.2.1/ui-test/src/navigation.ts (about)

     1  import {By, WebDriver} from 'selenium-webdriver';
     2  import {ApplicationsList} from './applications-list/applications-list';
     3  import UiTestUtilities from './UiTestUtilities';
     4  import {Base} from './base';
     5  import {AuthLoginPage} from './auth/login-page';
     6  
     7  const NAVBAR_APPLICATIONS_BUTTON: By = By.css('#app .sidebar .argo-icon-application');
     8  const NAVBAR_SETTINGS_BUTTON: By = By.css('#app .sidebar .argo-icon-settings');
     9  const NAVBAR_USER_INFO_BUTTON: By = By.css('#app .sidebar .fa-user-circle');
    10  const NAVBAR_DOCS_BUTTON: By = By.css('#app .sidebar .argo-icon-docs');
    11  
    12  export class Navigation extends Base {
    13      private applicationsList: ApplicationsList;
    14      private authLoginPage: AuthLoginPage;
    15  
    16      public constructor(driver: WebDriver) {
    17          super(driver);
    18          this.applicationsList = new ApplicationsList(this.driver);
    19          this.authLoginPage = new AuthLoginPage(this.driver);
    20      }
    21  
    22      public getLoginPage(): AuthLoginPage {
    23          return this.authLoginPage;
    24      }
    25  
    26      /**
    27       * Click the Applications Nav Bar Button
    28       * Return: reference to ApplicationsList page
    29       */
    30      public async clickApplicationsNavBarButton(): Promise<ApplicationsList> {
    31          try {
    32              const navBarButton = await UiTestUtilities.findUiElement(this.driver, NAVBAR_APPLICATIONS_BUTTON);
    33              await navBarButton.click();
    34          } catch (err: any) {
    35              throw new Error(err);
    36          }
    37          return this.applicationsList;
    38      }
    39  
    40      /**
    41       * Click the Settings Nav Bar Button
    42       * TODO return settings page
    43       */
    44      public async clickSettingsNavBarButton() {
    45          try {
    46              const navBarButton = await UiTestUtilities.findUiElement(this.driver, NAVBAR_SETTINGS_BUTTON);
    47              await navBarButton.click();
    48          } catch (err: any) {
    49              throw new Error(err);
    50          }
    51      }
    52  
    53      /**
    54       * Click the User Info Nav Bar Button
    55       * TODO return User Info page
    56       */
    57      public async clickUserInfoNavBarButton() {
    58          try {
    59              const navBarButton = await UiTestUtilities.findUiElement(this.driver, NAVBAR_USER_INFO_BUTTON);
    60              await navBarButton.click();
    61          } catch (err: any) {
    62              throw new Error(err);
    63          }
    64      }
    65  
    66      /**
    67       * Click the Documentation Nav Bar Button
    68       * TODO return docs page
    69       */
    70      public async clickDocsNavBarButton() {
    71          try {
    72              const navBarButton = await UiTestUtilities.findUiElement(this.driver, NAVBAR_DOCS_BUTTON);
    73              await navBarButton.click();
    74          } catch (err: any) {
    75              throw new Error(err);
    76          }
    77      }
    78  
    79      /**
    80       * Get the WebDriver. Test cases are not recommended to use this. Use Page/Component objects to perform actions
    81       */
    82      public getDriver(): WebDriver {
    83          return this.driver;
    84      }
    85  
    86      /**
    87       * Call when test case is finished
    88       */
    89      public async quit() {
    90          await this.driver.quit();
    91      }
    92  
    93      /**
    94       * Sleep for t milliseconds. This is not recommended for use by test cases.
    95       * @param t
    96       */
    97      public async sleep(t: number) {
    98          await this.driver.sleep(t);
    99      }
   100  }