From 3b633ad57b2763052c57d0038450e51ee77d2cdb Mon Sep 17 00:00:00 2001 From: Mysteriedev Date: Sat, 5 Mar 2022 12:23:04 +0100 Subject: [PATCH 01/12] fix cy tests --- .../fixtures/01_setup/default-settings.yaml | 3 + .../01_setup/01-system-setup-signup.spec.js | 162 +++++ .../01_setup/02-initial-frontend.spec.js | 152 +++++ .../integration/03-system-settings.spec.js | 101 +++ cypress/integration/04-theme-settings.spec.js | 149 +++++ .../05-blox-editor.spec.js} | 614 +++++++++--------- cypress/integration/99-login.spec.js | 67 ++ cypress/plugins/index.js | 34 + cypress/support/commands.js | 25 + cypress/support/index.js | 20 + cypress/test01-system-setup.spec.js | 167 ----- cypress/test02-initial-frontend.spec.js | 145 ----- cypress/test03-system-settings.spec.js | 109 ---- cypress/test04-theme-settings.spec.js | 158 ----- cypress/test99-login.spec.js | 70 -- 15 files changed, 1020 insertions(+), 956 deletions(-) create mode 100644 cypress/fixtures/01_setup/default-settings.yaml create mode 100644 cypress/integration/01_setup/01-system-setup-signup.spec.js create mode 100644 cypress/integration/01_setup/02-initial-frontend.spec.js create mode 100644 cypress/integration/03-system-settings.spec.js create mode 100644 cypress/integration/04-theme-settings.spec.js rename cypress/{test05-blox-editor.spec.js => integration/05-blox-editor.spec.js} (96%) create mode 100644 cypress/integration/99-login.spec.js create mode 100644 cypress/plugins/index.js create mode 100644 cypress/support/commands.js create mode 100644 cypress/support/index.js delete mode 100644 cypress/test01-system-setup.spec.js delete mode 100644 cypress/test02-initial-frontend.spec.js delete mode 100644 cypress/test03-system-settings.spec.js delete mode 100644 cypress/test04-theme-settings.spec.js delete mode 100644 cypress/test99-login.spec.js diff --git a/cypress/fixtures/01_setup/default-settings.yaml b/cypress/fixtures/01_setup/default-settings.yaml new file mode 100644 index 0000000..1957802 --- /dev/null +++ b/cypress/fixtures/01_setup/default-settings.yaml @@ -0,0 +1,3 @@ +setup: true +language: en +welcome: true diff --git a/cypress/integration/01_setup/01-system-setup-signup.spec.js b/cypress/integration/01_setup/01-system-setup-signup.spec.js new file mode 100644 index 0000000..3dbb6c5 --- /dev/null +++ b/cypress/integration/01_setup/01-system-setup-signup.spec.js @@ -0,0 +1,162 @@ +describe("Typemill Setup with Signup", function() { + it("validates form input", function() { + // reset users and settings + cy.task("resetSetup"); + // visit setup form + cy.visit("/setup"); + // cy.visit('/setup',{ onBeforeLoad: (_contentWindow) => { Object.defineProperty(navigator, 'language', { value: 'fr-FR' }) } }) + cy.url().should("include", "/setup"); + + // add data and check attributes + cy.get('input[name="username"]') + .type("?1") + .should("have.value", "?1") + .and("have.attr", "required"); + + cy.get('input[name="email"]') + .type("trendschau.net") + .should("have.value", "trendschau.net") + .and("have.attr", "required"); + + cy.get('input[name="password"]') + .type("pass") + .should("have.value", "pass") + .and("have.attr", "required"); + + // submit and get validation errors + cy.get("form").submit(); + cy.get("#flash-message").should( + "contain", + "Please check your input and try again" + ); + cy.get(".error").should("contain", "invalid characters"); + cy.get(".error").should("contain", "e-mail is invalid"); + cy.get(".error").should("contain", "Length between 5 - 20"); + }); + + /* + it('fails without CSRF-token', function () + { + cy.request({ + method: 'POST', + url: '/setup', // baseUrl is prepended to url + form: true, // indicates the body should be form urlencoded and sets Content-Type: application/x-www-form-urlencoded headers + failOnStatusCode: false, + body: { + username: 'trendschau', + email: 'trendschau@gmail.com', + password: 'password' + } + }) + .its('body') + .should('include', 'The form has a timeout') + }) +*/ + it("fails without CSRF-token", function() { + cy.visit("/setup"); + + // enter correct data + cy.get('input[name="username"]').clear().type("trendschau"); + cy.get('input[name="email"]').clear().type("trendschau@gmail.com"); + cy.get('input[name="password"]').clear().type("password"); + cy.get("#csrf_value").then((elem) => { + elem.val("wrongvalue"); + }); + + // submit and get validation errors + cy.get("form").submit(); + cy.get("#flash-message").should("contain", "form has a timeout"); + }); + + it("submits valid form data and visit welcome and settings page", function() { + cy.visit("/setup"); + + // enter correct data + cy.get('input[name="username"]').clear().type("trendschau"); + cy.get('input[name="email"]').clear().type("trendschau@gmail.com"); + cy.get('input[name="password"]').clear().type("password"); + + // submits valid form + cy.get("form").submit(); + cy.url().should("include", "/welcome"); + cy.getCookie("typemill-session").should("exist"); + Cypress.Cookies.preserveOnce("typemill-session"); + + // clicks link on welcome page to settings page + // cy.get('.button').should('contain', 'Configure your website') + cy.get(".button").click(); + cy.url().should("include", "/tm/settings"); + }); + + it("creates default settings data", function() { + cy.get('input[name="settings[title]"]') + .should("have.value", "TYPEMILL") + .and("have.attr", "required"); + cy.get('input[name="settings[author]"]'); + cy.get('select[name="settings[copyright]"]'); + cy.get('input[name="settings[year]"]').should("have.attr", "required"); + cy.get('select[name="settings[language]"]'); + // cy.get('select[name="settings[langattr]"]') + cy.get('input[name="settings[sitemap]"]') + .should("have.value", `${Cypress.config().baseUrl}/cache/sitemap.xml`) + .and("have.attr", "readonly"); + cy.get('input[name="settings[logo]"]'); + cy.get('input[name="settings[deletelogo]"]'); + cy.get('input[name="settings[favicon]"]'); + cy.get('input[name="settings[deletefav]"]'); + cy.get('input[name="settings[headlineanchors]"]'); + cy.get('input[name="settings[editor]"]'); + + cy.get('select[name="settings[language]"]') + .select("en") + .should("have.value", "en"); + + cy.get("form").submit(); + cy.get("#flash-message").should("contain", "Settings are stored"); + + Cypress.Cookies.preserveOnce("typemill-session"); + }); + + it("creates default user data", function() { + cy.visit("/tm/user/trendschau"); + cy.url().should("include", "/tm/user/trendschau"); + cy.get('input[name="user[username]"]').should("have.value", "trendschau"); + cy.get('input[name="user[firstname]"]') + .clear() + .type("Sebastian") + .should("have.value", "Sebastian"); + cy.get('input[name="user[lastname]"]') + .clear() + .type("Schürmanns") + .should("have.value", "Schürmanns"); + cy.get('input[name="user[email]"]').should( + "have.value", + "trendschau@gmail.com" + ); + cy.get('select[name="user[userrole]"]').should( + "have.value", + "administrator" + ); + cy.get('input[name="user[password]"]').should("have.value", ""); + cy.get('input[name="user[newpassword]"]').should("have.value", ""); + + cy.get("#userform").submit(); + cy.get("#flash-message").should("contain", "Saved all changes"); + }); + + it("logouts out", function() { + // visits logout link + cy.visit("/tm/logout"); + cy.url().should("include", "/tm/login"); + + // tries to open setup form again and gets redirected to login + cy.visit("/setup"); + cy.url().should("include", "/login"); + }); + + it("redirects when tries to setup again", function() { + // tries to open setup form again and gets redirected to login + cy.visit("/setup"); + cy.url().should("include", "/login"); + }); +}); \ No newline at end of file diff --git a/cypress/integration/01_setup/02-initial-frontend.spec.js b/cypress/integration/01_setup/02-initial-frontend.spec.js new file mode 100644 index 0000000..d9b64bf --- /dev/null +++ b/cypress/integration/01_setup/02-initial-frontend.spec.js @@ -0,0 +1,152 @@ +describe("Typemill Initial Frontend", function() { + it("has startpage with navigation", function() { + /* visit homepage */ + cy.visit("/"); + + /* has startpage with headline */ + cy.get("h1").contains("Typemill"); + + /* has start and setup button */ + cy.get("nav") + .find("a") + .should(($a) => { + expect($a).to.have.length(11); + expect($a[0].href).to.match(/welcome/); + expect($a[1].href).to.match(/welcome\/setup-your-website/); + expect($a[2].href).to.match(/welcome\/manage-access/); + expect($a[3].href).to.match(/welcome\/write-content/); + expect($a[4].href).to.match(/welcome\/get-help/); + expect($a[5].href).to.match(/welcome\/markdown-test/); + expect($a[6].href).to.match(/cyanine-theme/); + expect($a[7].href).to.match(/cyanine-theme\/landingpage/); + expect($a[8].href).to.match(/cyanine-theme\/colors-and-fonts/); + expect($a[9].href).to.match(/cyanine-theme\/footer/); + expect($a[10].href).to.match(/cyanine-theme\/content-elements/); + }); + }); + + it("has error page", function() { + cy.request({ + url: "/error", + failOnStatusCode: false, + }).then((resp) => { + /* should return 404 not found */ + expect(resp.status).to.eq(404); + }); + + cy.visit("/error", { failOnStatusCode: false }); + cy.url().should("include", "/error"); + + cy.get("h1").contains("Not Found"); + }); + + it("has no access to cache files", function() { + cy.request({ + url: "/cache/structure.txt", + failOnStatusCode: false, + }).then((resp) => { + // redirect status code is 302 + expect(resp.status).to.eq(403); + }); + }); + + it("has no access to dashboard", function() { + cy.visit("/tm/settings"); + cy.url().should("include", "/tm/login"); + }); + + it("has proper markdown test page", function() { + cy.visit("/welcome/markdown-test"); + cy.url().should("include", "/welcome/markdown-test"); + + /* has navigation element */ + cy.get("nav").should("exist"); + + /* check if toc exists */ + cy.get(".TOC").within(($toc) => { + /* check if a certain link in toc exists */ + cy.get("a").eq(2).should("have.attr", "href", "#h-headlines"); + }); + + /* check if corresponding anchor exists */ + cy.get("#h-headlines").should("exist"); + + /* soft linebreaks */ + cy.get("br").should("exist"); + + /* emphasis */ + cy.get("em").should("exist"); + + /* strong */ + cy.get("strong").should("exist"); + + /* ordered list */ + cy.get("ol").should("exist"); + + /* linebreak */ + cy.get("hr").should("exist"); + + /* links exists? hard to test, any idea? We need to wrap it in a div... */ + + /* images */ + cy.get("img").eq(0).should("have.attr", "alt", "alt"); + cy.get("img") + .eq(0) + .should("have.attr", "src") + .should("include", "media/files/markdown.png"); + cy.get("figure") + .eq(2) + .should("have.id", "myid") + .and("have.class", "otherclass"); + cy.get("img") + .eq(2) + .should("have.attr", "alt", "alt-text") + .and("have.attr", "title", "my title") + .and("have.attr", "width", "150px"); + + /* blockquote */ + cy.get("blockquote").should("exist"); + + /* has navigation element */ + cy.get(".notice1").should("exist"); + cy.get(".notice2").should("exist"); + cy.get(".notice3").should("exist"); + + /* footnote */ + cy.get("sup").eq(0).should("have.id", "fnref1:1"); + cy.get("sup") + .eq(0) + .within(($sup) => { + cy.get("a") + .eq(0) + .should("have.attr", "href", "#fn%3A1") + .and("have.class", "footnote-ref"); + }); + + /* abbreviation */ + cy.get("abbr").should("exist"); + + /* definition list */ + cy.get("dl").should("exist"); + + /* table */ + cy.get("table").should("exist"); + + /* code */ + cy.get("pre").should("exist"); + cy.get("code").should("exist"); + + /* math */ + cy.get(".math").should("exist"); + + /* footnote end */ + cy.get(".footnotes").within(($footnotes) => { + cy.get("li").eq(0).should("have.id", "fn:1"); + cy.get("a") + .eq(0) + .should("have.class", "footnote-backref") + .and("have.attr", "href", "#fnref1%3A1") + .and("have.attr", "rev", "footnote"); + }); + }); +}); \ No newline at end of file diff --git a/cypress/integration/03-system-settings.spec.js b/cypress/integration/03-system-settings.spec.js new file mode 100644 index 0000000..ba6ee61 --- /dev/null +++ b/cypress/integration/03-system-settings.spec.js @@ -0,0 +1,101 @@ +describe("Typemill System Settings", function() { + before(function() { + cy.visit("/tm/login"); + cy.url().should("include", "/tm/login"); + + cy.get('input[name="username"]').type("trendschau"); + cy.get('input[name="password"]').type("password"); + + cy.get("form").submit(); + cy.url().should("include", "/tm/content"); + cy.getCookie("typemill-session").should("exist"); + + cy.visit("/tm/settings"); + cy.url().should("include", "/tm/settings"); + }); + + beforeEach(function() { + Cypress.Cookies.preserveOnce("typemill-session"); + }); + + it("validates the form", function() { + // fill out valid data + cy.get('input[name="settings[title]"]') + .clear() + .type("Cypress a').eq(0).click() - - /* Check dublicates cannot be made */ - - /* Check new page can be created */ - cy.get('.addNaviForm').within(($naviform) =>{ - - /* add Testpage into input */ - cy.get('input') - .clear() - .type('Testpage') - .should('have.value', 'Testpage') - - cy.get('.b-left').click() - }) - - /* get Navilist */ - cy.get('.navi-list') - .should('contain', 'Testpage') - .eq(2).find('a').should(($a) => { - expect($a).to.have.length(6) - expect($a[5].href).to.include('/welcome\/testpage') - }) - }) - - it('edits default content', function() - { - cy.visit('/tm/content/visual/welcome/testpage') - cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') - - cy.get('#blox').within(($blox) => { - - /* Change Title */ - cy.get('#blox-0').click() - cy.get("input") - .clear() - .type("This is my Testpage") - - cy.get(".edit").click() - cy.get('#blox-0').should("contain", "This is my Testpage") - - /* Change Text */ - cy.get('#blox-1').click() - cy.get("textarea") - .clear() - .type("This is the new paragraph for the first line with some text.") - - cy.get(".edit").click() - cy.get('#blox-1').should("contain", "new paragraph") - - }) - }) - - it('edits paragraph', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(0).click() - cy.get("textarea") - .type("This is a second paragraph.") - - /* save table */ - cy.get(".edit").click() - cy.get(".cancel").click() - - }) - - cy.get('#blox-2').should("contain", "second paragraph") - }) - }) - - it('edits headline', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(1).click() - cy.get("input") - .type("Second Level Headline") - - /* save block */ - cy.get(".edit").click() - - /* close new standard textarea */ - cy.get(".cancel").click() - - }) - - cy.get('#blox-3').should("contain", "Second Level Headline") - }) - }) - - it('edits unordered list', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(2).click() - cy.get("textarea") - .type("first list item{enter}second list item") - - /* save block */ - cy.get(".edit").click() - - /* close new standard textarea */ - cy.get(".cancel").click() - - }) - - cy.get('#blox-4').within(($block) => { - cy.get("li").should(($lis) => { - expect($lis).to.have.length(2) - expect($lis.eq(0)).to.contain('first list item') - }) - }) - }) - }) - - it('edits ordered list', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(3).click() - cy.get("textarea") - .type("first ordered item{enter}second ordered item") - - /* save block */ - cy.get(".edit").click() - - /* close new standard textarea */ - cy.get(".cancel").click() - - }) - - cy.get('#blox-5').within(($block) => { - cy.get("li").should(($lis) => { - expect($lis).to.have.length(2) - expect($lis.eq(0)).to.contain('first ordered item') - }) - }) - }) - }) - - it('edits table', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(4).click() - cy.get("table").within(($table) => { - - /* edit table head */ - cy.get("tr").eq(1).within(($row) => { - cy.get("th").eq(1).click() - .clear() - .type("first Headline") - cy.get("th").eq(2).click() - .clear() - .type("Second Headline") - }) - - /* edit first content row */ - cy.get("tr").eq(2).within(($row) => { - cy.get("td").eq(1).click() - .clear() - .type("Some") - cy.get("td").eq(2).click() - .clear() - .type("More") - }) - - /* edit second content row */ - cy.get("tr").eq(3).within(($row) => { - cy.get("td").eq(1).click() - .clear() - .type("Beautiful") - cy.get("td").eq(2).click() - .clear() - .type("Content") - }) - - /* add new column on the right */ - cy.get("tr").eq(0).within(($row) => { - cy.get("td").eq(2).click() - cy.get(".actionline").eq(0).click() - }) - }) - - cy.get("table").within(($table) => { - - /* edit second new column head */ - cy.get("tr").eq(1).within(($row) => { - cy.get("th").eq(3).click() - .clear() - .type("New Head") - }) - - /* edit second new column head */ - cy.get("tr").eq(2).within(($row) => { - cy.get("td").eq(3).click() - .clear() - .type("With") - }) - - /* edit second new column head */ - cy.get("tr").eq(3).within(($row) => { - cy.get("td").eq(3).click() - .clear() - .type("new Content") - }) - }) - - /* save table */ - cy.get(".edit").click() - - }) - - cy.get('#blox-6').should("contain", "Beautiful").click() - - cy.get('.editactive').within(($activeblock) => { - cy.get('.component').should("contain", "Beautiful") - }) - - }) - }) - - it('Publishes new page', function() - { - cy.visit('/tm/content/visual/welcome/testpage') - cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') - - cy.get('#publish').click().wait(500) - - cy.visit('/welcome/testpage') - cy.url().should('include','/welcome/testpage') - - cy.get('.cy-nav') - .should('contain', 'Testpage') - }) - - it('has sitemap xml', function () - { - cy.request({ - url: '/cache/sitemap.xml', - }) - .then((resp) => { - /* should return xml-format */ - expect(resp.headers).to.have.property('content-type','application/xml') - }) - }) - - it('Deletes new page', function() - { - cy.visit('/tm/content/visual/welcome/testpage') - cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') - - cy.get('.danger').click() - - cy.get('#modalWindow').within(($modal) => { - cy.get('button').click() - }) - - cy.visit('/tm/content/visual/welcome') - cy.get('.navi-list') - .not('contain', 'Testpage') - .eq(2).find('a').should(($a) => { - expect($a).to.have.length(5) - }) - }) +describe('Blox Editor', function() +{ + before(function () + { + cy.visit('/tm/login') + cy.url().should('include','/tm/login') + + cy.get('input[name="username"]').type('trendschau') + cy.get('input[name="password"]').type('password') + + cy.get('form').submit() + cy.url().should('include','/tm/content') + cy.getCookie('typemill-session').should('exist') + + cy.visit('/tm/content/visual') + cy.url().should('include','/tm\/content\/visual') + }) + + beforeEach(function () + { + Cypress.Cookies.preserveOnce('typemill-session') + }) + + it('creates new page', function() + { + // click on add element + cy.get('.addNaviItem > a').eq(0).click() + + /* Check dublicates cannot be made */ + + /* Check new page can be created */ + cy.get('.addNaviForm').within(($naviform) =>{ + + /* add Testpage into input */ + cy.get('input') + .clear() + .type('Testpage') + .should('have.value', 'Testpage') + + cy.get('.b-left').click() + }) + + /* get Navilist */ + cy.get('.navi-list') + .should('contain', 'Testpage') + .eq(2).find('a').should(($a) => { + expect($a).to.have.length(6) + expect($a[5].href).to.include('/welcome\/testpage') + }) + }) + + it('edits default content', function() + { + cy.visit('/tm/content/visual/welcome/testpage') + cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') + + cy.get('#blox').within(($blox) => { + + /* Change Title */ + cy.get('#blox-0').click() + cy.get("input") + .clear() + .type("This is my Testpage") + + cy.get(".edit").click() + cy.get('#blox-0').should("contain", "This is my Testpage") + + /* Change Text */ + cy.get('#blox-1').click() + cy.get("textarea") + .clear() + .type("This is the new paragraph for the first line with some text.") + + cy.get(".edit").click() + cy.get('#blox-1').should("contain", "new paragraph") + + }) + }) + + it('edits paragraph', function() + { + cy.get('#blox').within(($blox) => { + /* Get Format Bar */ + cy.get('.format-bar').within(($formats) => { + + /* Edit Table */ + cy.get("button").eq(0).click() + cy.get("textarea") + .type("This is a second paragraph.") + + /* save table */ + cy.get(".edit").click() + cy.get(".cancel").click() + + }) + + cy.get('#blox-2').should("contain", "second paragraph") + }) + }) + + it('edits headline', function() + { + cy.get('#blox').within(($blox) => { + /* Get Format Bar */ + cy.get('.format-bar').within(($formats) => { + + /* Edit Table */ + cy.get("button").eq(1).click() + cy.get("input") + .type("Second Level Headline") + + /* save block */ + cy.get(".edit").click() + + /* close new standard textarea */ + cy.get(".cancel").click() + + }) + + cy.get('#blox-3').should("contain", "Second Level Headline") + }) + }) + + it('edits unordered list', function() + { + cy.get('#blox').within(($blox) => { + /* Get Format Bar */ + cy.get('.format-bar').within(($formats) => { + + /* Edit Table */ + cy.get("button").eq(2).click() + cy.get("textarea") + .type("first list item{enter}second list item") + + /* save block */ + cy.get(".edit").click() + + /* close new standard textarea */ + cy.get(".cancel").click() + + }) + + cy.get('#blox-4').within(($block) => { + cy.get("li").should(($lis) => { + expect($lis).to.have.length(2) + expect($lis.eq(0)).to.contain('first list item') + }) + }) + }) + }) + + it('edits ordered list', function() + { + cy.get('#blox').within(($blox) => { + /* Get Format Bar */ + cy.get('.format-bar').within(($formats) => { + + /* Edit Table */ + cy.get("button").eq(3).click() + cy.get("textarea") + .type("first ordered item{enter}second ordered item") + + /* save block */ + cy.get(".edit").click() + + /* close new standard textarea */ + cy.get(".cancel").click() + + }) + + cy.get('#blox-5').within(($block) => { + cy.get("li").should(($lis) => { + expect($lis).to.have.length(2) + expect($lis.eq(0)).to.contain('first ordered item') + }) + }) + }) + }) + + it('edits table', function() + { + cy.get('#blox').within(($blox) => { + /* Get Format Bar */ + cy.get('.format-bar').within(($formats) => { + + /* Edit Table */ + cy.get("button").eq(4).click() + cy.get("table").within(($table) => { + + /* edit table head */ + cy.get("tr").eq(1).within(($row) => { + cy.get("th").eq(1).click() + .clear() + .type("first Headline") + cy.get("th").eq(2).click() + .clear() + .type("Second Headline") + }) + + /* edit first content row */ + cy.get("tr").eq(2).within(($row) => { + cy.get("td").eq(1).click() + .clear() + .type("Some") + cy.get("td").eq(2).click() + .clear() + .type("More") + }) + + /* edit second content row */ + cy.get("tr").eq(3).within(($row) => { + cy.get("td").eq(1).click() + .clear() + .type("Beautiful") + cy.get("td").eq(2).click() + .clear() + .type("Content") + }) + + /* add new column on the right */ + cy.get("tr").eq(0).within(($row) => { + cy.get("td").eq(2).click() + cy.get(".actionline").eq(0).click() + }) + }) + + cy.get("table").within(($table) => { + + /* edit second new column head */ + cy.get("tr").eq(1).within(($row) => { + cy.get("th").eq(3).click() + .clear() + .type("New Head") + }) + + /* edit second new column head */ + cy.get("tr").eq(2).within(($row) => { + cy.get("td").eq(3).click() + .clear() + .type("With") + }) + + /* edit second new column head */ + cy.get("tr").eq(3).within(($row) => { + cy.get("td").eq(3).click() + .clear() + .type("new Content") + }) + }) + + /* save table */ + cy.get(".edit").click() + + }) + + cy.get('#blox-6').should("contain", "Beautiful").click() + + cy.get('.editactive').within(($activeblock) => { + cy.get('.component').should("contain", "Beautiful") + }) + + }) + }) + + it('Publishes new page', function() + { + cy.visit('/tm/content/visual/welcome/testpage') + cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') + + cy.get('#publish').click().wait(500) + + cy.visit('/welcome/testpage') + cy.url().should('include','/welcome/testpage') + + cy.get('.cy-nav') + .should('contain', 'Testpage') + }) + + it('has sitemap xml', function () + { + cy.request({ + url: '/cache/sitemap.xml', + }) + .then((resp) => { + /* should return xml-format */ + expect(resp.headers).to.have.property('content-type','application/xml') + }) + }) + + it('Deletes new page', function() + { + cy.visit('/tm/content/visual/welcome/testpage') + cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') + + cy.get('.danger').click() + + cy.get('#modalWindow').within(($modal) => { + cy.get('button').click() + }) + + cy.visit('/tm/content/visual/welcome') + cy.get('.navi-list') + .not('contain', 'Testpage') + .eq(2).find('a').should(($a) => { + expect($a).to.have.length(5) + }) + }) }) \ No newline at end of file diff --git a/cypress/integration/99-login.spec.js b/cypress/integration/99-login.spec.js new file mode 100644 index 0000000..6428ee5 --- /dev/null +++ b/cypress/integration/99-login.spec.js @@ -0,0 +1,67 @@ +describe("Typemill Login", function() { + before(function() { + cy.clearCookies(); + }); + it("redirects if visits dashboard without login", function() { + cy.visit("/tm/content"); + cy.url().should("include", "/tm/login"); + }); + + it("submits a valid form and logout", function() { + // visits login page and adds valid input + cy.visit("/tm/login"); + cy.url().should("include", "/tm/login"); + + cy.get('input[name="username"]') + .type("trendschau") + .should("have.value", "trendschau") + .and("have.attr", "required"); + + cy.get('input[name="password"]') + .type("password") + .should("have.value", "password") + .and("have.attr", "required"); + + // can login + cy.get("form").submit(); + cy.url().should("include", "/tm/content"); + cy.getCookie("typemill-session").should("exist"); + + Cypress.Cookies.preserveOnce("typemill-session"); + }); + + it("redirects if visits login form when logged in", function() { + cy.visit("/tm/login"); + cy.url().should("include", "/tm/content"); + + Cypress.Cookies.preserveOnce("typemill-session"); + }); + + it("logs out", function() { + cy.contains("Logout").click(); + cy.url().should("include", "/tm/login"); + }); + + it("captcha after 1 fail", function() { + cy.visit("/tm/login"); + + // validation fails first + cy.get('input[name="username"]').clear().type("wrong"); + cy.get('input[name="password"]').clear().type("pass"); + cy.get("form").submit(); + cy.get("#flash-message").should("contain", "wrong password or username"); + cy.get('input[name="username"]').should("have.value", "wrong"); + cy.get('input[name="password"]').should("have.value", ""); + cy.get('input[name="captcha"]').should("have.value", ""); + + // captcha fails first + cy.get('input[name="username"]').clear().type("trendschau"); + cy.get('input[name="password"]').clear().type("password"); + cy.get('input[name="captcha"]').clear().type("wrong"); + cy.get("form").submit(); + cy.get("#flash-message").should("contain", "Captcha is wrong"); + cy.get('input[name="username"]').should("have.value", "trendschau"); + cy.get('input[name="password"]').should("have.value", ""); + cy.get('input[name="captcha"]').should("have.value", ""); + }); +}); \ No newline at end of file diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js new file mode 100644 index 0000000..5aaa3da --- /dev/null +++ b/cypress/plugins/index.js @@ -0,0 +1,34 @@ +const fs = require("fs"); + +/// +// *********************************************************** +// 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("task", { + resetSetup() { + fs.rmSync("settings/users", { recursive: true, force: true }); + fs.rmSync("settings/settings.yaml"); + fs.copyFileSync( + "cypress/fixtures/01_setup/default-settings.yaml", + "settings/settings.yaml" + ); + + return null; + }, + }); +}; \ No newline at end of file diff --git a/cypress/support/commands.js b/cypress/support/commands.js new file mode 100644 index 0000000..119ab03 --- /dev/null +++ b/cypress/support/commands.js @@ -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) => { ... }) diff --git a/cypress/support/index.js b/cypress/support/index.js new file mode 100644 index 0000000..d68db96 --- /dev/null +++ b/cypress/support/index.js @@ -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') diff --git a/cypress/test01-system-setup.spec.js b/cypress/test01-system-setup.spec.js deleted file mode 100644 index f0e3fba..0000000 --- a/cypress/test01-system-setup.spec.js +++ /dev/null @@ -1,167 +0,0 @@ -describe('Typemill Setup', function() -{ - it('validates form input', function () - { - // visit setup form - cy.visit('/setup') -// cy.visit('/setup',{ onBeforeLoad: (_contentWindow) => { Object.defineProperty(navigator, 'language', { value: 'fr-FR' }) } }) - cy.url().should('include','/setup') - - // add data and check attributes - cy.get('input[name="username"]') - .type('?1') - .should('have.value', '?1') - .and('have.attr', 'required') - - cy.get('input[name="email"]') - .type('trendschau.net') - .should('have.value', 'trendschau.net') - .and('have.attr', 'required') - - cy.get('input[name="password"]') - .type('pass') - .should('have.value', 'pass') - .and('have.attr', 'required') - - // submit and get validation errors - cy.get('form').submit() - cy.get('#flash-message').should('contain', 'Please check your input and try again') - cy.get('.error').should('contain', 'invalid characters') - cy.get('.error').should('contain', 'e-mail is invalid') - cy.get('.error').should('contain', 'Length between 5 - 20') - }) - -/* - it('fails without CSRF-token', function () - { - cy.request({ - method: 'POST', - url: '/setup', // baseUrl is prepended to url - form: true, // indicates the body should be form urlencoded and sets Content-Type: application/x-www-form-urlencoded headers - failOnStatusCode: false, - body: { - username: 'trendschau', - email: 'trendschau@gmail.com', - password: 'password' - } - }) - .its('body') - .should('include', 'The form has a timeout') - }) -*/ - it('fails without CSRF-token', function () - { - cy.visit('/setup') - - // enter correct data - cy.get('input[name="username"]').clear().type('trendschau') - cy.get('input[name="email"]').clear().type('trendschau@gmail.com') - cy.get('input[name="password"]').clear().type('password') - cy.get('#csrf_value').then(elem => { - elem.val('wrongvalue'); - }); - - // submit and get validation errors - cy.get('form').submit() - cy.get('#flash-message').should('contain', 'form has a timeout') - }) - - - it('submits valid form data and visit welcome and settings page', function () - { - cy.visit('/setup') - - // enter correct data - cy.get('input[name="username"]').clear().type('trendschau') - cy.get('input[name="email"]').clear().type('trendschau@gmail.com') - cy.get('input[name="password"]').clear().type('password') - - // submits valid form - cy.get('form').submit() - cy.url().should('include','/welcome') - cy.getCookie('typemill-session').should('exist') - Cypress.Cookies.preserveOnce('typemill-session') - - // clicks link on welcome page to settings page -// cy.get('.button').should('contain', 'Configure your website') - cy.get('.button').click() - cy.url().should('include', '/tm/settings') - }) - - it('creates default settings data', function() - { - cy.get('input[name="settings[title]"]') - .should('have.value', 'TYPEMILL') - .and('have.attr','required') - cy.get('input[name="settings[author]"]') - cy.get('select[name="settings[copyright]"]') - cy.get('input[name="settings[year]"]') - .should('have.attr', 'required') - cy.get('select[name="settings[language]"]') -// cy.get('select[name="settings[langattr]"]') - cy.get('input[name="settings[sitemap]"]') - .should('have.value', 'http://localhost/typemillTest/cache/sitemap.xml') - .and('have.attr','readonly') - cy.get('input[name="settings[logo]"]') - cy.get('input[name="settings[deletelogo]"]') - cy.get('input[name="settings[favicon]"]') - cy.get('input[name="settings[deletefav]"]') - cy.get('input[name="settings[headlineanchors]"]') - cy.get('input[name="settings[editor]"]') - - cy.get('select[name="settings[language]"]') - .select('en') - .should('have.value', 'en') - - cy.get('form').submit() - cy.get('#flash-message').should('contain', 'Settings are stored') - - Cypress.Cookies.preserveOnce('typemill-session') - }) - - it('creates default user data', function() - { - cy.visit('/tm/user/trendschau') - cy.url().should('include', '/tm/user/trendschau') - cy.get('input[name="user[username]"]') - .should('have.value', 'trendschau') - cy.get('input[name="user[firstname]"]') - .clear() - .type('Sebastian') - .should('have.value', 'Sebastian') - cy.get('input[name="user[lastname]"]') - .clear() - .type('Schürmanns') - .should('have.value', 'Schürmanns') - cy.get('input[name="user[email]"]') - .should('have.value', 'trendschau@gmail.com') - cy.get('select[name="user[userrole]"]') - .should('have.value','administrator') - cy.get('input[name="user[password]"]') - .should('have.value', '') - cy.get('input[name="user[newpassword]"]') - .should('have.value', '') - - cy.get('#userform').submit() - cy.get('#flash-message').should('contain', 'Saved all changes') - - }) - - it('logouts out', function() - { - // visits logout link - cy.visit('/tm/logout') - cy.url().should('include', '/tm/login') - - // tries to open setup form again and gets redirected to login - cy.visit('/setup') - cy.url().should('include','/login') - }) - - it('redirects when tries to setup again', function() - { - // tries to open setup form again and gets redirected to login - cy.visit('/setup') - cy.url().should('include','/login') - }) -}) \ No newline at end of file diff --git a/cypress/test02-initial-frontend.spec.js b/cypress/test02-initial-frontend.spec.js deleted file mode 100644 index 220f534..0000000 --- a/cypress/test02-initial-frontend.spec.js +++ /dev/null @@ -1,145 +0,0 @@ -describe('Typemill Initial Frontend', function() -{ - it('has startpage with navigation', function () - { - /* visit homepage */ - cy.visit('/') - - /* has startpage with headline */ - cy.get('h1').contains("Typemill") - - /* has start and setup button */ - cy.get('nav').find('a').should(($a) => { - expect($a).to.have.length(11) - expect($a[0].href).to.match(/welcome/) - expect($a[1].href).to.match(/welcome\/setup-your-website/) - expect($a[2].href).to.match(/welcome\/manage-access/) - expect($a[3].href).to.match(/welcome\/write-content/) - expect($a[4].href).to.match(/welcome\/get-help/) - expect($a[5].href).to.match(/welcome\/markdown-test/) - expect($a[6].href).to.match(/cyanine-theme/) - expect($a[7].href).to.match(/cyanine-theme\/landingpage/) - expect($a[8].href).to.match(/cyanine-theme\/colors-and-fonts/) - expect($a[9].href).to.match(/cyanine-theme\/footer/) - expect($a[10].href).to.match(/cyanine-theme\/content-elements/) - }) - }) - - it('has error page', function () - { - cy.request({ - url: '/error', - failOnStatusCode: false, - }) - .then((resp) => { - /* should return 404 not found */ - expect(resp.status).to.eq(404) - }) - - cy.visit('/error', { failOnStatusCode: false }) - cy.url().should('include','/error') - - cy.get('h1').contains('Not Found') - }) - - it('has no access to cache files', function () - { - cy.request({ - url: '/cache/structure.txt', - failOnStatusCode: false, - }) - .then((resp) => { - // redirect status code is 302 - expect(resp.status).to.eq(403) - }) - }) - - it('has no access to dashboard', function () - { - cy.visit('/tm/settings') - cy.url().should('include','/tm/login') - }) - - it('has proper markdown test page', function () - { - cy.visit('/welcome/markdown-test') - cy.url().should('include','/welcome/markdown-test') - - /* has navigation element */ - cy.get('nav').should('exist') - - /* check if toc exists */ - cy.get('.TOC').within(($toc) =>{ - /* check if a certain link in toc exists */ - cy.get('a').eq(2).should('have.attr', 'href', '#h-headlines') - }) - - /* check if corresponding anchor exists */ - cy.get('#h-headlines').should('exist') - - /* soft linebreaks */ - cy.get('br').should('exist') - - /* emphasis */ - cy.get('em').should('exist') - - /* strong */ - cy.get('strong').should('exist') - - /* ordered list */ - cy.get('ol').should('exist') - - /* linebreak */ - cy.get('hr').should('exist') - - /* links exists? hard to test, any idea? We need to wrap it in a div... */ - - /* images */ - cy.get('img').eq(0).should('have.attr', 'alt', 'alt') - cy.get('img').eq(0).should('have.attr', 'src').should('include','media/files/markdown.png') - cy.get('figure').eq(2).should('have.id', 'myid') - .and('have.class', 'otherclass') - cy.get('img').eq(2).should('have.attr', 'alt', 'alt-text') - .and('have.attr', 'title', 'my title') - .and('have.attr', 'width', '150px') - - /* blockquote */ - cy.get('blockquote').should('exist') - - /* has navigation element */ - cy.get('.notice1').should('exist') - cy.get('.notice2').should('exist') - cy.get('.notice3').should('exist') - - /* footnote */ - cy.get('sup').eq(0).should('have.id', 'fnref1:1') - cy.get('sup').eq(0).within(($sup) =>{ - cy.get('a').eq(0).should('have.attr', 'href', '#fn%3A1') - .and('have.class', 'footnote-ref') - }) - - /* abbreviation */ - cy.get('abbr').should('exist') - - /* definition list */ - cy.get('dl').should('exist') - - /* table */ - cy.get('table').should('exist') - - /* code */ - cy.get('pre').should('exist') - cy.get('code').should('exist') - - /* math */ - cy.get('.math').should('exist') - - /* footnote end */ - cy.get('.footnotes').within(($footnotes) => { - cy.get('li').eq(0).should('have.id', 'fn:1') - cy.get('a').eq(0).should('have.class', 'footnote-backref') - .and('have.attr', 'href', '#fnref1%3A1') - .and('have.attr', 'rev', 'footnote') - }) - }) -}) \ No newline at end of file diff --git a/cypress/test03-system-settings.spec.js b/cypress/test03-system-settings.spec.js deleted file mode 100644 index 4211609..0000000 --- a/cypress/test03-system-settings.spec.js +++ /dev/null @@ -1,109 +0,0 @@ -describe('Typemill System Settings', function() -{ - before(function () - { - cy.visit('/tm/login') - cy.url().should('include','/tm/login') - - cy.get('input[name="username"]').type('trendschau') - cy.get('input[name="password"]').type('password') - - cy.get('form').submit() - cy.url().should('include','/tm/content') - cy.getCookie('typemill-session').should('exist') - - cy.visit('/tm/settings') - cy.url().should('include','/tm/settings') - }) - - beforeEach(function () - { - Cypress.Cookies.preserveOnce('typemill-session') - }) - - it('validates the form', function() - { - // fill out valid data - cy.get('input[name="settings[title]"]') - .clear() - .type('Cypress Date: Sat, 5 Mar 2022 12:42:16 +0100 Subject: [PATCH 02/12] Revert "fix cy tests" This reverts commit 3b633ad57b2763052c57d0038450e51ee77d2cdb. --- .../fixtures/01_setup/default-settings.yaml | 3 - .../01_setup/01-system-setup-signup.spec.js | 162 ----- .../01_setup/02-initial-frontend.spec.js | 152 ----- .../integration/03-system-settings.spec.js | 101 --- cypress/integration/04-theme-settings.spec.js | 149 ----- cypress/integration/99-login.spec.js | 67 -- cypress/plugins/index.js | 34 - cypress/support/commands.js | 25 - cypress/support/index.js | 20 - cypress/test01-system-setup.spec.js | 167 +++++ cypress/test02-initial-frontend.spec.js | 145 +++++ cypress/test03-system-settings.spec.js | 109 ++++ cypress/test04-theme-settings.spec.js | 158 +++++ ...tor.spec.js => test05-blox-editor.spec.js} | 614 +++++++++--------- cypress/test99-login.spec.js | 70 ++ 15 files changed, 956 insertions(+), 1020 deletions(-) delete mode 100644 cypress/fixtures/01_setup/default-settings.yaml delete mode 100644 cypress/integration/01_setup/01-system-setup-signup.spec.js delete mode 100644 cypress/integration/01_setup/02-initial-frontend.spec.js delete mode 100644 cypress/integration/03-system-settings.spec.js delete mode 100644 cypress/integration/04-theme-settings.spec.js delete mode 100644 cypress/integration/99-login.spec.js delete mode 100644 cypress/plugins/index.js delete mode 100644 cypress/support/commands.js delete mode 100644 cypress/support/index.js create mode 100644 cypress/test01-system-setup.spec.js create mode 100644 cypress/test02-initial-frontend.spec.js create mode 100644 cypress/test03-system-settings.spec.js create mode 100644 cypress/test04-theme-settings.spec.js rename cypress/{integration/05-blox-editor.spec.js => test05-blox-editor.spec.js} (96%) create mode 100644 cypress/test99-login.spec.js diff --git a/cypress/fixtures/01_setup/default-settings.yaml b/cypress/fixtures/01_setup/default-settings.yaml deleted file mode 100644 index 1957802..0000000 --- a/cypress/fixtures/01_setup/default-settings.yaml +++ /dev/null @@ -1,3 +0,0 @@ -setup: true -language: en -welcome: true diff --git a/cypress/integration/01_setup/01-system-setup-signup.spec.js b/cypress/integration/01_setup/01-system-setup-signup.spec.js deleted file mode 100644 index 3dbb6c5..0000000 --- a/cypress/integration/01_setup/01-system-setup-signup.spec.js +++ /dev/null @@ -1,162 +0,0 @@ -describe("Typemill Setup with Signup", function() { - it("validates form input", function() { - // reset users and settings - cy.task("resetSetup"); - // visit setup form - cy.visit("/setup"); - // cy.visit('/setup',{ onBeforeLoad: (_contentWindow) => { Object.defineProperty(navigator, 'language', { value: 'fr-FR' }) } }) - cy.url().should("include", "/setup"); - - // add data and check attributes - cy.get('input[name="username"]') - .type("?1") - .should("have.value", "?1") - .and("have.attr", "required"); - - cy.get('input[name="email"]') - .type("trendschau.net") - .should("have.value", "trendschau.net") - .and("have.attr", "required"); - - cy.get('input[name="password"]') - .type("pass") - .should("have.value", "pass") - .and("have.attr", "required"); - - // submit and get validation errors - cy.get("form").submit(); - cy.get("#flash-message").should( - "contain", - "Please check your input and try again" - ); - cy.get(".error").should("contain", "invalid characters"); - cy.get(".error").should("contain", "e-mail is invalid"); - cy.get(".error").should("contain", "Length between 5 - 20"); - }); - - /* - it('fails without CSRF-token', function () - { - cy.request({ - method: 'POST', - url: '/setup', // baseUrl is prepended to url - form: true, // indicates the body should be form urlencoded and sets Content-Type: application/x-www-form-urlencoded headers - failOnStatusCode: false, - body: { - username: 'trendschau', - email: 'trendschau@gmail.com', - password: 'password' - } - }) - .its('body') - .should('include', 'The form has a timeout') - }) -*/ - it("fails without CSRF-token", function() { - cy.visit("/setup"); - - // enter correct data - cy.get('input[name="username"]').clear().type("trendschau"); - cy.get('input[name="email"]').clear().type("trendschau@gmail.com"); - cy.get('input[name="password"]').clear().type("password"); - cy.get("#csrf_value").then((elem) => { - elem.val("wrongvalue"); - }); - - // submit and get validation errors - cy.get("form").submit(); - cy.get("#flash-message").should("contain", "form has a timeout"); - }); - - it("submits valid form data and visit welcome and settings page", function() { - cy.visit("/setup"); - - // enter correct data - cy.get('input[name="username"]').clear().type("trendschau"); - cy.get('input[name="email"]').clear().type("trendschau@gmail.com"); - cy.get('input[name="password"]').clear().type("password"); - - // submits valid form - cy.get("form").submit(); - cy.url().should("include", "/welcome"); - cy.getCookie("typemill-session").should("exist"); - Cypress.Cookies.preserveOnce("typemill-session"); - - // clicks link on welcome page to settings page - // cy.get('.button').should('contain', 'Configure your website') - cy.get(".button").click(); - cy.url().should("include", "/tm/settings"); - }); - - it("creates default settings data", function() { - cy.get('input[name="settings[title]"]') - .should("have.value", "TYPEMILL") - .and("have.attr", "required"); - cy.get('input[name="settings[author]"]'); - cy.get('select[name="settings[copyright]"]'); - cy.get('input[name="settings[year]"]').should("have.attr", "required"); - cy.get('select[name="settings[language]"]'); - // cy.get('select[name="settings[langattr]"]') - cy.get('input[name="settings[sitemap]"]') - .should("have.value", `${Cypress.config().baseUrl}/cache/sitemap.xml`) - .and("have.attr", "readonly"); - cy.get('input[name="settings[logo]"]'); - cy.get('input[name="settings[deletelogo]"]'); - cy.get('input[name="settings[favicon]"]'); - cy.get('input[name="settings[deletefav]"]'); - cy.get('input[name="settings[headlineanchors]"]'); - cy.get('input[name="settings[editor]"]'); - - cy.get('select[name="settings[language]"]') - .select("en") - .should("have.value", "en"); - - cy.get("form").submit(); - cy.get("#flash-message").should("contain", "Settings are stored"); - - Cypress.Cookies.preserveOnce("typemill-session"); - }); - - it("creates default user data", function() { - cy.visit("/tm/user/trendschau"); - cy.url().should("include", "/tm/user/trendschau"); - cy.get('input[name="user[username]"]').should("have.value", "trendschau"); - cy.get('input[name="user[firstname]"]') - .clear() - .type("Sebastian") - .should("have.value", "Sebastian"); - cy.get('input[name="user[lastname]"]') - .clear() - .type("Schürmanns") - .should("have.value", "Schürmanns"); - cy.get('input[name="user[email]"]').should( - "have.value", - "trendschau@gmail.com" - ); - cy.get('select[name="user[userrole]"]').should( - "have.value", - "administrator" - ); - cy.get('input[name="user[password]"]').should("have.value", ""); - cy.get('input[name="user[newpassword]"]').should("have.value", ""); - - cy.get("#userform").submit(); - cy.get("#flash-message").should("contain", "Saved all changes"); - }); - - it("logouts out", function() { - // visits logout link - cy.visit("/tm/logout"); - cy.url().should("include", "/tm/login"); - - // tries to open setup form again and gets redirected to login - cy.visit("/setup"); - cy.url().should("include", "/login"); - }); - - it("redirects when tries to setup again", function() { - // tries to open setup form again and gets redirected to login - cy.visit("/setup"); - cy.url().should("include", "/login"); - }); -}); \ No newline at end of file diff --git a/cypress/integration/01_setup/02-initial-frontend.spec.js b/cypress/integration/01_setup/02-initial-frontend.spec.js deleted file mode 100644 index d9b64bf..0000000 --- a/cypress/integration/01_setup/02-initial-frontend.spec.js +++ /dev/null @@ -1,152 +0,0 @@ -describe("Typemill Initial Frontend", function() { - it("has startpage with navigation", function() { - /* visit homepage */ - cy.visit("/"); - - /* has startpage with headline */ - cy.get("h1").contains("Typemill"); - - /* has start and setup button */ - cy.get("nav") - .find("a") - .should(($a) => { - expect($a).to.have.length(11); - expect($a[0].href).to.match(/welcome/); - expect($a[1].href).to.match(/welcome\/setup-your-website/); - expect($a[2].href).to.match(/welcome\/manage-access/); - expect($a[3].href).to.match(/welcome\/write-content/); - expect($a[4].href).to.match(/welcome\/get-help/); - expect($a[5].href).to.match(/welcome\/markdown-test/); - expect($a[6].href).to.match(/cyanine-theme/); - expect($a[7].href).to.match(/cyanine-theme\/landingpage/); - expect($a[8].href).to.match(/cyanine-theme\/colors-and-fonts/); - expect($a[9].href).to.match(/cyanine-theme\/footer/); - expect($a[10].href).to.match(/cyanine-theme\/content-elements/); - }); - }); - - it("has error page", function() { - cy.request({ - url: "/error", - failOnStatusCode: false, - }).then((resp) => { - /* should return 404 not found */ - expect(resp.status).to.eq(404); - }); - - cy.visit("/error", { failOnStatusCode: false }); - cy.url().should("include", "/error"); - - cy.get("h1").contains("Not Found"); - }); - - it("has no access to cache files", function() { - cy.request({ - url: "/cache/structure.txt", - failOnStatusCode: false, - }).then((resp) => { - // redirect status code is 302 - expect(resp.status).to.eq(403); - }); - }); - - it("has no access to dashboard", function() { - cy.visit("/tm/settings"); - cy.url().should("include", "/tm/login"); - }); - - it("has proper markdown test page", function() { - cy.visit("/welcome/markdown-test"); - cy.url().should("include", "/welcome/markdown-test"); - - /* has navigation element */ - cy.get("nav").should("exist"); - - /* check if toc exists */ - cy.get(".TOC").within(($toc) => { - /* check if a certain link in toc exists */ - cy.get("a").eq(2).should("have.attr", "href", "#h-headlines"); - }); - - /* check if corresponding anchor exists */ - cy.get("#h-headlines").should("exist"); - - /* soft linebreaks */ - cy.get("br").should("exist"); - - /* emphasis */ - cy.get("em").should("exist"); - - /* strong */ - cy.get("strong").should("exist"); - - /* ordered list */ - cy.get("ol").should("exist"); - - /* linebreak */ - cy.get("hr").should("exist"); - - /* links exists? hard to test, any idea? We need to wrap it in a div... */ - - /* images */ - cy.get("img").eq(0).should("have.attr", "alt", "alt"); - cy.get("img") - .eq(0) - .should("have.attr", "src") - .should("include", "media/files/markdown.png"); - cy.get("figure") - .eq(2) - .should("have.id", "myid") - .and("have.class", "otherclass"); - cy.get("img") - .eq(2) - .should("have.attr", "alt", "alt-text") - .and("have.attr", "title", "my title") - .and("have.attr", "width", "150px"); - - /* blockquote */ - cy.get("blockquote").should("exist"); - - /* has navigation element */ - cy.get(".notice1").should("exist"); - cy.get(".notice2").should("exist"); - cy.get(".notice3").should("exist"); - - /* footnote */ - cy.get("sup").eq(0).should("have.id", "fnref1:1"); - cy.get("sup") - .eq(0) - .within(($sup) => { - cy.get("a") - .eq(0) - .should("have.attr", "href", "#fn%3A1") - .and("have.class", "footnote-ref"); - }); - - /* abbreviation */ - cy.get("abbr").should("exist"); - - /* definition list */ - cy.get("dl").should("exist"); - - /* table */ - cy.get("table").should("exist"); - - /* code */ - cy.get("pre").should("exist"); - cy.get("code").should("exist"); - - /* math */ - cy.get(".math").should("exist"); - - /* footnote end */ - cy.get(".footnotes").within(($footnotes) => { - cy.get("li").eq(0).should("have.id", "fn:1"); - cy.get("a") - .eq(0) - .should("have.class", "footnote-backref") - .and("have.attr", "href", "#fnref1%3A1") - .and("have.attr", "rev", "footnote"); - }); - }); -}); \ No newline at end of file diff --git a/cypress/integration/03-system-settings.spec.js b/cypress/integration/03-system-settings.spec.js deleted file mode 100644 index ba6ee61..0000000 --- a/cypress/integration/03-system-settings.spec.js +++ /dev/null @@ -1,101 +0,0 @@ -describe("Typemill System Settings", function() { - before(function() { - cy.visit("/tm/login"); - cy.url().should("include", "/tm/login"); - - cy.get('input[name="username"]').type("trendschau"); - cy.get('input[name="password"]').type("password"); - - cy.get("form").submit(); - cy.url().should("include", "/tm/content"); - cy.getCookie("typemill-session").should("exist"); - - cy.visit("/tm/settings"); - cy.url().should("include", "/tm/settings"); - }); - - beforeEach(function() { - Cypress.Cookies.preserveOnce("typemill-session"); - }); - - it("validates the form", function() { - // fill out valid data - cy.get('input[name="settings[title]"]') - .clear() - .type("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("task", { - resetSetup() { - fs.rmSync("settings/users", { recursive: true, force: true }); - fs.rmSync("settings/settings.yaml"); - fs.copyFileSync( - "cypress/fixtures/01_setup/default-settings.yaml", - "settings/settings.yaml" - ); - - return null; - }, - }); -}; \ No newline at end of file diff --git a/cypress/support/commands.js b/cypress/support/commands.js deleted file mode 100644 index 119ab03..0000000 --- a/cypress/support/commands.js +++ /dev/null @@ -1,25 +0,0 @@ -// *********************************************** -// 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) => { ... }) diff --git a/cypress/support/index.js b/cypress/support/index.js deleted file mode 100644 index d68db96..0000000 --- a/cypress/support/index.js +++ /dev/null @@ -1,20 +0,0 @@ -// *********************************************************** -// 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') diff --git a/cypress/test01-system-setup.spec.js b/cypress/test01-system-setup.spec.js new file mode 100644 index 0000000..f0e3fba --- /dev/null +++ b/cypress/test01-system-setup.spec.js @@ -0,0 +1,167 @@ +describe('Typemill Setup', function() +{ + it('validates form input', function () + { + // visit setup form + cy.visit('/setup') +// cy.visit('/setup',{ onBeforeLoad: (_contentWindow) => { Object.defineProperty(navigator, 'language', { value: 'fr-FR' }) } }) + cy.url().should('include','/setup') + + // add data and check attributes + cy.get('input[name="username"]') + .type('?1') + .should('have.value', '?1') + .and('have.attr', 'required') + + cy.get('input[name="email"]') + .type('trendschau.net') + .should('have.value', 'trendschau.net') + .and('have.attr', 'required') + + cy.get('input[name="password"]') + .type('pass') + .should('have.value', 'pass') + .and('have.attr', 'required') + + // submit and get validation errors + cy.get('form').submit() + cy.get('#flash-message').should('contain', 'Please check your input and try again') + cy.get('.error').should('contain', 'invalid characters') + cy.get('.error').should('contain', 'e-mail is invalid') + cy.get('.error').should('contain', 'Length between 5 - 20') + }) + +/* + it('fails without CSRF-token', function () + { + cy.request({ + method: 'POST', + url: '/setup', // baseUrl is prepended to url + form: true, // indicates the body should be form urlencoded and sets Content-Type: application/x-www-form-urlencoded headers + failOnStatusCode: false, + body: { + username: 'trendschau', + email: 'trendschau@gmail.com', + password: 'password' + } + }) + .its('body') + .should('include', 'The form has a timeout') + }) +*/ + it('fails without CSRF-token', function () + { + cy.visit('/setup') + + // enter correct data + cy.get('input[name="username"]').clear().type('trendschau') + cy.get('input[name="email"]').clear().type('trendschau@gmail.com') + cy.get('input[name="password"]').clear().type('password') + cy.get('#csrf_value').then(elem => { + elem.val('wrongvalue'); + }); + + // submit and get validation errors + cy.get('form').submit() + cy.get('#flash-message').should('contain', 'form has a timeout') + }) + + + it('submits valid form data and visit welcome and settings page', function () + { + cy.visit('/setup') + + // enter correct data + cy.get('input[name="username"]').clear().type('trendschau') + cy.get('input[name="email"]').clear().type('trendschau@gmail.com') + cy.get('input[name="password"]').clear().type('password') + + // submits valid form + cy.get('form').submit() + cy.url().should('include','/welcome') + cy.getCookie('typemill-session').should('exist') + Cypress.Cookies.preserveOnce('typemill-session') + + // clicks link on welcome page to settings page +// cy.get('.button').should('contain', 'Configure your website') + cy.get('.button').click() + cy.url().should('include', '/tm/settings') + }) + + it('creates default settings data', function() + { + cy.get('input[name="settings[title]"]') + .should('have.value', 'TYPEMILL') + .and('have.attr','required') + cy.get('input[name="settings[author]"]') + cy.get('select[name="settings[copyright]"]') + cy.get('input[name="settings[year]"]') + .should('have.attr', 'required') + cy.get('select[name="settings[language]"]') +// cy.get('select[name="settings[langattr]"]') + cy.get('input[name="settings[sitemap]"]') + .should('have.value', 'http://localhost/typemillTest/cache/sitemap.xml') + .and('have.attr','readonly') + cy.get('input[name="settings[logo]"]') + cy.get('input[name="settings[deletelogo]"]') + cy.get('input[name="settings[favicon]"]') + cy.get('input[name="settings[deletefav]"]') + cy.get('input[name="settings[headlineanchors]"]') + cy.get('input[name="settings[editor]"]') + + cy.get('select[name="settings[language]"]') + .select('en') + .should('have.value', 'en') + + cy.get('form').submit() + cy.get('#flash-message').should('contain', 'Settings are stored') + + Cypress.Cookies.preserveOnce('typemill-session') + }) + + it('creates default user data', function() + { + cy.visit('/tm/user/trendschau') + cy.url().should('include', '/tm/user/trendschau') + cy.get('input[name="user[username]"]') + .should('have.value', 'trendschau') + cy.get('input[name="user[firstname]"]') + .clear() + .type('Sebastian') + .should('have.value', 'Sebastian') + cy.get('input[name="user[lastname]"]') + .clear() + .type('Schürmanns') + .should('have.value', 'Schürmanns') + cy.get('input[name="user[email]"]') + .should('have.value', 'trendschau@gmail.com') + cy.get('select[name="user[userrole]"]') + .should('have.value','administrator') + cy.get('input[name="user[password]"]') + .should('have.value', '') + cy.get('input[name="user[newpassword]"]') + .should('have.value', '') + + cy.get('#userform').submit() + cy.get('#flash-message').should('contain', 'Saved all changes') + + }) + + it('logouts out', function() + { + // visits logout link + cy.visit('/tm/logout') + cy.url().should('include', '/tm/login') + + // tries to open setup form again and gets redirected to login + cy.visit('/setup') + cy.url().should('include','/login') + }) + + it('redirects when tries to setup again', function() + { + // tries to open setup form again and gets redirected to login + cy.visit('/setup') + cy.url().should('include','/login') + }) +}) \ No newline at end of file diff --git a/cypress/test02-initial-frontend.spec.js b/cypress/test02-initial-frontend.spec.js new file mode 100644 index 0000000..220f534 --- /dev/null +++ b/cypress/test02-initial-frontend.spec.js @@ -0,0 +1,145 @@ +describe('Typemill Initial Frontend', function() +{ + it('has startpage with navigation', function () + { + /* visit homepage */ + cy.visit('/') + + /* has startpage with headline */ + cy.get('h1').contains("Typemill") + + /* has start and setup button */ + cy.get('nav').find('a').should(($a) => { + expect($a).to.have.length(11) + expect($a[0].href).to.match(/welcome/) + expect($a[1].href).to.match(/welcome\/setup-your-website/) + expect($a[2].href).to.match(/welcome\/manage-access/) + expect($a[3].href).to.match(/welcome\/write-content/) + expect($a[4].href).to.match(/welcome\/get-help/) + expect($a[5].href).to.match(/welcome\/markdown-test/) + expect($a[6].href).to.match(/cyanine-theme/) + expect($a[7].href).to.match(/cyanine-theme\/landingpage/) + expect($a[8].href).to.match(/cyanine-theme\/colors-and-fonts/) + expect($a[9].href).to.match(/cyanine-theme\/footer/) + expect($a[10].href).to.match(/cyanine-theme\/content-elements/) + }) + }) + + it('has error page', function () + { + cy.request({ + url: '/error', + failOnStatusCode: false, + }) + .then((resp) => { + /* should return 404 not found */ + expect(resp.status).to.eq(404) + }) + + cy.visit('/error', { failOnStatusCode: false }) + cy.url().should('include','/error') + + cy.get('h1').contains('Not Found') + }) + + it('has no access to cache files', function () + { + cy.request({ + url: '/cache/structure.txt', + failOnStatusCode: false, + }) + .then((resp) => { + // redirect status code is 302 + expect(resp.status).to.eq(403) + }) + }) + + it('has no access to dashboard', function () + { + cy.visit('/tm/settings') + cy.url().should('include','/tm/login') + }) + + it('has proper markdown test page', function () + { + cy.visit('/welcome/markdown-test') + cy.url().should('include','/welcome/markdown-test') + + /* has navigation element */ + cy.get('nav').should('exist') + + /* check if toc exists */ + cy.get('.TOC').within(($toc) =>{ + /* check if a certain link in toc exists */ + cy.get('a').eq(2).should('have.attr', 'href', '#h-headlines') + }) + + /* check if corresponding anchor exists */ + cy.get('#h-headlines').should('exist') + + /* soft linebreaks */ + cy.get('br').should('exist') + + /* emphasis */ + cy.get('em').should('exist') + + /* strong */ + cy.get('strong').should('exist') + + /* ordered list */ + cy.get('ol').should('exist') + + /* linebreak */ + cy.get('hr').should('exist') + + /* links exists? hard to test, any idea? We need to wrap it in a div... */ + + /* images */ + cy.get('img').eq(0).should('have.attr', 'alt', 'alt') + cy.get('img').eq(0).should('have.attr', 'src').should('include','media/files/markdown.png') + cy.get('figure').eq(2).should('have.id', 'myid') + .and('have.class', 'otherclass') + cy.get('img').eq(2).should('have.attr', 'alt', 'alt-text') + .and('have.attr', 'title', 'my title') + .and('have.attr', 'width', '150px') + + /* blockquote */ + cy.get('blockquote').should('exist') + + /* has navigation element */ + cy.get('.notice1').should('exist') + cy.get('.notice2').should('exist') + cy.get('.notice3').should('exist') + + /* footnote */ + cy.get('sup').eq(0).should('have.id', 'fnref1:1') + cy.get('sup').eq(0).within(($sup) =>{ + cy.get('a').eq(0).should('have.attr', 'href', '#fn%3A1') + .and('have.class', 'footnote-ref') + }) + + /* abbreviation */ + cy.get('abbr').should('exist') + + /* definition list */ + cy.get('dl').should('exist') + + /* table */ + cy.get('table').should('exist') + + /* code */ + cy.get('pre').should('exist') + cy.get('code').should('exist') + + /* math */ + cy.get('.math').should('exist') + + /* footnote end */ + cy.get('.footnotes').within(($footnotes) => { + cy.get('li').eq(0).should('have.id', 'fn:1') + cy.get('a').eq(0).should('have.class', 'footnote-backref') + .and('have.attr', 'href', '#fnref1%3A1') + .and('have.attr', 'rev', 'footnote') + }) + }) +}) \ No newline at end of file diff --git a/cypress/test03-system-settings.spec.js b/cypress/test03-system-settings.spec.js new file mode 100644 index 0000000..4211609 --- /dev/null +++ b/cypress/test03-system-settings.spec.js @@ -0,0 +1,109 @@ +describe('Typemill System Settings', function() +{ + before(function () + { + cy.visit('/tm/login') + cy.url().should('include','/tm/login') + + cy.get('input[name="username"]').type('trendschau') + cy.get('input[name="password"]').type('password') + + cy.get('form').submit() + cy.url().should('include','/tm/content') + cy.getCookie('typemill-session').should('exist') + + cy.visit('/tm/settings') + cy.url().should('include','/tm/settings') + }) + + beforeEach(function () + { + Cypress.Cookies.preserveOnce('typemill-session') + }) + + it('validates the form', function() + { + // fill out valid data + cy.get('input[name="settings[title]"]') + .clear() + .type('Cypress a').eq(0).click() - - /* Check dublicates cannot be made */ - - /* Check new page can be created */ - cy.get('.addNaviForm').within(($naviform) =>{ - - /* add Testpage into input */ - cy.get('input') - .clear() - .type('Testpage') - .should('have.value', 'Testpage') - - cy.get('.b-left').click() - }) - - /* get Navilist */ - cy.get('.navi-list') - .should('contain', 'Testpage') - .eq(2).find('a').should(($a) => { - expect($a).to.have.length(6) - expect($a[5].href).to.include('/welcome\/testpage') - }) - }) - - it('edits default content', function() - { - cy.visit('/tm/content/visual/welcome/testpage') - cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') - - cy.get('#blox').within(($blox) => { - - /* Change Title */ - cy.get('#blox-0').click() - cy.get("input") - .clear() - .type("This is my Testpage") - - cy.get(".edit").click() - cy.get('#blox-0').should("contain", "This is my Testpage") - - /* Change Text */ - cy.get('#blox-1').click() - cy.get("textarea") - .clear() - .type("This is the new paragraph for the first line with some text.") - - cy.get(".edit").click() - cy.get('#blox-1').should("contain", "new paragraph") - - }) - }) - - it('edits paragraph', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(0).click() - cy.get("textarea") - .type("This is a second paragraph.") - - /* save table */ - cy.get(".edit").click() - cy.get(".cancel").click() - - }) - - cy.get('#blox-2').should("contain", "second paragraph") - }) - }) - - it('edits headline', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(1).click() - cy.get("input") - .type("Second Level Headline") - - /* save block */ - cy.get(".edit").click() - - /* close new standard textarea */ - cy.get(".cancel").click() - - }) - - cy.get('#blox-3').should("contain", "Second Level Headline") - }) - }) - - it('edits unordered list', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(2).click() - cy.get("textarea") - .type("first list item{enter}second list item") - - /* save block */ - cy.get(".edit").click() - - /* close new standard textarea */ - cy.get(".cancel").click() - - }) - - cy.get('#blox-4').within(($block) => { - cy.get("li").should(($lis) => { - expect($lis).to.have.length(2) - expect($lis.eq(0)).to.contain('first list item') - }) - }) - }) - }) - - it('edits ordered list', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(3).click() - cy.get("textarea") - .type("first ordered item{enter}second ordered item") - - /* save block */ - cy.get(".edit").click() - - /* close new standard textarea */ - cy.get(".cancel").click() - - }) - - cy.get('#blox-5').within(($block) => { - cy.get("li").should(($lis) => { - expect($lis).to.have.length(2) - expect($lis.eq(0)).to.contain('first ordered item') - }) - }) - }) - }) - - it('edits table', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(4).click() - cy.get("table").within(($table) => { - - /* edit table head */ - cy.get("tr").eq(1).within(($row) => { - cy.get("th").eq(1).click() - .clear() - .type("first Headline") - cy.get("th").eq(2).click() - .clear() - .type("Second Headline") - }) - - /* edit first content row */ - cy.get("tr").eq(2).within(($row) => { - cy.get("td").eq(1).click() - .clear() - .type("Some") - cy.get("td").eq(2).click() - .clear() - .type("More") - }) - - /* edit second content row */ - cy.get("tr").eq(3).within(($row) => { - cy.get("td").eq(1).click() - .clear() - .type("Beautiful") - cy.get("td").eq(2).click() - .clear() - .type("Content") - }) - - /* add new column on the right */ - cy.get("tr").eq(0).within(($row) => { - cy.get("td").eq(2).click() - cy.get(".actionline").eq(0).click() - }) - }) - - cy.get("table").within(($table) => { - - /* edit second new column head */ - cy.get("tr").eq(1).within(($row) => { - cy.get("th").eq(3).click() - .clear() - .type("New Head") - }) - - /* edit second new column head */ - cy.get("tr").eq(2).within(($row) => { - cy.get("td").eq(3).click() - .clear() - .type("With") - }) - - /* edit second new column head */ - cy.get("tr").eq(3).within(($row) => { - cy.get("td").eq(3).click() - .clear() - .type("new Content") - }) - }) - - /* save table */ - cy.get(".edit").click() - - }) - - cy.get('#blox-6').should("contain", "Beautiful").click() - - cy.get('.editactive').within(($activeblock) => { - cy.get('.component').should("contain", "Beautiful") - }) - - }) - }) - - it('Publishes new page', function() - { - cy.visit('/tm/content/visual/welcome/testpage') - cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') - - cy.get('#publish').click().wait(500) - - cy.visit('/welcome/testpage') - cy.url().should('include','/welcome/testpage') - - cy.get('.cy-nav') - .should('contain', 'Testpage') - }) - - it('has sitemap xml', function () - { - cy.request({ - url: '/cache/sitemap.xml', - }) - .then((resp) => { - /* should return xml-format */ - expect(resp.headers).to.have.property('content-type','application/xml') - }) - }) - - it('Deletes new page', function() - { - cy.visit('/tm/content/visual/welcome/testpage') - cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') - - cy.get('.danger').click() - - cy.get('#modalWindow').within(($modal) => { - cy.get('button').click() - }) - - cy.visit('/tm/content/visual/welcome') - cy.get('.navi-list') - .not('contain', 'Testpage') - .eq(2).find('a').should(($a) => { - expect($a).to.have.length(5) - }) - }) +describe('Blox Editor', function() +{ + before(function () + { + cy.visit('/tm/login') + cy.url().should('include','/tm/login') + + cy.get('input[name="username"]').type('trendschau') + cy.get('input[name="password"]').type('password') + + cy.get('form').submit() + cy.url().should('include','/tm/content') + cy.getCookie('typemill-session').should('exist') + + cy.visit('/tm/content/visual') + cy.url().should('include','/tm\/content\/visual') + }) + + beforeEach(function () + { + Cypress.Cookies.preserveOnce('typemill-session') + }) + + it('creates new page', function() + { + // click on add element + cy.get('.addNaviItem > a').eq(0).click() + + /* Check dublicates cannot be made */ + + /* Check new page can be created */ + cy.get('.addNaviForm').within(($naviform) =>{ + + /* add Testpage into input */ + cy.get('input') + .clear() + .type('Testpage') + .should('have.value', 'Testpage') + + cy.get('.b-left').click() + }) + + /* get Navilist */ + cy.get('.navi-list') + .should('contain', 'Testpage') + .eq(2).find('a').should(($a) => { + expect($a).to.have.length(6) + expect($a[5].href).to.include('/welcome\/testpage') + }) + }) + + it('edits default content', function() + { + cy.visit('/tm/content/visual/welcome/testpage') + cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') + + cy.get('#blox').within(($blox) => { + + /* Change Title */ + cy.get('#blox-0').click() + cy.get("input") + .clear() + .type("This is my Testpage") + + cy.get(".edit").click() + cy.get('#blox-0').should("contain", "This is my Testpage") + + /* Change Text */ + cy.get('#blox-1').click() + cy.get("textarea") + .clear() + .type("This is the new paragraph for the first line with some text.") + + cy.get(".edit").click() + cy.get('#blox-1').should("contain", "new paragraph") + + }) + }) + + it('edits paragraph', function() + { + cy.get('#blox').within(($blox) => { + /* Get Format Bar */ + cy.get('.format-bar').within(($formats) => { + + /* Edit Table */ + cy.get("button").eq(0).click() + cy.get("textarea") + .type("This is a second paragraph.") + + /* save table */ + cy.get(".edit").click() + cy.get(".cancel").click() + + }) + + cy.get('#blox-2').should("contain", "second paragraph") + }) + }) + + it('edits headline', function() + { + cy.get('#blox').within(($blox) => { + /* Get Format Bar */ + cy.get('.format-bar').within(($formats) => { + + /* Edit Table */ + cy.get("button").eq(1).click() + cy.get("input") + .type("Second Level Headline") + + /* save block */ + cy.get(".edit").click() + + /* close new standard textarea */ + cy.get(".cancel").click() + + }) + + cy.get('#blox-3').should("contain", "Second Level Headline") + }) + }) + + it('edits unordered list', function() + { + cy.get('#blox').within(($blox) => { + /* Get Format Bar */ + cy.get('.format-bar').within(($formats) => { + + /* Edit Table */ + cy.get("button").eq(2).click() + cy.get("textarea") + .type("first list item{enter}second list item") + + /* save block */ + cy.get(".edit").click() + + /* close new standard textarea */ + cy.get(".cancel").click() + + }) + + cy.get('#blox-4').within(($block) => { + cy.get("li").should(($lis) => { + expect($lis).to.have.length(2) + expect($lis.eq(0)).to.contain('first list item') + }) + }) + }) + }) + + it('edits ordered list', function() + { + cy.get('#blox').within(($blox) => { + /* Get Format Bar */ + cy.get('.format-bar').within(($formats) => { + + /* Edit Table */ + cy.get("button").eq(3).click() + cy.get("textarea") + .type("first ordered item{enter}second ordered item") + + /* save block */ + cy.get(".edit").click() + + /* close new standard textarea */ + cy.get(".cancel").click() + + }) + + cy.get('#blox-5').within(($block) => { + cy.get("li").should(($lis) => { + expect($lis).to.have.length(2) + expect($lis.eq(0)).to.contain('first ordered item') + }) + }) + }) + }) + + it('edits table', function() + { + cy.get('#blox').within(($blox) => { + /* Get Format Bar */ + cy.get('.format-bar').within(($formats) => { + + /* Edit Table */ + cy.get("button").eq(4).click() + cy.get("table").within(($table) => { + + /* edit table head */ + cy.get("tr").eq(1).within(($row) => { + cy.get("th").eq(1).click() + .clear() + .type("first Headline") + cy.get("th").eq(2).click() + .clear() + .type("Second Headline") + }) + + /* edit first content row */ + cy.get("tr").eq(2).within(($row) => { + cy.get("td").eq(1).click() + .clear() + .type("Some") + cy.get("td").eq(2).click() + .clear() + .type("More") + }) + + /* edit second content row */ + cy.get("tr").eq(3).within(($row) => { + cy.get("td").eq(1).click() + .clear() + .type("Beautiful") + cy.get("td").eq(2).click() + .clear() + .type("Content") + }) + + /* add new column on the right */ + cy.get("tr").eq(0).within(($row) => { + cy.get("td").eq(2).click() + cy.get(".actionline").eq(0).click() + }) + }) + + cy.get("table").within(($table) => { + + /* edit second new column head */ + cy.get("tr").eq(1).within(($row) => { + cy.get("th").eq(3).click() + .clear() + .type("New Head") + }) + + /* edit second new column head */ + cy.get("tr").eq(2).within(($row) => { + cy.get("td").eq(3).click() + .clear() + .type("With") + }) + + /* edit second new column head */ + cy.get("tr").eq(3).within(($row) => { + cy.get("td").eq(3).click() + .clear() + .type("new Content") + }) + }) + + /* save table */ + cy.get(".edit").click() + + }) + + cy.get('#blox-6').should("contain", "Beautiful").click() + + cy.get('.editactive').within(($activeblock) => { + cy.get('.component').should("contain", "Beautiful") + }) + + }) + }) + + it('Publishes new page', function() + { + cy.visit('/tm/content/visual/welcome/testpage') + cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') + + cy.get('#publish').click().wait(500) + + cy.visit('/welcome/testpage') + cy.url().should('include','/welcome/testpage') + + cy.get('.cy-nav') + .should('contain', 'Testpage') + }) + + it('has sitemap xml', function () + { + cy.request({ + url: '/cache/sitemap.xml', + }) + .then((resp) => { + /* should return xml-format */ + expect(resp.headers).to.have.property('content-type','application/xml') + }) + }) + + it('Deletes new page', function() + { + cy.visit('/tm/content/visual/welcome/testpage') + cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') + + cy.get('.danger').click() + + cy.get('#modalWindow').within(($modal) => { + cy.get('button').click() + }) + + cy.visit('/tm/content/visual/welcome') + cy.get('.navi-list') + .not('contain', 'Testpage') + .eq(2).find('a').should(($a) => { + expect($a).to.have.length(5) + }) + }) }) \ No newline at end of file diff --git a/cypress/test99-login.spec.js b/cypress/test99-login.spec.js new file mode 100644 index 0000000..2956676 --- /dev/null +++ b/cypress/test99-login.spec.js @@ -0,0 +1,70 @@ +describe('Typemill Login', function() +{ + it('redirects if visits dashboard without login', function () + { + cy.visit('/tm/content') + cy.url().should('include', '/tm/login') + }) + + it('submits a valid form and logout', function () + { + // visits login page and adds valid input + cy.visit('/tm/login') + cy.url().should('include','/tm/login') + + cy.get('input[name="username"]') + .type('trendschau') + .should('have.value', 'trendschau') + .and('have.attr', 'required') + + cy.get('input[name="password"]') + .type('password') + .should('have.value', 'password') + .and('have.attr', 'required') + + // can login + cy.get('form').submit() + cy.url().should('include','/tm/content') + cy.getCookie('typemill-session').should('exist') + + Cypress.Cookies.preserveOnce('typemill-session') + }) + + it('redirects if visits login form when logged in', function () + { + cy.visit('/tm/login') + cy.url().should('include', '/tm/content') + + Cypress.Cookies.preserveOnce('typemill-session') + }) + + it('logs out', function () + { + cy.contains('Logout').click() + cy.url().should('include', '/tm/login') + }) + + it('captcha after 1 fail', function () + { + cy.visit('/tm/login') + + // validation fails first + cy.get('input[name="username"]').clear().type('wrong') + cy.get('input[name="password"]').clear().type('pass') + cy.get('form').submit() + cy.get('#flash-message').should('contain', 'wrong password or username') + cy.get('input[name="username"]').should('have.value', 'wrong') + cy.get('input[name="password"]').should('have.value', '') + cy.get('input[name="captcha"]').should('have.value', '') + + // captcha fails first + cy.get('input[name="username"]').clear().type('trendschau') + cy.get('input[name="password"]').clear().type('password') + cy.get('input[name="captcha"]').clear().type('wrong') + cy.get('form').submit() + cy.get('#flash-message').should('contain', 'Captcha is wrong') + cy.get('input[name="username"]').should('have.value', 'trendschau') + cy.get('input[name="password"]').should('have.value', '') + cy.get('input[name="captcha"]').should('have.value', '') + }) +}) \ No newline at end of file From a801801956d96140e01fe798d2401f25a89f0fd2 Mon Sep 17 00:00:00 2001 From: Mysteriedev Date: Sat, 5 Mar 2022 12:47:49 +0100 Subject: [PATCH 03/12] add structure --- .../fixtures/01_setup/default-settings.yaml | 3 + .../01_setup/01-system-setup-signup.spec.js | 162 +++++ .../01_setup/02-initial-frontend.spec.js | 152 +++++ .../integration/03-system-settings.spec.js | 101 +++ cypress/integration/04-theme-settings.spec.js | 149 +++++ .../05-blox-editor.spec.js} | 614 +++++++++--------- cypress/integration/99-login.spec.js | 67 ++ cypress/plugins/index.js | 34 + cypress/support/commands.js | 25 + cypress/support/index.js | 20 + cypress/test01-system-setup.spec.js | 167 ----- cypress/test02-initial-frontend.spec.js | 145 ----- cypress/test03-system-settings.spec.js | 109 ---- cypress/test04-theme-settings.spec.js | 158 ----- cypress/test99-login.spec.js | 70 -- 15 files changed, 1020 insertions(+), 956 deletions(-) create mode 100644 cypress/fixtures/01_setup/default-settings.yaml create mode 100644 cypress/integration/01_setup/01-system-setup-signup.spec.js create mode 100644 cypress/integration/01_setup/02-initial-frontend.spec.js create mode 100644 cypress/integration/03-system-settings.spec.js create mode 100644 cypress/integration/04-theme-settings.spec.js rename cypress/{test05-blox-editor.spec.js => integration/05-blox-editor.spec.js} (96%) create mode 100644 cypress/integration/99-login.spec.js create mode 100644 cypress/plugins/index.js create mode 100644 cypress/support/commands.js create mode 100644 cypress/support/index.js delete mode 100644 cypress/test01-system-setup.spec.js delete mode 100644 cypress/test02-initial-frontend.spec.js delete mode 100644 cypress/test03-system-settings.spec.js delete mode 100644 cypress/test04-theme-settings.spec.js delete mode 100644 cypress/test99-login.spec.js diff --git a/cypress/fixtures/01_setup/default-settings.yaml b/cypress/fixtures/01_setup/default-settings.yaml new file mode 100644 index 0000000..1957802 --- /dev/null +++ b/cypress/fixtures/01_setup/default-settings.yaml @@ -0,0 +1,3 @@ +setup: true +language: en +welcome: true diff --git a/cypress/integration/01_setup/01-system-setup-signup.spec.js b/cypress/integration/01_setup/01-system-setup-signup.spec.js new file mode 100644 index 0000000..3dbb6c5 --- /dev/null +++ b/cypress/integration/01_setup/01-system-setup-signup.spec.js @@ -0,0 +1,162 @@ +describe("Typemill Setup with Signup", function() { + it("validates form input", function() { + // reset users and settings + cy.task("resetSetup"); + // visit setup form + cy.visit("/setup"); + // cy.visit('/setup',{ onBeforeLoad: (_contentWindow) => { Object.defineProperty(navigator, 'language', { value: 'fr-FR' }) } }) + cy.url().should("include", "/setup"); + + // add data and check attributes + cy.get('input[name="username"]') + .type("?1") + .should("have.value", "?1") + .and("have.attr", "required"); + + cy.get('input[name="email"]') + .type("trendschau.net") + .should("have.value", "trendschau.net") + .and("have.attr", "required"); + + cy.get('input[name="password"]') + .type("pass") + .should("have.value", "pass") + .and("have.attr", "required"); + + // submit and get validation errors + cy.get("form").submit(); + cy.get("#flash-message").should( + "contain", + "Please check your input and try again" + ); + cy.get(".error").should("contain", "invalid characters"); + cy.get(".error").should("contain", "e-mail is invalid"); + cy.get(".error").should("contain", "Length between 5 - 20"); + }); + + /* + it('fails without CSRF-token', function () + { + cy.request({ + method: 'POST', + url: '/setup', // baseUrl is prepended to url + form: true, // indicates the body should be form urlencoded and sets Content-Type: application/x-www-form-urlencoded headers + failOnStatusCode: false, + body: { + username: 'trendschau', + email: 'trendschau@gmail.com', + password: 'password' + } + }) + .its('body') + .should('include', 'The form has a timeout') + }) +*/ + it("fails without CSRF-token", function() { + cy.visit("/setup"); + + // enter correct data + cy.get('input[name="username"]').clear().type("trendschau"); + cy.get('input[name="email"]').clear().type("trendschau@gmail.com"); + cy.get('input[name="password"]').clear().type("password"); + cy.get("#csrf_value").then((elem) => { + elem.val("wrongvalue"); + }); + + // submit and get validation errors + cy.get("form").submit(); + cy.get("#flash-message").should("contain", "form has a timeout"); + }); + + it("submits valid form data and visit welcome and settings page", function() { + cy.visit("/setup"); + + // enter correct data + cy.get('input[name="username"]').clear().type("trendschau"); + cy.get('input[name="email"]').clear().type("trendschau@gmail.com"); + cy.get('input[name="password"]').clear().type("password"); + + // submits valid form + cy.get("form").submit(); + cy.url().should("include", "/welcome"); + cy.getCookie("typemill-session").should("exist"); + Cypress.Cookies.preserveOnce("typemill-session"); + + // clicks link on welcome page to settings page + // cy.get('.button').should('contain', 'Configure your website') + cy.get(".button").click(); + cy.url().should("include", "/tm/settings"); + }); + + it("creates default settings data", function() { + cy.get('input[name="settings[title]"]') + .should("have.value", "TYPEMILL") + .and("have.attr", "required"); + cy.get('input[name="settings[author]"]'); + cy.get('select[name="settings[copyright]"]'); + cy.get('input[name="settings[year]"]').should("have.attr", "required"); + cy.get('select[name="settings[language]"]'); + // cy.get('select[name="settings[langattr]"]') + cy.get('input[name="settings[sitemap]"]') + .should("have.value", `${Cypress.config().baseUrl}/cache/sitemap.xml`) + .and("have.attr", "readonly"); + cy.get('input[name="settings[logo]"]'); + cy.get('input[name="settings[deletelogo]"]'); + cy.get('input[name="settings[favicon]"]'); + cy.get('input[name="settings[deletefav]"]'); + cy.get('input[name="settings[headlineanchors]"]'); + cy.get('input[name="settings[editor]"]'); + + cy.get('select[name="settings[language]"]') + .select("en") + .should("have.value", "en"); + + cy.get("form").submit(); + cy.get("#flash-message").should("contain", "Settings are stored"); + + Cypress.Cookies.preserveOnce("typemill-session"); + }); + + it("creates default user data", function() { + cy.visit("/tm/user/trendschau"); + cy.url().should("include", "/tm/user/trendschau"); + cy.get('input[name="user[username]"]').should("have.value", "trendschau"); + cy.get('input[name="user[firstname]"]') + .clear() + .type("Sebastian") + .should("have.value", "Sebastian"); + cy.get('input[name="user[lastname]"]') + .clear() + .type("Schürmanns") + .should("have.value", "Schürmanns"); + cy.get('input[name="user[email]"]').should( + "have.value", + "trendschau@gmail.com" + ); + cy.get('select[name="user[userrole]"]').should( + "have.value", + "administrator" + ); + cy.get('input[name="user[password]"]').should("have.value", ""); + cy.get('input[name="user[newpassword]"]').should("have.value", ""); + + cy.get("#userform").submit(); + cy.get("#flash-message").should("contain", "Saved all changes"); + }); + + it("logouts out", function() { + // visits logout link + cy.visit("/tm/logout"); + cy.url().should("include", "/tm/login"); + + // tries to open setup form again and gets redirected to login + cy.visit("/setup"); + cy.url().should("include", "/login"); + }); + + it("redirects when tries to setup again", function() { + // tries to open setup form again and gets redirected to login + cy.visit("/setup"); + cy.url().should("include", "/login"); + }); +}); \ No newline at end of file diff --git a/cypress/integration/01_setup/02-initial-frontend.spec.js b/cypress/integration/01_setup/02-initial-frontend.spec.js new file mode 100644 index 0000000..d9b64bf --- /dev/null +++ b/cypress/integration/01_setup/02-initial-frontend.spec.js @@ -0,0 +1,152 @@ +describe("Typemill Initial Frontend", function() { + it("has startpage with navigation", function() { + /* visit homepage */ + cy.visit("/"); + + /* has startpage with headline */ + cy.get("h1").contains("Typemill"); + + /* has start and setup button */ + cy.get("nav") + .find("a") + .should(($a) => { + expect($a).to.have.length(11); + expect($a[0].href).to.match(/welcome/); + expect($a[1].href).to.match(/welcome\/setup-your-website/); + expect($a[2].href).to.match(/welcome\/manage-access/); + expect($a[3].href).to.match(/welcome\/write-content/); + expect($a[4].href).to.match(/welcome\/get-help/); + expect($a[5].href).to.match(/welcome\/markdown-test/); + expect($a[6].href).to.match(/cyanine-theme/); + expect($a[7].href).to.match(/cyanine-theme\/landingpage/); + expect($a[8].href).to.match(/cyanine-theme\/colors-and-fonts/); + expect($a[9].href).to.match(/cyanine-theme\/footer/); + expect($a[10].href).to.match(/cyanine-theme\/content-elements/); + }); + }); + + it("has error page", function() { + cy.request({ + url: "/error", + failOnStatusCode: false, + }).then((resp) => { + /* should return 404 not found */ + expect(resp.status).to.eq(404); + }); + + cy.visit("/error", { failOnStatusCode: false }); + cy.url().should("include", "/error"); + + cy.get("h1").contains("Not Found"); + }); + + it("has no access to cache files", function() { + cy.request({ + url: "/cache/structure.txt", + failOnStatusCode: false, + }).then((resp) => { + // redirect status code is 302 + expect(resp.status).to.eq(403); + }); + }); + + it("has no access to dashboard", function() { + cy.visit("/tm/settings"); + cy.url().should("include", "/tm/login"); + }); + + it("has proper markdown test page", function() { + cy.visit("/welcome/markdown-test"); + cy.url().should("include", "/welcome/markdown-test"); + + /* has navigation element */ + cy.get("nav").should("exist"); + + /* check if toc exists */ + cy.get(".TOC").within(($toc) => { + /* check if a certain link in toc exists */ + cy.get("a").eq(2).should("have.attr", "href", "#h-headlines"); + }); + + /* check if corresponding anchor exists */ + cy.get("#h-headlines").should("exist"); + + /* soft linebreaks */ + cy.get("br").should("exist"); + + /* emphasis */ + cy.get("em").should("exist"); + + /* strong */ + cy.get("strong").should("exist"); + + /* ordered list */ + cy.get("ol").should("exist"); + + /* linebreak */ + cy.get("hr").should("exist"); + + /* links exists? hard to test, any idea? We need to wrap it in a div... */ + + /* images */ + cy.get("img").eq(0).should("have.attr", "alt", "alt"); + cy.get("img") + .eq(0) + .should("have.attr", "src") + .should("include", "media/files/markdown.png"); + cy.get("figure") + .eq(2) + .should("have.id", "myid") + .and("have.class", "otherclass"); + cy.get("img") + .eq(2) + .should("have.attr", "alt", "alt-text") + .and("have.attr", "title", "my title") + .and("have.attr", "width", "150px"); + + /* blockquote */ + cy.get("blockquote").should("exist"); + + /* has navigation element */ + cy.get(".notice1").should("exist"); + cy.get(".notice2").should("exist"); + cy.get(".notice3").should("exist"); + + /* footnote */ + cy.get("sup").eq(0).should("have.id", "fnref1:1"); + cy.get("sup") + .eq(0) + .within(($sup) => { + cy.get("a") + .eq(0) + .should("have.attr", "href", "#fn%3A1") + .and("have.class", "footnote-ref"); + }); + + /* abbreviation */ + cy.get("abbr").should("exist"); + + /* definition list */ + cy.get("dl").should("exist"); + + /* table */ + cy.get("table").should("exist"); + + /* code */ + cy.get("pre").should("exist"); + cy.get("code").should("exist"); + + /* math */ + cy.get(".math").should("exist"); + + /* footnote end */ + cy.get(".footnotes").within(($footnotes) => { + cy.get("li").eq(0).should("have.id", "fn:1"); + cy.get("a") + .eq(0) + .should("have.class", "footnote-backref") + .and("have.attr", "href", "#fnref1%3A1") + .and("have.attr", "rev", "footnote"); + }); + }); +}); \ No newline at end of file diff --git a/cypress/integration/03-system-settings.spec.js b/cypress/integration/03-system-settings.spec.js new file mode 100644 index 0000000..ba6ee61 --- /dev/null +++ b/cypress/integration/03-system-settings.spec.js @@ -0,0 +1,101 @@ +describe("Typemill System Settings", function() { + before(function() { + cy.visit("/tm/login"); + cy.url().should("include", "/tm/login"); + + cy.get('input[name="username"]').type("trendschau"); + cy.get('input[name="password"]').type("password"); + + cy.get("form").submit(); + cy.url().should("include", "/tm/content"); + cy.getCookie("typemill-session").should("exist"); + + cy.visit("/tm/settings"); + cy.url().should("include", "/tm/settings"); + }); + + beforeEach(function() { + Cypress.Cookies.preserveOnce("typemill-session"); + }); + + it("validates the form", function() { + // fill out valid data + cy.get('input[name="settings[title]"]') + .clear() + .type("Cypress a').eq(0).click() - - /* Check dublicates cannot be made */ - - /* Check new page can be created */ - cy.get('.addNaviForm').within(($naviform) =>{ - - /* add Testpage into input */ - cy.get('input') - .clear() - .type('Testpage') - .should('have.value', 'Testpage') - - cy.get('.b-left').click() - }) - - /* get Navilist */ - cy.get('.navi-list') - .should('contain', 'Testpage') - .eq(2).find('a').should(($a) => { - expect($a).to.have.length(6) - expect($a[5].href).to.include('/welcome\/testpage') - }) - }) - - it('edits default content', function() - { - cy.visit('/tm/content/visual/welcome/testpage') - cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') - - cy.get('#blox').within(($blox) => { - - /* Change Title */ - cy.get('#blox-0').click() - cy.get("input") - .clear() - .type("This is my Testpage") - - cy.get(".edit").click() - cy.get('#blox-0').should("contain", "This is my Testpage") - - /* Change Text */ - cy.get('#blox-1').click() - cy.get("textarea") - .clear() - .type("This is the new paragraph for the first line with some text.") - - cy.get(".edit").click() - cy.get('#blox-1').should("contain", "new paragraph") - - }) - }) - - it('edits paragraph', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(0).click() - cy.get("textarea") - .type("This is a second paragraph.") - - /* save table */ - cy.get(".edit").click() - cy.get(".cancel").click() - - }) - - cy.get('#blox-2').should("contain", "second paragraph") - }) - }) - - it('edits headline', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(1).click() - cy.get("input") - .type("Second Level Headline") - - /* save block */ - cy.get(".edit").click() - - /* close new standard textarea */ - cy.get(".cancel").click() - - }) - - cy.get('#blox-3').should("contain", "Second Level Headline") - }) - }) - - it('edits unordered list', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(2).click() - cy.get("textarea") - .type("first list item{enter}second list item") - - /* save block */ - cy.get(".edit").click() - - /* close new standard textarea */ - cy.get(".cancel").click() - - }) - - cy.get('#blox-4').within(($block) => { - cy.get("li").should(($lis) => { - expect($lis).to.have.length(2) - expect($lis.eq(0)).to.contain('first list item') - }) - }) - }) - }) - - it('edits ordered list', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(3).click() - cy.get("textarea") - .type("first ordered item{enter}second ordered item") - - /* save block */ - cy.get(".edit").click() - - /* close new standard textarea */ - cy.get(".cancel").click() - - }) - - cy.get('#blox-5').within(($block) => { - cy.get("li").should(($lis) => { - expect($lis).to.have.length(2) - expect($lis.eq(0)).to.contain('first ordered item') - }) - }) - }) - }) - - it('edits table', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(4).click() - cy.get("table").within(($table) => { - - /* edit table head */ - cy.get("tr").eq(1).within(($row) => { - cy.get("th").eq(1).click() - .clear() - .type("first Headline") - cy.get("th").eq(2).click() - .clear() - .type("Second Headline") - }) - - /* edit first content row */ - cy.get("tr").eq(2).within(($row) => { - cy.get("td").eq(1).click() - .clear() - .type("Some") - cy.get("td").eq(2).click() - .clear() - .type("More") - }) - - /* edit second content row */ - cy.get("tr").eq(3).within(($row) => { - cy.get("td").eq(1).click() - .clear() - .type("Beautiful") - cy.get("td").eq(2).click() - .clear() - .type("Content") - }) - - /* add new column on the right */ - cy.get("tr").eq(0).within(($row) => { - cy.get("td").eq(2).click() - cy.get(".actionline").eq(0).click() - }) - }) - - cy.get("table").within(($table) => { - - /* edit second new column head */ - cy.get("tr").eq(1).within(($row) => { - cy.get("th").eq(3).click() - .clear() - .type("New Head") - }) - - /* edit second new column head */ - cy.get("tr").eq(2).within(($row) => { - cy.get("td").eq(3).click() - .clear() - .type("With") - }) - - /* edit second new column head */ - cy.get("tr").eq(3).within(($row) => { - cy.get("td").eq(3).click() - .clear() - .type("new Content") - }) - }) - - /* save table */ - cy.get(".edit").click() - - }) - - cy.get('#blox-6').should("contain", "Beautiful").click() - - cy.get('.editactive').within(($activeblock) => { - cy.get('.component').should("contain", "Beautiful") - }) - - }) - }) - - it('Publishes new page', function() - { - cy.visit('/tm/content/visual/welcome/testpage') - cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') - - cy.get('#publish').click().wait(500) - - cy.visit('/welcome/testpage') - cy.url().should('include','/welcome/testpage') - - cy.get('.cy-nav') - .should('contain', 'Testpage') - }) - - it('has sitemap xml', function () - { - cy.request({ - url: '/cache/sitemap.xml', - }) - .then((resp) => { - /* should return xml-format */ - expect(resp.headers).to.have.property('content-type','application/xml') - }) - }) - - it('Deletes new page', function() - { - cy.visit('/tm/content/visual/welcome/testpage') - cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') - - cy.get('.danger').click() - - cy.get('#modalWindow').within(($modal) => { - cy.get('button').click() - }) - - cy.visit('/tm/content/visual/welcome') - cy.get('.navi-list') - .not('contain', 'Testpage') - .eq(2).find('a').should(($a) => { - expect($a).to.have.length(5) - }) - }) +describe('Blox Editor', function() +{ + before(function () + { + cy.visit('/tm/login') + cy.url().should('include','/tm/login') + + cy.get('input[name="username"]').type('trendschau') + cy.get('input[name="password"]').type('password') + + cy.get('form').submit() + cy.url().should('include','/tm/content') + cy.getCookie('typemill-session').should('exist') + + cy.visit('/tm/content/visual') + cy.url().should('include','/tm\/content\/visual') + }) + + beforeEach(function () + { + Cypress.Cookies.preserveOnce('typemill-session') + }) + + it('creates new page', function() + { + // click on add element + cy.get('.addNaviItem > a').eq(0).click() + + /* Check dublicates cannot be made */ + + /* Check new page can be created */ + cy.get('.addNaviForm').within(($naviform) =>{ + + /* add Testpage into input */ + cy.get('input') + .clear() + .type('Testpage') + .should('have.value', 'Testpage') + + cy.get('.b-left').click() + }) + + /* get Navilist */ + cy.get('.navi-list') + .should('contain', 'Testpage') + .eq(2).find('a').should(($a) => { + expect($a).to.have.length(6) + expect($a[5].href).to.include('/welcome\/testpage') + }) + }) + + it('edits default content', function() + { + cy.visit('/tm/content/visual/welcome/testpage') + cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') + + cy.get('#blox').within(($blox) => { + + /* Change Title */ + cy.get('#blox-0').click() + cy.get("input") + .clear() + .type("This is my Testpage") + + cy.get(".edit").click() + cy.get('#blox-0').should("contain", "This is my Testpage") + + /* Change Text */ + cy.get('#blox-1').click() + cy.get("textarea") + .clear() + .type("This is the new paragraph for the first line with some text.") + + cy.get(".edit").click() + cy.get('#blox-1').should("contain", "new paragraph") + + }) + }) + + it('edits paragraph', function() + { + cy.get('#blox').within(($blox) => { + /* Get Format Bar */ + cy.get('.format-bar').within(($formats) => { + + /* Edit Table */ + cy.get("button").eq(0).click() + cy.get("textarea") + .type("This is a second paragraph.") + + /* save table */ + cy.get(".edit").click() + cy.get(".cancel").click() + + }) + + cy.get('#blox-2').should("contain", "second paragraph") + }) + }) + + it('edits headline', function() + { + cy.get('#blox').within(($blox) => { + /* Get Format Bar */ + cy.get('.format-bar').within(($formats) => { + + /* Edit Table */ + cy.get("button").eq(1).click() + cy.get("input") + .type("Second Level Headline") + + /* save block */ + cy.get(".edit").click() + + /* close new standard textarea */ + cy.get(".cancel").click() + + }) + + cy.get('#blox-3').should("contain", "Second Level Headline") + }) + }) + + it('edits unordered list', function() + { + cy.get('#blox').within(($blox) => { + /* Get Format Bar */ + cy.get('.format-bar').within(($formats) => { + + /* Edit Table */ + cy.get("button").eq(2).click() + cy.get("textarea") + .type("first list item{enter}second list item") + + /* save block */ + cy.get(".edit").click() + + /* close new standard textarea */ + cy.get(".cancel").click() + + }) + + cy.get('#blox-4').within(($block) => { + cy.get("li").should(($lis) => { + expect($lis).to.have.length(2) + expect($lis.eq(0)).to.contain('first list item') + }) + }) + }) + }) + + it('edits ordered list', function() + { + cy.get('#blox').within(($blox) => { + /* Get Format Bar */ + cy.get('.format-bar').within(($formats) => { + + /* Edit Table */ + cy.get("button").eq(3).click() + cy.get("textarea") + .type("first ordered item{enter}second ordered item") + + /* save block */ + cy.get(".edit").click() + + /* close new standard textarea */ + cy.get(".cancel").click() + + }) + + cy.get('#blox-5').within(($block) => { + cy.get("li").should(($lis) => { + expect($lis).to.have.length(2) + expect($lis.eq(0)).to.contain('first ordered item') + }) + }) + }) + }) + + it('edits table', function() + { + cy.get('#blox').within(($blox) => { + /* Get Format Bar */ + cy.get('.format-bar').within(($formats) => { + + /* Edit Table */ + cy.get("button").eq(4).click() + cy.get("table").within(($table) => { + + /* edit table head */ + cy.get("tr").eq(1).within(($row) => { + cy.get("th").eq(1).click() + .clear() + .type("first Headline") + cy.get("th").eq(2).click() + .clear() + .type("Second Headline") + }) + + /* edit first content row */ + cy.get("tr").eq(2).within(($row) => { + cy.get("td").eq(1).click() + .clear() + .type("Some") + cy.get("td").eq(2).click() + .clear() + .type("More") + }) + + /* edit second content row */ + cy.get("tr").eq(3).within(($row) => { + cy.get("td").eq(1).click() + .clear() + .type("Beautiful") + cy.get("td").eq(2).click() + .clear() + .type("Content") + }) + + /* add new column on the right */ + cy.get("tr").eq(0).within(($row) => { + cy.get("td").eq(2).click() + cy.get(".actionline").eq(0).click() + }) + }) + + cy.get("table").within(($table) => { + + /* edit second new column head */ + cy.get("tr").eq(1).within(($row) => { + cy.get("th").eq(3).click() + .clear() + .type("New Head") + }) + + /* edit second new column head */ + cy.get("tr").eq(2).within(($row) => { + cy.get("td").eq(3).click() + .clear() + .type("With") + }) + + /* edit second new column head */ + cy.get("tr").eq(3).within(($row) => { + cy.get("td").eq(3).click() + .clear() + .type("new Content") + }) + }) + + /* save table */ + cy.get(".edit").click() + + }) + + cy.get('#blox-6').should("contain", "Beautiful").click() + + cy.get('.editactive').within(($activeblock) => { + cy.get('.component').should("contain", "Beautiful") + }) + + }) + }) + + it('Publishes new page', function() + { + cy.visit('/tm/content/visual/welcome/testpage') + cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') + + cy.get('#publish').click().wait(500) + + cy.visit('/welcome/testpage') + cy.url().should('include','/welcome/testpage') + + cy.get('.cy-nav') + .should('contain', 'Testpage') + }) + + it('has sitemap xml', function () + { + cy.request({ + url: '/cache/sitemap.xml', + }) + .then((resp) => { + /* should return xml-format */ + expect(resp.headers).to.have.property('content-type','application/xml') + }) + }) + + it('Deletes new page', function() + { + cy.visit('/tm/content/visual/welcome/testpage') + cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') + + cy.get('.danger').click() + + cy.get('#modalWindow').within(($modal) => { + cy.get('button').click() + }) + + cy.visit('/tm/content/visual/welcome') + cy.get('.navi-list') + .not('contain', 'Testpage') + .eq(2).find('a').should(($a) => { + expect($a).to.have.length(5) + }) + }) }) \ No newline at end of file diff --git a/cypress/integration/99-login.spec.js b/cypress/integration/99-login.spec.js new file mode 100644 index 0000000..6428ee5 --- /dev/null +++ b/cypress/integration/99-login.spec.js @@ -0,0 +1,67 @@ +describe("Typemill Login", function() { + before(function() { + cy.clearCookies(); + }); + it("redirects if visits dashboard without login", function() { + cy.visit("/tm/content"); + cy.url().should("include", "/tm/login"); + }); + + it("submits a valid form and logout", function() { + // visits login page and adds valid input + cy.visit("/tm/login"); + cy.url().should("include", "/tm/login"); + + cy.get('input[name="username"]') + .type("trendschau") + .should("have.value", "trendschau") + .and("have.attr", "required"); + + cy.get('input[name="password"]') + .type("password") + .should("have.value", "password") + .and("have.attr", "required"); + + // can login + cy.get("form").submit(); + cy.url().should("include", "/tm/content"); + cy.getCookie("typemill-session").should("exist"); + + Cypress.Cookies.preserveOnce("typemill-session"); + }); + + it("redirects if visits login form when logged in", function() { + cy.visit("/tm/login"); + cy.url().should("include", "/tm/content"); + + Cypress.Cookies.preserveOnce("typemill-session"); + }); + + it("logs out", function() { + cy.contains("Logout").click(); + cy.url().should("include", "/tm/login"); + }); + + it("captcha after 1 fail", function() { + cy.visit("/tm/login"); + + // validation fails first + cy.get('input[name="username"]').clear().type("wrong"); + cy.get('input[name="password"]').clear().type("pass"); + cy.get("form").submit(); + cy.get("#flash-message").should("contain", "wrong password or username"); + cy.get('input[name="username"]').should("have.value", "wrong"); + cy.get('input[name="password"]').should("have.value", ""); + cy.get('input[name="captcha"]').should("have.value", ""); + + // captcha fails first + cy.get('input[name="username"]').clear().type("trendschau"); + cy.get('input[name="password"]').clear().type("password"); + cy.get('input[name="captcha"]').clear().type("wrong"); + cy.get("form").submit(); + cy.get("#flash-message").should("contain", "Captcha is wrong"); + cy.get('input[name="username"]').should("have.value", "trendschau"); + cy.get('input[name="password"]').should("have.value", ""); + cy.get('input[name="captcha"]').should("have.value", ""); + }); +}); \ No newline at end of file diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js new file mode 100644 index 0000000..5aaa3da --- /dev/null +++ b/cypress/plugins/index.js @@ -0,0 +1,34 @@ +const fs = require("fs"); + +/// +// *********************************************************** +// 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("task", { + resetSetup() { + fs.rmSync("settings/users", { recursive: true, force: true }); + fs.rmSync("settings/settings.yaml"); + fs.copyFileSync( + "cypress/fixtures/01_setup/default-settings.yaml", + "settings/settings.yaml" + ); + + return null; + }, + }); +}; \ No newline at end of file diff --git a/cypress/support/commands.js b/cypress/support/commands.js new file mode 100644 index 0000000..119ab03 --- /dev/null +++ b/cypress/support/commands.js @@ -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) => { ... }) diff --git a/cypress/support/index.js b/cypress/support/index.js new file mode 100644 index 0000000..d68db96 --- /dev/null +++ b/cypress/support/index.js @@ -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') diff --git a/cypress/test01-system-setup.spec.js b/cypress/test01-system-setup.spec.js deleted file mode 100644 index f0e3fba..0000000 --- a/cypress/test01-system-setup.spec.js +++ /dev/null @@ -1,167 +0,0 @@ -describe('Typemill Setup', function() -{ - it('validates form input', function () - { - // visit setup form - cy.visit('/setup') -// cy.visit('/setup',{ onBeforeLoad: (_contentWindow) => { Object.defineProperty(navigator, 'language', { value: 'fr-FR' }) } }) - cy.url().should('include','/setup') - - // add data and check attributes - cy.get('input[name="username"]') - .type('?1') - .should('have.value', '?1') - .and('have.attr', 'required') - - cy.get('input[name="email"]') - .type('trendschau.net') - .should('have.value', 'trendschau.net') - .and('have.attr', 'required') - - cy.get('input[name="password"]') - .type('pass') - .should('have.value', 'pass') - .and('have.attr', 'required') - - // submit and get validation errors - cy.get('form').submit() - cy.get('#flash-message').should('contain', 'Please check your input and try again') - cy.get('.error').should('contain', 'invalid characters') - cy.get('.error').should('contain', 'e-mail is invalid') - cy.get('.error').should('contain', 'Length between 5 - 20') - }) - -/* - it('fails without CSRF-token', function () - { - cy.request({ - method: 'POST', - url: '/setup', // baseUrl is prepended to url - form: true, // indicates the body should be form urlencoded and sets Content-Type: application/x-www-form-urlencoded headers - failOnStatusCode: false, - body: { - username: 'trendschau', - email: 'trendschau@gmail.com', - password: 'password' - } - }) - .its('body') - .should('include', 'The form has a timeout') - }) -*/ - it('fails without CSRF-token', function () - { - cy.visit('/setup') - - // enter correct data - cy.get('input[name="username"]').clear().type('trendschau') - cy.get('input[name="email"]').clear().type('trendschau@gmail.com') - cy.get('input[name="password"]').clear().type('password') - cy.get('#csrf_value').then(elem => { - elem.val('wrongvalue'); - }); - - // submit and get validation errors - cy.get('form').submit() - cy.get('#flash-message').should('contain', 'form has a timeout') - }) - - - it('submits valid form data and visit welcome and settings page', function () - { - cy.visit('/setup') - - // enter correct data - cy.get('input[name="username"]').clear().type('trendschau') - cy.get('input[name="email"]').clear().type('trendschau@gmail.com') - cy.get('input[name="password"]').clear().type('password') - - // submits valid form - cy.get('form').submit() - cy.url().should('include','/welcome') - cy.getCookie('typemill-session').should('exist') - Cypress.Cookies.preserveOnce('typemill-session') - - // clicks link on welcome page to settings page -// cy.get('.button').should('contain', 'Configure your website') - cy.get('.button').click() - cy.url().should('include', '/tm/settings') - }) - - it('creates default settings data', function() - { - cy.get('input[name="settings[title]"]') - .should('have.value', 'TYPEMILL') - .and('have.attr','required') - cy.get('input[name="settings[author]"]') - cy.get('select[name="settings[copyright]"]') - cy.get('input[name="settings[year]"]') - .should('have.attr', 'required') - cy.get('select[name="settings[language]"]') -// cy.get('select[name="settings[langattr]"]') - cy.get('input[name="settings[sitemap]"]') - .should('have.value', 'http://localhost/typemillTest/cache/sitemap.xml') - .and('have.attr','readonly') - cy.get('input[name="settings[logo]"]') - cy.get('input[name="settings[deletelogo]"]') - cy.get('input[name="settings[favicon]"]') - cy.get('input[name="settings[deletefav]"]') - cy.get('input[name="settings[headlineanchors]"]') - cy.get('input[name="settings[editor]"]') - - cy.get('select[name="settings[language]"]') - .select('en') - .should('have.value', 'en') - - cy.get('form').submit() - cy.get('#flash-message').should('contain', 'Settings are stored') - - Cypress.Cookies.preserveOnce('typemill-session') - }) - - it('creates default user data', function() - { - cy.visit('/tm/user/trendschau') - cy.url().should('include', '/tm/user/trendschau') - cy.get('input[name="user[username]"]') - .should('have.value', 'trendschau') - cy.get('input[name="user[firstname]"]') - .clear() - .type('Sebastian') - .should('have.value', 'Sebastian') - cy.get('input[name="user[lastname]"]') - .clear() - .type('Schürmanns') - .should('have.value', 'Schürmanns') - cy.get('input[name="user[email]"]') - .should('have.value', 'trendschau@gmail.com') - cy.get('select[name="user[userrole]"]') - .should('have.value','administrator') - cy.get('input[name="user[password]"]') - .should('have.value', '') - cy.get('input[name="user[newpassword]"]') - .should('have.value', '') - - cy.get('#userform').submit() - cy.get('#flash-message').should('contain', 'Saved all changes') - - }) - - it('logouts out', function() - { - // visits logout link - cy.visit('/tm/logout') - cy.url().should('include', '/tm/login') - - // tries to open setup form again and gets redirected to login - cy.visit('/setup') - cy.url().should('include','/login') - }) - - it('redirects when tries to setup again', function() - { - // tries to open setup form again and gets redirected to login - cy.visit('/setup') - cy.url().should('include','/login') - }) -}) \ No newline at end of file diff --git a/cypress/test02-initial-frontend.spec.js b/cypress/test02-initial-frontend.spec.js deleted file mode 100644 index 220f534..0000000 --- a/cypress/test02-initial-frontend.spec.js +++ /dev/null @@ -1,145 +0,0 @@ -describe('Typemill Initial Frontend', function() -{ - it('has startpage with navigation', function () - { - /* visit homepage */ - cy.visit('/') - - /* has startpage with headline */ - cy.get('h1').contains("Typemill") - - /* has start and setup button */ - cy.get('nav').find('a').should(($a) => { - expect($a).to.have.length(11) - expect($a[0].href).to.match(/welcome/) - expect($a[1].href).to.match(/welcome\/setup-your-website/) - expect($a[2].href).to.match(/welcome\/manage-access/) - expect($a[3].href).to.match(/welcome\/write-content/) - expect($a[4].href).to.match(/welcome\/get-help/) - expect($a[5].href).to.match(/welcome\/markdown-test/) - expect($a[6].href).to.match(/cyanine-theme/) - expect($a[7].href).to.match(/cyanine-theme\/landingpage/) - expect($a[8].href).to.match(/cyanine-theme\/colors-and-fonts/) - expect($a[9].href).to.match(/cyanine-theme\/footer/) - expect($a[10].href).to.match(/cyanine-theme\/content-elements/) - }) - }) - - it('has error page', function () - { - cy.request({ - url: '/error', - failOnStatusCode: false, - }) - .then((resp) => { - /* should return 404 not found */ - expect(resp.status).to.eq(404) - }) - - cy.visit('/error', { failOnStatusCode: false }) - cy.url().should('include','/error') - - cy.get('h1').contains('Not Found') - }) - - it('has no access to cache files', function () - { - cy.request({ - url: '/cache/structure.txt', - failOnStatusCode: false, - }) - .then((resp) => { - // redirect status code is 302 - expect(resp.status).to.eq(403) - }) - }) - - it('has no access to dashboard', function () - { - cy.visit('/tm/settings') - cy.url().should('include','/tm/login') - }) - - it('has proper markdown test page', function () - { - cy.visit('/welcome/markdown-test') - cy.url().should('include','/welcome/markdown-test') - - /* has navigation element */ - cy.get('nav').should('exist') - - /* check if toc exists */ - cy.get('.TOC').within(($toc) =>{ - /* check if a certain link in toc exists */ - cy.get('a').eq(2).should('have.attr', 'href', '#h-headlines') - }) - - /* check if corresponding anchor exists */ - cy.get('#h-headlines').should('exist') - - /* soft linebreaks */ - cy.get('br').should('exist') - - /* emphasis */ - cy.get('em').should('exist') - - /* strong */ - cy.get('strong').should('exist') - - /* ordered list */ - cy.get('ol').should('exist') - - /* linebreak */ - cy.get('hr').should('exist') - - /* links exists? hard to test, any idea? We need to wrap it in a div... */ - - /* images */ - cy.get('img').eq(0).should('have.attr', 'alt', 'alt') - cy.get('img').eq(0).should('have.attr', 'src').should('include','media/files/markdown.png') - cy.get('figure').eq(2).should('have.id', 'myid') - .and('have.class', 'otherclass') - cy.get('img').eq(2).should('have.attr', 'alt', 'alt-text') - .and('have.attr', 'title', 'my title') - .and('have.attr', 'width', '150px') - - /* blockquote */ - cy.get('blockquote').should('exist') - - /* has navigation element */ - cy.get('.notice1').should('exist') - cy.get('.notice2').should('exist') - cy.get('.notice3').should('exist') - - /* footnote */ - cy.get('sup').eq(0).should('have.id', 'fnref1:1') - cy.get('sup').eq(0).within(($sup) =>{ - cy.get('a').eq(0).should('have.attr', 'href', '#fn%3A1') - .and('have.class', 'footnote-ref') - }) - - /* abbreviation */ - cy.get('abbr').should('exist') - - /* definition list */ - cy.get('dl').should('exist') - - /* table */ - cy.get('table').should('exist') - - /* code */ - cy.get('pre').should('exist') - cy.get('code').should('exist') - - /* math */ - cy.get('.math').should('exist') - - /* footnote end */ - cy.get('.footnotes').within(($footnotes) => { - cy.get('li').eq(0).should('have.id', 'fn:1') - cy.get('a').eq(0).should('have.class', 'footnote-backref') - .and('have.attr', 'href', '#fnref1%3A1') - .and('have.attr', 'rev', 'footnote') - }) - }) -}) \ No newline at end of file diff --git a/cypress/test03-system-settings.spec.js b/cypress/test03-system-settings.spec.js deleted file mode 100644 index 4211609..0000000 --- a/cypress/test03-system-settings.spec.js +++ /dev/null @@ -1,109 +0,0 @@ -describe('Typemill System Settings', function() -{ - before(function () - { - cy.visit('/tm/login') - cy.url().should('include','/tm/login') - - cy.get('input[name="username"]').type('trendschau') - cy.get('input[name="password"]').type('password') - - cy.get('form').submit() - cy.url().should('include','/tm/content') - cy.getCookie('typemill-session').should('exist') - - cy.visit('/tm/settings') - cy.url().should('include','/tm/settings') - }) - - beforeEach(function () - { - Cypress.Cookies.preserveOnce('typemill-session') - }) - - it('validates the form', function() - { - // fill out valid data - cy.get('input[name="settings[title]"]') - .clear() - .type('Cypress Date: Sun, 6 Mar 2022 15:58:49 +0100 Subject: [PATCH 04/12] start command for developers --- cypress.json | 3 +++ cypress/plugins/index.js | 28 ++++++++++++++++------------ package.json | 19 +++++++++++++++++++ 3 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 cypress.json create mode 100644 package.json diff --git a/cypress.json b/cypress.json new file mode 100644 index 0000000..91eeb63 --- /dev/null +++ b/cypress.json @@ -0,0 +1,3 @@ +{ + "baseUrl": "http://localhost/EDIT_THIS_URL_FOR_YOUR_LOCAL_SETUP" +} \ No newline at end of file diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index 5aaa3da..10d3bef 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -19,16 +19,20 @@ const fs = require("fs"); */ // eslint-disable-next-line no-unused-vars module.exports = (on, config) => { - on("task", { - resetSetup() { - fs.rmSync("settings/users", { recursive: true, force: true }); - fs.rmSync("settings/settings.yaml"); - fs.copyFileSync( - "cypress/fixtures/01_setup/default-settings.yaml", - "settings/settings.yaml" - ); + on("task", { + resetSetup() { + const users = "settings/users"; + const settings = "settings/settings.yaml"; + if (fs.existsSync(settings) && fs.existsSync(users)) { + fs.rmSync(users, { recursive: true, force: true }); + fs.rmSync(settings); + fs.copyFileSync( + "cypress/fixtures/01_setup/default-settings.yaml", + "settings/settings.yaml" + ); + } - return null; - }, - }); -}; \ No newline at end of file + return null; + }, + }); +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..e858ce0 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "typemill", + "version": "1.0.0", + "description": "TYPEMILL is a lightweight flat file cms for micro-publishers. You can use it for documentations, manuals, special interest websites, and any other information-driven web-project. You can also enhance Typemill with plugins and generate professional e-books in pdf-format with it. The website http://typemill.net runs with Typemill.", + "main": "index.js", + "scripts": { + "e2e": "composer update && cypress open --project ." + }, + "repository": { + "type": "git", + "url": "git+https://github.com/typemill/typemill.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/typemill/typemill/issues" + }, + "homepage": "https://github.com/typemill/typemill#readme" +} \ No newline at end of file From be57ce57d94abaa90e4e10f003aa982560d4a2d9 Mon Sep 17 00:00:00 2001 From: Mysteriedev Date: Sun, 6 Mar 2022 16:02:05 +0100 Subject: [PATCH 05/12] add comment --- cypress/plugins/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index 10d3bef..7438135 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -23,6 +23,7 @@ module.exports = (on, config) => { resetSetup() { const users = "settings/users"; const settings = "settings/settings.yaml"; + // of course files need to exist in order to perform a delete if (fs.existsSync(settings) && fs.existsSync(users)) { fs.rmSync(users, { recursive: true, force: true }); fs.rmSync(settings); From d8217302c63bc656c29b2d3b07b870f003a8c5ba Mon Sep 17 00:00:00 2001 From: Mysteriedev Date: Sun, 6 Mar 2022 16:18:57 +0100 Subject: [PATCH 06/12] test seeding --- .gitignore | 3 +- composer.lock | 52 ++-- cypress.json | 2 +- .../settings/settings.yaml | 129 ++++++++ .../settings/users/trendschau.yaml | 9 + .../01_setup/01-system-setup-signup.spec.js | 253 +++++++-------- .../01_setup/02-initial-frontend.spec.js | 289 +++++++++--------- cypress/plugins/index.js | 11 +- package-lock.json | 41 +++ package.json | 8 +- 10 files changed, 498 insertions(+), 299 deletions(-) create mode 100644 cypress/fixtures/01_setup/prepulate_settings_seed/settings/settings.yaml create mode 100644 cypress/fixtures/01_setup/prepulate_settings_seed/settings/users/trendschau.yaml create mode 100644 package-lock.json diff --git a/.gitignore b/.gitignore index 1c1c5f3..902f6fe 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ settings/users system/vendor plugins/demo zips -build.php \ No newline at end of file +build.php +node_modules \ No newline at end of file diff --git a/composer.lock b/composer.lock index 7207d43..3cbf36e 100644 --- a/composer.lock +++ b/composer.lock @@ -367,12 +367,12 @@ }, "type": "library", "autoload": { - "psr-4": { - "FastRoute\\": "src/" - }, "files": [ "src/functions.php" - ] + ], + "psr-4": { + "FastRoute\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -982,16 +982,16 @@ }, { "name": "symfony/finder", - "version": "v5.4.2", + "version": "v5.4.3", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "e77046c252be48c48a40816187ed527703c8f76c" + "reference": "231313534dded84c7ecaa79d14bc5da4ccb69b7d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/e77046c252be48c48a40816187ed527703c8f76c", - "reference": "e77046c252be48c48a40816187ed527703c8f76c", + "url": "https://api.github.com/repos/symfony/finder/zipball/231313534dded84c7ecaa79d14bc5da4ccb69b7d", + "reference": "231313534dded84c7ecaa79d14bc5da4ccb69b7d", "shasum": "" }, "require": { @@ -1025,7 +1025,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v5.4.2" + "source": "https://github.com/symfony/finder/tree/v5.4.3" }, "funding": [ { @@ -1041,11 +1041,11 @@ "type": "tidelift" } ], - "time": "2021-12-15T11:06:13+00:00" + "time": "2022-01-26T16:34:36+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -1077,12 +1077,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1107,7 +1107,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" }, "funding": [ { @@ -1127,16 +1127,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9" + "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9", - "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4407588e0d3f1f52efb65fbe92babe41f37fe50c", + "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c", "shasum": "" }, "require": { @@ -1153,12 +1153,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, "classmap": [ "Resources/stubs" ] @@ -1190,7 +1190,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.25.0" }, "funding": [ { @@ -1206,7 +1206,7 @@ "type": "tidelift" } ], - "time": "2021-09-13T13:58:33+00:00" + "time": "2022-03-04T08:16:47+00:00" }, { "name": "symfony/yaml", @@ -1411,5 +1411,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.2.0" } diff --git a/cypress.json b/cypress.json index 91eeb63..cd7f6e3 100644 --- a/cypress.json +++ b/cypress.json @@ -1,3 +1,3 @@ { - "baseUrl": "http://localhost/EDIT_THIS_URL_FOR_YOUR_LOCAL_SETUP" + "baseUrl": "http://localhost/e2e/gitrepo/typemill" } \ No newline at end of file diff --git a/cypress/fixtures/01_setup/prepulate_settings_seed/settings/settings.yaml b/cypress/fixtures/01_setup/prepulate_settings_seed/settings/settings.yaml new file mode 100644 index 0000000..b94591e --- /dev/null +++ b/cypress/fixtures/01_setup/prepulate_settings_seed/settings/settings.yaml @@ -0,0 +1,129 @@ +setup: false +language: en +welcome: false +title: Cypress +author: robot +copyright: CC-BY-ND +year: '2017' +langattr: en +editor: visual +formats: + - markdown + - headline + - ulist + - olist + - table + - quote + - notice + - image + - video + - file + - toc + - hr + - definition + - code + - shortcode +access: null +pageaccess: null +hrdelimiter: null +restrictionnotice: '' +wraprestrictionnotice: null +headlineanchors: null +displayErrorDetails: null +twigcache: null +proxy: null +trustedproxies: '' +headersoff: null +urlschemes: '' +svg: null +recoverpw: null +recoverfrom: '' +recoversubject: '' +recovermessage: '' +securitylog: null +oldslug: null +refreshcache: null +pingsitemap: null +images: + live: + width: '820' +logo: '' +favicon: '' +theme: cyanine +themes: + cyanine: + layoutsize: standard + blogfolder: '' + landingpage: 'on' + landingpageIntro: '1' + introTitle: '' + introMarkdown: '' + introButtonLink: 'https://typemill.net' + introButtonLabel: Typemill + introImageOpacity: '' + landingpageInfo: '' + infoMarkdown: '' + landingpageTeaser: '' + teaser1title: '' + teaser1text: '' + teaser1link: '' + teaser1label: '' + teaser2title: '' + teaser2text: '' + teaser2link: '' + teaser2label: '' + teaser3title: '' + teaser3text: '' + teaser3link: '' + teaser3label: '' + landingpageContrast: '' + contrastTitle: '' + contrastText: '' + contrastLink: '' + contrastLabel: '' + landingpageNavi: '2' + naviTitle: 'Get Started' + naviDepth: '' + landingpageNews: '' + newsHeadline: '' + newsFolder: '' + newsLabel: '' + authorPosition: + top: 'on' + authorIntro: Writer + datePosition: + bottom: 'on' + dateIntro: 'Final update' + dateFormat: m/d/Y + gitPosition: + top: 'on' + gitLink: 'https://github.com/typemill/docs' + editText: '' + printText: '' + chapnum: 'on' + expand: '' + collapse: '' + next: '' + previous: '' + footer1: '' + footer2: '' + footer3: '' + copyrightlinetext: '' + font: 'BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif' + fontheadline: 'BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif' + fontnavi: 'BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif' + brandcolorprimary: '' + fontcolorprimary: '' + newsbackground: '' + newscolor: '' + brandcolortertiary: '' + fontcolortertiary: '' + bordercolortertiary: '' + fontcolorlink: '' + brandcolorsecondary: '' + fontcolorsecondary: '' + codebackground: '' + codecolor: '' + contentnavihoverbackground: '' + contentnavihovercolor: '' + thinbordercolor: '' diff --git a/cypress/fixtures/01_setup/prepulate_settings_seed/settings/users/trendschau.yaml b/cypress/fixtures/01_setup/prepulate_settings_seed/settings/users/trendschau.yaml new file mode 100644 index 0000000..d76b8c3 --- /dev/null +++ b/cypress/fixtures/01_setup/prepulate_settings_seed/settings/users/trendschau.yaml @@ -0,0 +1,9 @@ +username: trendschau +email: trendschau@gmail.com +userrole: administrator +password: $2y$10$SMeVwJeo/5vyjeI68uFi.OJZhSR.3KQTVb5zcKF5D65eZ8CDpX29. +lastlogin: 1646578390 +image: '' +description: '' +firstname: Sebastian +lastname: Schürmanns diff --git a/cypress/integration/01_setup/01-system-setup-signup.spec.js b/cypress/integration/01_setup/01-system-setup-signup.spec.js index 3dbb6c5..c8ed308 100644 --- a/cypress/integration/01_setup/01-system-setup-signup.spec.js +++ b/cypress/integration/01_setup/01-system-setup-signup.spec.js @@ -1,40 +1,43 @@ -describe("Typemill Setup with Signup", function() { - it("validates form input", function() { - // reset users and settings - cy.task("resetSetup"); - // visit setup form - cy.visit("/setup"); - // cy.visit('/setup',{ onBeforeLoad: (_contentWindow) => { Object.defineProperty(navigator, 'language', { value: 'fr-FR' }) } }) - cy.url().should("include", "/setup"); +describe("Typemill Setup with Signup", function () { + before(function () { + // reset users and settings + cy.task("resetSetup"); + }); - // add data and check attributes - cy.get('input[name="username"]') - .type("?1") - .should("have.value", "?1") - .and("have.attr", "required"); + it("validates form input", function () { + // visit setup form + cy.visit("/setup"); + // cy.visit('/setup',{ onBeforeLoad: (_contentWindow) => { Object.defineProperty(navigator, 'language', { value: 'fr-FR' }) } }) + cy.url().should("include", "/setup"); - cy.get('input[name="email"]') - .type("trendschau.net") - .should("have.value", "trendschau.net") - .and("have.attr", "required"); + // add data and check attributes + cy.get('input[name="username"]') + .type("?1") + .should("have.value", "?1") + .and("have.attr", "required"); - cy.get('input[name="password"]') - .type("pass") - .should("have.value", "pass") - .and("have.attr", "required"); + cy.get('input[name="email"]') + .type("trendschau.net") + .should("have.value", "trendschau.net") + .and("have.attr", "required"); - // submit and get validation errors - cy.get("form").submit(); - cy.get("#flash-message").should( - "contain", - "Please check your input and try again" - ); - cy.get(".error").should("contain", "invalid characters"); - cy.get(".error").should("contain", "e-mail is invalid"); - cy.get(".error").should("contain", "Length between 5 - 20"); - }); + cy.get('input[name="password"]') + .type("pass") + .should("have.value", "pass") + .and("have.attr", "required"); - /* + // submit and get validation errors + cy.get("form").submit(); + cy.get("#flash-message").should( + "contain", + "Please check your input and try again" + ); + cy.get(".error").should("contain", "invalid characters"); + cy.get(".error").should("contain", "e-mail is invalid"); + cy.get(".error").should("contain", "Length between 5 - 20"); + }); + + /* it('fails without CSRF-token', function () { cy.request({ @@ -52,111 +55,111 @@ describe("Typemill Setup with Signup", function() { .should('include', 'The form has a timeout') }) */ - it("fails without CSRF-token", function() { - cy.visit("/setup"); + it("fails without CSRF-token", function () { + cy.visit("/setup"); - // enter correct data - cy.get('input[name="username"]').clear().type("trendschau"); - cy.get('input[name="email"]').clear().type("trendschau@gmail.com"); - cy.get('input[name="password"]').clear().type("password"); - cy.get("#csrf_value").then((elem) => { - elem.val("wrongvalue"); - }); - - // submit and get validation errors - cy.get("form").submit(); - cy.get("#flash-message").should("contain", "form has a timeout"); + // enter correct data + cy.get('input[name="username"]').clear().type("trendschau"); + cy.get('input[name="email"]').clear().type("trendschau@gmail.com"); + cy.get('input[name="password"]').clear().type("password"); + cy.get("#csrf_value").then((elem) => { + elem.val("wrongvalue"); }); - it("submits valid form data and visit welcome and settings page", function() { - cy.visit("/setup"); + // submit and get validation errors + cy.get("form").submit(); + cy.get("#flash-message").should("contain", "form has a timeout"); + }); - // enter correct data - cy.get('input[name="username"]').clear().type("trendschau"); - cy.get('input[name="email"]').clear().type("trendschau@gmail.com"); - cy.get('input[name="password"]').clear().type("password"); + it("submits valid form data and visit welcome and settings page", function () { + cy.visit("/setup"); - // submits valid form - cy.get("form").submit(); - cy.url().should("include", "/welcome"); - cy.getCookie("typemill-session").should("exist"); - Cypress.Cookies.preserveOnce("typemill-session"); + // enter correct data + cy.get('input[name="username"]').clear().type("trendschau"); + cy.get('input[name="email"]').clear().type("trendschau@gmail.com"); + cy.get('input[name="password"]').clear().type("password"); - // clicks link on welcome page to settings page - // cy.get('.button').should('contain', 'Configure your website') - cy.get(".button").click(); - cy.url().should("include", "/tm/settings"); - }); + // submits valid form + cy.get("form").submit(); + cy.url().should("include", "/welcome"); + cy.getCookie("typemill-session").should("exist"); + Cypress.Cookies.preserveOnce("typemill-session"); - it("creates default settings data", function() { - cy.get('input[name="settings[title]"]') - .should("have.value", "TYPEMILL") - .and("have.attr", "required"); - cy.get('input[name="settings[author]"]'); - cy.get('select[name="settings[copyright]"]'); - cy.get('input[name="settings[year]"]').should("have.attr", "required"); - cy.get('select[name="settings[language]"]'); - // cy.get('select[name="settings[langattr]"]') - cy.get('input[name="settings[sitemap]"]') - .should("have.value", `${Cypress.config().baseUrl}/cache/sitemap.xml`) - .and("have.attr", "readonly"); - cy.get('input[name="settings[logo]"]'); - cy.get('input[name="settings[deletelogo]"]'); - cy.get('input[name="settings[favicon]"]'); - cy.get('input[name="settings[deletefav]"]'); - cy.get('input[name="settings[headlineanchors]"]'); - cy.get('input[name="settings[editor]"]'); + // clicks link on welcome page to settings page + // cy.get('.button').should('contain', 'Configure your website') + cy.get(".button").click(); + cy.url().should("include", "/tm/settings"); + }); - cy.get('select[name="settings[language]"]') - .select("en") - .should("have.value", "en"); + it("creates default settings data", function () { + cy.get('input[name="settings[title]"]') + .should("have.value", "TYPEMILL") + .and("have.attr", "required"); + cy.get('input[name="settings[author]"]'); + cy.get('select[name="settings[copyright]"]'); + cy.get('input[name="settings[year]"]').should("have.attr", "required"); + cy.get('select[name="settings[language]"]'); + // cy.get('select[name="settings[langattr]"]') + cy.get('input[name="settings[sitemap]"]') + .should("have.value", `${Cypress.config().baseUrl}/cache/sitemap.xml`) + .and("have.attr", "readonly"); + cy.get('input[name="settings[logo]"]'); + cy.get('input[name="settings[deletelogo]"]'); + cy.get('input[name="settings[favicon]"]'); + cy.get('input[name="settings[deletefav]"]'); + cy.get('input[name="settings[headlineanchors]"]'); + cy.get('input[name="settings[editor]"]'); - cy.get("form").submit(); - cy.get("#flash-message").should("contain", "Settings are stored"); + cy.get('select[name="settings[language]"]') + .select("en") + .should("have.value", "en"); - Cypress.Cookies.preserveOnce("typemill-session"); - }); + cy.get("form").submit(); + cy.get("#flash-message").should("contain", "Settings are stored"); - it("creates default user data", function() { - cy.visit("/tm/user/trendschau"); - cy.url().should("include", "/tm/user/trendschau"); - cy.get('input[name="user[username]"]').should("have.value", "trendschau"); - cy.get('input[name="user[firstname]"]') - .clear() - .type("Sebastian") - .should("have.value", "Sebastian"); - cy.get('input[name="user[lastname]"]') - .clear() - .type("Schürmanns") - .should("have.value", "Schürmanns"); - cy.get('input[name="user[email]"]').should( - "have.value", - "trendschau@gmail.com" - ); - cy.get('select[name="user[userrole]"]').should( - "have.value", - "administrator" - ); - cy.get('input[name="user[password]"]').should("have.value", ""); - cy.get('input[name="user[newpassword]"]').should("have.value", ""); + Cypress.Cookies.preserveOnce("typemill-session"); + }); - cy.get("#userform").submit(); - cy.get("#flash-message").should("contain", "Saved all changes"); - }); + it("creates default user data", function () { + cy.visit("/tm/user/trendschau"); + cy.url().should("include", "/tm/user/trendschau"); + cy.get('input[name="user[username]"]').should("have.value", "trendschau"); + cy.get('input[name="user[firstname]"]') + .clear() + .type("Sebastian") + .should("have.value", "Sebastian"); + cy.get('input[name="user[lastname]"]') + .clear() + .type("Schürmanns") + .should("have.value", "Schürmanns"); + cy.get('input[name="user[email]"]').should( + "have.value", + "trendschau@gmail.com" + ); + cy.get('select[name="user[userrole]"]').should( + "have.value", + "administrator" + ); + cy.get('input[name="user[password]"]').should("have.value", ""); + cy.get('input[name="user[newpassword]"]').should("have.value", ""); - it("logouts out", function() { - // visits logout link - cy.visit("/tm/logout"); - cy.url().should("include", "/tm/login"); + cy.get("#userform").submit(); + cy.get("#flash-message").should("contain", "Saved all changes"); + }); - // tries to open setup form again and gets redirected to login - cy.visit("/setup"); - cy.url().should("include", "/login"); - }); + it("logouts out", function () { + // visits logout link + cy.visit("/tm/logout"); + cy.url().should("include", "/tm/login"); - it("redirects when tries to setup again", function() { - // tries to open setup form again and gets redirected to login - cy.visit("/setup"); - cy.url().should("include", "/login"); - }); -}); \ No newline at end of file + // tries to open setup form again and gets redirected to login + cy.visit("/setup"); + cy.url().should("include", "/login"); + }); + + it("redirects when tries to setup again", function () { + // tries to open setup form again and gets redirected to login + cy.visit("/setup"); + cy.url().should("include", "/login"); + }); +}); diff --git a/cypress/integration/01_setup/02-initial-frontend.spec.js b/cypress/integration/01_setup/02-initial-frontend.spec.js index d9b64bf..1d54d5a 100644 --- a/cypress/integration/01_setup/02-initial-frontend.spec.js +++ b/cypress/integration/01_setup/02-initial-frontend.spec.js @@ -1,152 +1,155 @@ -describe("Typemill Initial Frontend", function() { - it("has startpage with navigation", function() { - /* visit homepage */ - cy.visit("/"); +describe("Typemill Initial Frontend", function () { + before(function () { + cy.task("prepopulateSetup"); + }); + it("has startpage with navigation", function () { + /* visit homepage */ + cy.visit("/"); - /* has startpage with headline */ - cy.get("h1").contains("Typemill"); + /* has startpage with headline */ + cy.get("h1").contains("Typemill"); - /* has start and setup button */ - cy.get("nav") - .find("a") - .should(($a) => { - expect($a).to.have.length(11); - expect($a[0].href).to.match(/welcome/); - expect($a[1].href).to.match(/welcome\/setup-your-website/); - expect($a[2].href).to.match(/welcome\/manage-access/); - expect($a[3].href).to.match(/welcome\/write-content/); - expect($a[4].href).to.match(/welcome\/get-help/); - expect($a[5].href).to.match(/welcome\/markdown-test/); - expect($a[6].href).to.match(/cyanine-theme/); - expect($a[7].href).to.match(/cyanine-theme\/landingpage/); - expect($a[8].href).to.match(/cyanine-theme\/colors-and-fonts/); - expect($a[9].href).to.match(/cyanine-theme\/footer/); - expect($a[10].href).to.match(/cyanine-theme\/content-elements/); - }); + /* has start and setup button */ + cy.get("nav") + .find("a") + .should(($a) => { + expect($a).to.have.length(11); + expect($a[0].href).to.match(/welcome/); + expect($a[1].href).to.match(/welcome\/setup-your-website/); + expect($a[2].href).to.match(/welcome\/manage-access/); + expect($a[3].href).to.match(/welcome\/write-content/); + expect($a[4].href).to.match(/welcome\/get-help/); + expect($a[5].href).to.match(/welcome\/markdown-test/); + expect($a[6].href).to.match(/cyanine-theme/); + expect($a[7].href).to.match(/cyanine-theme\/landingpage/); + expect($a[8].href).to.match(/cyanine-theme\/colors-and-fonts/); + expect($a[9].href).to.match(/cyanine-theme\/footer/); + expect($a[10].href).to.match(/cyanine-theme\/content-elements/); + }); + }); + + it("has error page", function () { + cy.request({ + url: "/error", + failOnStatusCode: false, + }).then((resp) => { + /* should return 404 not found */ + expect(resp.status).to.eq(404); }); - it("has error page", function() { - cy.request({ - url: "/error", - failOnStatusCode: false, - }).then((resp) => { - /* should return 404 not found */ - expect(resp.status).to.eq(404); - }); + cy.visit("/error", { failOnStatusCode: false }); + cy.url().should("include", "/error"); - cy.visit("/error", { failOnStatusCode: false }); - cy.url().should("include", "/error"); + cy.get("h1").contains("Not Found"); + }); - cy.get("h1").contains("Not Found"); + it("has no access to cache files", function () { + cy.request({ + url: "/cache/structure.txt", + failOnStatusCode: false, + }).then((resp) => { + // redirect status code is 302 + expect(resp.status).to.eq(403); + }); + }); + + it("has no access to dashboard", function () { + cy.visit("/tm/settings"); + cy.url().should("include", "/tm/login"); + }); + + it("has proper markdown test page", function () { + cy.visit("/welcome/markdown-test"); + cy.url().should("include", "/welcome/markdown-test"); + + /* has navigation element */ + cy.get("nav").should("exist"); + + /* check if toc exists */ + cy.get(".TOC").within(($toc) => { + /* check if a certain link in toc exists */ + cy.get("a").eq(2).should("have.attr", "href", "#h-headlines"); }); - it("has no access to cache files", function() { - cy.request({ - url: "/cache/structure.txt", - failOnStatusCode: false, - }).then((resp) => { - // redirect status code is 302 - expect(resp.status).to.eq(403); - }); + /* check if corresponding anchor exists */ + cy.get("#h-headlines").should("exist"); + + /* soft linebreaks */ + cy.get("br").should("exist"); + + /* emphasis */ + cy.get("em").should("exist"); + + /* strong */ + cy.get("strong").should("exist"); + + /* ordered list */ + cy.get("ol").should("exist"); + + /* linebreak */ + cy.get("hr").should("exist"); + + /* links exists? hard to test, any idea? We need to wrap it in a div... */ + + /* images */ + cy.get("img").eq(0).should("have.attr", "alt", "alt"); + cy.get("img") + .eq(0) + .should("have.attr", "src") + .should("include", "media/files/markdown.png"); + cy.get("figure") + .eq(2) + .should("have.id", "myid") + .and("have.class", "otherclass"); + cy.get("img") + .eq(2) + .should("have.attr", "alt", "alt-text") + .and("have.attr", "title", "my title") + .and("have.attr", "width", "150px"); + + /* blockquote */ + cy.get("blockquote").should("exist"); + + /* has navigation element */ + cy.get(".notice1").should("exist"); + cy.get(".notice2").should("exist"); + cy.get(".notice3").should("exist"); + + /* footnote */ + cy.get("sup").eq(0).should("have.id", "fnref1:1"); + cy.get("sup") + .eq(0) + .within(($sup) => { + cy.get("a") + .eq(0) + .should("have.attr", "href", "#fn%3A1") + .and("have.class", "footnote-ref"); + }); + + /* abbreviation */ + cy.get("abbr").should("exist"); + + /* definition list */ + cy.get("dl").should("exist"); + + /* table */ + cy.get("table").should("exist"); + + /* code */ + cy.get("pre").should("exist"); + cy.get("code").should("exist"); + + /* math */ + cy.get(".math").should("exist"); + + /* footnote end */ + cy.get(".footnotes").within(($footnotes) => { + cy.get("li").eq(0).should("have.id", "fn:1"); + cy.get("a") + .eq(0) + .should("have.class", "footnote-backref") + .and("have.attr", "href", "#fnref1%3A1") + .and("have.attr", "rev", "footnote"); }); - - it("has no access to dashboard", function() { - cy.visit("/tm/settings"); - cy.url().should("include", "/tm/login"); - }); - - it("has proper markdown test page", function() { - cy.visit("/welcome/markdown-test"); - cy.url().should("include", "/welcome/markdown-test"); - - /* has navigation element */ - cy.get("nav").should("exist"); - - /* check if toc exists */ - cy.get(".TOC").within(($toc) => { - /* check if a certain link in toc exists */ - cy.get("a").eq(2).should("have.attr", "href", "#h-headlines"); - }); - - /* check if corresponding anchor exists */ - cy.get("#h-headlines").should("exist"); - - /* soft linebreaks */ - cy.get("br").should("exist"); - - /* emphasis */ - cy.get("em").should("exist"); - - /* strong */ - cy.get("strong").should("exist"); - - /* ordered list */ - cy.get("ol").should("exist"); - - /* linebreak */ - cy.get("hr").should("exist"); - - /* links exists? hard to test, any idea? We need to wrap it in a div... */ - - /* images */ - cy.get("img").eq(0).should("have.attr", "alt", "alt"); - cy.get("img") - .eq(0) - .should("have.attr", "src") - .should("include", "media/files/markdown.png"); - cy.get("figure") - .eq(2) - .should("have.id", "myid") - .and("have.class", "otherclass"); - cy.get("img") - .eq(2) - .should("have.attr", "alt", "alt-text") - .and("have.attr", "title", "my title") - .and("have.attr", "width", "150px"); - - /* blockquote */ - cy.get("blockquote").should("exist"); - - /* has navigation element */ - cy.get(".notice1").should("exist"); - cy.get(".notice2").should("exist"); - cy.get(".notice3").should("exist"); - - /* footnote */ - cy.get("sup").eq(0).should("have.id", "fnref1:1"); - cy.get("sup") - .eq(0) - .within(($sup) => { - cy.get("a") - .eq(0) - .should("have.attr", "href", "#fn%3A1") - .and("have.class", "footnote-ref"); - }); - - /* abbreviation */ - cy.get("abbr").should("exist"); - - /* definition list */ - cy.get("dl").should("exist"); - - /* table */ - cy.get("table").should("exist"); - - /* code */ - cy.get("pre").should("exist"); - cy.get("code").should("exist"); - - /* math */ - cy.get(".math").should("exist"); - - /* footnote end */ - cy.get(".footnotes").within(($footnotes) => { - cy.get("li").eq(0).should("have.id", "fn:1"); - cy.get("a") - .eq(0) - .should("have.class", "footnote-backref") - .and("have.attr", "href", "#fnref1%3A1") - .and("have.attr", "rev", "footnote"); - }); - }); -}); \ No newline at end of file + }); +}); diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index 7438135..9b34b67 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -1,4 +1,4 @@ -const fs = require("fs"); +const fs = require("fs-extra"); /// // *********************************************************** @@ -33,6 +33,15 @@ module.exports = (on, config) => { ); } + return null; + }, + prepopulateSetup() { + const settings = "settings"; + const settingsFixture = + "cypress/fixtures/01_setup/prepulate_settings_seed/settings"; + // of course files need to exist in order to perform a delete + fs.copySync(settingsFixture, settings); + return null; }, }); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..8be4d23 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,41 @@ +{ + "name": "typemill", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "fs-extra": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz", + "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "graceful-fs": { + "version": "4.2.9", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", + "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==", + "dev": true + }, + "jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" + } + }, + "universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "dev": true + } + } +} diff --git a/package.json b/package.json index e858ce0..3bf9aef 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "TYPEMILL is a lightweight flat file cms for micro-publishers. You can use it for documentations, manuals, special interest websites, and any other information-driven web-project. You can also enhance Typemill with plugins and generate professional e-books in pdf-format with it. The website http://typemill.net runs with Typemill.", "main": "index.js", "scripts": { - "e2e": "composer update && cypress open --project ." + "e2e": "cypress open --project .", + "install-and-e2e": "npm i && composer update && cypress open --project ." }, "repository": { "type": "git", @@ -15,5 +16,8 @@ "bugs": { "url": "https://github.com/typemill/typemill/issues" }, - "homepage": "https://github.com/typemill/typemill#readme" + "homepage": "https://github.com/typemill/typemill#readme", + "devDependencies": { + "fs-extra": "^10.0.1" + } } \ No newline at end of file From 51ea4c71dcfafcac33258b0c8a135ea50ddb1790 Mon Sep 17 00:00:00 2001 From: Mysteriedev Date: Sun, 6 Mar 2022 16:20:27 +0100 Subject: [PATCH 07/12] baseurl --- cypress.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress.json b/cypress.json index cd7f6e3..264e36e 100644 --- a/cypress.json +++ b/cypress.json @@ -1,3 +1,3 @@ { - "baseUrl": "http://localhost/e2e/gitrepo/typemill" + "baseUrl": "http://localhost/EDIT_YOUR_LOCAL_BASE_URL_HERE" } \ No newline at end of file From 637cf4b77df631f5513fb81858c8c73886b68fa7 Mon Sep 17 00:00:00 2001 From: Mysteriedev Date: Sun, 6 Mar 2022 18:29:23 +0100 Subject: [PATCH 08/12] make tests easier --- .../settings/settings.yaml | 136 ++------ .../integration/03-system-settings.spec.js | 158 +++++---- cypress/integration/04-theme-settings.spec.js | 232 +++++++------ cypress/integration/05-blox-editor.spec.js | 308 ------------------ .../05_visual-editor/05-blox-editor.spec.js | 259 +++++++++++++++ cypress/support/commands.js | 16 + 6 files changed, 491 insertions(+), 618 deletions(-) delete mode 100644 cypress/integration/05-blox-editor.spec.js create mode 100644 cypress/integration/05_visual-editor/05-blox-editor.spec.js diff --git a/cypress/fixtures/01_setup/prepulate_settings_seed/settings/settings.yaml b/cypress/fixtures/01_setup/prepulate_settings_seed/settings/settings.yaml index b94591e..71492b7 100644 --- a/cypress/fixtures/01_setup/prepulate_settings_seed/settings/settings.yaml +++ b/cypress/fixtures/01_setup/prepulate_settings_seed/settings/settings.yaml @@ -1,129 +1,51 @@ setup: false language: en welcome: false -title: Cypress -author: robot -copyright: CC-BY-ND -year: '2017' +title: TYPEMILL +author: Unknown +copyright: © +year: "2022" langattr: en editor: visual formats: - - markdown - - headline - - ulist - - olist - - table - - quote - - notice - - image - - video - - file - - toc - - hr - - definition - - code - - shortcode + - markdown + - headline + - ulist + - olist + - table + - quote + - notice + - image + - video + - file + - toc + - hr + - definition + - code + - shortcode access: null pageaccess: null hrdelimiter: null -restrictionnotice: '' +restrictionnotice: "" wraprestrictionnotice: null headlineanchors: null displayErrorDetails: null twigcache: null proxy: null -trustedproxies: '' +trustedproxies: "" headersoff: null -urlschemes: '' +urlschemes: "" svg: null recoverpw: null -recoverfrom: '' -recoversubject: '' -recovermessage: '' +recoverfrom: "" +recoversubject: "" +recovermessage: "" securitylog: null oldslug: null refreshcache: null pingsitemap: null images: - live: - width: '820' -logo: '' -favicon: '' -theme: cyanine -themes: - cyanine: - layoutsize: standard - blogfolder: '' - landingpage: 'on' - landingpageIntro: '1' - introTitle: '' - introMarkdown: '' - introButtonLink: 'https://typemill.net' - introButtonLabel: Typemill - introImageOpacity: '' - landingpageInfo: '' - infoMarkdown: '' - landingpageTeaser: '' - teaser1title: '' - teaser1text: '' - teaser1link: '' - teaser1label: '' - teaser2title: '' - teaser2text: '' - teaser2link: '' - teaser2label: '' - teaser3title: '' - teaser3text: '' - teaser3link: '' - teaser3label: '' - landingpageContrast: '' - contrastTitle: '' - contrastText: '' - contrastLink: '' - contrastLabel: '' - landingpageNavi: '2' - naviTitle: 'Get Started' - naviDepth: '' - landingpageNews: '' - newsHeadline: '' - newsFolder: '' - newsLabel: '' - authorPosition: - top: 'on' - authorIntro: Writer - datePosition: - bottom: 'on' - dateIntro: 'Final update' - dateFormat: m/d/Y - gitPosition: - top: 'on' - gitLink: 'https://github.com/typemill/docs' - editText: '' - printText: '' - chapnum: 'on' - expand: '' - collapse: '' - next: '' - previous: '' - footer1: '' - footer2: '' - footer3: '' - copyrightlinetext: '' - font: 'BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif' - fontheadline: 'BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif' - fontnavi: 'BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif' - brandcolorprimary: '' - fontcolorprimary: '' - newsbackground: '' - newscolor: '' - brandcolortertiary: '' - fontcolortertiary: '' - bordercolortertiary: '' - fontcolorlink: '' - brandcolorsecondary: '' - fontcolorsecondary: '' - codebackground: '' - codecolor: '' - contentnavihoverbackground: '' - contentnavihovercolor: '' - thinbordercolor: '' + live: + width: "820" +logo: "" +favicon: "" diff --git a/cypress/integration/03-system-settings.spec.js b/cypress/integration/03-system-settings.spec.js index ba6ee61..6e9e3c7 100644 --- a/cypress/integration/03-system-settings.spec.js +++ b/cypress/integration/03-system-settings.spec.js @@ -1,101 +1,93 @@ -describe("Typemill System Settings", function() { - before(function() { - cy.visit("/tm/login"); - cy.url().should("include", "/tm/login"); +describe("Typemill System Settings", function () { + before(function () { + cy.loginTypemill(); - cy.get('input[name="username"]').type("trendschau"); - cy.get('input[name="password"]').type("password"); + cy.visit("/tm/settings"); + cy.url().should("include", "/tm/settings"); + }); - cy.get("form").submit(); - cy.url().should("include", "/tm/content"); - cy.getCookie("typemill-session").should("exist"); + beforeEach(function () { + Cypress.Cookies.preserveOnce("typemill-session"); + }); - cy.visit("/tm/settings"); - cy.url().should("include", "/tm/settings"); - }); + it("validates the form", function () { + // fill out valid data + cy.get('input[name="settings[title]"]') + .clear() + .type("Cypress a').eq(0).click() - - /* Check dublicates cannot be made */ - - /* Check new page can be created */ - cy.get('.addNaviForm').within(($naviform) =>{ - - /* add Testpage into input */ - cy.get('input') - .clear() - .type('Testpage') - .should('have.value', 'Testpage') - - cy.get('.b-left').click() - }) - - /* get Navilist */ - cy.get('.navi-list') - .should('contain', 'Testpage') - .eq(2).find('a').should(($a) => { - expect($a).to.have.length(6) - expect($a[5].href).to.include('/welcome\/testpage') - }) - }) - - it('edits default content', function() - { - cy.visit('/tm/content/visual/welcome/testpage') - cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') - - cy.get('#blox').within(($blox) => { - - /* Change Title */ - cy.get('#blox-0').click() - cy.get("input") - .clear() - .type("This is my Testpage") - - cy.get(".edit").click() - cy.get('#blox-0').should("contain", "This is my Testpage") - - /* Change Text */ - cy.get('#blox-1').click() - cy.get("textarea") - .clear() - .type("This is the new paragraph for the first line with some text.") - - cy.get(".edit").click() - cy.get('#blox-1').should("contain", "new paragraph") - - }) - }) - - it('edits paragraph', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(0).click() - cy.get("textarea") - .type("This is a second paragraph.") - - /* save table */ - cy.get(".edit").click() - cy.get(".cancel").click() - - }) - - cy.get('#blox-2').should("contain", "second paragraph") - }) - }) - - it('edits headline', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(1).click() - cy.get("input") - .type("Second Level Headline") - - /* save block */ - cy.get(".edit").click() - - /* close new standard textarea */ - cy.get(".cancel").click() - - }) - - cy.get('#blox-3').should("contain", "Second Level Headline") - }) - }) - - it('edits unordered list', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(2).click() - cy.get("textarea") - .type("first list item{enter}second list item") - - /* save block */ - cy.get(".edit").click() - - /* close new standard textarea */ - cy.get(".cancel").click() - - }) - - cy.get('#blox-4').within(($block) => { - cy.get("li").should(($lis) => { - expect($lis).to.have.length(2) - expect($lis.eq(0)).to.contain('first list item') - }) - }) - }) - }) - - it('edits ordered list', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(3).click() - cy.get("textarea") - .type("first ordered item{enter}second ordered item") - - /* save block */ - cy.get(".edit").click() - - /* close new standard textarea */ - cy.get(".cancel").click() - - }) - - cy.get('#blox-5').within(($block) => { - cy.get("li").should(($lis) => { - expect($lis).to.have.length(2) - expect($lis.eq(0)).to.contain('first ordered item') - }) - }) - }) - }) - - it('edits table', function() - { - cy.get('#blox').within(($blox) => { - /* Get Format Bar */ - cy.get('.format-bar').within(($formats) => { - - /* Edit Table */ - cy.get("button").eq(4).click() - cy.get("table").within(($table) => { - - /* edit table head */ - cy.get("tr").eq(1).within(($row) => { - cy.get("th").eq(1).click() - .clear() - .type("first Headline") - cy.get("th").eq(2).click() - .clear() - .type("Second Headline") - }) - - /* edit first content row */ - cy.get("tr").eq(2).within(($row) => { - cy.get("td").eq(1).click() - .clear() - .type("Some") - cy.get("td").eq(2).click() - .clear() - .type("More") - }) - - /* edit second content row */ - cy.get("tr").eq(3).within(($row) => { - cy.get("td").eq(1).click() - .clear() - .type("Beautiful") - cy.get("td").eq(2).click() - .clear() - .type("Content") - }) - - /* add new column on the right */ - cy.get("tr").eq(0).within(($row) => { - cy.get("td").eq(2).click() - cy.get(".actionline").eq(0).click() - }) - }) - - cy.get("table").within(($table) => { - - /* edit second new column head */ - cy.get("tr").eq(1).within(($row) => { - cy.get("th").eq(3).click() - .clear() - .type("New Head") - }) - - /* edit second new column head */ - cy.get("tr").eq(2).within(($row) => { - cy.get("td").eq(3).click() - .clear() - .type("With") - }) - - /* edit second new column head */ - cy.get("tr").eq(3).within(($row) => { - cy.get("td").eq(3).click() - .clear() - .type("new Content") - }) - }) - - /* save table */ - cy.get(".edit").click() - - }) - - cy.get('#blox-6').should("contain", "Beautiful").click() - - cy.get('.editactive').within(($activeblock) => { - cy.get('.component').should("contain", "Beautiful") - }) - - }) - }) - - it('Publishes new page', function() - { - cy.visit('/tm/content/visual/welcome/testpage') - cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') - - cy.get('#publish').click().wait(500) - - cy.visit('/welcome/testpage') - cy.url().should('include','/welcome/testpage') - - cy.get('.cy-nav') - .should('contain', 'Testpage') - }) - - it('has sitemap xml', function () - { - cy.request({ - url: '/cache/sitemap.xml', - }) - .then((resp) => { - /* should return xml-format */ - expect(resp.headers).to.have.property('content-type','application/xml') - }) - }) - - it('Deletes new page', function() - { - cy.visit('/tm/content/visual/welcome/testpage') - cy.url().should('include','/tm\/content\/visual\/welcome\/testpage') - - cy.get('.danger').click() - - cy.get('#modalWindow').within(($modal) => { - cy.get('button').click() - }) - - cy.visit('/tm/content/visual/welcome') - cy.get('.navi-list') - .not('contain', 'Testpage') - .eq(2).find('a').should(($a) => { - expect($a).to.have.length(5) - }) - }) -}) \ No newline at end of file diff --git a/cypress/integration/05_visual-editor/05-blox-editor.spec.js b/cypress/integration/05_visual-editor/05-blox-editor.spec.js new file mode 100644 index 0000000..5603a08 --- /dev/null +++ b/cypress/integration/05_visual-editor/05-blox-editor.spec.js @@ -0,0 +1,259 @@ +describe("Blox Editor", function () { + before(function () { + cy.loginTypemill(); + cy.visit("/tm/content/visual"); + cy.url().should("include", "/tm/content/visual"); + }); + + beforeEach(function () { + Cypress.Cookies.preserveOnce("typemill-session"); + }); + + it("creates new page", function () { + // click on add element + cy.get(".addNaviItem > a").eq(0).click(); + + /* Check dublicates cannot be made */ + + /* Check new page can be created */ + cy.get(".addNaviForm").within(($naviform) => { + /* add Testpage into input */ + cy.get("input").clear().type("Testpage").should("have.value", "Testpage"); + + cy.get(".b-left").click(); + }); + + /* get Navilist */ + cy.get(".navi-list") + .should("contain", "Testpage") + .eq(2) + .find("a") + .should(($a) => { + expect($a).to.have.length(6); + expect($a[5].href).to.include("/welcome/testpage"); + }); + }); + + it("edits default content", function () { + cy.visit("/tm/content/visual/welcome/testpage"); + cy.url().should("include", "/tm/content/visual/welcome/testpage"); + + cy.get("#blox").within(($blox) => { + /* Change Title */ + cy.get("#blox-0").click(); + cy.get("input").clear().type("This is my Testpage"); + + cy.get(".edit").click(); + cy.get("#blox-0").should("contain", "This is my Testpage"); + + /* Change Text */ + cy.get("#blox-1").click(); + cy.get("textarea") + .clear() + .type("This is the new paragraph for the first line with some text."); + + cy.get(".edit").click(); + cy.get("#blox-1").should("contain", "new paragraph"); + }); + }); + + it("edits paragraph", function () { + cy.get("#blox").within(($blox) => { + /* Get Format Bar */ + cy.get(".format-bar").within(($formats) => { + /* Edit Table */ + cy.get("button").eq(0).click(); + cy.get("textarea").type("This is a second paragraph."); + + /* save table */ + cy.get(".edit").click(); + cy.get(".cancel").click(); + }); + + cy.get("#blox-2").should("contain", "second paragraph"); + }); + }); + + it("edits headline", function () { + cy.get("#blox").within(($blox) => { + /* Get Format Bar */ + cy.get(".format-bar").within(($formats) => { + /* Edit Table */ + cy.get("button").eq(1).click(); + cy.get("input").type("Second Level Headline"); + + /* save block */ + cy.get(".edit").click(); + + /* close new standard textarea */ + cy.get(".cancel").click(); + }); + + cy.get("#blox-3").should("contain", "Second Level Headline"); + }); + }); + + it("edits unordered list", function () { + cy.get("#blox").within(($blox) => { + /* Get Format Bar */ + cy.get(".format-bar").within(($formats) => { + /* Edit Table */ + cy.get("button").eq(2).click(); + cy.get("textarea").type("first list item{enter}second list item"); + + /* save block */ + cy.get(".edit").click(); + + /* close new standard textarea */ + cy.get(".cancel").click(); + }); + + cy.get("#blox-4").within(($block) => { + cy.get("li").should(($lis) => { + expect($lis).to.have.length(2); + expect($lis.eq(0)).to.contain("first list item"); + }); + }); + }); + }); + + it("edits ordered list", function () { + cy.get("#blox").within(($blox) => { + /* Get Format Bar */ + cy.get(".format-bar").within(($formats) => { + /* Edit Table */ + cy.get("button").eq(3).click(); + cy.get("textarea").type("first ordered item{enter}second ordered item"); + + /* save block */ + cy.get(".edit").click(); + + /* close new standard textarea */ + cy.get(".cancel").click(); + }); + + cy.get("#blox-5").within(($block) => { + cy.get("li").should(($lis) => { + expect($lis).to.have.length(2); + expect($lis.eq(0)).to.contain("first ordered item"); + }); + }); + }); + }); + + it("edits table", function () { + cy.get("#blox").within(($blox) => { + /* Get Format Bar */ + cy.get(".format-bar").within(($formats) => { + /* Edit Table */ + cy.get("button").eq(4).click(); + cy.get("table").within(($table) => { + /* edit table head */ + cy.get("tr") + .eq(1) + .within(($row) => { + cy.get("th").eq(1).click().clear().type("first Headline"); + cy.get("th").eq(2).click().clear().type("Second Headline"); + }); + + /* edit first content row */ + cy.get("tr") + .eq(2) + .within(($row) => { + cy.get("td").eq(1).click().clear().type("Some"); + cy.get("td").eq(2).click().clear().type("More"); + }); + + /* edit second content row */ + cy.get("tr") + .eq(3) + .within(($row) => { + cy.get("td").eq(1).click().clear().type("Beautiful"); + cy.get("td").eq(2).click().clear().type("Content"); + }); + + /* add new column on the right */ + cy.get("tr") + .eq(0) + .within(($row) => { + cy.get("td").eq(2).click(); + cy.get(".actionline").eq(0).click(); + }); + }); + + cy.get("table").within(($table) => { + /* edit second new column head */ + cy.get("tr") + .eq(1) + .within(($row) => { + cy.get("th").eq(3).click().clear().type("New Head"); + }); + + /* edit second new column head */ + cy.get("tr") + .eq(2) + .within(($row) => { + cy.get("td").eq(3).click().clear().type("With"); + }); + + /* edit second new column head */ + cy.get("tr") + .eq(3) + .within(($row) => { + cy.get("td").eq(3).click().clear().type("new Content"); + }); + }); + + /* save table */ + cy.get(".edit").click(); + }); + + cy.get("#blox-6").should("contain", "Beautiful").click(); + + cy.get(".editactive").within(($activeblock) => { + cy.get(".component").should("contain", "Beautiful"); + }); + }); + }); + + it("Publishes new page", function () { + cy.visit("/tm/content/visual/welcome/testpage"); + cy.url().should("include", "/tm/content/visual/welcome/testpage"); + + cy.get("#publish").click().wait(500); + + cy.visit("/welcome/testpage"); + cy.url().should("include", "/welcome/testpage"); + + cy.get(".cy-nav").should("contain", "Testpage"); + }); + + it("has sitemap xml", function () { + cy.request({ + url: "/cache/sitemap.xml", + }).then((resp) => { + /* should return xml-format */ + expect(resp.headers).to.have.property("content-type", "application/xml"); + }); + }); + + it("Deletes new page", function () { + cy.visit("/tm/content/visual/welcome/testpage"); + cy.url().should("include", "/tm/content/visual/welcome/testpage"); + + cy.get(".danger").click(); + + cy.get("#modalWindow").within(($modal) => { + cy.get("button").click(); + }); + + cy.visit("/tm/content/visual/welcome"); + cy.get(".navi-list") + .not("contain", "Testpage") + .eq(2) + .find("a") + .should(($a) => { + expect($a).to.have.length(5); + }); + }); +}); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 119ab03..45cd5a2 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -23,3 +23,19 @@ // // -- This will overwrite an existing command -- // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) + +Cypress.Commands.add("loginTypemill", () => { + cy.visit("/tm/login"); + cy.url().should("include", "/tm/login"); + + cy.get('input[name="username"]').type("trendschau"); + cy.get('input[name="password"]').type("password"); + + cy.get("form").submit(); + cy.url().should("include", "/tm/content"); + cy.getCookie("typemill-session").should("exist"); +}); + +Cypress.Commands.add("logoutTypemill", () => { + cy.visit("/tm/logout"); +}); From 1f39fa1a255f1118a39ad5450efca525e8547cdb Mon Sep 17 00:00:00 2001 From: Mysteriedev Date: Sun, 6 Mar 2022 18:32:27 +0100 Subject: [PATCH 09/12] logout after system specs --- themes/cyanine/cyanine.yaml | 54 ++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/themes/cyanine/cyanine.yaml b/themes/cyanine/cyanine.yaml index 0da0c89..64f1925 100644 --- a/themes/cyanine/cyanine.yaml +++ b/themes/cyanine/cyanine.yaml @@ -1,6 +1,6 @@ name: Cyanine Theme version: 1.1.11 -description: Cyanine is a modern and flexible multi-purpose theme and the standard theme for typemill. +description: Cyanine is a modern and flexible multi-purpose theme and the standard theme for typemill. author: Trendschau homepage: https://trendschau.net licence: MIT @@ -17,7 +17,6 @@ settings: forms: fields: - layoutsize: type: select label: Layout Size @@ -101,7 +100,7 @@ forms: landingpageInfo: type: number label: Position of Info Segment - description: Use 0 to disable the section + description: Use 0 to disable the section infoMarkdown: type: textarea label: Use Markdown @@ -164,7 +163,7 @@ forms: landingpageContrast: type: number label: Position of Contrast Segment - description: Use 0 to disable the section + description: Use 0 to disable the section contrastTitle: type: text label: Title @@ -185,7 +184,7 @@ forms: landingpageNavi: type: number label: Position of Navi Segment - description: Use 0 to disable the section + description: Use 0 to disable the section naviTitle: type: text label: Title for navigation @@ -195,12 +194,12 @@ forms: landingpageNews: type: fieldset - legend: Landingpage News Segment + legend: Landingpage News Segment fields: landingpageNews: type: number label: Position of News Segment - description: Use 0 to disable the section + description: Use 0 to disable the section newsHeadline: type: text label: Headline for news-segment @@ -251,8 +250,8 @@ forms: type: select label: Date format options: - 'm/d/Y': 01/20/2020 - 'd.m.Y': 20.01.2020 + "m/d/Y": 01/20/2020 + "d.m.Y": 20.01.2020 fieldsetGitHub: type: fieldset @@ -352,7 +351,6 @@ forms: type: textarea label: footer column 3 (use markdown) - fieldsetcopyrightline: type: fieldset legend: Copyright Line @@ -379,7 +377,7 @@ forms: courier,sans-serif: courier (sans-serif) helvetica,sans-serif: helvetica (sans-serif) avenir,sans-serif: avenir (sans-serif) - athelas,serif: athelas (serif) + athelas,serif: athelas (serif) georgia,serif: georgia (serif) times,serif: times (serif) bodoni,serif: bodoni (serif) @@ -396,7 +394,7 @@ forms: courier,sans-serif: courier (sans-serif) helvetica,sans-serif: helvetica (sans-serif) avenir,sans-serif: avenir (sans-serif) - athelas,serif: athelas (serif) + athelas,serif: athelas (serif) georgia,serif: georgia (serif) times,serif: times (serif) bodoni,serif: bodoni (serif) @@ -413,7 +411,7 @@ forms: courier,sans-serif: courier (sans-serif) helvetica,sans-serif: helvetica (sans-serif) avenir,sans-serif: avenir (sans-serif) - athelas,serif: athelas (serif) + athelas,serif: athelas (serif) georgia,serif: georgia (serif) times,serif: times (serif) bodoni,serif: bodoni (serif) @@ -427,77 +425,77 @@ forms: brandcolorprimary: type: text label: Background color for body - placeholder: 'leightseagreen' + placeholder: "leightseagreen" fieldsize: half fontcolorprimary: type: text label: Font color for body - placeholder: 'white' + placeholder: "white" fieldsize: half newsbackground: type: text label: Background color for news-box - placeholder: 'white' + placeholder: "white" fieldsize: half newscolor: type: text label: Font color for news-box - placeholder: '#333' + placeholder: "#333" fieldsize: half brandcolortertiary: type: text label: Background color for buttons - placeholder: 'lightseagreen' + placeholder: "lightseagreen" fieldsize: half fontcolortertiary: type: text label: Font color for buttons - placeholder: '#F7F7F7' + placeholder: "#F7F7F7" fieldsize: half bordercolortertiary: type: text label: Border color for buttons - placeholder: '#F7F7F7' + placeholder: "#F7F7F7" fieldsize: half fontcolorlink: type: text label: Font color for content links - placeholder: '#007F7F' + placeholder: "#007F7F" fieldsize: half brandcolorsecondary: type: text label: Background color for content - placeholder: '#f7f7f7' + placeholder: "#f7f7f7" fieldsize: half fontcolorsecondary: type: text label: Font color for content - placeholder: '#333' + placeholder: "#333" fieldsize: half codebackground: type: text label: Background color for code - placeholder: '#ddd' + placeholder: "#ddd" fieldsize: half codecolor: type: text label: Font color for code - placeholder: '#333' + placeholder: "#333" fieldsize: half contentnavihoverbackground: type: text label: Background color for hover of content navigation - placeholder: 'lightseagreen' + placeholder: "lightseagreen" fieldsize: half contentnavihovercolor: type: text label: Font color for hover of content navigation - placeholder: 'white' + placeholder: "white" fieldsize: half thinbordercolor: type: text label: Thin border color - placeholder: 'lightgray' + placeholder: "lightgray" description: Used for content navigation, table and horizontal line fieldsize: half noticecolors: From 47204ada61d424a2f89342048f05d94129c7f832 Mon Sep 17 00:00:00 2001 From: Mysteriedev Date: Sun, 6 Mar 2022 18:32:39 +0100 Subject: [PATCH 10/12] logout after test --- cypress/integration/03-system-settings.spec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cypress/integration/03-system-settings.spec.js b/cypress/integration/03-system-settings.spec.js index 6e9e3c7..b7943b5 100644 --- a/cypress/integration/03-system-settings.spec.js +++ b/cypress/integration/03-system-settings.spec.js @@ -10,6 +10,10 @@ describe("Typemill System Settings", function () { Cypress.Cookies.preserveOnce("typemill-session"); }); + after(function () { + cy.logoutTypemill(); + }); + it("validates the form", function () { // fill out valid data cy.get('input[name="settings[title]"]') From 9d355d88f856ca85d005293b1f6770358eeebb7e Mon Sep 17 00:00:00 2001 From: Mysteriedev Date: Sun, 6 Mar 2022 18:34:25 +0100 Subject: [PATCH 11/12] Revert "logout after system specs" This reverts commit 1f39fa1a255f1118a39ad5450efca525e8547cdb. --- themes/cyanine/cyanine.yaml | 54 +++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/themes/cyanine/cyanine.yaml b/themes/cyanine/cyanine.yaml index 64f1925..0da0c89 100644 --- a/themes/cyanine/cyanine.yaml +++ b/themes/cyanine/cyanine.yaml @@ -1,6 +1,6 @@ name: Cyanine Theme version: 1.1.11 -description: Cyanine is a modern and flexible multi-purpose theme and the standard theme for typemill. +description: Cyanine is a modern and flexible multi-purpose theme and the standard theme for typemill. author: Trendschau homepage: https://trendschau.net licence: MIT @@ -17,6 +17,7 @@ settings: forms: fields: + layoutsize: type: select label: Layout Size @@ -100,7 +101,7 @@ forms: landingpageInfo: type: number label: Position of Info Segment - description: Use 0 to disable the section + description: Use 0 to disable the section infoMarkdown: type: textarea label: Use Markdown @@ -163,7 +164,7 @@ forms: landingpageContrast: type: number label: Position of Contrast Segment - description: Use 0 to disable the section + description: Use 0 to disable the section contrastTitle: type: text label: Title @@ -184,7 +185,7 @@ forms: landingpageNavi: type: number label: Position of Navi Segment - description: Use 0 to disable the section + description: Use 0 to disable the section naviTitle: type: text label: Title for navigation @@ -194,12 +195,12 @@ forms: landingpageNews: type: fieldset - legend: Landingpage News Segment + legend: Landingpage News Segment fields: landingpageNews: type: number label: Position of News Segment - description: Use 0 to disable the section + description: Use 0 to disable the section newsHeadline: type: text label: Headline for news-segment @@ -250,8 +251,8 @@ forms: type: select label: Date format options: - "m/d/Y": 01/20/2020 - "d.m.Y": 20.01.2020 + 'm/d/Y': 01/20/2020 + 'd.m.Y': 20.01.2020 fieldsetGitHub: type: fieldset @@ -351,6 +352,7 @@ forms: type: textarea label: footer column 3 (use markdown) + fieldsetcopyrightline: type: fieldset legend: Copyright Line @@ -377,7 +379,7 @@ forms: courier,sans-serif: courier (sans-serif) helvetica,sans-serif: helvetica (sans-serif) avenir,sans-serif: avenir (sans-serif) - athelas,serif: athelas (serif) + athelas,serif: athelas (serif) georgia,serif: georgia (serif) times,serif: times (serif) bodoni,serif: bodoni (serif) @@ -394,7 +396,7 @@ forms: courier,sans-serif: courier (sans-serif) helvetica,sans-serif: helvetica (sans-serif) avenir,sans-serif: avenir (sans-serif) - athelas,serif: athelas (serif) + athelas,serif: athelas (serif) georgia,serif: georgia (serif) times,serif: times (serif) bodoni,serif: bodoni (serif) @@ -411,7 +413,7 @@ forms: courier,sans-serif: courier (sans-serif) helvetica,sans-serif: helvetica (sans-serif) avenir,sans-serif: avenir (sans-serif) - athelas,serif: athelas (serif) + athelas,serif: athelas (serif) georgia,serif: georgia (serif) times,serif: times (serif) bodoni,serif: bodoni (serif) @@ -425,77 +427,77 @@ forms: brandcolorprimary: type: text label: Background color for body - placeholder: "leightseagreen" + placeholder: 'leightseagreen' fieldsize: half fontcolorprimary: type: text label: Font color for body - placeholder: "white" + placeholder: 'white' fieldsize: half newsbackground: type: text label: Background color for news-box - placeholder: "white" + placeholder: 'white' fieldsize: half newscolor: type: text label: Font color for news-box - placeholder: "#333" + placeholder: '#333' fieldsize: half brandcolortertiary: type: text label: Background color for buttons - placeholder: "lightseagreen" + placeholder: 'lightseagreen' fieldsize: half fontcolortertiary: type: text label: Font color for buttons - placeholder: "#F7F7F7" + placeholder: '#F7F7F7' fieldsize: half bordercolortertiary: type: text label: Border color for buttons - placeholder: "#F7F7F7" + placeholder: '#F7F7F7' fieldsize: half fontcolorlink: type: text label: Font color for content links - placeholder: "#007F7F" + placeholder: '#007F7F' fieldsize: half brandcolorsecondary: type: text label: Background color for content - placeholder: "#f7f7f7" + placeholder: '#f7f7f7' fieldsize: half fontcolorsecondary: type: text label: Font color for content - placeholder: "#333" + placeholder: '#333' fieldsize: half codebackground: type: text label: Background color for code - placeholder: "#ddd" + placeholder: '#ddd' fieldsize: half codecolor: type: text label: Font color for code - placeholder: "#333" + placeholder: '#333' fieldsize: half contentnavihoverbackground: type: text label: Background color for hover of content navigation - placeholder: "lightseagreen" + placeholder: 'lightseagreen' fieldsize: half contentnavihovercolor: type: text label: Font color for hover of content navigation - placeholder: "white" + placeholder: 'white' fieldsize: half thinbordercolor: type: text label: Thin border color - placeholder: "lightgray" + placeholder: 'lightgray' description: Used for content navigation, table and horizontal line fieldsize: half noticecolors: From 140cc0ca03079744b2b07c94d8a35e2fb6b334fe Mon Sep 17 00:00:00 2001 From: Mysteriedev Date: Sun, 6 Mar 2022 18:42:04 +0100 Subject: [PATCH 12/12] remove php fragmet syntax --- .../05_visual-editor/05-blox-editor.spec.js | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/cypress/integration/05_visual-editor/05-blox-editor.spec.js b/cypress/integration/05_visual-editor/05-blox-editor.spec.js index 5603a08..b6f935d 100644 --- a/cypress/integration/05_visual-editor/05-blox-editor.spec.js +++ b/cypress/integration/05_visual-editor/05-blox-editor.spec.js @@ -16,7 +16,7 @@ describe("Blox Editor", function () { /* Check dublicates cannot be made */ /* Check new page can be created */ - cy.get(".addNaviForm").within(($naviform) => { + cy.get(".addNaviForm").within((naviform) => { /* add Testpage into input */ cy.get("input").clear().type("Testpage").should("have.value", "Testpage"); @@ -28,9 +28,9 @@ describe("Blox Editor", function () { .should("contain", "Testpage") .eq(2) .find("a") - .should(($a) => { - expect($a).to.have.length(6); - expect($a[5].href).to.include("/welcome/testpage"); + .should((a) => { + expect(a).to.have.length(6); + expect(a[5].href).to.include("/welcome/testpage"); }); }); @@ -38,7 +38,7 @@ describe("Blox Editor", function () { cy.visit("/tm/content/visual/welcome/testpage"); cy.url().should("include", "/tm/content/visual/welcome/testpage"); - cy.get("#blox").within(($blox) => { + cy.get("#blox").within((blox) => { /* Change Title */ cy.get("#blox-0").click(); cy.get("input").clear().type("This is my Testpage"); @@ -58,9 +58,9 @@ describe("Blox Editor", function () { }); it("edits paragraph", function () { - cy.get("#blox").within(($blox) => { + cy.get("#blox").within((blox) => { /* Get Format Bar */ - cy.get(".format-bar").within(($formats) => { + cy.get(".format-bar").within((formats) => { /* Edit Table */ cy.get("button").eq(0).click(); cy.get("textarea").type("This is a second paragraph."); @@ -75,9 +75,9 @@ describe("Blox Editor", function () { }); it("edits headline", function () { - cy.get("#blox").within(($blox) => { + cy.get("#blox").within((blox) => { /* Get Format Bar */ - cy.get(".format-bar").within(($formats) => { + cy.get(".format-bar").within((formats) => { /* Edit Table */ cy.get("button").eq(1).click(); cy.get("input").type("Second Level Headline"); @@ -94,9 +94,9 @@ describe("Blox Editor", function () { }); it("edits unordered list", function () { - cy.get("#blox").within(($blox) => { + cy.get("#blox").within((blox) => { /* Get Format Bar */ - cy.get(".format-bar").within(($formats) => { + cy.get(".format-bar").within((formats) => { /* Edit Table */ cy.get("button").eq(2).click(); cy.get("textarea").type("first list item{enter}second list item"); @@ -108,19 +108,19 @@ describe("Blox Editor", function () { cy.get(".cancel").click(); }); - cy.get("#blox-4").within(($block) => { - cy.get("li").should(($lis) => { - expect($lis).to.have.length(2); - expect($lis.eq(0)).to.contain("first list item"); + cy.get("#blox-4").within((block) => { + cy.get("li").should((lis) => { + expect(lis).to.have.length(2); + expect(lis.eq(0)).to.contain("first list item"); }); }); }); }); it("edits ordered list", function () { - cy.get("#blox").within(($blox) => { + cy.get("#blox").within((blox) => { /* Get Format Bar */ - cy.get(".format-bar").within(($formats) => { + cy.get(".format-bar").within((formats) => { /* Edit Table */ cy.get("button").eq(3).click(); cy.get("textarea").type("first ordered item{enter}second ordered item"); @@ -132,26 +132,26 @@ describe("Blox Editor", function () { cy.get(".cancel").click(); }); - cy.get("#blox-5").within(($block) => { - cy.get("li").should(($lis) => { - expect($lis).to.have.length(2); - expect($lis.eq(0)).to.contain("first ordered item"); + cy.get("#blox-5").within((block) => { + cy.get("li").should((lis) => { + expect(lis).to.have.length(2); + expect(lis.eq(0)).to.contain("first ordered item"); }); }); }); }); it("edits table", function () { - cy.get("#blox").within(($blox) => { + cy.get("#blox").within((blox) => { /* Get Format Bar */ - cy.get(".format-bar").within(($formats) => { + cy.get(".format-bar").within((formats) => { /* Edit Table */ cy.get("button").eq(4).click(); - cy.get("table").within(($table) => { + cy.get("table").within((table) => { /* edit table head */ cy.get("tr") .eq(1) - .within(($row) => { + .within((row) => { cy.get("th").eq(1).click().clear().type("first Headline"); cy.get("th").eq(2).click().clear().type("Second Headline"); }); @@ -159,7 +159,7 @@ describe("Blox Editor", function () { /* edit first content row */ cy.get("tr") .eq(2) - .within(($row) => { + .within((row) => { cy.get("td").eq(1).click().clear().type("Some"); cy.get("td").eq(2).click().clear().type("More"); }); @@ -167,7 +167,7 @@ describe("Blox Editor", function () { /* edit second content row */ cy.get("tr") .eq(3) - .within(($row) => { + .within((row) => { cy.get("td").eq(1).click().clear().type("Beautiful"); cy.get("td").eq(2).click().clear().type("Content"); }); @@ -175,31 +175,31 @@ describe("Blox Editor", function () { /* add new column on the right */ cy.get("tr") .eq(0) - .within(($row) => { + .within((row) => { cy.get("td").eq(2).click(); cy.get(".actionline").eq(0).click(); }); }); - cy.get("table").within(($table) => { + cy.get("table").within((table) => { /* edit second new column head */ cy.get("tr") .eq(1) - .within(($row) => { + .within((row) => { cy.get("th").eq(3).click().clear().type("New Head"); }); /* edit second new column head */ cy.get("tr") .eq(2) - .within(($row) => { + .within((row) => { cy.get("td").eq(3).click().clear().type("With"); }); /* edit second new column head */ cy.get("tr") .eq(3) - .within(($row) => { + .within((row) => { cy.get("td").eq(3).click().clear().type("new Content"); }); }); @@ -210,7 +210,7 @@ describe("Blox Editor", function () { cy.get("#blox-6").should("contain", "Beautiful").click(); - cy.get(".editactive").within(($activeblock) => { + cy.get(".editactive").within((activeblock) => { cy.get(".component").should("contain", "Beautiful"); }); }); @@ -243,7 +243,7 @@ describe("Blox Editor", function () { cy.get(".danger").click(); - cy.get("#modalWindow").within(($modal) => { + cy.get("#modalWindow").within((modal) => { cy.get("button").click(); }); @@ -252,8 +252,8 @@ describe("Blox Editor", function () { .not("contain", "Testpage") .eq(2) .find("a") - .should(($a) => { - expect($a).to.have.length(5); + .should((a) => { + expect(a).to.have.length(5); }); }); });