Allow access to clipboard in Cypress tests (#2147)
This commit is contained in:
parent
07098c3f5a
commit
297cb4677b
2 changed files with 15 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
import type PolicyRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyRepresentation";
|
||||
import type ResourceRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceRepresentation";
|
||||
import type ScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/scopeRepresentation";
|
||||
import grantClipboardAccess from "../../../../util/grantClipboardAccess";
|
||||
|
||||
type PermissionType = "resource" | "scope";
|
||||
|
||||
|
@ -133,6 +134,7 @@ export default class AuthorizationTab {
|
|||
}
|
||||
|
||||
copy() {
|
||||
grantClipboardAccess();
|
||||
cy.findByTestId(this.exportCopyButton).click();
|
||||
return this;
|
||||
}
|
||||
|
|
13
cypress/support/util/grantClipboardAccess.ts
Normal file
13
cypress/support/util/grantClipboardAccess.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
export default function grantClipboardAccess() {
|
||||
// Use the Chrome debugger protocol to grant access to the clipboard.
|
||||
// https://chromedevtools.github.io/devtools-protocol/tot/Browser/#method-grantPermissions
|
||||
cy.wrap(
|
||||
Cypress.automation("remote:debugger:protocol", {
|
||||
command: "Browser.grantPermissions",
|
||||
params: {
|
||||
permissions: ["clipboardReadWrite", "clipboardSanitizedWrite"],
|
||||
origin: window.location.origin,
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
Loading…
Reference in a new issue