github.com/minio/console@v1.4.1/web-app/tests/permissions-1/test-fix-ui-crash-for-policy.ts (about) 1 // This file is part of MinIO Console Server 2 // Copyright (c) 2022 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 17 import { Role, Selector } from "testcafe"; 18 import { readFileSync } from "fs"; 19 import { getMenuElement } from "../utils/elements-menu"; 20 21 const data = readFileSync(__dirname + "/../constants/timestamp.txt", "utf-8"); 22 const $TIMESTAMP = data.trim(); 23 24 let testDomainUrl = "http://localhost:9090"; 25 26 let insAllowedAccKey = `prefix-policy-ui-crash-${$TIMESTAMP}`; 27 let insAllowedSeckey = "poluicrashfix1234"; 28 29 /* Begin Local Testing config block */ 30 31 // For local Testing Create users and assign policies then update here. 32 // Command to invoke the test locally: testcafe chrome tests/permissions/inspect.ts 33 /*testDomainUrl = "http://localhost:5005"; 34 insAllowedAccKey = `prefix-policy-ui-crash`; 35 insAllowedSeckey = "poluicrashfix1234";*/ 36 /* End Local Testing config block */ 37 38 const loginUrl = `${testDomainUrl}/login`; 39 const bucketsScreenUrl = `${testDomainUrl}/buckets`; 40 41 const loginSubmitBtn = Selector("button").withAttribute("id", "do-login"); 42 43 export const bucketsSidebarEl = getMenuElement("buckets"); 44 45 export const inspectAllowedRole = Role( 46 loginUrl, 47 async (t) => { 48 await t 49 .typeText("#accessKey", insAllowedAccKey) 50 .typeText("#secretKey", insAllowedSeckey) 51 .click(loginSubmitBtn); 52 }, 53 { preserveUrl: true }, 54 ); 55 56 fixture("For user with Bucket Prefix permissions") 57 .page(testDomainUrl) 58 .beforeEach(async (t) => { 59 await t.useRole(inspectAllowedRole); 60 }); 61 62 test("Bucket page can be opened", async (t) => { 63 await t.navigateTo(bucketsScreenUrl); 64 }); 65 test("Buckets sidebar item exists", async (t) => { 66 await t.expect(bucketsSidebarEl.exists).ok(); 67 }); 68 69 /** 70 * Without the fix UI crashes with 71 * TypeError: simpleResources is not iterable (if fixed -> ) 72 * TypeError: scopes is not iterable (if fixed -> ) 73 * TypeError: values is not iterable 74 */