{"size": 913, "ext": "js", "max_stars_repo_path": "tests/leftNavigation_test.js", "max_stars_repo_name": "percona/pmm-ui-tests", "max_stars_repo_stars_event_min_datetime": "2021-05-09T06:21:26.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-18T16:50:24.000Z", "max_issues_repo_path": "tests/leftNavigation_test.js", "max_issues_repo_name": "percona/pmm-ui-tests", "max_issues_repo_issues_event_min_datetime": "2021-04-19T08:13:14.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T11:04:11.000Z", "max_forks_repo_path": "tests/leftNavigation_test.js", "max_forks_repo_name": "percona/pmm-ui-tests", "max_forks_repo_forks_event_min_datetime": "2021-04-20T04:17:01.000Z", "max_forks_repo_forks_event_max_datetime": "2021-10-03T12:56:48.000Z"}
{"max_stars_count": 4, "max_issues_count": 36, "max_forks_count": 4, "avg_line_length": 24.6756756757, "max_line_length": 103, "alphanum_fraction": 0.6078860898}
const { leftNavMenu } = inject();

const sidebar = new DataTable(['name', 'locator', 'path', 'click']);

const parse = (obj) => {
  if (obj !== null && typeof obj == 'object') {
    if ('path' in obj && 'click' in obj
      // excludes top level clickable icon
      && 'label' in obj) {
      sidebar.add([obj.label, obj.locator, obj.path, obj.click]);
    }

    Object.values(obj).forEach((value) => {
      // key is either an array index or object key
      parse(value);
    });
  }
};

parse(leftNavMenu);

Feature('Left Navigation menu tests').retry(1);

Before(async ({ I, homePage }) => {
  await I.Authorize();
  await homePage.open();
});

Data(sidebar).Scenario(
  'PMM-T433, PMM-T591 - Verify menu items on Grafana sidebar redirects to correct page @nightly @menu',
  async ({ I, current }) => {
    I.seeElementInDOM(current.locator);
    current.click();
    I.waitInUrl(current.path, 5);
  },
);
