Skip to content

Commit

Permalink
Cypress Tests & Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
JSat3st authored Aug 9, 2021
1 parent 9248ca7 commit f0c0371
Show file tree
Hide file tree
Showing 13 changed files with 503 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cypress-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Installation
### NPM
`npm install cypress --save-dev`

### Direktdownload
[Download from CDN](https://download.cypress.io/desktop)

### Installation im Docker-Container
[Dokumentation](https://github.com/cypress-io/cypress-docker-images)

### Dokumentation zu Installation
[Installationsguide](https://docs.cypress.io/guides/getting-started/installing-cypress#System-requirements)

## Cypress starten
### Installationen mit npm
`npx cypress open` oder `npx cypress run`, letzteres startet alle definierten Tests in der Kommandozeile.

### Direktinstallation
Die Cypress-App starten und die Testdateien auswählen. Dann einfach starten.

## Tests schreiben
Die Testverfahren können einfach erweitert werden. Die [Dokumentation](https://docs.cypress.io/guides/getting-started/writing-your-first-test) zeigt alle wichtigen Schritte auf.

## Fehlermeldungen
Cypress prüft und validiert nach vielen Faktoren. Wenn ein Test fehlschlägt wird eine detaillierte Fehlermeldung angegeben. Bei Timeout-Fehlern lohnt es sich den Test erneut zu starten, da diese auch an einer zeitweise schlechten Verbindung liegen können.
19 changes: 19 additions & 0 deletions cypress/integration/cookies.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// <reference types="cypress" />
context('Cookiebanner', () => {
it('Prüft generelle Funktionalität', () => {
cy.visit('https://codingdavinci.de/');
cy.clearCookies()
cy.getCookies().should('be.empty')
cy.get('.agree-button').click();
cy.getCookie('cookie-agreed').should('have.property', 'value', '2')
cy.wait(1000)
cy.clearCookies()
cy.wait(1000)
cy.visit('https://codingdavinci.de/');
cy.clearCookies()
cy.wait(1000)
cy.getCookies().should('be.empty')
cy.get('.decline-button').click();
cy.getCookie('cookie-agreed').should('have.property', 'value', '0')
})
})
33 changes: 33 additions & 0 deletions cypress/integration/daten.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/// <reference types="cypress" />
context('Daten', () => {
it('Prüft ob data-view einwandfrei funktioniert', () => {
cy.visit('https://codingdavinci.de/de/daten');
// Check if filter works
cy.get('#edit-project-type li:nth-child(1) .bef-link').click();
cy.get('#edit-project-type li:nth-child(8) .bef-link').click();
cy.get('#edit-project-type li:nth-child(10) .bef-link').click();
cy.get('#edit-object-types li:nth-child(4) .bef-link').click();
cy.get('#edit-license li:nth-child(2) .bef-link').click();
cy.get('#edit-theme li:nth-child(1) .bef-link').click();
cy.get('.col-lg-9').should('not.be.empty')
cy.wait(1)
cy.get('.card')

cy.get('.react-autosuggest__input').click();
cy.get('.react-autosuggest__input').type('test');
cy.get('#edit-search').type('test');
cy.get('.button:nth-child(1)').click();
cy.get('.button:nth-child(1)').click();
cy.contains('Es sind keine den Filtereinstellungen entsprechenden Datensets vorhanden.')
cy.get('.button:nth-child(2)').should('have.value', 'Zurücksetzen').click();
cy.get('.card')

// Check if pager works
cy.get('.pager__item:nth-child(2) > a').click();
cy.get('.pager__item:nth-child(8) span:nth-child(2)').click();
cy.get('.pager__item:nth-child(10) span:nth-child(2)').click();
cy.get('.pager__item--previous span:nth-child(2)').click();
cy.get('.pager__item:nth-child(1) span:nth-child(2)').click();

})
})
19 changes: 19 additions & 0 deletions cypress/integration/events.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// <reference types="cypress" />
context("Events", () => {
it("Allgemeine Tests", () => {
cy.visit("https://codingdavinci.de/de/events");
cy.get(".node--view-mode-teaser")
.first()
.click();
cy.go("back");
cy.get(".navbar-toggler-icon")
.click();
cy.get(".nav-item:nth-child(2) > .nav-link")
.click();
cy.url().should("contains", "https://codingdavinci.de/de/events");
cy.get(".node--view-mode-preview")
.first()
.click();
cy.go('back')
});
});
8 changes: 8 additions & 0 deletions cypress/integration/https.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// <reference types="cypress" />
context('HTTPS', () => {
it('Prüft ob Seiten von http auf https umgeleitet werden', () => {
cy.visit('http://codingdavinci.de/');
cy.wait(1000);
cy.url().should('contains', 'https://');
})
})
44 changes: 44 additions & 0 deletions cypress/integration/languageswitch.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/// <reference types="cypress" />
context('Sprachschalter', () => {
it('Deutsch - Englisch', () => {
cy.visit('https://codingdavinci.de/');
cy.get('.en > .language-link').click();
cy.wait(500);
cy.url().should('eq', 'https://codingdavinci.de/en');
})

it('Deutsch - Französisch', () => {
cy.visit('https://codingdavinci.de/');
cy.get('.fr > .language-link').click();
cy.wait(500);
cy.url().should('eq', 'https://codingdavinci.de/fr');
})

it('Französisch - Englisch', () =>{
cy.visit('https://codingdavinci.de/fr');
cy.get('.en > .language-link').click();
cy.wait(500);
cy.url().should('eq', 'https://codingdavinci.de/en');
})

it('Französisch - Deutsch', () =>{
cy.visit('https://codingdavinci.de/fr');
cy.get('.de > .language-link').click();
cy.wait(500);
cy.url().should('eq', 'https://codingdavinci.de/de');
})

it('Englisch - Deutsch', () =>{
cy.visit('https://codingdavinci.de/en');
cy.get('.de > .language-link').click();
cy.wait(500);
cy.url().should('eq', 'https://codingdavinci.de/de');
})

it('Englisch - Französisch', () =>{
cy.visit('https://codingdavinci.de/en');
cy.get('.fr > .language-link').click();
cy.wait(500);
cy.url().should('eq', 'https://codingdavinci.de/fr');
})
})
232 changes: 232 additions & 0 deletions cypress/integration/linkcheck.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
/// <reference types="cypress" />
context('Link-Check', () => {
it('Startseite', () =>{
cy.visit('https://codingdavinci.de/de');
cy.get("a:not([href*='mailto:'])").each(item => {
cy.request(item.prop("href"));
cy.on('fail', (e) => {
if (e.message.includes('cy.request() requires a url.')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
return true
// on any other error message the test fails
})
});
})

it("Über - Was ist Coding da Vinci", () => {
cy.visit('https://codingdavinci.de/de/was-ist-coding-da-vinci');
cy.get("a:not([href*='mailto:'])").each(item => {
cy.request(item.prop("href"));
cy.on('fail', (e) => {
if (e.message.includes('cy.request() requires a url.')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
return true
// on any other error message the test fails
})
});
});

it("Über - Ziele Chancen und Challenges", () => {
cy.visit('https://codingdavinci.de/de/ziele-chancen-und-challenges');
cy.get("a:not([href*='mailto:'])").each(item => {
cy.request(item.prop("href"));
cy.on('fail', (e) => {
if (e.message.includes('cy.request() requires a url.')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
return true
// on any other error message the test fails
})
});
});
it("Über - Dokumentationen", () => {
cy.visit('https://codingdavinci.de/de/dokumentationen');
cy.get("a:not([href*='mailto:'])").each(item => {
cy.request(item.prop("href"));
cy.on('fail', (e) => {
if (e.message.includes('cy.request() requires a url.')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
return true
// on any other error message the test fails
})
});
});
it("Über - Wer steckt hinter Coding da Vinci", () => {
cy.visit('https://codingdavinci.de/de/wer-steckt-hinter-coding-da-vinci');
cy.get("a:not([href*='mailto:'])").each(item => {
cy.request(item.prop("href"));
cy.on('fail', (e) => {
if (e.message.includes('cy.request() requires a url.')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
return true
// on any other error message the test fails
})
});
});

it("Über - Presse", () => {
cy.visit('https://codingdavinci.de/de/presse');
cy.get("a:not([href*='mailto:'])").each(item => {
cy.request(item.prop("href"));
cy.on('fail', (e) => {
if (e.message.includes('cy.request() requires a url.')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
return true
// on any other error message the test fails
})
});
});
it("Events", () => {
cy.visit('https://codingdavinci.de/de/events');
cy.get("a:not([href*='mailto:'])").each(item => {
cy.request(item.prop("href"));
cy.on('fail', (e) => {
if (e.message.includes('cy.request() requires a url.')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
return true
// on any other error message the test fails
})
});
});
it("Daten", () => {
cy.visit('https://codingdavinci.de/de/daten');
cy.get("a:not([href*='mailto:'])").each(item => {
cy.request(item.prop("href"));
cy.on('fail', (e) => {
if (e.message.includes('cy.request() requires a url.')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
return true
// on any other error message the test fails
})
});
});
it("Projekte", () => {
cy.visit('https://codingdavinci.de/de/projekte');
cy.get("a:not([href*='mailto:'])").each(item => {
cy.request(item.prop("href"));
cy.on('fail', (e) => {
if (e.message.includes('cy.request() requires a url.')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
return true
// on any other error message the test fails
})
});
});
it("News", () => {
cy.visit('https://codingdavinci.de/de/news');
cy.get("a:not([href*='mailto:'])").each(item => {
cy.request(item.prop("href"));
cy.on('fail', (e) => {
if (e.message.includes('cy.request() requires a url.')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
return true
// on any other error message the test fails
})
});
});
it("Stipendien - Antrag und Bedingungen", () => {
cy.visit('https://codingdavinci.de/de/stipendien/antrag-und-bedingungen');
cy.get("a:not([href*='mailto:'])").each(item => {
cy.request(item.prop("href"));
cy.on('fail', (e) => {
if (e.message.includes('cy.request() requires a url.')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
return true
// on any other error message the test fails
})
});
});
it("Stipendien - Übersicht", () => {
cy.visit('https://codingdavinci.de/de/stipendien/uebersicht');
cy.get("a:not([href*='mailto:'])").each(item => {
cy.request(item.prop("href"));
cy.on('fail', (e) => {
if (e.message.includes('cy.request() requires a url.')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
return true
// on any other error message the test fails
})
});
});
it("FAQ", () => {
cy.visit('https://codingdavinci.de/de/faq');
cy.get("a:not([href*='mailto:'])").each(item => {
cy.request(item.prop("href"));
cy.on('fail', (e) => {
if (e.message.includes('cy.request() requires a url.')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
return true
// on any other error message the test fails
})
});
});
it("Impressum", () => {
cy.visit('https://codingdavinci.de/impressum-datenschutz');
// cy.get("a:not([href*='mailto:'])").each(item => {
// cy.request(item.prop("href"));
// cy.on('fail', (e) => {
// if (e.message.includes('cy.request() requires a url.')) {
// // we expected this error, so let's ignore it
// // and let the test continue
// return false
// }
// return true
// on any other error message the test fails
// })
// });
});
it("Login", () => {
cy.visit('https://codingdavinci.de/de/user/login');
cy.get("a:not([href*='mailto:'])").each(item => {
cy.request(item.prop("href"));
cy.on('fail', (e) => {
if (e.message.includes('cy.request() requires a url.')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
return true
// on any other error message the test fails
})
});
});

})
Loading

0 comments on commit f0c0371

Please sign in to comment.