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

Fix typing issues that appeared with cypress v9.1 upgrade #1791

Merged
merged 12 commits into from
Dec 1, 2021
17 changes: 11 additions & 6 deletions packages/files-ui/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

import { authenticationPage } from "./page-objects/authenticationPage"
import { apiTestHelper } from "./utils/apiTestHelper"
import { apiTestHelper, ClearBucketType } from "./utils/apiTestHelper"
import { ethers, Wallet } from "ethers"
import { homePage } from "./page-objects/homePage"
import { testPrivateKey, testAccountPassword, localHost } from "../fixtures/loginData"
import { CustomizedBridge } from "./utils/CustomBridge"
import "cypress-file-upload"
import "cypress-pipe"
import { BucketType } from "@chainsafe/files-api-client"
import { navigationMenu } from "./page-objects/navigationMenu"

Cypress.Commands.add("clearBucket", (bucketType: BucketType) => {
Cypress.Commands.add("clearBucket", (bucketType: ClearBucketType) => {
apiTestHelper.clearBucket(bucketType)
})

Expand Down Expand Up @@ -115,7 +114,7 @@ Cypress.Commands.add(
}
)

Cypress.Commands.add("safeClick", { prevSubject: "element" }, $element => {
Cypress.Commands.add("safeClick", { prevSubject: "element" }, ($element?: JQuery<HTMLElement>) => {
const click = ($el: JQuery<HTMLElement>) => $el.trigger("click")
return cy
.wrap($element)
Expand All @@ -139,7 +138,7 @@ declare global {
* @param {Boolean} options.deleteShareBucket - (default: false) - whether any shared bucket should be deleted.
* @example cy.web3Login({saveBrowser: true, url: 'http://localhost:8080'})
*/
web3Login: (options?: Web3LoginOptions) => Chainable
web3Login: (options?: Web3LoginOptions) => void

/**
* Use this when encountering race condition issues resulting in
Expand All @@ -153,8 +152,14 @@ declare global {
* https://github.com/cypress-io/cypress/issues/7306
*
*/
safeClick: () => Chainable
safeClick: ($element?: JQuery<HTMLElement>) => Chainable

/**
* Clear a bucket.
* @param {BucketType} - what bucket type to clear for this user.
* @example cy.clearBucket("csf")
*/
clearBucket: (bucketType: ClearBucketType) => void
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/files-ui/cypress/support/utils/apiTestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { homePage } from "../page-objects/homePage"
const API_BASE_USE = "https://stage.imploy.site/api/v1"
const REFRESH_TOKEN_KEY = "csf.refreshToken"

export type ClearBucketType = Exclude<BucketType, "share" | "pinning" | "fps">
const getApiClient = () => {
// Disable the internal Axios JSON deserialization as this is handled by the client
const axiosInstance = axios.create({ transformResponse: [] })
Expand Down Expand Up @@ -34,7 +35,7 @@ export const apiTestHelper = {
})
})
},
clearBucket(bucketType: BucketType) {
clearBucket(bucketType: ClearBucketType) {
const apiClient = getApiClient()

return new Cypress.Promise(async (resolve) => {
Expand Down