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

Programmatic folder creation for tests #1430

Merged
merged 9 commits into from
Aug 25, 2021

Conversation

Tbaut
Copy link
Collaborator

@Tbaut Tbaut commented Aug 10, 2021

closes #1410

@Tbaut Tbaut added the Status: Review Needed 👀 Added to PRs when they need more review label Aug 10, 2021
@github-actions github-actions bot added the Type: Feature Added to PRs to identify that the change is a new feature. label Aug 10, 2021
@render
Copy link

render bot commented Aug 10, 2021

@render
Copy link

render bot commented Aug 10, 2021

@render
Copy link

render bot commented Aug 10, 2021

@render
Copy link

render bot commented Aug 10, 2021

@asnaith
Copy link
Contributor

asnaith commented Aug 10, 2021

This is going to be great, thank you for doing this 😃

This is very useful and efficient to use in the scenarios when we need a folder as a requisite for a test but are not testing the folder creation directly.

@asnaith
Copy link
Contributor

asnaith commented Aug 10, 2021

I was just experimenting with this new functionality and found a few issues -

  1. If you use apiTestHelper.createFolder more than once in a test then only the first folder is created

  2. Sometimes a folder is there when the next test starts, it seems like the clearing does not always work now

  3. Sometimes a folder is not created at all

Perhaps for reliability the api test helper should confirm the intended creation / deletion was completed before exiting?

I was using this custom test to check the new command:

Cypress._.times(100, () => {
      it.only("Folder creation", () => {
        cy.web3Login({ clearCSFBucket: true, clearTrashBucket: true })

        apiTestHelper.createFolder("/test folder 1/subfolderA")
        homePage.fileItemRow().should("have.length", 1)
        apiTestHelper.createFolder("/test folder 2/subfolderB")
        homePage.fileItemRow().should("have.length", 2)
        apiTestHelper.createFolder("/test folder 3/subfolderC")
        homePage.fileItemRow().should("have.length", 3)
      })
    })

@Tbaut
Copy link
Collaborator Author

Tbaut commented Aug 11, 2021

@asnaith feel free to check my 5841a94 commit. I've tried to do the check after the folder elegantly, but it basically fails because of other things. I really think we need to get this flow together, I've added logs and when running the test we can see that they are fired in an order that doesn't work at all.

@asnaith
Copy link
Contributor

asnaith commented Aug 11, 2021

@Tbaut It's looking good in code but I can't get it to run successfully

Seeing this error which seems to come after trying to clear the bucket

Screen Shot 2021-08-11 at 4 26 17 PM

also this when trying to assert on the folder name

Screen Shot 2021-08-11 at 4 36 51 PM

I can look into it more tomorrow

@Tbaut Tbaut added Status: Changes Requested ❌ Added to PRs that require further changes from the contributor. and removed Status: Review Needed 👀 Added to PRs when they need more review labels Aug 12, 2021
@lgtm-com
Copy link

lgtm-com bot commented Aug 24, 2021

This pull request introduces 2 alerts when merging 2268162 into 51808aa - view on LGTM.com

new alerts:

  • 2 for Unused variable, import, function or class

@Tbaut Tbaut requested a review from asnaith August 24, 2021 14:41
@Tbaut Tbaut added Status: Review Needed 👀 Added to PRs when they need more review and removed Status: Changes Requested ❌ Added to PRs that require further changes from the contributor. labels Aug 24, 2021
@Tbaut
Copy link
Collaborator Author

Tbaut commented Aug 24, 2021

I managed to beat the monster. The trick is: use new Cypress.Promise. This makes sure that Cypress will wait for us to call the associated resolve before continuing. This way, we can actually do our calls the way we want. The logs that I left in the helper function show that everything is happening in the correct order, which wasn't the case before and was the origin of the race conditions we had.

@Tbaut Tbaut enabled auto-merge (squash) August 24, 2021 14:44
@Tbaut Tbaut merged commit d5347a7 into dev Aug 25, 2021
@Tbaut Tbaut deleted the feat/tbaut-programmatic-folder-creation-1410 branch August 25, 2021 01:27
@asnaith
Copy link
Contributor

asnaith commented Aug 25, 2021

This is fantastic, tried it out and it's working great! 🥳

The whole test suite is going to be more efficient and reliable with this in place. Thank you 🙏

@FSM1 FSM1 mentioned this pull request Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Review Needed 👀 Added to PRs when they need more review Type: Feature Added to PRs to identify that the change is a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a command in test to programmatically create a folder
3 participants