Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/folio-org/stripes-testing
Browse files Browse the repository at this point in the history
…into FAT-10294-C422050
  • Loading branch information
TetianaParanich committed Sep 23, 2024
2 parents 5864a82 + 59e8c81 commit 459fd3b
Show file tree
Hide file tree
Showing 1,862 changed files with 75,639 additions and 33,227 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-npm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ jobs:
comment_title: Jest Unit Test Statistics

- name: Publish Jest coverage report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: jest-coverage-report
Expand All @@ -169,15 +169,15 @@ jobs:
comment_title: BigTest Unit Test Statistics

- name: Publish BigTest coverage report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: bigtest-coverage-report
path: ${{ env.BIGTEST_COVERAGE_REPORT_DIR }}
retention-days: 30

- name: Publish yarn.lock
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: failure()
with:
name: yarn.lock
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
comment_title: Jest Unit Test Statistics

- name: Publish Jest coverage report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: jest-coverage-report
Expand All @@ -110,15 +110,15 @@ jobs:
comment_title: BigTest Unit Test Statistics

- name: Publish BigTest coverage report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: bigtest-coverage-report
path: ${{ env.BIGTEST_COVERAGE_REPORT_DIR }}
retention-days: 30

- name: Publish yarn.lock
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: failure()
with:
name: yarn.lock
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ cypress/screenshots
allure-results

videos
.vs
.vs

/collect-failed-tests.js
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
## 4.8.0 IN PROGRESS

- Updated Call Number search option labels. Refs FAT-13489.
- Update `<MultiSelection>` interactor. Refs STCOM-1304.
- Hide call number type options for Local, Other scheme, and SuDoc. Refs FAT-16052.
- Change the labels of the Classification and Call number sections in Inventory browse options. Refs FAT-16040.

## [4.7.0](https://github.com/folio-org/stripes-testing/tree/v4.7.0) (2024-03-12)

Expand Down
5 changes: 3 additions & 2 deletions DockerfileCypress
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
72 changes: 14 additions & 58 deletions README.md
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)
Expand Down
125 changes: 125 additions & 0 deletions collect-failed-tests.js
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();
26 changes: 26 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ const fs = require('fs');
const allureWriter = require('@shelex/cypress-allure-plugin/writer');
const { cloudPlugin } = require('cypress-cloud/plugin');
const registerReportPortalPlugin = require('@reportportal/agent-js-cypress/lib/plugin');
const webpackPreprocessor = require('@cypress/webpack-batteries-included-preprocessor');

const delay = async (ms) => new Promise((res) => setTimeout(res, ms));

const reportportalOptions = {
apiKey: process.env.CI_API_KEY ? process.env.CI_API_KEY : '',
restClientConfig: {
timeout: 360000,
},
};

module.exports = defineConfig({
retries: {
Expand Down Expand Up @@ -37,8 +47,11 @@ module.exports = defineConfig({
rtrAuth: true,
ecsEnabled: false,
},
reporterOptions: reportportalOptions,
e2e: {
async setupNodeEvents(on, config) {
on('file:preprocessor', webpackPreprocessor());

allureWriter(on, config);

on('task', {
Expand Down Expand Up @@ -103,6 +116,19 @@ module.exports = defineConfig({
},
});

// keep Cypress running until the ReportPortal reporter is finished. this is a
// very critical step, as otherwise results might not be completely pushed into
// ReportPortal, resulting in unfinished launches and failing merges
on('after:run', async (result) => {
if (result) {
if (globby.sync('rplaunchinprogress*.tmp').length > 0) {
// eslint-disable-next-line no-console
console.log('Report portal. Await for a 20s...');
await delay(20000);
}
}
});

// fix for cypress-testrail-simple plugin
if ('TESTRAIL_PROJECTID' in process.env && process.env.TESTRAIL_PROJECTID === '') {
delete process.env.TESTRAIL_PROJECTID;
Expand Down
37 changes: 37 additions & 0 deletions cypress/e2e/aaa.cy.js
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);
});
},
);
});
Loading

0 comments on commit 459fd3b

Please sign in to comment.