Remove find.ts and custom commands on Cypress Testing Library (#10544)
Signed-off-by: Suguru Hirahara <luixxiul@users.noreply.github.com>
This commit is contained in:
parent
b5493680ce
commit
5316bb58f7
3 changed files with 1 additions and 74 deletions
|
@ -38,4 +38,3 @@ import "./network";
|
||||||
import "./composer";
|
import "./composer";
|
||||||
import "./proxy";
|
import "./proxy";
|
||||||
import "./axe";
|
import "./axe";
|
||||||
import "./find";
|
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2023 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;
|
|
||||||
|
|
||||||
declare global {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
||||||
namespace Cypress {
|
|
||||||
interface Chainable {
|
|
||||||
/**
|
|
||||||
* Finds an element with the role "button".
|
|
||||||
*
|
|
||||||
* @param name - accessible name of the element to find
|
|
||||||
*/
|
|
||||||
findButton(name: string): Chainable<JQuery>;
|
|
||||||
/**
|
|
||||||
* Finds an element with the role "textbox".
|
|
||||||
*
|
|
||||||
* @param name - accessible name of the element to find
|
|
||||||
*/
|
|
||||||
findTextbox(name: string): Chainable<JQuery>;
|
|
||||||
/**
|
|
||||||
* Finds an element with the role "option".
|
|
||||||
*
|
|
||||||
* @param name - accessible name of the element to find
|
|
||||||
*/
|
|
||||||
findOption(name: string): Chainable<JQuery>;
|
|
||||||
/**
|
|
||||||
* Finds an element with the role "menuitem".
|
|
||||||
*
|
|
||||||
* @param name - accessible name of the element to find
|
|
||||||
*/
|
|
||||||
findMenuitem(name: string): Chainable<JQuery>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Cypress.Commands.add("findButton", (name: string): Chainable<JQuery> => {
|
|
||||||
return cy.findByRole("button", { name });
|
|
||||||
});
|
|
||||||
|
|
||||||
Cypress.Commands.add("findTextbox", (name: string): Chainable<JQuery> => {
|
|
||||||
return cy.findByRole("textbox", { name });
|
|
||||||
});
|
|
||||||
|
|
||||||
Cypress.Commands.add("findOption", (name: string): Chainable<JQuery> => {
|
|
||||||
return cy.findByRole("option", { name });
|
|
||||||
});
|
|
||||||
|
|
||||||
Cypress.Commands.add("findMenuitem", (name: string): Chainable<JQuery> => {
|
|
||||||
return cy.findByRole("menuitem", { name });
|
|
||||||
});
|
|
||||||
|
|
||||||
// Needed to make this file a module
|
|
||||||
export {};
|
|
|
@ -158,9 +158,7 @@ creation that can be called to set up tests.
|
||||||
|
|
||||||
Like for instance a user will not look for a button by querying a CSS selector. Instead you should work
|
Like for instance a user will not look for a button by querying a CSS selector. Instead you should work
|
||||||
with roles / labels etc.. You can make use of `cy.findBy…` queries provided by
|
with roles / labels etc.. You can make use of `cy.findBy…` queries provided by
|
||||||
[Cypress Testing Library](https://github.com/testing-library/cypress-testing-library) and some convencience
|
[Cypress Testing Library](https://github.com/testing-library/cypress-testing-library).
|
||||||
commands, such as `findButton(name)` or `findTextbox(name)`.
|
|
||||||
See [`/cypress/support/find.ts`](../cypress/support/find.ts) for a complete list.
|
|
||||||
|
|
||||||
### Using matrix-js-sdk
|
### Using matrix-js-sdk
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue