github.com/siglens/siglens@v0.0.0-20240328180423-f7ce9ae441ed/selenium-tests/tests/cluster-stats-test.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 const {By,Key,Builder, until, WebDriverWait} = require("selenium-webdriver"); 18 const assert = require("assert"); 19 const chrome = require('selenium-webdriver/chrome'); 20 let driver; 21 const chromeOptions = new chrome.Options() 22 chromeOptions.addArguments('--headless'); 23 24 async function testClusterStatsPageButtons(){ 25 try{ 26 //To wait for browser to build and launch properly 27 driver = await new Builder().forBrowser("chrome") 28 .setChromeOptions(chromeOptions) 29 .build(); 30 31 await driver.get("http://localhost:5122/cluster-stats.html"); 32 33 // test time picker button 34 let timePickerBtn = await driver.findElement(By.id("date-picker-btn")); 35 let datePickerTxt = await timePickerBtn.getText(); 36 assert.equal(datePickerTxt, "Time Picker", 'button text is not "Time Picker"'); 37 38 //test all charts 39 const eventCountGraph = await driver.findElement(By.id('EventCountChart')); 40 await driver.wait(until.elementIsVisible(eventCountGraph)); 41 42 const gbCountGraph = await driver.findElement(By.id('GBCountChart')); 43 await driver.wait(until.elementIsVisible(gbCountGraph),5000); 44 45 const totalVolumeGraph = await driver.findElement(By.id('TotalVolumeChart')); 46 await driver.wait(until.elementIsVisible(totalVolumeGraph),5000); 47 48 const storageSavingsPercent = await driver.wait(until.elementLocated(By.className('storage-savings-percent')), 5000); 49 const isStorageSavingsDisplayed = await storageSavingsPercent.isDisplayed(); 50 assert.equal(isStorageSavingsDisplayed, true, 'Storage Savings Percent is not displayed'); 51 52 //test all tables 53 const queryStatsContainer = await driver.findElement(By.className('query-stats')); 54 const indexStatsContainer = await driver.findElement(By.className('index-stats')); 55 await driver.sleep(1000); 56 57 const isQueryStatsDisplayed = await queryStatsContainer.isDisplayed(); 58 assert.equal(isQueryStatsDisplayed, true, 'Query Stats container is not displayed'); 59 60 await driver.sleep(1000); 61 const isIndexStatsDisplayed = await indexStatsContainer.isDisplayed(); 62 assert.equal(isIndexStatsDisplayed, true, 'Index Stats container is not displayed'); 63 64 const queryTable = await driver.findElement(By.id('query-table')); 65 const isQueryTableExists = await queryTable.isDisplayed(); 66 assert.equal(isQueryTableExists, true, 'Query Table element exists'); 67 68 const indexDataTable = await driver.findElement(By.id('index-data-table')); 69 const isIndexDataTableExists = await indexDataTable.isDisplayed(); 70 assert.equal(isIndexDataTableExists, true, 'Index Table element exists'); 71 72 console.log("All Cluster Stats Screen test passed") 73 } 74 catch (err) { 75 // Handle any errors that occur during test execution 76 console.error(err); 77 78 } finally { 79 // Close the driver instance, even if an error occurred 80 await driver.quit(); 81 } 82 } 83 84 testClusterStatsPageButtons();