mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 03:36:07 +03:00
f3f14afbbf
* Move spaces tests from Puppeteer to Cypress * Add missing fixture * Tweak synapsedocker to not double error on a docker failure * Fix space hierarchy loading race condition Fixes https://github.com/matrix-org/element-web-rageshakes/issues/10345 * Fix race condition when creating public space with url update code * Try Electron once more due to perms issues around clipboard * Try set browser permissions properly * Try to enable clipboard another way * Try electron again * Try electron again again * Switch to built-in cypress feature for file uploads * Mock clipboard instead * TMPDIR ftw? * uid:gid pls * Clipboard tests can now run on any browser due to mocking * Test Enter as well as button for space creation * Make the test actually work * Update cypress/support/util.ts Co-authored-by: Eric Eastwood <erice@element.io> Co-authored-by: Eric Eastwood <erice@element.io>
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
/*
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
/// <reference types="cypress" />
|
|
|
|
import Chainable = Cypress.Chainable;
|
|
|
|
// Mock the clipboard, as only Electron gives the app permission to the clipboard API by default
|
|
// Virtual clipboard
|
|
let copyText: string;
|
|
|
|
declare global {
|
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
namespace Cypress {
|
|
interface Chainable {
|
|
/**
|
|
* Mock the clipboard on the current window, ready for calling `getClipboardText`.
|
|
* Irreversible, refresh the window to restore mock.
|
|
*/
|
|
mockClipboard(): Chainable<AUTWindow>;
|
|
/**
|
|
* Read text from the mocked clipboard.
|
|
* @return {string} the clipboard text
|
|
*/
|
|
getClipboardText(): Chainable<string>;
|
|
}
|
|
}
|
|
}
|
|
|
|
Cypress.Commands.add("mockClipboard", () => {
|
|
cy.window({ log: false }).then(win => {
|
|
win.navigator.clipboard.writeText = (text) => {
|
|
copyText = text;
|
|
return Promise.resolve();
|
|
};
|
|
});
|
|
});
|
|
|
|
Cypress.Commands.add("getClipboardText", (): Chainable<string> => {
|
|
return cy.wrap(copyText);
|
|
});
|
|
|
|
// Needed to make this file a module
|
|
export { };
|