Allow access to clipboard in Cypress tests (#2147)

This commit is contained in:
Jon Koops 2022-02-24 16:47:06 +01:00 committed by GitHub
parent 07098c3f5a
commit 297cb4677b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -1,6 +1,7 @@
import type PolicyRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyRepresentation"; import type PolicyRepresentation from "@keycloak/keycloak-admin-client/lib/defs/policyRepresentation";
import type ResourceRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceRepresentation"; import type ResourceRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceRepresentation";
import type ScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/scopeRepresentation"; import type ScopeRepresentation from "@keycloak/keycloak-admin-client/lib/defs/scopeRepresentation";
import grantClipboardAccess from "../../../../util/grantClipboardAccess";
type PermissionType = "resource" | "scope"; type PermissionType = "resource" | "scope";
@ -133,6 +134,7 @@ export default class AuthorizationTab {
} }
copy() { copy() {
grantClipboardAccess();
cy.findByTestId(this.exportCopyButton).click(); cy.findByTestId(this.exportCopyButton).click();
return this; return this;
} }

View 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,
},
})
);
}