Skip to content

Commit

Permalink
Start testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mpourismaiel committed Dec 1, 2019
1 parent 388019e commit aa3ad05
Show file tree
Hide file tree
Showing 13 changed files with 767 additions and 43 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
node_modules
yarn-error.log
exampleSite/public/*
cypress/videos
cypress/plugins
cypress/screenshots
cypress/support
3 changes: 3 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"baseUrl": "http://localhost:1313"
}
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
23 changes: 23 additions & 0 deletions cypress/integration/fragment-structure.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
describe("Fragment structure", () => {
it("should display fragments from global", () => {
cy.visit("/dev/fragment-fallthrough");
cy.get("#nav").should("have.length", 1);
cy.get("#hero").should("have.length", 1);
cy.get("#content").should("have.length", 1);
cy.get("#copyright").should("have.length", 1);
cy.get("#footer").should("have.length", 1);
});

it("should support fragment falltrough", () => {
cy.visit("/dev/fragment-fallthrough");
cy.get("#hero .hero-subtitle").should(
"contain",
"If you see this, directory fragment fallthrough is working"
);
cy.get("#content h2").should("contain", "Content fragment from Page");
cy.get("#copyright .copyright-notice").should(
"contain",
"This is loaded from globals of the current section"
);
});
});
8 changes: 8 additions & 0 deletions cypress/integration/list.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe("List fragment", () => {
it("should display pages from same, specific section, with subsections and with subsection leaves", () => {
cy.visit("/dev/list");
cy.get("#upper-leaves article").should("have.length", 4);
cy.get("#branches article").should("have.length", 6);
cy.get("#leaves article").should("have.length", 10);
});
});
14 changes: 14 additions & 0 deletions cypress/integration/navbar.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
describe("Navbar", () => {
it("should display proper breadcrumb", () => {
cy.visit("/dev");
cy.get(".breadcrumb li").should("have.length", 1);
cy.get(".breadcrumb li").should("contain", "Dev section");
cy.get(".breadcrumb li a").should("have.length", 0);

cy.visit("/dev/blog");
cy.get(".breadcrumb li").should("have.length", 2);
cy.get(".breadcrumb li:nth-child(1) a").should("have.length", 1);
cy.get(".breadcrumb li:nth-child(2)").should("contain", "Blog");
cy.get(".breadcrumb li:nth-child(2) a").should("have.length", 0);
});
});
28 changes: 28 additions & 0 deletions cypress/integration/resource-fallthrough.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
describe("Image Fallthrough", () => {
it("should display image from fragment", () => {
cy.visit("/dev/resource-fallthrough/fragment/");
cy.get("#hero .header-image").should(
"have.css",
"background-image",
'url("http://localhost:1313/dev/resource-fallthrough/fragment/hero/resource_logo.svg")'
);
});

it("should display image from page", () => {
cy.visit("/dev/resource-fallthrough/page/");
cy.get("#hero .header-image").should(
"have.css",
"background-image",
'url("http://localhost:1313/dev/resource-fallthrough/page/resource_logo.svg")'
);
});

it("should display image from global", () => {
cy.visit("/dev/resource-fallthrough/global/");
cy.get("#hero .header-image").should(
"have.css",
"background-image",
'url("http://localhost:1313/images/resource_logo.svg")'
);
});
});
17 changes: 17 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// 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)

module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
25 changes: 25 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -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 changes: 20 additions & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -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')
27 changes: 0 additions & 27 deletions exampleSite/layouts/partials/fragments/sample-custom-fragment.html

This file was deleted.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
"start": "npm run watch-js",
"build": "npm run build-js && npm run build-hugo",
"test:colors": "node _tests/colors-generator/index.js",
"test:alignments": "node _tests/align-generator/index.js"
"test:alignments": "node _tests/align-generator/index.js",
"cypress:open": "cypress open",
"cypress:run": "cypress run"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"concurrently": "^3.5.1",
"cypress": "^3.6.0",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"node-sass": "^4.8.3",
"style-loader": "^0.20.3",
Expand Down
Loading

0 comments on commit aa3ad05

Please sign in to comment.