From: Jeremy Thomas Date: Sat, 30 Oct 2021 22:10:31 +0000 (+0100) Subject: Add container tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74b9b1e665c185f3ae001b682bf61b5ef711a5f0;p=thirdparty%2Fbulma.git Add container tests --- diff --git a/cypress.json b/cypress.json index 25998d1a6..1fa27aadf 100644 --- a/cypress.json +++ b/cypress.json @@ -60,6 +60,14 @@ "scheme-main": "rgb(255, 255, 255)", "border": "rgb(219, 219, 219)", "text": "rgb(74, 74, 74)", - "text-strong": "rgb(54, 54, 54)" + "text-strong": "rgb(54, 54, 54)", + + "viewports": { + "mobile": [320, 480], + "tablet": [769, 640], + "desktop": [1024, 800], + "widescreen": [1216, 900], + "fullhd": [1408, 1200] + } } } diff --git a/cypress/integration/elements/container.spec.js b/cypress/integration/elements/container.spec.js new file mode 100644 index 000000000..1cc5059bd --- /dev/null +++ b/cypress/integration/elements/container.spec.js @@ -0,0 +1,169 @@ +describe("Elements/Container", () => { + beforeEach(() => { + cy.visit("http://127.0.0.1:4000/cypress/elements/container/"); + }); + + it("has a Container element", () => { + cy.get("#container").should("exist"); + }); + + it("has fullwidth mobile Containers", () => { + cy.viewport( + Cypress.env("viewports").mobile[0], + Cypress.env("viewports").mobile[1] + ); + + let viewport; + + cy.document() + .then((doc) => { + return doc.documentElement.getBoundingClientRect(); + }) + .then((rect) => { + viewport = rect; + }); + + cy.get("#container").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal(`${viewport.width}px`); + }); + + cy.get("#container-fluid").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal(`${viewport.width}px`); + }); + + cy.get("#container-max-desktop").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal(`${viewport.width}px`); + }); + + cy.get("#container-max-widescreen").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal(`${viewport.width}px`); + }); + }); + + it("has centered desktop Containers", () => { + cy.viewport( + Cypress.env("viewports").desktop[0], + Cypress.env("viewports").desktop[1] + ); + + let viewport; + + cy.document() + .then((doc) => { + return doc.documentElement.getBoundingClientRect(); + }) + .then((rect) => { + viewport = rect; + }); + + cy.get("#container").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal("960px"); + }); + + cy.get("#container-widescreen").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal(`${viewport.width}px`); + }); + + cy.get("#container-fullhd").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal(`${viewport.width}px`); + }); + }); + + it("has centered widescreen Containers", () => { + cy.viewport( + Cypress.env("viewports").widescreen[0], + Cypress.env("viewports").widescreen[1] + ); + + let viewport; + + cy.document() + .then((doc) => { + return doc.documentElement.getBoundingClientRect(); + }) + .then((rect) => { + viewport = rect; + }); + + cy.get("#container").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal("1152px"); + }); + + cy.get("#container-max-desktop").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal("960px"); + }); + + cy.get("#container-widescreen").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal("1152px"); + }); + + cy.get("#container-fullhd").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal(`${viewport.width}px`); + }); + }); + + it("has centered fullhd Containers", () => { + cy.viewport( + Cypress.env("viewports").fullhd[0], + Cypress.env("viewports").fullhd[1] + ); + + cy.get("#container").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal("1344px"); + }); + + cy.get("#container-max-desktop").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal("960px"); + }); + + cy.get("#container-max-widescreen").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal("1152px"); + }); + + cy.get("#container-widescreen").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal("1344px"); + }); + + cy.get("#container-fullhd").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal("1344px"); + }); + }); + + it("has a fullwidth fluid Container", () => { + cy.viewport( + Cypress.env("viewports").fullhd[0], + Cypress.env("viewports").fullhd[1] + ); + + let viewport; + + cy.document() + .then((doc) => { + return doc.documentElement.getBoundingClientRect(); + }) + .then((rect) => { + viewport = rect; + }); + + cy.get("#container-fluid").then(($) => { + const cs = window.getComputedStyle($[0]); + expect(cs.width).to.equal(`${viewport.width}px`); + }); + }); +}); diff --git a/docs/_layouts/cypress.html b/docs/_layouts/cypress.html index 0b16c9835..9906ea927 100644 --- a/docs/_layouts/cypress.html +++ b/docs/_layouts/cypress.html @@ -10,7 +10,7 @@ - + {{ content }} diff --git a/docs/bulma.scss b/docs/bulma.scss index 1292aa4cc..c04c1dbfb 100644 --- a/docs/bulma.scss +++ b/docs/bulma.scss @@ -1,2 +1,30 @@ @charset "utf-8"; @import "../bulma"; + +.yolo { + content: "default"; +} + +@include tablet { + .yolo { + content: "tablet"; + } +} + +@include desktop { + .yolo { + content: "desktop"; + } +} + +@include widescreen { + .yolo { + content: "widescreen"; + } +} + +@include fullhd { + .yolo { + content: "fullhd"; + } +} diff --git a/docs/css/bulma.css b/docs/css/bulma.css index 746d31d14..6a48de220 100644 --- a/docs/css/bulma.css +++ b/docs/css/bulma.css @@ -11788,3 +11788,31 @@ a.has-text-danger-dark:hover, a.has-text-danger-dark:focus { background-color: #fafafa; padding: 3rem 1.5rem 6rem; } + +.yolo { + content: "default"; +} + +@media screen and (min-width: 769px), print { + .yolo { + content: "tablet"; + } +} + +@media screen and (min-width: 1024px) { + .yolo { + content: "desktop"; + } +} + +@media screen and (min-width: 1216px) { + .yolo { + content: "widescreen"; + } +} + +@media screen and (min-width: 1408px) { + .yolo { + content: "fullhd"; + } +} diff --git a/docs/cypress/elements/container.html b/docs/cypress/elements/container.html new file mode 100644 index 000000000..15b40c454 --- /dev/null +++ b/docs/cypress/elements/container.html @@ -0,0 +1,28 @@ +--- +layout: cypress +title: Elements/Container +--- + +
+ I'm a container +
+ +
+ I'm a max desktop container +
+ +
+ I'm a max widescreen container +
+ +
+ I'm a widescreen container +
+ +
+ I'm a fullhd container +
+ +
+ I'm a fluid container +