github.com/minio/console@v1.4.1/web-app/tests/permissions-8/rewind.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 * as roles from "../utils/roles"; 18 import * as elements from "../utils/elements"; 19 import * as functions from "../utils/functions"; 20 import { 21 namedTestBucketBrowseButtonFor, 22 setUpNamedBucket, 23 setVersionedBucket, 24 testBucketBrowseButtonFor, 25 } from "../utils/functions"; 26 import { Selector } from "testcafe"; 27 import { deniedError, file } from "../permissions-6/resourceTesting"; 28 29 fixture("Rewind Testing").page("http://localhost:9090"); 30 31 const bucketname = "bucketname"; 32 const test3BucketBrowseButton = namedTestBucketBrowseButtonFor(bucketname); 33 34 test 35 .before(async (t) => { 36 // Create a bucket 37 await functions.setUpBucket(t, "abucketrewind"); 38 await functions.setVersioned(t, "abucketrewind"); 39 await t 40 .useRole(roles.bucketReadWrite) 41 .navigateTo("http://localhost:9090/browser") 42 .click(testBucketBrowseButtonFor("abucketrewind")) 43 // Upload object to bucket 44 .setFilesToUpload(elements.uploadInput, "../uploads/test.txt") 45 .wait(1000) 46 .navigateTo("http://localhost:9090/browser") 47 .click(testBucketBrowseButtonFor("abucketrewind")) 48 // Upload object to bucket 49 .setFilesToUpload(elements.uploadInput, "../uploads/test.txt") 50 .wait(1000); 51 })("Rewind works in bucket", async (t) => { 52 await t 53 .useRole(roles.bucketReadWrite) 54 .navigateTo("http://localhost:9090/browser") 55 .click(testBucketBrowseButtonFor("abucketrewind")) 56 .expect(elements.table.exists) 57 .ok() 58 .click(elements.rewindButton) 59 .click(elements.rewindToBaseInput) 60 .expect(elements.rewindToInput.exists) 61 .ok() 62 .click(elements.rewindToInput) 63 .typeText(elements.rewindToInput, "01/01/2015 00:00") 64 .click(elements.rewindDataButton); 65 }) 66 .after(async (t) => { 67 // Cleanup created bucket and corresponding uploads 68 await functions.cleanUpBucketAndUploads(t, "abucketrewind"); 69 }); 70 71 test 72 .before(async (t) => { 73 await functions.setUpNamedBucket(t, bucketname); 74 await functions.setVersionedBucket(t, bucketname); 75 await functions.uploadNamedObjectToBucket( 76 t, 77 bucketname, 78 "test.txt", 79 "web-app/tests/uploads/test.txt", 80 ); 81 await functions.uploadNamedObjectToBucket( 82 t, 83 bucketname, 84 "firstlevel/secondlevel/test.txt", 85 "web-app/tests/uploads/test.txt", 86 ); 87 })("Rewind button enabled in bucket", async (t) => { 88 await t 89 .useRole(roles.rewindEnabled) 90 .navigateTo(`http://localhost:9090/browser`) 91 .click(test3BucketBrowseButton) 92 .wait(1500) 93 .click( 94 Selector(".ReactVirtualized__Table__rowColumn").withText("firstlevel"), 95 ) 96 .wait(1500) 97 .click( 98 Selector(".ReactVirtualized__Table__rowColumn").withText("secondlevel"), 99 ) 100 .wait(1500) 101 .expect(elements.rewindButton.exists) 102 .ok(); 103 }) 104 .after(async (t) => { 105 await functions.cleanUpNamedBucketAndUploads(t, bucketname); 106 }); 107 108 test 109 .before(async (t) => { 110 await functions.setUpNamedBucket(t, bucketname); 111 await functions.setVersionedBucket(t, bucketname); 112 await functions.uploadNamedObjectToBucket( 113 t, 114 bucketname, 115 "test.txt", 116 "web-app/tests/uploads/test.txt", 117 ); 118 await functions.uploadNamedObjectToBucket( 119 t, 120 bucketname, 121 "firstlevel/secondlevel/test.txt", 122 "web-app/tests/uploads/test.txt", 123 ); 124 })("Rewind button disabled in bucket", async (t) => { 125 await t 126 .useRole(roles.rewindNotEnabled) 127 .navigateTo(`http://localhost:9090/browser`) 128 .click(test3BucketBrowseButton) 129 .wait(1500) 130 .click( 131 Selector(".ReactVirtualized__Table__rowColumn").withText("firstlevel"), 132 ) 133 .wait(1500) 134 .click( 135 Selector(".ReactVirtualized__Table__rowColumn").withText("secondlevel"), 136 ) 137 .wait(1500) 138 .expect(elements.rewindButton.exists) 139 .ok() 140 .wait(1500) 141 .expect(elements.rewindButton.hasAttribute("disabled")) 142 .ok(); 143 }) 144 .after(async (t) => { 145 await functions.cleanUpNamedBucketAndUploads(t, bucketname); 146 });