Skip to content

Commit 8e63818

Browse files
authored
Cypress-based test suite (#157)
* Add initial Cypress test suite * ci: Run Cypress tests * Rename CI workflow to match reality * Add missing Cypress install step * Add Cache action to avoid downloading too many things
1 parent 73afaa0 commit 8e63818

File tree

13 files changed

+3280
-5
lines changed

13 files changed

+3280
-5
lines changed
Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
33

4-
name: Java CI with Maven
4+
name: CI
55

66
on:
77
push:
@@ -25,20 +25,38 @@ jobs:
2525
distribution: 'temurin'
2626
cache: maven
2727

28+
- name: Setup Node
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '20'
32+
33+
- name: Restore dependency cache
34+
uses: actions/cache@v4
35+
with:
36+
path: |
37+
cypress/openrefine-*.tar.gz
38+
**/node_modules
39+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
40+
2841
- name: Build with Maven
2942
run: mvn -B package
3043

44+
- name: Install Cypress
45+
run: |
46+
cd ./cypress
47+
npm i -g yarn
48+
yarn install
49+
50+
- name: Run Cypress tests
51+
run: ./cypress/run_headless.sh
52+
3153
- name: Get release upload URL
3254
id: get_release_upload_url
3355
if: github.event_name == 'release'
3456
uses: bruceadams/[email protected]
3557
env:
3658
GITHUB_TOKEN: ${{ github.token }}
3759

38-
- name: Extract version string
39-
id: version_string_variable
40-
run: echo "VERSION_STRING=$(mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
41-
4260
- name: Upload release asset
4361
id: upload-release-asset
4462
if: github.event_name == 'release'

cypress/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
.yarn/
3+
.yarnrc.yml
4+
openrefine*

cypress/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Commons extension E2E tests
2+
3+
Inspired from [OpenRefine's own Cypress test suite](https://openrefine.org/docs/technical-reference/functional-tests)
4+
5+
Install the dependencies with `yarn install`.
6+
7+
Run the test suite with `yarn run cypress open`.
8+
9+
This requires a running instance of OpenRefine with the CommonsExtension installed at `http://localhost:3333/`.

cypress/cypress.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const { defineConfig } = require('cypress')
2+
3+
module.exports = defineConfig({
4+
keystrokeDelay: 0,
5+
viewportWidth: 1280,
6+
viewportHeight: 768,
7+
retries: {
8+
runMode: 3,
9+
openMode: 0,
10+
},
11+
env: {
12+
OPENREFINE_URL: 'http://localhost:3333',
13+
DISABLE_PROJECT_CLEANUP: 0,
14+
},
15+
e2e: {
16+
experimentalRunAllSpecs: true,
17+
// We've imported your old cypress plugins here.
18+
// You may want to clean this up later by importing these.
19+
setupNodeEvents(on, config) {
20+
return require('./cypress/plugins/index.js')(on, config)
21+
},
22+
specPattern: './cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
23+
},
24+
})
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
describe(__filename, function () {
2+
afterEach(() => {
3+
cy.addProjectForDeletion();
4+
});
5+
6+
it('Test the create project from a Commons category', function () {
7+
cy.visitOpenRefine();
8+
cy.navigateTo('Create project');
9+
cy.get('#create-project-ui-source-selection-tabs > a')
10+
.contains('Wikimedia Commons')
11+
.click();
12+
// enter a category name
13+
cy.get(
14+
'input.category-input-box'
15+
).type('Official OpenRefine logos');
16+
cy.get(
17+
'.fbs-item-name'
18+
)
19+
.contains('Official OpenRefine logos')
20+
.click();
21+
22+
cy.get(
23+
'.create-project-ui-source-selection-tab-body.selected button.button-primary'
24+
)
25+
.contains('Next »')
26+
.click();
27+
28+
// then ensure we are on the preview page
29+
cy.get('.create-project-ui-panel').contains('Configure Parsing Options');
30+
31+
// preview and click next
32+
cy.get('button[bind="createProjectButton"]')
33+
.contains('Create Project »')
34+
.click();
35+
cy.waitForProjectTable();
36+
});
37+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
const fixtures = {
3+
};
4+
5+
export default fixtures;

cypress/cypress/plugins/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// / <reference types="cypress" />
2+
// ***********************************************************
3+
// This example plugins/index.js can be used to load plugins
4+
//
5+
// You can change the location of this file or turn off loading
6+
// the plugins file with the 'pluginsFile' configuration option.
7+
//
8+
// You can read more here:
9+
// https://on.cypress.io/plugins-guide
10+
// ***********************************************************
11+
12+
// This function is called when a project is opened or re-opened (e.g. due to
13+
// the project's config changing)
14+
/**
15+
* @type {Cypress.PluginConfig}
16+
*/
17+
18+
module.exports = (on, config) => {
19+
// `on` is used to hook into various events Cypress emits
20+
// `config` is the resolved Cypress config
21+
return config;
22+
};

0 commit comments

Comments
 (0)