-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/folio-org/stripes-testing …
…into FAT-10294-C422050
- Loading branch information
Showing
1,862 changed files
with
75,639 additions
and
33,227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,6 @@ cypress/screenshots | |
allure-results | ||
|
||
videos | ||
.vs | ||
.vs | ||
|
||
/collect-failed-tests.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
ARG NODE_VERSION='18.18.0' | ||
ARG NODE_VERSION='18.20.3' | ||
ARG YARN_VERSION='1.22.19' | ||
ARG CHROME_VERSION='124.0.6367.60-1' | ||
ARG CYPRESS_VERSION='12.0.0' | ||
|
||
FROM cypress/factory:3.5.4 | ||
|
||
WORKDIR /opt/app | ||
RUN npm install --save-dev cypress | ||
RUN npm install --save-dev cypress | ||
RUN apt-get update; apt install -y curl python-is-python3 pkg-config build-essential |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,37 @@ | ||
# stripes-testing | ||
|
||
Copyright (C) 2017-2020 The Open Library Foundation | ||
Copyright (C) 2017-2024 The Open Library Foundation | ||
|
||
This software is distributed under the terms of the Apache License, | ||
Version 2.0. See the file "[LICENSE](LICENSE)" for more information. | ||
|
||
## Introduction | ||
|
||
stripes-testing is a toolkit for building integration tests against Stripes | ||
UI modules and platforms. There are no tests in this repository; | ||
instead they exist in the platforms they exercise (e.g. platform-core). | ||
Tests that operate only a single app (unit tests) should be written with | ||
the [BigTest](https://github.com/folio-org/stripes/blob/master/doc/bigtest.md) | ||
toolkit instead. | ||
UI modules and platforms. This repository contains: | ||
|
||
* `accessibility`: axe helper functions | ||
* `bigtest`: BigTest helper furnctions, compatible with React >= 17 | ||
* `cypress`: end-to-end tests | ||
* `interactors`: interactors provide "hooks" into components as rendered in the DOM, | ||
allowing tests written in BigTest, Cypress, etc. to use the interactor's consistent | ||
API regardless of how the component implementation changes. | ||
|
||
- [TL;DR](#tldr-i-just-want-to-run-some-tests) | ||
- [Stripes Component Interactors](doc/interactors.md) | ||
- [Prerequisites](#prerequisites) | ||
- [Choose the source of UI module tests to run](#choose-the-source-of-ui-module-tests-to-run) | ||
- [Writing tests](#writing-tests) | ||
|
||
## TL;DR I just want to run some tests | ||
|
||
To run the tests for a platform, clone the platform and checkout its `snapshot` | ||
branch, install its dependencies with `yarn`, then run the tests. For example, | ||
for platform-core: | ||
## Running | ||
|
||
``` | ||
git clone [email protected]:folio-org/platform-core.git | ||
cd platform-core | ||
git checkout snapshot | ||
yarn | ||
yarn prepare | ||
yarn test-int | ||
``` | ||
|
||
This will start stripes at http://localhost:3000, run the platform's tests, and | ||
quit stripes. | ||
First, install dependencies with npm or yarn. | ||
* To run all Cypress tests at the CLI, run `npx cypress run`. | ||
* To run a specific Cypress test at the CLI, run `npx cypress run --spec ./path/to/spec.cy.js` | ||
* To open the Cypress test-runner in a browser, run `npx cypress open`. | ||
|
||
## Prerequisites | ||
|
||
- [Node.js](https://nodejs.org/) with an [active LTS version](https://github.com/nodejs/Release#release-schedule) | ||
- [Yarn](https://yarnpkg.com/) JavaScript package manager | ||
|
||
## Choose the source of UI module tests to run | ||
|
||
When building the platform, there are three potential sources for an | ||
application module and its tests: | ||
|
||
- FOLIO's continuous integration repository: `npm-folioci` at repository.folio.org. | ||
Modules in this repository reflect the head-of-master, i.e. code that has been | ||
committed but is not yet part of an official release. This is appropriate for | ||
regression tests and continuous integration. This would also suit developers | ||
who are programming test suites or UI modules, and want to test very the latest | ||
developments. | ||
|
||
This is the default source for `platform-core#snapshot`. | ||
|
||
- Folio's release repository: `npm-folio` at repository.folio.org. | ||
Modules in this repository reflect officially released code. | ||
|
||
This is the default source for `platform-core#master`. | ||
|
||
- A local checkout of a module, brought into the platform by building it in | ||
a [workspace](https://github.com/folio-org/stripes-cli/blob/master/doc/user-guide.md). | ||
|
||
Change a platform's source for its modules with the `npm config` command: | ||
|
||
``` | ||
npm config set @folio:registry https://repository.folio.org/repository/npm-folio/ | ||
``` | ||
|
||
## Writing Tests | ||
|
||
- Write [integration tests for a platform](doc/nightmare.md) with Nightmare | ||
- Write [unit tests for an app](https://github.com/folio-org/stripes/blob/master/doc/bigtest.md) with BigTest | ||
|
||
## Additional information | ||
|
||
See project [UITEST](https://issues.folio.org/browse/UITEST) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/* eslint-disable no-console */ | ||
const { glob } = require('glob'); | ||
const fs = require('fs'); | ||
const { getTestNames } = require('find-test-names'); | ||
const axios = require('axios'); | ||
|
||
const status = { | ||
Passed: 1, | ||
Blocked: 2, | ||
Untested: 3, | ||
Retest: 4, | ||
Failed: 5, | ||
}; | ||
|
||
const team = { | ||
Firebird: 3, | ||
Folijet: 4, | ||
Spitfire: 6, | ||
Thunderjet: 8, | ||
Vega: 9, | ||
Volaris: 13, | ||
Corsair: 19, | ||
}; | ||
|
||
const selectedStatus = [status.Failed, status.Retest]; | ||
const selectedTeams = [team.Firebird, team.Folijet, team.Spitfire, team.Thunderjet, team.Vega, team.Volaris, team.Corsair]; | ||
|
||
const testUsername = ''; | ||
const testPassword = ''; | ||
const runId = 2108; | ||
|
||
const ids = []; | ||
const arrayOfFiles = []; | ||
let filteredFiles = []; | ||
|
||
function getTest(offsetToPass) { | ||
return axios({ | ||
method: 'get', | ||
url: `https://foliotest.testrail.io/index.php?/api/v2/get_tests/${runId}`, | ||
headers: { 'Content-Type': 'application/json' }, | ||
params: { offset: offsetToPass }, | ||
auth: { | ||
username: testUsername, | ||
password: testPassword, | ||
}, | ||
}).then((response) => { | ||
console.log(`GET /tests (offset: ${offsetToPass}, length: ${response.data.tests.length})`); | ||
return response.data.tests; | ||
}); | ||
} | ||
|
||
async function getTests() { | ||
const tests = []; | ||
let offset = 0; | ||
let testsFromResponse = 0; | ||
do { | ||
testsFromResponse = await getTest(offset); | ||
tests.push(...testsFromResponse); | ||
offset += 250; | ||
} while (testsFromResponse.length === 250); | ||
return tests; | ||
} | ||
|
||
function removeRootPath(path) { | ||
return path.substring(path.indexOf('cypress\\e2e\\')); | ||
} | ||
|
||
function titleContainsId(title, testCaseIds) { | ||
if (title === undefined) { | ||
return false; | ||
} | ||
for (let i = 0; i < testCaseIds.length; i++) { | ||
if (title.includes(testCaseIds[i])) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
function parseCommand() { | ||
getTests() | ||
.then((tests) => { | ||
console.log(`\nNumber of all tests in the #${runId} run: ${tests.length}\n`); | ||
tests.forEach((test) => { | ||
if ( | ||
selectedStatus.includes(test.status_id) && | ||
selectedTeams.includes(test.custom_dev_team) | ||
) { | ||
ids.push('C' + test.case_id); | ||
} | ||
}); | ||
}) | ||
.then(() => { | ||
glob('cypress/e2e/**/*') | ||
.then((res) => { | ||
res.forEach((file) => { | ||
if (file.includes('.cy.js')) { | ||
arrayOfFiles.push(removeRootPath(file).replace(/\\/g, '/')); | ||
} | ||
}); | ||
}) | ||
.then(() => { | ||
arrayOfFiles.forEach((file) => { | ||
const text = fs.readFileSync(file, { encoding: 'utf8' }); | ||
const names = getTestNames(text); | ||
names.tests.forEach((test) => { | ||
if (test.type === 'test' && titleContainsId(test.name, ids)) { | ||
filteredFiles.push(file); | ||
} | ||
}); | ||
}); | ||
console.log(`Number of filtered tests with duplicates: ${filteredFiles.length}\n`); | ||
// remove duplicates | ||
filteredFiles = Array.from(new Set(filteredFiles)); | ||
filteredFiles.sort(); | ||
console.log(`Number of filtered tests without duplicates: ${filteredFiles.length}\n`); | ||
}) | ||
.then(() => { | ||
const parsedCommand = `--spec "${filteredFiles.join(',')}"`; | ||
console.log(parsedCommand); | ||
}); | ||
}); | ||
} | ||
|
||
parseCommand(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
describe.skip('Specifications sync', () => { | ||
it( | ||
'Sync marc bibliographic and marc authority records fields (smoke tests)', | ||
{ tags: ['smoke', 'spitfire'] }, | ||
() => { | ||
cy.getAdminToken(); | ||
cy.getSpecificatoinIds().then((specifications) => { | ||
cy.syncSpecifications(specifications[0].id); | ||
cy.syncSpecifications(specifications[1].id); | ||
}); | ||
}, | ||
); | ||
|
||
it( | ||
'Sync marc bibliographic and marc authority records fields (criticalPath tests)', | ||
{ tags: ['criticalPath', 'spitfire'] }, | ||
() => { | ||
cy.getAdminToken(); | ||
cy.getSpecificatoinIds().then((specifications) => { | ||
cy.syncSpecifications(specifications[0].id); | ||
cy.syncSpecifications(specifications[1].id); | ||
}); | ||
}, | ||
); | ||
|
||
it( | ||
'Sync marc bibliographic and marc authority records fields (extendedPath tests)', | ||
{ tags: ['extendedPath', 'spitfire'] }, | ||
() => { | ||
cy.getAdminToken(); | ||
cy.getSpecificatoinIds().then((specifications) => { | ||
cy.syncSpecifications(specifications[0].id); | ||
cy.syncSpecifications(specifications[1].id); | ||
}); | ||
}, | ||
); | ||
}); |
Oops, something went wrong.