github.com/siglens/siglens@v0.0.0-20240328180423-f7ce9ae441ed/ui-test/specs/index/index.js (about)

     1  /*
     2  Copyright 2023.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  /**
    18   * siglens
    19   * (c) 2022 - All rights reserved.
    20   */
    21  
    22  'use strict';
    23  
    24  describe('search indices', () => {
    25      let page;
    26  
    27      before(async () => {
    28          page = await browser.newPage();
    29  
    30          page.on('error', (err) => {
    31              console.error('error happen at the page: ', err);
    32          });
    33  
    34          page.on('pageerror', (pageerr) => {
    35              console.error('pageerror occurred: ', pageerr);
    36          });
    37  
    38          // page.on('request', (req) => {
    39          //     console.log('request', req.url);
    40          // });
    41  
    42          // page.on('requestfailed', (err) => {
    43          //     console.log('request failed', err);
    44          // });
    45  
    46          await page.goto(`file://${__dirname}/index.html`);
    47          // await page.waitForNavigation();
    48  
    49          page.on('console', (msg) => {
    50              console.log('PAGE LOG:', msg.text());
    51          });
    52      });
    53  
    54      it('should have the correct page title', async () => {
    55          expect(await page.title()).to.eql('SigLens - Index');
    56      });
    57  
    58      it('should render the index dropdown', async () => {
    59  
    60          //evaluate in page context
    61          await page.evaluate(() => {
    62              let data = [
    63                  {"index": "foo"},
    64                  {"index": "bar"}
    65              ];
    66              renderIndexDropdown(data);
    67          });
    68  
    69          let indexOptions = await page.$$eval('.index-dropdown-item', (elements) => {
    70              // this is running in the webpage's context
    71              // so we'll need to use a plain object to pass back data
    72              return elements.map(el => {
    73                  return {
    74                      html: el.outerHTML,
    75                      // index: el.dataset.index,
    76                      // checked: $(el).find('.toggle-field').hasClass('fa-square-check')
    77                  };
    78              });
    79          });
    80  
    81          //console.log(indexOptions);
    82          expect(indexOptions).to.have.length(3);
    83  
    84      });
    85  
    86  });