mirror of
https://github.com/jgthms/bulma.git
synced 2025-01-09 15:44:25 +00:00
Setup Cypress tests for box and button
This commit is contained in:
parent
a6cd4f302e
commit
69a991ade1
65
cypress.json
Normal file
65
cypress.json
Normal file
@ -0,0 +1,65 @@
|
||||
{
|
||||
"env": {
|
||||
"black": "rgb(10, 10, 10)",
|
||||
"black-bis": "rgb(18, 18, 18)",
|
||||
"black-ter": "rgb(36, 36, 36)",
|
||||
"grey-darker": "rgb(54, 54, 54)",
|
||||
"grey-dark": "rgb(74, 74, 74)",
|
||||
"grey": "rgb(122, 122, 122)",
|
||||
"grey-light": "rgb(181, 181, 181)",
|
||||
"grey-lighter": "rgb(219, 219, 219)",
|
||||
"grey-lightest": "rgb(237, 237, 237)",
|
||||
"white-ter": "rgb(245, 245, 245)",
|
||||
"white-bis": "rgb(250, 250, 250)",
|
||||
"white": "rgb(255, 255, 255)",
|
||||
|
||||
"transparent": "rgba(0, 0, 0, 0)",
|
||||
"black-transparent": "rgba(0, 0, 0, 0.7)",
|
||||
|
||||
"orange": "rgb(255, 71, 15)",
|
||||
"yellow": "rgb(255, 224, 138)",
|
||||
"green": "rgb(72, 199, 142)",
|
||||
"turquoise": "rgb(0, 209, 178)",
|
||||
"cyan": "rgb(62, 142, 208)",
|
||||
"blue": "rgb(72, 95, 199)",
|
||||
"purple": "rgb(184, 107, 255)",
|
||||
"red": "rgb(241, 70, 104)",
|
||||
|
||||
"color-names": ["primary", "link", "info", "success", "warning", "danger"],
|
||||
|
||||
"primary": "rgb(0, 209, 178)",
|
||||
"primary-invert": "rgb(255, 255, 255)",
|
||||
"primary-light": "rgb(235, 255, 252)",
|
||||
"primary-dark": "rgb(0, 148, 126)",
|
||||
|
||||
"link": "rgb(72, 95, 199)",
|
||||
"link-invert": "rgb(255, 255, 255)",
|
||||
"link-light": "rgb(239, 241, 250)",
|
||||
"link-dark": "rgb(56, 80, 183)",
|
||||
|
||||
"info": "rgb(62, 142, 208)",
|
||||
"info-invert": "rgb(255, 255, 255)",
|
||||
"info-light": "rgb(239, 245, 251)",
|
||||
"info-dark": "rgb(41, 111, 168)",
|
||||
|
||||
"success": "rgb(72, 199, 142)",
|
||||
"success-invert": "rgb(255, 255, 255)",
|
||||
"success-light": "rgb(239, 250, 245)",
|
||||
"success-dark": "rgb(37, 121, 83)",
|
||||
|
||||
"warning": "rgb(255, 224, 138)",
|
||||
"warning-invert": "rgba(0, 0, 0, 0.7)",
|
||||
"warning-light": "rgb(255, 250, 235)",
|
||||
"warning-dark": "rgb(148, 108, 0)",
|
||||
|
||||
"danger": "rgb(241, 70, 104)",
|
||||
"danger-invert": "rgb(255, 255, 255)",
|
||||
"danger-light": "rgb(254, 236, 240)",
|
||||
"danger-dark": "rgb(204, 15, 53)",
|
||||
|
||||
"scheme-main": "rgb(255, 255, 255)",
|
||||
"border": "rgb(219, 219, 219)",
|
||||
"text": "rgb(74, 74, 74)",
|
||||
"text-strong": "rgb(54, 54, 54)"
|
||||
}
|
||||
}
|
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"
|
||||
}
|
2
cypress/integration/.gitignore
vendored
Normal file
2
cypress/integration/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
1-getting-started
|
||||
2-advanced-examples
|
23
cypress/integration/elements/box.spec.js
Normal file
23
cypress/integration/elements/box.spec.js
Normal file
@ -0,0 +1,23 @@
|
||||
describe("Elements/Box", () => {
|
||||
beforeEach(() => {
|
||||
cy.visit("http://127.0.0.1:4000/cypress/elements/box/");
|
||||
});
|
||||
|
||||
it("has a .box element", () => {
|
||||
cy.get(".box").should("exist");
|
||||
});
|
||||
|
||||
it("has a correct .box element", () => {
|
||||
cy.get(".box").then(($) => {
|
||||
const el = $[0];
|
||||
const cs = window.getComputedStyle(el);
|
||||
expect(cs.backgroundColor).to.equal(Cypress.env("scheme-main"));
|
||||
expect(cs.borderRadius).to.equal("6px");
|
||||
expect(cs.boxShadow).to.equal(
|
||||
"rgba(10, 10, 10, 0.1) 0px 8px 16px -2px, rgba(10, 10, 10, 0.02) 0px 0px 0px 1px"
|
||||
);
|
||||
expect(cs.color).to.equal(Cypress.env("text"));
|
||||
expect(cs.padding).to.equal("20px");
|
||||
});
|
||||
});
|
||||
});
|
124
cypress/integration/elements/button.spec.js
Normal file
124
cypress/integration/elements/button.spec.js
Normal file
@ -0,0 +1,124 @@
|
||||
describe("Elements/Button", () => {
|
||||
beforeEach(() => {
|
||||
cy.visit("http://127.0.0.1:4000/cypress/elements/button/");
|
||||
});
|
||||
|
||||
it("has a Button", () => {
|
||||
cy.get(".button").should("exist");
|
||||
});
|
||||
|
||||
it("has a correct Button", () => {
|
||||
cy.get("#button-default").then(($) => {
|
||||
const cs = window.getComputedStyle($[0]);
|
||||
expect(cs.backgroundColor).to.equal(Cypress.env("white"));
|
||||
expect(cs.borderColor).to.equal(Cypress.env("grey-lighter"));
|
||||
expect(cs.borderRadius).to.equal("4px");
|
||||
expect(cs.color).to.equal(Cypress.env("grey-darker"));
|
||||
expect(cs.height).to.equal("40px");
|
||||
expect(cs.lineHeight).to.equal("24px");
|
||||
expect(cs.padding).to.equal("7px 16px");
|
||||
});
|
||||
});
|
||||
|
||||
// States
|
||||
it("has a correct hover Button", () => {
|
||||
cy.get("#button-hover").then(($) => {
|
||||
const cs = window.getComputedStyle($[0]);
|
||||
expect(cs.backgroundColor).to.equal(Cypress.env("white"));
|
||||
expect(cs.borderColor).to.equal(Cypress.env("grey-light"));
|
||||
expect(cs.borderRadius).to.equal("4px");
|
||||
expect(cs.color).to.equal(Cypress.env("grey-darker"));
|
||||
expect(cs.height).to.equal("40px");
|
||||
expect(cs.lineHeight).to.equal("24px");
|
||||
expect(cs.padding).to.equal("7px 16px");
|
||||
});
|
||||
});
|
||||
|
||||
it("has a correct focus Button", () => {
|
||||
cy.get("#button-focus").then(($) => {
|
||||
const cs = window.getComputedStyle($[0]);
|
||||
expect(cs.backgroundColor).to.equal(Cypress.env("white"));
|
||||
expect(cs.borderColor).to.equal(Cypress.env("blue"));
|
||||
expect(cs.borderRadius).to.equal("4px");
|
||||
expect(cs.boxShadow).to.equal(
|
||||
`rgba${Cypress.env("blue").slice(3, -1)}, 0.25) 0px 0px 0px 2px`
|
||||
);
|
||||
expect(cs.color).to.equal(Cypress.env("grey-darker"));
|
||||
expect(cs.height).to.equal("40px");
|
||||
expect(cs.lineHeight).to.equal("24px");
|
||||
expect(cs.padding).to.equal("7px 16px");
|
||||
});
|
||||
});
|
||||
|
||||
// Colors
|
||||
it(`has correct color Buttons`, () => {
|
||||
for (let i = 0; i < Cypress.env("color-names").length; i++) {
|
||||
const name = Cypress.env("color-names")[i];
|
||||
const baseColor = Cypress.env(name);
|
||||
const invertColor = Cypress.env(`${name}-invert`);
|
||||
const lightColor = Cypress.env(`${name}-light`);
|
||||
const darkColor = Cypress.env(`${name}-dark`);
|
||||
|
||||
cy.get(`#button-${name}`).then(($) => {
|
||||
const cs = window.getComputedStyle($[0]);
|
||||
expect(cs.backgroundColor).to.equal(baseColor);
|
||||
expect(cs.borderColor).to.equal(Cypress.env("transparent"));
|
||||
expect(cs.color).to.equal(invertColor);
|
||||
});
|
||||
|
||||
cy.get(`#button-${name}-hover`).then(($) => {
|
||||
const cs = window.getComputedStyle($[0]);
|
||||
expect(cs.borderColor).to.equal(Cypress.env("transparent"));
|
||||
expect(cs.color).to.equal(invertColor);
|
||||
});
|
||||
|
||||
cy.get(`#button-${name}-focus`).then(($) => {
|
||||
const cs = window.getComputedStyle($[0]);
|
||||
expect(cs.boxShadow).to.equal(
|
||||
`rgba${baseColor.slice(3, -1)}, 0.25) 0px 0px 0px 2px`
|
||||
);
|
||||
expect(cs.borderColor).to.equal(Cypress.env("transparent"));
|
||||
expect(cs.color).to.equal(invertColor);
|
||||
});
|
||||
|
||||
cy.get(`#button-${name}-active`).then(($) => {
|
||||
const cs = window.getComputedStyle($[0]);
|
||||
expect(cs.borderColor).to.equal(Cypress.env("transparent"));
|
||||
expect(cs.color).to.equal(invertColor);
|
||||
});
|
||||
|
||||
cy.get(`#button-${name}-inverted`).then(($) => {
|
||||
const cs = window.getComputedStyle($[0]);
|
||||
expect(cs.backgroundColor).to.equal(invertColor);
|
||||
expect(cs.color).to.equal(baseColor);
|
||||
});
|
||||
|
||||
cy.get(`#button-${name}-outlined`).then(($) => {
|
||||
const cs = window.getComputedStyle($[0]);
|
||||
expect(cs.backgroundColor).to.equal(Cypress.env("transparent"));
|
||||
expect(cs.borderColor).to.equal(baseColor);
|
||||
expect(cs.color).to.equal(baseColor);
|
||||
});
|
||||
|
||||
cy.get(`#button-${name}-outlined-hover`).then(($) => {
|
||||
const cs = window.getComputedStyle($[0]);
|
||||
expect(cs.backgroundColor).to.equal(baseColor);
|
||||
expect(cs.borderColor).to.equal(baseColor);
|
||||
expect(cs.color).to.equal(invertColor);
|
||||
});
|
||||
|
||||
cy.get(`#button-${name}-inverted-outlined`).then(($) => {
|
||||
const cs = window.getComputedStyle($[0]);
|
||||
expect(cs.backgroundColor).to.equal(Cypress.env("transparent"));
|
||||
expect(cs.borderColor).to.equal(invertColor);
|
||||
expect(cs.color).to.equal(invertColor);
|
||||
});
|
||||
|
||||
cy.get(`#button-${name}-light`).then(($) => {
|
||||
const cs = window.getComputedStyle($[0]);
|
||||
expect(cs.backgroundColor).to.equal(lightColor);
|
||||
expect(cs.color).to.equal(darkColor);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
22
cypress/plugins/index.js
Normal file
22
cypress/plugins/index.js
Normal file
@ -0,0 +1,22 @@
|
||||
/// <reference types="cypress" />
|
||||
// ***********************************************************
|
||||
// This example plugins/index.js can be used to load plugins
|
||||
//
|
||||
// You can change the location of this file or turn off loading
|
||||
// the plugins file with the 'pluginsFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/plugins-guide
|
||||
// ***********************************************************
|
||||
|
||||
// This function is called when a project is opened or re-opened (e.g. due to
|
||||
// the project's config changing)
|
||||
|
||||
/**
|
||||
* @type {Cypress.PluginConfig}
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
module.exports = (on, config) => {
|
||||
// `on` is used to hook into various events Cypress emits
|
||||
// `config` is the resolved Cypress config
|
||||
}
|
31
cypress/support/commands.js
Normal file
31
cypress/support/commands.js
Normal file
@ -0,0 +1,31 @@
|
||||
// ***********************************************
|
||||
// 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) => { ... })
|
||||
|
||||
// function colorDarken(color, amount) {
|
||||
// return cy.wrap(color);
|
||||
// }
|
||||
|
||||
// Cypress.Commands.add("colorDarken", colorDarken);
|
20
cypress/support/index.js
Normal file
20
cypress/support/index.js
Normal file
@ -0,0 +1,20 @@
|
||||
// ***********************************************************
|
||||
// This example support/index.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')
|
16
docs/_layouts/cypress.html
Normal file
16
docs/_layouts/cypress.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>{% if page.fulltitle %}{{ page.fulltitle | markdownify | strip_html }}{% else %}{% if page.title %}{{ page.title | markdownify | strip_html }} | {% endif %}{{ site.data.meta.title | markdownify | strip_html }}{% endif %}</title>
|
||||
|
||||
<link rel="stylesheet" href="{{ site.url }}/vendor/fontawesome-free-5.15.2-web/css/all.min.css">
|
||||
<link rel="stylesheet" href="{{ site.url }}/css/bulma.css?v={{ site.time | date: "%Y%m%d%H%M" }}">
|
||||
</head>
|
||||
<body style="padding: 1.5rem;">
|
||||
{{ content }}
|
||||
</body>
|
||||
</html>
|
@ -9,13 +9,25 @@
|
||||
>
|
||||
{% include global/deprecated.html %}
|
||||
{{ content }}
|
||||
{% include global/footer.html %}
|
||||
{% include
|
||||
global/footer.html %}
|
||||
{% include global/scripts.html %}
|
||||
<div id="surveyModal" class="modal">
|
||||
<div class="modal-background"></div>
|
||||
<div class="modal-content">
|
||||
<div class="modal-card-body py-6 px-0 is-flex is-justify-content-center" style="border-radius: 0.5rem;">
|
||||
<iframe src="https://docs.google.com/forms/d/e/1FAIpQLSfnJaOck3NuWcuUT5eSk39_qEDa56DhWEU5BRsQ8u9tMfvPWg/viewform?embedded=true" width="600" height="600" frameborder="0" marginheight="0" marginwidth="0">Loading…</iframe>
|
||||
<div
|
||||
class="modal-card-body py-6 px-0 is-flex is-justify-content-center"
|
||||
style="border-radius: 0.5rem"
|
||||
>
|
||||
<iframe
|
||||
src="https://docs.google.com/forms/d/e/1FAIpQLSfnJaOck3NuWcuUT5eSk39_qEDa56DhWEU5BRsQ8u9tMfvPWg/viewform?embedded=true"
|
||||
width="600"
|
||||
height="600"
|
||||
frameborder="0"
|
||||
marginheight="0"
|
||||
marginwidth="0"
|
||||
>Loading…</iframe
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<button class="modal-close is-large" aria-label="close"></button>
|
||||
|
@ -32,6 +32,8 @@
|
||||
.bd-categories {
|
||||
--height: 1.25;
|
||||
|
||||
overflow-y: auto;
|
||||
max-height: 100vh;
|
||||
padding: var(--docs-side-padding);
|
||||
position: sticky;
|
||||
top: 0;
|
||||
|
2
docs/bulma.scss
vendored
Normal file
2
docs/bulma.scss
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
@charset "utf-8";
|
||||
@import "../bulma";
|
11790
docs/css/bulma.css
vendored
Normal file
11790
docs/css/bulma.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8
docs/cypress/elements/box.html
Normal file
8
docs/cypress/elements/box.html
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
layout: cypress
|
||||
title: Elements/Box
|
||||
---
|
||||
|
||||
<div class="box">
|
||||
I'm in a box.
|
||||
</div>
|
66
docs/cypress/elements/button.html
Normal file
66
docs/cypress/elements/button.html
Normal file
@ -0,0 +1,66 @@
|
||||
---
|
||||
layout: cypress
|
||||
title: Elements/Button
|
||||
---
|
||||
|
||||
<div class="block">
|
||||
<button id="button-default" class="button">
|
||||
Button
|
||||
</button>
|
||||
|
||||
<button id="button-hover" class="button is-hovered">
|
||||
Hover
|
||||
</button>
|
||||
|
||||
<button id="button-focus" class="button is-focused">
|
||||
Focus
|
||||
</button>
|
||||
|
||||
<button id="button-active" class="button is-active">
|
||||
Active
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{% for color in site.data.colors.justColors %}
|
||||
<div class="block">
|
||||
<button id="button-{{ color }}" class="button is-{{ color }}">
|
||||
{{ color | capitalize }}
|
||||
</button>
|
||||
|
||||
<button id="button-{{ color }}-hover" class="button is-hovered is-{{ color }}">
|
||||
Hover
|
||||
</button>
|
||||
|
||||
<button id="button-{{ color }}-focus" class="button is-focused is-{{ color }}">
|
||||
Focus
|
||||
</button>
|
||||
|
||||
<button id="button-{{ color }}-active" class="button is-active is-{{ color }}">
|
||||
Active
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="block">
|
||||
<button id="button-{{ color }}-outlined" class="button is-outlined is-{{ color }}">
|
||||
Outlined
|
||||
</button>
|
||||
|
||||
<button id="button-{{ color }}-outlined-hover" class="button is-outlined is-hovered is-{{ color }}">
|
||||
Hover
|
||||
</button>
|
||||
|
||||
<button id="button-{{ color }}-inverted" class="button is-inverted is-{{ color }}">
|
||||
Inverted
|
||||
</button>
|
||||
|
||||
<button id="button-{{ color }}-inverted-outlined" class="button is-inverted is-outlined is-{{ color }}">
|
||||
Inverted Outlined
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="block">
|
||||
<button id="button-{{ color }}-light" class="button is-light is-{{ color }}">
|
||||
Light
|
||||
</button>
|
||||
</div>
|
||||
{% endfor %}
|
@ -16,6 +16,8 @@
|
||||
"postcss-cli": "^7.1.0"
|
||||
},
|
||||
"scripts": {
|
||||
"bulma-sass": "node-sass --output-style expanded bulma.scss css/bulma.css",
|
||||
"bulma-watch": "npm run bulma-sass -- --watch",
|
||||
"css-build": "npm run css-sass && npm run css-autoprefix && npm run css-cleancss",
|
||||
"css-autoprefix": "postcss --use autoprefixer --map false --output css/bulma-docs.css css/bulma-docs.css",
|
||||
"css-cleancss": "cleancss -o css/bulma-docs.min.css css/bulma-docs.css",
|
||||
|
1132
package-lock.json
generated
1132
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,7 @@
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^9.8.6",
|
||||
"clean-css-cli": "^4.3.0",
|
||||
"cypress": "^8.7.0",
|
||||
"node-sass": "^4.14.1",
|
||||
"postcss-cli": "^7.1.2",
|
||||
"rimraf": "^3.0.2"
|
||||
|
Loading…
Reference in New Issue
Block a user