github.com/minio/console@v1.4.1/web-app/e2e/pom/CreateBucketPage.tsx (about) 1 import { Page, Locator } from "@playwright/test"; 2 import { BUCKET_LIST_PAGE } from "../consts"; 3 4 export class CreateBucketPage { 5 page: Page; 6 7 /* Locators */ 8 9 submitBtn: Locator | undefined; 10 clearBtn: Locator | undefined; 11 bucketNameInput: Locator | undefined; 12 versioningToggle: Locator | undefined; 13 lockingToggle: Locator | undefined; 14 quotaToggle: Locator | undefined; 15 bucketNamingRules: Locator | undefined; 16 17 bucketRetentionToggle: Locator | undefined; 18 quotaSizeInput: Locator | undefined; 19 retentionModeRadio: Locator | undefined; 20 retentionValidity: Locator | undefined; 21 22 constructor(page: Page) { 23 this.page = page; 24 this.initLocators(); 25 } 26 getLocator(selector: string): Locator { 27 const page = this.page; 28 const locator: Locator = page.locator(`${selector}`); 29 return locator; 30 } 31 32 initLocators() { 33 this.submitBtn = this.getLocator("#create-bucket"); 34 this.clearBtn = this.getLocator("#clear"); 35 this.versioningToggle = this.getLocator("#versioned-switch"); 36 this.lockingToggle = this.getLocator("#locking-switch"); 37 this.quotaToggle = this.getLocator("#bucket_quota-switch"); 38 this.bucketNamingRules = this.getLocator("#toggle-naming-rules"); 39 this.bucketNameInput = this.getLocator("#bucket-name"); 40 } 41 42 //Lazy/Conditional selectors Note: These respective methods must be called before using them. 43 onVersioningToggleOn() { 44 this.bucketRetentionToggle = this.getLocator("#bucket_retention"); 45 } 46 47 onBucketQuotaToggleOn() { 48 this.quotaSizeInput = this.getLocator("#quota_size"); 49 } 50 51 onRetentionToggleOn() { 52 this.retentionModeRadio = this.getLocator("#retention_mode"); 53 this.retentionValidity = this.getLocator("#retention_validity"); 54 } 55 56 loadPage() { 57 const page = this.page; 58 page.goto(BUCKET_LIST_PAGE); 59 } 60 61 async fillBucketName(bucketName: string) { 62 await this.bucketNameInput?.click(); 63 await this.bucketNameInput?.fill(bucketName); 64 } 65 66 async toggleBucketNamingRules() { 67 await this.bucketNamingRules?.click(); 68 } 69 70 async toggleVersioning() { 71 await this.versioningToggle?.check(); 72 this.onVersioningToggleOn(); 73 //expect to be on 74 } 75 76 async toggleObjectLocking() { 77 await this.lockingToggle?.click(); 78 this.onVersioningToggleOn(); 79 this.onRetentionToggleOn(); 80 } 81 82 async toggleBucketQuota() { 83 await this.quotaToggle?.click(); 84 this.onBucketQuotaToggleOn(); 85 } 86 87 async toggleRetention() { 88 await this.bucketRetentionToggle?.click(); 89 } 90 91 async submitForm() { 92 await this.submitBtn?.click(); 93 } 94 95 //Convenience Methods for easy testing 96 97 //create a bucket without any features like versioning, locking, quota etc. 98 async createBucket(bucketName: string) { 99 await this.fillBucketName(bucketName); 100 await this.submitForm(); 101 } 102 103 //create a bucket with versioning feature 104 async createVersionedBucket(bucketName: string) { 105 await this.fillBucketName(bucketName); 106 await this.toggleVersioning(); 107 await this.submitForm(); 108 } 109 //create a bucket with locking feature 110 111 async goToCreateBucket() { 112 await this.submitBtn?.click(); 113 } 114 }