Skip to content
Snippets Groups Projects
Commit e4182b35 authored by Fabian Kongelf's avatar Fabian Kongelf
Browse files

added the last two project to the repository

parent 78d5c776
No related branches found
No related tags found
No related merge requests found
variables:
JEKYLL_ENV: production
LC_ALL: C.UTF-8
stages:
- vuln-scan
- e2e
#Job utilizing Snyk for vulnerability scanning
#Snyk documentation available: https://snyk.io/
dependency_scanning:
stage: vuln-scan
image:
name: cypress/included:9.4.1
entrypoint: [""]
variables:
SNYK_TOKEN: $SNYK_TOKEN
script:
- apt-get update
- apt-get -y install nodejs
- apt-get -y install npm
- npm i
# Install npm, snyk, and snyk-to-html
- npm install -g npm@latest
- npm install -g snyk
- npm install snyk-to-html -g
# Run snyk help, snyk auth, snyk monitor, snyk test to break build and out report
- snyk --help
- snyk auth $SNYK_TOKEN
- snyk monitor --project-name=$CI_PROJECT_NAME
- snyk test --json | snyk-to-html -o snyk_results.html
artifacts: # Save report to artifacts
when: always
paths:
- snyk_results.html
#Job for javascripted testing of websites. Used to verify that website functions properly in Gitlab Pages URL supplied as a downstream variable
public-e2e:
image:
name: cypress/included:9.4.1
entrypoint: [""]
stage: e2e
allow_failure: true
script:
#Install Dependencies
- npm i
#Replace the URL with downstream CI/CD pipeline variable. Effectively the URL to run tests against
- sed -i "s,replace-me,$url,g" cypress/integration/gitlab-pages.spec.js
#Run javascripted testing
- npx cypress run
except:
variables:
- $url == ""
artifacts: #Upload report
when: always
paths:
- /builds/bachelor1/cypress_gitlab_pages/cypress/reports
# cypress_gitlab_pages
Creates a docker container throug Gitlab CI/CD with automated testing for websites.
As of now used in relation to "Git da gitt" bachelor thesis: [README](https://gitlab.stud.idi.ntnu.no/bachelor1/Website/-/tree/master)
Uses Cypress to enact javascripted testing on a given website.
Cypress is an end-to-end testing framework for web test automation: [Docuemtnation](https://www.cypress.io/)
{
"video": false,
"screenshotOnRunFailure": false,
"reporter": "cypress-mochawesome-reporter",
"failOnStatusCode": false
}
/************************************************************************
* All tests below are ran inside browser "Electron 94" with Test runner
* @see https://docs.cypress.io/guides/core-concepts/test-runner
* Cypress tests can be configured to run on the followin browsers:
* @see https://docs.cypress.io/guides/guides/launching-browsers#Browsers
* @author Nicholas Sellevåg
* @date 03.05.2022
************************************************************************/
/***********************************************************
* Test wether the navigation menu part of bachelor thesis's
* gitlab template can be opened or not.
*
* @returns true when openable, false when not.
* @author Nicholas Bodvin Sellevåg
* @date 03.05.2022
**********************************************************/
describe('Check navigation menu becomes visible', () => {
it('Opens hamburger menu', () => {
cy.visit('replace-me')
cy.get('.hamburger').click()
cy.get('.hamburger-content').should('be.visible')
})
})
/***********************************************************
* Retrieves all anchor tags in DOM of bachelor Thesis's
* index page.
* Filters away anchor tags that are for mails.
* Validates remaining links are valid, if link returns
* web error codes such as 404 it is considered as not
* working.
*
* @returns false when link receives web error codes
* @author Nicholas Bodvin Sellevåg
* @date 03.05.2022
**********************************************************/
describe('Check for broken links', () => {
it('Clicks on all links in index page', () => {
cy.visit('replace-me')
cy.get("a:not([href*='mailto:'])").each(page => {
cy.request(page.prop('href'))
})
})
})
/***********************************************************
* Retrieves element with a class of "contact list".
* Validates that class has two child elements.
* Test serves a demonstrative purpose, wether there are
* two entries or more does not depict that website is
* working correctly. In future, such tests could be
* updated with validating the textual content of a course's
* contact list.
*
* @returns true when two child elements in "contact list".
* @author Nicholas Bodvin Sellevåg
* @date 03.05.2022
**********************************************************/
describe('Check contact info', () => {
it('Validates that course responsible is updatd', () => {
cy.visit('replace-me')
cy.get(".contact-list >li").should('have.length', 2)
})
})
\ No newline at end of file
/// <reference types="cypress" />
/*******************************************************************************
* Function is called whenever a project is opened or re-opened.
* For example, when a project's configuration changes the project will re-open.
* @type {Cypress.PluginConfig}
* @author Nicholas Bodvin Sellevåg
* @date 03.05.2022
******************************************************************************/
module.exports = (on, config) => {
require('cypress-mochawesome-reporter/plugin')(on);
}
// ***********************************************
// 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) => { ... })
// ***********************************************************
// 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'
import 'cypress-mochawesome-reporter/register'
// Alternatively you can use CommonJS syntax:
// require('./commands')
\ No newline at end of file
{
"name": "cypress_gitlab_pages",
"version": "1.0.0",
"description": "\"Git da gitt\" Bachelor thesis cypress tests",
"main": "index.js",
"dependencies": {
"cypress-mochawesome-reporter": "^3.0.1"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@gitlab.stud.idi.ntnu.no:bachelor1/cypress_gitlab_pages.git"
},
"author": "",
"license": "ISC"
}
/***********************************************************
* Configurations of cypress reporters that generate html
* report is configured below.
* For example:
* Choice of "reporter"
* Type of report "html"
*
* @author Nicholas Bodvin Sellevåg
* @date 03.05.2022
**********************************************************/
{
"reporter": "cypress-mochawesome-reporter",
"reporterOptions": {
"toConsole": true
"html": true
}
}
variables: #Define the page to test WCAG appliance from
a11y_urls: "https://..."
stages:
- accessibility #accessibility testing
#Use the accessibility image from Gitlab
include:
- template: "Verify/Accessibility.gitlab-ci.yml" #accessibility testing
# - template: Verify/Browser-Performance.gitlab-ci.yml
# webpage-accessibility-test
Continous Integration / Continious Development project to verify the accessibility of a given webpage(s)
Creates docker container from gitlab's templates
Documentation: https://docs.gitlab.com/ee/user/project/merge_requests/accessibility_testing.html
And runs Pa11y's tests on the website(s)
Documentation: https://pa11y.org/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment