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

Add new session capability to storage tests #2045

Merged
merged 7 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 1 addition & 4 deletions packages/files-ui/cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@
// Import commands.js using ES2015 syntax:
import "./commands"

// the following gets rid of the exception "ResizeObserver loop limit exceeded"
// which someone on the internet says we can safely ignore
// source https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded
// returning false prevents Cypress from failing the test automatically
Cypress.on("uncaught:exception", () => {
/* returning false here prevents Cypress from failing the test */
return false
})

Expand Down
35 changes: 24 additions & 11 deletions packages/storage-ui/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface Web3LoginOptions {
withNewUser?: boolean
clearPins?: boolean
deleteFpsBuckets?: boolean
withNewSession?: boolean
}

Cypress.Commands.add("clearPins", apiTestHelper.clearPins)
Expand All @@ -57,7 +58,8 @@ Cypress.Commands.add(
url = localHost,
clearPins = false,
withNewUser = true,
deleteFpsBuckets = false
deleteFpsBuckets = false,
withNewSession = false
}: Web3LoginOptions = {}) => {

cy.on("window:before:load", (win) => {
Expand All @@ -74,16 +76,26 @@ Cypress.Commands.add(
})
})

// with nothing in localstorage (and in session storage)
// the whole login flow should kick in
cy.session("web3loginNewUser", () => {
cy.visit(url)
authenticationPage.web3Button().click()
authenticationPage.showMoreButton().click()
authenticationPage.detectedWallet().click()
authenticationPage.web3SignInButton().safeClick()
bucketsPage.bucketsHeaderLabel().should("be.visible")
})
if (withNewUser || withNewSession){
const sessionName = `web3loginNewUser-${withNewSession ? new Date().toString() : "0"}`
cy.session(sessionName, () => {
cy.visit(url)
authenticationPage.web3Button().click()
authenticationPage.showMoreButton().click()
authenticationPage.detectedWallet().click()
authenticationPage.web3SignInButton().safeClick()
bucketsPage.bucketsHeaderLabel().should("be.visible")
})
} else {
cy.session("web3loginTestUser", () => {
cy.visit(url)
authenticationPage.web3Button().click()
authenticationPage.showMoreButton().click()
authenticationPage.detectedWallet().click()
authenticationPage.web3SignInButton().safeClick()
bucketsPage.bucketsHeaderLabel().should("be.visible")
})
}

cy.visit(url)
bucketsPage.bucketsHeaderLabel().should("be.visible")
Expand Down Expand Up @@ -120,6 +132,7 @@ declare global {
* @param {String} options.url - (default: "http://localhost:3000") - what url to visit.
* @param {Boolean} options.withNewUser - (default: true) - whether to create a new user for this session.
* @param {Boolean} options.clearCSFBucket - (default: false) - whether any file in the csf bucket should be deleted.
* @param {Boolean} options.withNewSession - (default: false) - whether to create a new session.
*/
web3Login: (options?: Web3LoginOptions) => void

Expand Down
13 changes: 3 additions & 10 deletions packages/storage-ui/cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,9 @@
// Import commands.js using ES2015 syntax:
import "./commands"

// the following gets rid of the exception "ResizeObserver loop limit exceeded"
// which someone on the internet says we can safely ignore
// source https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded
Cypress.on("uncaught:exception", (err) => {
/* returning false here prevents Cypress from failing the test */
if (err.message.includes("ResizeObserver loop limit exceeded")) {
// returning false here prevents Cypress from
// failing the test
return false
}
// returning false prevents Cypress from failing the test automatically
Cypress.on("uncaught:exception", () => {
return false
})

// Hide fetch/XHR requests
Expand Down