Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Storage] Validate errors on create bucket modal test #2224

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions packages/storage-ui/cypress/tests/bucket-management.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,35 @@ describe("Bucket management", () => {
createBucketModal.cancelButton().click()
createBucketModal.body().should("not.exist")

// create a bucket and see it in the bucket table
// go to create bucket modal
bucketsPage.createBucketButton().click()
createBucketModal.body().should("be.visible")

// ensure can't create an empty bucket
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor thing but I find that leaving a whitespace before each comment / individual check in the flow of the test helps readability, it's not done here but is elsewhere in the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep! it helps, done!

createBucketModal.submitButton().click()
createBucketModal.bucketNameInput().should("have.class", "error")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I've never thought about using the class name before like this. I would usually avoid doing that (as I'd be concerned about it being too generic and potentially picking up a false match from elsewhere on the page)...but you've scoped it to within the bucketNameInput element so I guess that's not a valid concern, nice! 🤩

Copy link
Contributor Author

@juans-chainsafe juans-chainsafe Jul 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! the other way around is checking that the modal is still present and validating the text... but we don't want to add validations that have hardcoded text, so I ended up doing that inside the input, so we shouldn't have any problem. Also, I added a validation when the input is correct that the class 'error' should not be present


// ensure can't create a bucket with only spaces
createBucketModal.bucketNameInput().type(" ")
createBucketModal.submitButton().click()
createBucketModal.bucketNameInput().should("have.class", "error")

// create a bucket and see it in the bucket table
createBucketModal.bucketNameInput().type(chainSafeBucketName)
createBucketModal.bucketNameInput().should("not.have.class", "error")
createBucketModal.chainsafeRadioInput().click()
createBucketModal.submitButton().click()
bucketsPage.bucketItemRow().should("have.length", 1)
bucketsPage.bucketItemName().should("have.text", chainSafeBucketName)
bucketsPage.bucketFileSystemType().should("have.text", "Chainsafe")

// ensure can't create a bucket with the same name
bucketsPage.createBucketButton().click()
createBucketModal.bucketNameInput().type(chainSafeBucketName)
createBucketModal.submitButton().click()
createBucketModal.bucketNameInput().should("have.class", "error")
createBucketModal.cancelButton().click()

// open bucket and ensure header matches the expected value
bucketsPage.bucketItemName().dblclick()
bucketContentsPage.bucketHeaderLabel()
Expand Down Expand Up @@ -67,16 +86,34 @@ describe("Bucket management", () => {
cy.web3Login({ clearPins: true, deleteFpsBuckets: true })
navigationMenu.bucketsNavButton().click()

// create a bucket and see it in the bucket table
// go to create bucket modal
bucketsPage.createBucketButton().click()
createBucketModal.body().should("be.visible")

// ensure can't create an empty bucket
createBucketModal.submitButton().click()
createBucketModal.bucketNameInput().should("have.class", "error")

// ensure can't create a bucket with only spaces
createBucketModal.bucketNameInput().type(" ")
createBucketModal.submitButton().click()
createBucketModal.bucketNameInput().should("have.class", "error")

// create a bucket and see it in the bucket table
createBucketModal.bucketNameInput().type(ipfsBucketName)
createBucketModal.ipfsRadioInput().click()
createBucketModal.submitButton().click()
bucketsPage.bucketItemRow().should("have.length", 1)
bucketsPage.bucketItemName().should("have.text", ipfsBucketName)
bucketsPage.bucketFileSystemType().should("have.text", "IPFS MFS")

// ensure can't create a bucket with the same name
bucketsPage.createBucketButton().click()
createBucketModal.bucketNameInput().type(ipfsBucketName)
createBucketModal.submitButton().click()
createBucketModal.bucketNameInput().should("have.class", "error")
createBucketModal.cancelButton().click()

// open bucket and ensure header matches the expected value
bucketsPage.bucketItemName().dblclick()
bucketContentsPage.bucketHeaderLabel()
Expand Down