diff --git a/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantDetails.tsx b/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantDetails.tsx
index b31f7c63d..51ad2ad96 100644
--- a/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantDetails.tsx
+++ b/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantDetails.tsx
@@ -359,6 +359,7 @@ const TenantDetails = ({ classes, match, history }: ITenantDetailsProps) => {
actions={
.
-import { Selector } from "testcafe";
+import { loginToOperator, createTenant, createTenantWithoutAuditLog, deleteTenant } from './utils';
fixture("For user with default permissions").page("http://localhost:9090");
test("Create Tenant and List Tenants", async (t) => {
const tenantName = `tenant-${Math.floor(Math.random() * 10000)}`;
-
- await t
- .navigateTo("http://localhost:9090/login")
- .typeText("#jwt", "anyrandompasswordwillwork")
- .click("#do-login")
- .click("#create-tenant")
- .typeText("#tenant-name", tenantName)
- .typeText("#namespace", tenantName)
- .click("#add-namespace")
- .click("#confirm-ok")
- .wait(1000)
- .click("#wizard-button-Create")
- .wait(1000)
- .click("#close")
- .expect(Selector(`#list-tenant-${tenantName}`).exists)
- .ok();
+ await loginToOperator();
+ await createTenant(tenantName);
+ await deleteTenant(tenantName);
});
test("Create Tenant Without Audit Log", async (t) => {
const tenantName = `tenant-${Math.floor(Math.random() * 10000)}`;
-
- await t
- .navigateTo("http://localhost:9090/login")
- .typeText("#jwt", "anyrandompasswordwillwork")
- .click("#do-login")
- .click("#create-tenant")
- .typeText("#tenant-name", tenantName)
- .typeText("#namespace", tenantName)
- .click("#add-namespace")
- .click("#confirm-ok")
- .wait(1000)
- .click("#wizard-step-audit-log")
- .click("#enableLogging")
- .click("#wizard-button-Create")
- .wait(1000)
- .click("#close")
- .expect(Selector(`#list-tenant-${tenantName}`).exists)
- .ok();
+ await loginToOperator();
+ await createTenantWithoutAuditLog(tenantName);
+ await deleteTenant(tenantName);
});
diff --git a/portal-ui/tests/operator/utils.ts b/portal-ui/tests/operator/utils.ts
new file mode 100644
index 000000000..655065905
--- /dev/null
+++ b/portal-ui/tests/operator/utils.ts
@@ -0,0 +1,75 @@
+// This file is part of MinIO Console Server
+// Copyright (c) 2022 MinIO, Inc.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+import { Selector, t } from 'testcafe';
+
+
+export const loginToOperator = async () => {
+ await t
+ .navigateTo("http://localhost:9090/login")
+ .typeText("#jwt", "anyrandompasswordwillwork")
+ .click("#do-login");
+}
+
+export const createTenant = async (tenantName: string) => {
+ await fillTenantInformation(tenantName);
+ await t.click("#wizard-button-Create");
+ await checkTenantExists(tenantName);
+}
+
+export const createTenantWithoutAuditLog = async (tenantName) => {
+ await fillTenantInformation(tenantName);
+ await t
+ .click("#wizard-step-audit-log")
+ .click("#enableLogging")
+ .click("#wizard-button-Create");
+ await checkTenantExists(tenantName);
+}
+
+const fillTenantInformation = async (tenantName: string) => {
+ await t
+ .click("#create-tenant")
+ .typeText("#tenant-name", tenantName)
+ .typeText("#namespace", tenantName)
+ .click("#add-namespace")
+ .click("#confirm-ok")
+ .wait(1000);
+}
+
+const checkTenantExists = async (tenantName) => {
+ await t
+ .wait(1000)
+ .click("#close")
+ .expect(Selector(`#list-tenant-${tenantName}`).exists)
+ .ok();
+ }
+
+
+export const deleteTenant = async (tenantName: string) => {
+ await goToTenant(tenantName);
+ await t
+ .click("#delete-tenant")
+ .typeText("#retype-tenant", tenantName)
+ .click("#confirm-ok")
+ .expect(Selector(`#list-tenant-${tenantName}`).exists)
+ .notOk();
+}
+
+
+const goToTenant = async (tenantName) => {
+ await t.click(Selector(`#list-tenant-${tenantName}`))
+}
+