github.com/minio/console@v1.4.1/web-app/e2e/buckets.spec.ts (about)

     1  // This file is part of MinIO Console Server
     2  // Copyright (c) 2023 MinIO, Inc.
     3  //
     4  // This program is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Affero General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // This program is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  // GNU Affero General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Affero General Public License
    15  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16  import { expect } from "@playwright/test";
    17  import { generateUUID, test } from "./fixtures/baseFixture";
    18  import { minioadminFile } from "./consts";
    19  import { BUCKET_LIST_PAGE } from "./consts";
    20  
    21  test.use({ storageState: minioadminFile });
    22  
    23  test.beforeEach(async ({ page }) => {
    24    await page.goto(BUCKET_LIST_PAGE);
    25    await page.waitForTimeout(1000);
    26  });
    27  
    28  test("create a new bucket", async ({ page }) => {
    29    await page.getByRole("button", { name: "Buckets" }).click();
    30    await page.getByRole("button", { name: "Create Bucket" }).click();
    31    await page.getByLabel("Bucket Name*").click();
    32  
    33    const bucketName = `new-bucket-${generateUUID()}`;
    34  
    35    await page.getByLabel("Bucket Name*").fill(bucketName);
    36    await page.getByRole("button", { name: "Create Bucket" }).click();
    37    await page.waitForTimeout(2000);
    38    await page.locator("#refresh-buckets").click();
    39    await page.getByPlaceholder("Search Buckets").fill(bucketName);
    40  
    41    await expect(page.locator(`#manageBucket-${bucketName}`)).toBeTruthy();
    42    const bucketLocatorEl = `#manageBucket-${bucketName}`;
    43    await page.locator(bucketLocatorEl).click();
    44    await page.locator("#delete-bucket-button").click();
    45    //confirm modal
    46    await page.locator("#confirm-ok").click();
    47    const listItemsCount = await page.locator(bucketLocatorEl).count();
    48    await expect(listItemsCount).toEqual(0);
    49  });
    50  
    51  test("invalid bucket name", async ({ page }) => {
    52    await page.getByRole("button", { name: "Buckets" }).click();
    53    await page.getByRole("button", { name: "Create Bucket" }).click();
    54    await page.getByLabel("Bucket Name*").click();
    55    await page.getByLabel("Bucket Name*").fill("invalid name");
    56    await page.getByRole("button", { name: "View Bucket Naming Rules" }).click();
    57    await expect(
    58      page.getByText(
    59        "Bucket names can consist only of lowercase letters, numbers, dots (.), and hyphe",
    60      ),
    61    ).toBeTruthy();
    62  });