mirror of
https://github.com/mschuepbach/matrix-kernel-filter-calculator.git
synced 2026-01-15 21:12:14 +01:00
Add cypress
This commit is contained in:
38
cypress/e2e/calculator.cy.js
Normal file
38
cypress/e2e/calculator.cy.js
Normal file
@@ -0,0 +1,38 @@
|
||||
describe("Claculator", () => {
|
||||
beforeEach(() => {
|
||||
cy.visit("/");
|
||||
});
|
||||
|
||||
it("shows default calculation", () => {
|
||||
cy.get("[data-test=matrix] input").should("have.length", 16);
|
||||
cy.get("[data-test=kernel] input").should("have.length", 9);
|
||||
cy.get("[data-test=result] input").should("have.length", 16);
|
||||
});
|
||||
|
||||
it("shows result when matrix changes", () => {
|
||||
cy.get("[data-test=matrix] input").first().type(2);
|
||||
cy.get("[data-test=result] input").first().should("have.value", 5);
|
||||
});
|
||||
|
||||
it("shows result when kernel changes", () => {
|
||||
cy.get("[data-test=kernel] input").first().type(2);
|
||||
cy.get("[data-test=result] input").last().should("have.value", 5);
|
||||
});
|
||||
|
||||
it("can change matrix size", () => {
|
||||
cy.get("[data-test=matrix-size] input").first().type(2);
|
||||
cy.get("[data-test=matrix-size] input").last().type(2);
|
||||
cy.get("[data-test=matrix] input").should("have.length", 4);
|
||||
});
|
||||
|
||||
it("can change kernel size", () => {
|
||||
cy.get("[data-test=kernel-size] input").first().type(2);
|
||||
cy.get("[data-test=kernel-size] input").last().type(2);
|
||||
cy.get("[data-test=kernel] input").should("have.length", 4);
|
||||
});
|
||||
|
||||
it("can toggle padding", () => {
|
||||
cy.get("[data-test=padding]").click();
|
||||
cy.get("[data-test=result] input").should("have.length", 4);
|
||||
});
|
||||
});
|
||||
45
cypress/e2e/theme.cy.js
Normal file
45
cypress/e2e/theme.cy.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const visit = (darkAppearance) =>
|
||||
cy.visit("/", {
|
||||
onBeforeLoad(win) {
|
||||
cy.stub(win, "matchMedia")
|
||||
.withArgs("(prefers-color-scheme: dark)")
|
||||
.returns({
|
||||
matches: darkAppearance,
|
||||
addEventListener: () => {},
|
||||
removeEventListener: () => {},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const isDarkMode = () => {
|
||||
cy.get("html").should("have.attr", "theme", "dark");
|
||||
cy.get("html").should("have.css", "background-color", "rgb(51, 51, 51)");
|
||||
cy.get("html").should("have.css", "color", "rgb(238, 238, 238)");
|
||||
};
|
||||
|
||||
const isLightMode = () => {
|
||||
cy.get("html").should("have.attr", "theme", "light");
|
||||
cy.get("html").should("have.css", "background-color", "rgb(255, 255, 255)");
|
||||
cy.get("html").should("have.css", "color", "rgb(51, 51, 51)");
|
||||
};
|
||||
|
||||
describe("Theme", () => {
|
||||
it("is dark by default", () => {
|
||||
cy.visit("/");
|
||||
isDarkMode();
|
||||
});
|
||||
|
||||
it("is light if user has set it in the browser", () => {
|
||||
visit(false);
|
||||
isLightMode();
|
||||
});
|
||||
|
||||
it("can toggle", () => {
|
||||
visit(true);
|
||||
isDarkMode();
|
||||
cy.get("[data-test=toggle-theme]").click();
|
||||
isLightMode();
|
||||
cy.get("[data-test=toggle-theme]").click();
|
||||
isDarkMode();
|
||||
});
|
||||
});
|
||||
5
cypress/fixtures/example.json
Normal file
5
cypress/fixtures/example.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
||||
25
cypress/support/commands.js
Normal file
25
cypress/support/commands.js
Normal file
@@ -0,0 +1,25 @@
|
||||
// ***********************************************
|
||||
// This example commands.js shows you how to
|
||||
// create various custom commands and overwrite
|
||||
// existing commands.
|
||||
//
|
||||
// For more comprehensive examples of custom
|
||||
// commands please read more here:
|
||||
// https://on.cypress.io/custom-commands
|
||||
// ***********************************************
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
// Cypress.Commands.add('login', (email, password) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a dual command --
|
||||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||
20
cypress/support/e2e.js
Normal file
20
cypress/support/e2e.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// ***********************************************************
|
||||
// This example support/e2e.js is processed and
|
||||
// loaded automatically before your test files.
|
||||
//
|
||||
// This is a great place to put global configuration and
|
||||
// behavior that modifies Cypress.
|
||||
//
|
||||
// You can change the location of this file or turn off
|
||||
// automatically serving support files with the
|
||||
// 'supportFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/configuration
|
||||
// ***********************************************************
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands'
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
||||
Reference in New Issue
Block a user