Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TD-3: Add Cypress test environment #188

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run Cypress tests

on:
pull_request:
workflow_dispatch:

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
bundler-cache: true # runs 'bundle install'

- name: Set up Node.js
uses: actions/[email protected]
with:
node-version: '20'

- name: Cypress run
uses: cypress-io/github-action@v6 # runs 'npm ci'
with:
start: npm start
wait-on: 'http://localhost:4000'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/*/.DS_Store
_site
.jekyll-cache
node_modules
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ github: # recreate gh-pages api
repository_nwo: archivesspace/tech-docs
owner_url: https://github.com/archivesspace
owner_name: ArchivesSpace
edit_base_url: https://github.com/archivesspace/tech-docs/edit/master/
new_issue_base_url: https://github.com/archivesspace/tech-docs/issues/new?title=Problem+on+
76 changes: 76 additions & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="{{ site.lang | default: "en-US" }}">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

{% seo %}
<link rel="stylesheet" href="{{ "/assets/css/style.css?v=" | append: site.github.build_revision | relative_url }}">
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<![endif]-->
{% include head-custom.html %}
</head>
<body>
<div class="wrapper">
<header>
<h1><a href="{{ "/" | absolute_url }}">{{ site.title | default: site.github.repository_name }}</a></h1>

{% if site.logo %}
<img src="{{site.logo | relative_url}}" alt="Logo" />
{% endif %}

<p>{{ site.description | default: site.github.project_tagline }}</p>

{% if site.github.is_project_page %}
<p class="view"><a href="{{ site.github.repository_url }}">View the Project on GitHub <small>{{ site.github.repository_nwo }}</small></a></p>
{% endif %}

{% if site.github.is_user_page %}
<p class="view"><a href="{{ site.github.owner_url }}">View My GitHub Profile</a></p>
{% endif %}

{% if site.show_downloads %}
<ul class="downloads">
<li><a href="{{ site.github.zip_url }}">Download <strong>ZIP File</strong></a></li>
<li><a href="{{ site.github.tar_url }}">Download <strong>TAR Ball</strong></a></li>
<li><a href="{{ site.github.repository_url }}">View On <strong>GitHub</strong></a></li>
</ul>
{% endif %}

<p>
<a
href="{{ site.github.edit_base_url }}{{ page.path }}"
title="Edit {{ page.path }} on GitHub"
>
Edit this page on GitHub
<small>{{ page.path }}</small>
</a>
</p>

<p>
<a
href="{{ site.github.new_issue_base_url }}{{ page.path | url_encode }}"
title="Report issue with {{ page.path }} on GitHub"
>
Report issue on GitHub
<small>{{ page.path }}</small>
</a>
</p>
</header>
<section>

{{ content }}

</section>
<footer>
{% if site.github.is_project_page %}
<p>This project is maintained by <a href="{{ site.github.owner_url }}">{{ site.github.owner_name }}</a></p>
{% endif %}
<p><small>Hosted on GitHub Pages &mdash; Theme by <a href="https://github.com/orderedlist">orderedlist</a></small></p>
</footer>
</div>
<script src="{{ "/assets/js/scale.fix.js" | relative_url }}"></script>
</body>
</html>
9 changes: 9 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
}
}
});
41 changes: 41 additions & 0 deletions cypress/e2e/feedback.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const editBaseUrl = 'https://github.com/archivesspace/tech-docs/edit/master/';
const issueBaseUrl =
'https://github.com/archivesspace/tech-docs/issues/new?title=Problem+on+';

describe('Feedback', () => {
it('includes an edit this page on GitHub link on every page', () => {
let file = 'README.md';
cy.visit('http://localhost:4000/');
cy.get('a')
.contains('Edit this page on GitHub')
.should('have.attr', 'href', `${editBaseUrl}${file}`)
.children()
.should('have.text', file);

file = 'readme_develop.md';
cy.visit('http://localhost:4000/readme_develop');
cy.get('a')
.contains('Edit this page on GitHub')
.should('have.attr', 'href', `${editBaseUrl}${file}`)
.children()
.should('have.text', file);
});

it('includes a report issue on GitHub link on every page', () => {
let file = 'README.md';
cy.visit('http://localhost:4000/');
cy.get('a')
.contains('Report issue on GitHub')
.should('have.attr', 'href', `${issueBaseUrl}${file}`)
.children()
.should('have.text', file);

file = 'readme_develop.md';
cy.visit('http://localhost:4000/readme_develop');
cy.get('a')
.contains('Report issue on GitHub')
.should('have.attr', 'href', `${issueBaseUrl}${file}`)
.children()
.should('have.text', file);
});
});
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
25 changes: 25 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
20 changes: 20 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.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')
Loading