|
| 1 | +/*! |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | +import { test, expect } from "@playwright/test"; |
| 20 | + |
| 21 | +import { ProvidersPage } from "../pages/ProvidersPage"; |
| 22 | + |
| 23 | +test.describe("Providers Page", () => { |
| 24 | + let providers: ProvidersPage; |
| 25 | + |
| 26 | + test.beforeEach(async ({ page }) => { |
| 27 | + providers = new ProvidersPage(page); |
| 28 | + await providers.navigate(); |
| 29 | + await providers.waitForLoad(); |
| 30 | + }); |
| 31 | + |
| 32 | + test("verify providers page heading", async () => { |
| 33 | + await expect(providers.heading).toBeVisible(); |
| 34 | + }); |
| 35 | + |
| 36 | + test("Verify Providers page is accessible via Admin menu", async ({ page }) => { |
| 37 | + await page.goto("/"); |
| 38 | + |
| 39 | + await page.getByRole("button", { name: /^admin$/i }).click(); |
| 40 | + |
| 41 | + // Click Providers |
| 42 | + const providersItem = page.getByRole("menuitem", { name: /^providers$/i }); |
| 43 | + |
| 44 | + await expect(providersItem).toBeVisible(); |
| 45 | + await providersItem.click(); |
| 46 | + |
| 47 | + await providers.waitForLoad(); |
| 48 | + // Assert Providers page loaded |
| 49 | + await expect(providers.heading).toBeVisible(); |
| 50 | + expect(await providers.getRowCount()).toBeGreaterThan(0); |
| 51 | + }); |
| 52 | + |
| 53 | + test("Verify the providers list displays", async () => { |
| 54 | + await expect(providers.table).toBeVisible(); |
| 55 | + }); |
| 56 | + |
| 57 | + test("Verify package name, version, and description are not blank", async () => { |
| 58 | + const count = await providers.getRowCount(); |
| 59 | + |
| 60 | + expect(count).toBeGreaterThan(0); |
| 61 | + |
| 62 | + for (let i = 0; i < 2; i++) { |
| 63 | + const { description, packageName, version } = await providers.getRowDetails(i); |
| 64 | + |
| 65 | + expect(packageName).not.toEqual(""); |
| 66 | + expect(version).not.toEqual(""); |
| 67 | + expect(description).not.toEqual(""); |
| 68 | + } |
| 69 | + }); |
| 70 | + |
| 71 | + test("verify providers pagination", async () => { |
| 72 | + const limit = 5; |
| 73 | + |
| 74 | + await providers.navigateTo(`/providers?offset=0&limit=${limit}`); |
| 75 | + await providers.waitForLoad(); |
| 76 | + |
| 77 | + const rows = await providers.getRowCount(); |
| 78 | + |
| 79 | + expect(rows).toBeGreaterThan(0); |
| 80 | + |
| 81 | + const initialProviderNames = await providers.providerNames(); |
| 82 | + |
| 83 | + expect(initialProviderNames.length).toBeGreaterThan(0); |
| 84 | + |
| 85 | + await expect(providers.paginationNextButton).toBeVisible(); |
| 86 | + await expect(providers.paginationPrevButton).toBeVisible(); |
| 87 | + |
| 88 | + await providers.paginationNextButton.click(); |
| 89 | + await providers.waitForLoad(); |
| 90 | + |
| 91 | + await providers.page.waitForURL((url) => { |
| 92 | + const u = new URL(url); |
| 93 | + const offset = u.searchParams.get("offset"); |
| 94 | + |
| 95 | + return offset !== null && offset !== "0"; |
| 96 | + }); |
| 97 | + |
| 98 | + const rowsPage2 = await providers.getRowCount(); |
| 99 | + |
| 100 | + expect(rowsPage2).toBeGreaterThan(0); |
| 101 | + |
| 102 | + const ProviderNamesAfterNext = await providers.providerNames(); |
| 103 | + |
| 104 | + expect(ProviderNamesAfterNext.length).toBeGreaterThan(0); |
| 105 | + expect(ProviderNamesAfterNext).not.toEqual(initialProviderNames); |
| 106 | + |
| 107 | + await providers.paginationPrevButton.click(); |
| 108 | + await providers.waitForLoad(); |
| 109 | + |
| 110 | + await providers.page.waitForURL((url) => { |
| 111 | + const u = new URL(url); |
| 112 | + const offset = u.searchParams.get("offset"); |
| 113 | + |
| 114 | + return offset === "0" || offset === null; |
| 115 | + }); |
| 116 | + |
| 117 | + const rowsBack = await providers.getRowCount(); |
| 118 | + |
| 119 | + expect(rowsBack).toBeGreaterThan(0); |
| 120 | + }); |
| 121 | +}); |
0 commit comments