Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
IhorBohdan committed Sep 3, 2024
2 parents 2cb5f24 + 175b9ec commit bef911c
Show file tree
Hide file tree
Showing 200 changed files with 3,292 additions and 645 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- 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
122 changes: 122 additions & 0 deletions collect-failed-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/* 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];
const selectedTeams = [team.Thunderjet, team.Folijet];

const testUsername = '';
const testPassword = '';
const runId = 2581;

const ids = [];
const arrayOfFiles = [];
const 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(`Number 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);
}
});
});
filteredFiles.sort();
})
.then(() => {
console.log(`Number of filtered tests: ${filteredFiles.length}\n`);
const parsedCommand = `--spec "${filteredFiles.join(',')}"`;
console.log(parsedCommand);
});
});
}

parseCommand();
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('bulk-edit', () => {

it(
'C350928 Verify error accordion during matching (Local approach) (firebird)',
{ tags: ['smoke', 'firebird'] },
{ tags: ['smoke', 'firebird', 'shiftLeft'] },
() => {
BulkEditSearchPane.checkUsersRadio();
BulkEditSearchPane.selectRecordIdentifier('User UUIDs');
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/bulk-edit/in-app/bulk-edit-in-app-elements.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('bulk-edit', () => {

it(
'C353232 Verify error accordion during matching (In app approach) (firebird)',
{ tags: ['smoke', 'firebird'] },
{ tags: ['smoke', 'firebird', 'shiftLeft'] },
() => {
BulkEditSearchPane.uploadFile(invalidItemBarcodesFileName);
BulkEditSearchPane.waitFileUploading();
Expand All @@ -72,7 +72,7 @@ describe('bulk-edit', () => {

it(
'C350941 Verify uploading file with identifiers -- In app approach (firebird)',
{ tags: ['smoke', 'firebird'] },
{ tags: ['smoke', 'firebird', 'shiftLeft'] },
() => {
BulkEditSearchPane.verifyDragNDropRecordTypeIdentifierArea('Items', 'Item barcode');
BulkEditSearchPane.uploadFile(validItemBarcodeFileName);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
import permissions from '../../../support/dictionary/permissions';
import BulkEditActions from '../../../support/fragments/bulk-edit/bulk-edit-actions';
import BulkEditSearchPane from '../../../support/fragments/bulk-edit/bulk-edit-search-pane';
import InventoryInstances from '../../../support/fragments/inventory/inventoryInstances';
import InventorySearchAndFilter from '../../../support/fragments/inventory/inventorySearchAndFilter';
import TopMenu from '../../../support/fragments/topMenu';
import TopMenuNavigation from '../../../support/fragments/topMenuNavigation';
import Users from '../../../support/fragments/users/users';
import FileManager from '../../../support/utils/fileManager';
import ExportFile from '../../../support/fragments/data-export/exportFile';
import getRandomPostfix from '../../../support/utils/stringTools';
import {
APPLICATION_NAMES,
BULK_EDIT_TABLE_COLUMN_HEADERS,
HOLDING_NOTE_TYPES,
} from '../../../support/constants';
import HoldingsRecordView from '../../../support/fragments/inventory/holdingsRecordView';

let user;
const notes = {
administrative: 'C430210 Administrative\n note text',
electronicBookplate: 'C430210 Electronic bookplate note text',
provenance: 'C430210 Provenance note text',
reproduction: 'C430210 Reproduction note text',
binding: "C430210 test binding note:~,!,@,#,$,%,^,&,*,(,),~,', {.[,]<},>,ø, Æ, §,;",
};
const instance = {
instanceName: `C430210 instance-${getRandomPostfix()}`,
itemBarcode: getRandomPostfix(),
};
const actionsToSelect = {
addNote: 'Add note',
};
const administrativeNoteActionOptions = [
'Add note',
'Change note type',
'Find (full field search)',
'Remove all',
];
const nonAdministrativeNoteActionOptions = [
'Add note',
'Change note type',
'Find (full field search)',
'Mark as staff only',
'Remove all',
'Remove mark as staff only',
];
const initialValueSets = [
[BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.ADMINISTRATIVE_NOTE, ''],
[BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.ACTION_NOTE, ''],
[BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.BINDING_NOTE, ''],
[BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.COPY_NOTE, ''],
[BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.ELECTRONIC_BOOKPLATE_NOTE, ''],
[BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.NOTE, ''],
[BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.PROVENANCE_NOTE, ''],
[BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.REPRODUCTION, ''],
];
const notesToAdd = [
[1, HOLDING_NOTE_TYPES.BINDING, notes.binding],
[2, HOLDING_NOTE_TYPES.ELECTRONIC_BOOKPLATE, notes.electronicBookplate],
[3, HOLDING_NOTE_TYPES.PROVENANCE, notes.provenance],
[4, HOLDING_NOTE_TYPES.REPRODUCTION, notes.reproduction],
];
const editedValueSets = [
[BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.ADMINISTRATIVE_NOTE, notes.administrative],
[BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.ACTION_NOTE, ''],
[BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.BINDING_NOTE, notes.binding],
[BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.COPY_NOTE, ''],
[
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.ELECTRONIC_BOOKPLATE_NOTE,
notes.electronicBookplate,
],
[BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.NOTE, ''],
[BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.PROVENANCE_NOTE, notes.provenance],
[BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.REPRODUCTION, notes.reproduction],
];
const holdingUUIDsFileName = `validHoldingUUIDs_${getRandomPostfix()}.csv`;
const matchedRecordsFileName = `*-Matched-Records-${holdingUUIDsFileName}`;
const changedRecordsFileName = `*-Changed-Records-${holdingUUIDsFileName}`;

function addNoteInBulkEdit(rowNumber, holdingNoteType, noteText) {
BulkEditActions.addNewBulkEditFilterString();
BulkEditActions.verifyNewBulkEditRow(rowNumber);
BulkEditActions.selectOption(holdingNoteType, rowNumber);
BulkEditActions.verifyTheActionOptions(nonAdministrativeNoteActionOptions, rowNumber);
BulkEditActions.selectSecondAction(actionsToSelect.addNote, rowNumber);
BulkEditActions.verifySecondActionSelected(actionsToSelect.addNote, rowNumber);
BulkEditActions.fillInSecondTextArea(noteText, rowNumber);
BulkEditActions.verifyValueInSecondTextArea(noteText, rowNumber);
BulkEditSearchPane.isConfirmButtonDisabled(false);
}

describe('bulk-edit', () => {
describe('in-app approach', () => {
before('create test data', () => {
cy.clearLocalStorage();

cy.createTempUser([
permissions.bulkEditView.gui,
permissions.bulkEditEdit.gui,
permissions.inventoryAll.gui,
]).then((userProperties) => {
user = userProperties;

instance.instanceId = InventoryInstances.createInstanceViaApi(
instance.instanceName,
instance.itemBarcode,
);
cy.getHoldings({
limit: 1,
query: `"instanceId"="${instance.instanceId}"`,
}).then((holdings) => {
instance.holdingHRID = holdings[0].hrid;
instance.holdingsUUID = holdings[0].id;

FileManager.createFile(`cypress/fixtures/${holdingUUIDsFileName}`, holdings[0].id);
});
cy.login(user.username, user.password, {
path: TopMenu.bulkEditPath,
waiter: BulkEditSearchPane.waitLoading,
});
});
});

after('delete test data', () => {
cy.getAdminToken();
InventoryInstances.deleteInstanceAndItsHoldingsAndItemsViaApi(instance.instanceId);
Users.deleteViaApi(user.userId);
FileManager.deleteFile(`cypress/fixtures/${holdingUUIDsFileName}`);
FileManager.deleteFileFromDownloadsByMask(matchedRecordsFileName, changedRecordsFileName);
});

it(
'C430210 Verify Bulk Edit actions for Holdings notes - columns titles (firebird)',
{ tags: ['criticalPath', 'firebird'] },
() => {
BulkEditSearchPane.verifyDragNDropRecordTypeIdentifierArea('Holdings', 'Holdings UUIDs');
BulkEditSearchPane.uploadFile(holdingUUIDsFileName);
BulkEditSearchPane.waitFileUploading();
BulkEditSearchPane.verifyMatchedResults(instance.holdingHRID);
BulkEditActions.openActions();
BulkEditSearchPane.searchColumnName('note');

initialValueSets.forEach((initialValueSet) => {
BulkEditSearchPane.changeShowColumnCheckbox(initialValueSet[0]);
});

initialValueSets.forEach((initialValueSet) => {
BulkEditSearchPane.verifyResultsUnderColumns(...initialValueSet);
});

BulkEditActions.openActions();
BulkEditActions.downloadMatchedResults();
ExportFile.verifyFileIncludes(matchedRecordsFileName, [instance.holdingsUUID]);
BulkEditActions.openInAppStartBulkEditFrom();
BulkEditSearchPane.verifyBulkEditsAccordionExists();
BulkEditActions.verifyOptionsDropdown();
BulkEditActions.verifyRowIcons();
BulkEditActions.verifyHoldingsOptions();
BulkEditActions.selectOption(HOLDING_NOTE_TYPES.ADMINISTRATIVE_NOTE, 0);
BulkEditActions.verifyTheActionOptions(administrativeNoteActionOptions);
BulkEditActions.selectSecondAction(actionsToSelect.addNote);
BulkEditActions.verifySecondActionSelected(actionsToSelect.addNote);
BulkEditActions.fillInSecondTextArea(notes.administrative);
BulkEditActions.verifyValueInSecondTextArea(notes.administrative);
BulkEditSearchPane.isConfirmButtonDisabled(false);

notesToAdd.forEach((noteToAdd) => {
addNoteInBulkEdit(...noteToAdd);
});

BulkEditActions.confirmChanges();
BulkEditActions.verifyMessageBannerInAreYouSureForm(1);
BulkEditActions.verifyChangesInAreYouSureForm(
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.HOLDINGS_HRID,
[instance.holdingHRID],
);

editedValueSets.forEach((editedValueSet) => {
BulkEditActions.verifyChangesInAreYouSureForm(editedValueSet[0], [editedValueSet[1]]);
});

BulkEditActions.commitChanges();
BulkEditSearchPane.waitFileUploading();
BulkEditActions.verifySuccessBanner(1);
BulkEditSearchPane.verifyExactChangesUnderColumns(
BULK_EDIT_TABLE_COLUMN_HEADERS.INVENTORY_HOLDINGS.HOLDINGS_HRID,
instance.holdingHRID,
);

editedValueSets.forEach((editedValueSet) => {
BulkEditSearchPane.verifyExactChangesUnderColumns(...editedValueSet);
});

BulkEditActions.openActions();
BulkEditActions.downloadChangedCSV();
ExportFile.verifyFileIncludes(changedRecordsFileName, [instance.holdingsUUID]);

editedValueSets.forEach((editedValueSet) => {
ExportFile.verifyFileIncludes(changedRecordsFileName, editedValueSet);
});

TopMenuNavigation.navigateToApp(APPLICATION_NAMES.INVENTORY);
InventorySearchAndFilter.switchToHoldings();
InventorySearchAndFilter.searchHoldingsByHRID(instance.holdingHRID);
InventorySearchAndFilter.selectViewHoldings();
HoldingsRecordView.checkExactContentInAdministrativeNote(notes.administrative);
HoldingsRecordView.checkNotesByType(0, HOLDING_NOTE_TYPES.BINDING, notes.binding);
HoldingsRecordView.checkNotesByType(
1,
HOLDING_NOTE_TYPES.ELECTRONIC_BOOKPLATE,
notes.electronicBookplate,
);
HoldingsRecordView.checkNotesByType(2, HOLDING_NOTE_TYPES.PROVENANCE, notes.provenance);
HoldingsRecordView.checkNotesByType(3, HOLDING_NOTE_TYPES.REPRODUCTION, notes.reproduction);
},
);
});
});
Loading

0 comments on commit bef911c

Please sign in to comment.