Skip to content

Commit

Permalink
FAT-12890 Fix, stabilize test cases for Q BugFest (#3542)
Browse files Browse the repository at this point in the history
* Fix, stabilize test cases

* Make natural ID unique

* Add optional argument to the method MarcAuthority.deleteViaAPI

* Remove the comment
  • Loading branch information
sviatlana-stsiapanava committed Apr 30, 2024
1 parent b0047bf commit 020d606
Show file tree
Hide file tree
Showing 108 changed files with 453 additions and 251 deletions.
Expand Up @@ -126,12 +126,12 @@ describe('Data Import', () => {

before('Create test data and login', () => {
cy.getAdminToken();
// make sure there are no duplicate authority records in the system
// make sure there are no duplicate records in the system
MarcAuthorities.getMarcAuthoritiesViaApi({ limit: 100, query: 'keyword="C374167"' }).then(
(records) => {
records.forEach((record) => {
if (record.authRefType === 'Authorized') {
MarcAuthority.deleteViaAPI(record.id);
MarcAuthority.deleteViaAPI(record.id, true);
}
});
},
Expand Down
Expand Up @@ -45,7 +45,7 @@ describe('Data Import', () => {
'245',
'1',
'0',
'$a Crossfire : $b deletion testing : poems 1998-2019 / $c Staceyann Chin ; foreword by Jacqueline Woodson.',
'$a Crossfire : $b deletion testing : poems 1998-2019 / $c Staceyann Chin ; foreword by Jacqueline Woodson. TEST',
],
};
function replace999SubfieldsInPreupdatedFile(
Expand Down
Expand Up @@ -132,6 +132,18 @@ describe('Data Import', () => {
const createdAuthorityIDs = [];

before('Creating user and test data', () => {
// make sure there are no duplicate records in the system
cy.getAdminToken();
MarcAuthorities.getMarcAuthoritiesViaApi({
limit: 100,
query: 'keyword="C377005*" and (authRefType==("Authorized" or "Auth/Ref"))',
}).then((authorities) => {
if (authorities) {
authorities.forEach(({ id }) => {
MarcAuthority.deleteViaAPI(id, true);
});
}
});
cy.createTempUser([
Permissions.moduleDataImportEnabled.gui,
Permissions.inventoryAll.gui,
Expand Down
Expand Up @@ -120,7 +120,7 @@ describe('Data Import', () => {
const marcFiles = [
{
marc: 'marcBibFileForC376967.mrc',
fileName: `testMarcFile.${getRandomPostfix()}.mrc`,
fileName: `C376967testMarcFile.${getRandomPostfix()}.mrc`,
jobProfileToRun: DEFAULT_JOB_PROFILE_NAMES.CREATE_INSTANCE_AND_SRS,
numOfRecords: 1,
propertyName: 'instance',
Expand All @@ -141,6 +141,18 @@ describe('Data Import', () => {
const createdAuthorityIDs = [];

before('Creating user and test data', () => {
// make sure there are no duplicate records in the system
cy.getAdminToken();
MarcAuthorities.getMarcAuthoritiesViaApi({
limit: 100,
query: 'keyword="C376967*" and (authRefType==("Authorized" or "Auth/Ref"))',
}).then((authorities) => {
if (authorities) {
authorities.forEach(({ id }) => {
MarcAuthority.deleteViaAPI(id, true);
});
}
});
cy.createTempUser([
Permissions.moduleDataImportEnabled.gui,
Permissions.inventoryAll.gui,
Expand All @@ -165,6 +177,7 @@ describe('Data Import', () => {
.then(() => {
cy.visit(TopMenu.inventoryPath);
InventoryInstances.searchByTitle(createdAuthorityIDs[0]);

InventoryInstances.selectInstance();
InventoryInstance.editMarcBibliographicRecord();
QuickMarcEditor.clickLinkIconInTagField(linkingTagAndValues.rowIndex);
Expand Down
Expand Up @@ -94,7 +94,7 @@ describe('Data Import', () => {
},
{
marc: 'marcFileForC380511.mrc',
fileName: `testMarcFile.${getRandomPostfix()}.mrc`,
fileName: `testMarcFileC380511.${getRandomPostfix()}.mrc`,
jobProfileToRun: DEFAULT_JOB_PROFILE_NAMES.CREATE_AUTHORITY,
numOfRecords: 4,
propertyName: 'authority',
Expand All @@ -103,34 +103,46 @@ describe('Data Import', () => {
const linkingTagAndValues = [
{
rowIndex: 17,
value: 'Ludwig van, Beethoven, 1770-1827.',
value: 'C380511 Ludwig van, Beethoven, 1770-1827.',
tag: '100',
},
{
rowIndex: 18,
value:
'Beethoven, Ludwig van, 1770-1827 Variations, piano, violin, cello, op. 44, E♭ major',
'C380511 Beethoven, Ludwig van, 1770-1827 Variations, piano, violin, cello, op. 44, E♭ major',
tag: '240',
},
{
rowIndex: 41,
value: 'Music piano',
value: 'C380511 Music piano',
tag: '650',
},
{
rowIndex: 50,
value: 'Hewitt, Angela, 1958-',
value: 'C380511 Hewitt, Angela, 1958-',
tag: '700',
},
{
rowIndex: 51,
value: 'Ludwig van, Beethoven, 1770-1827.',
value: 'C380511 Ludwig van, Beethoven, 1770-1827.',
tag: '700',
},
];
const createdAuthorityIDs = [];

before('Creating user', () => {
// make sure there are no duplicate records in the system
cy.getAdminToken();
MarcAuthorities.getMarcAuthoritiesViaApi({
limit: 100,
query: 'keyword="C380511*" and (authRefType==("Authorized" or "Auth/Ref"))',
}).then((authorities) => {
if (authorities) {
authorities.forEach(({ id }) => {
MarcAuthority.deleteViaAPI(id, true);
});
}
});
cy.createTempUser([
Permissions.moduleDataImportEnabled.gui,
Permissions.inventoryAll.gui,
Expand Down Expand Up @@ -279,18 +291,18 @@ describe('Data Import', () => {
nameForExportedMarcFile,
nameForUpdatedMarcFile,
[
'aLudwig van, Beethoven,d1770-1827ecomposer',
'aC380511 Ludwig van, Beethoven,d1770-1827ecomposer',
'0id.loc.gov/authorities/names/n83130832',
'aMusic piano',
'aC380511 Music piano',
'ewriter of supplementary textual content.',
'aLudwig van, Beethoven,d1770-1827iContainer of (work):0http://id.loc.gov/authorities/names/n79107741',
'aC380511 Ludwig van, Beethoven,d1770-1827iContainer of (work):0http://id.loc.gov/authorities/names/n79107741',
],
[
'aBeethoven, Ludwig V.d1770-1827eAuthor',
'aC380511 Beethoven, Ludwig V.d1770-1827eAuthor',
'0id.loc.gov/authorities/names/n83130833',
'aMusic pianocTest environment',
'aC380511 Music pianocTest environment',
'eauthor of supplementary textual content.',
'aBeethoven, Ludwig V.d1770-1827iContainer of (work):',
'aC380511 Beethoven, Ludwig V.d1770-1827iContainer of (work):',
],
);

Expand All @@ -313,7 +325,7 @@ describe('Data Import', () => {
'100',
'1',
'\\',
'$a Ludwig van, Beethoven, $d 1770-1827',
'$a C380511 Ludwig van, Beethoven, $d 1770-1827',
'$e composer.',
'$0 http://id.loc.gov/authorities/names/n79107741',
'',
Expand All @@ -333,7 +345,7 @@ describe('Data Import', () => {
'650',
'\\',
'0',
'$a Music piano',
'$a C380511 Music piano',
'$c Test environment',
'$0 http://id.loc.gov/authorities/childrensSubjects/sj2021056711',
'',
Expand All @@ -343,7 +355,7 @@ describe('Data Import', () => {
'700',
'1',
'\\',
'$a Hewitt, Angela, $d 1958-',
'$a C380511 Hewitt, Angela, $d 1958-',
'$e instrumentalist, $e writer of supplementary textual content.',
'$0 http://id.loc.gov/authorities/names/n91099716',
'',
Expand All @@ -353,7 +365,7 @@ describe('Data Import', () => {
'700',
'1',
'2',
'$a Ludwig van, Beethoven, $d 1770-1827',
'$a C380511 Ludwig van, Beethoven, $d 1770-1827',
'$i Container of (work):',
'$0 http://id.loc.gov/authorities/names/n79107741',
'',
Expand All @@ -363,14 +375,14 @@ describe('Data Import', () => {
'700',
'1',
'\\',
'$a Hewitt, Angela, $d 1958- $e instrumentalist, $e author of supplementary textual content. $0 http://id.loc.gov/authorities/names/n91099716',
'$a C380511 Hewitt, Angela, $d 1958- $e instrumentalist, $e author of supplementary textual content. $0 http://id.loc.gov/authorities/names/n91099716',
);
QuickMarcEditor.verifyTagFieldAfterUnlinking(
53,
'700',
'1',
'2',
'$a Beethoven, Ludwig V. $d 1770-1827 $i Container of (work):',
'$a C380511 Beethoven, Ludwig V. $d 1770-1827 $i Container of (work):',
);
},
);
Expand Down
Expand Up @@ -108,13 +108,13 @@ describe('Data Import', () => {
};

before('Creating test data', () => {
// make sure there are no duplicate authority records in the system
// make sure there are no duplicate records in the system
cy.getAdminToken().then(() => {
MarcAuthorities.getMarcAuthoritiesViaApi({ limit: 100, query: 'keyword="C385660"' }).then(
(records) => {
records.forEach((record) => {
if (record.authRefType === 'Authorized') {
MarcAuthority.deleteViaAPI(record.id);
MarcAuthority.deleteViaAPI(record.id, true);
}
});
},
Expand Down
Expand Up @@ -109,7 +109,7 @@ describe('Data Import', () => {
const linkingTagAndValues = [
{
rowIndex: 75,
value: 'Chin, Staceyann C385665',
value: 'C385665Chin, Staceyann',
},
{
rowIndex: 76,
Expand All @@ -124,6 +124,18 @@ describe('Data Import', () => {
const subfield = '$9';

before('Creating user', () => {
// make sure there are no duplicate records in the system
cy.getAdminToken();
MarcAuthorities.getMarcAuthoritiesViaApi({
limit: 100,
query: 'keyword="C385665*" and (authRefType==("Authorized" or "Auth/Ref"))',
}).then((authorities) => {
if (authorities) {
authorities.forEach(({ id }) => {
MarcAuthority.deleteViaAPI(id, true);
});
}
});
cy.createTempUser([
Permissions.moduleDataImportEnabled.gui,
Permissions.inventoryAll.gui,
Expand Down Expand Up @@ -221,6 +233,7 @@ describe('Data Import', () => {
});
QuickMarcEditor.pressSaveAndClose();
QuickMarcEditor.checkAfterSaveAndClose();
cy.pause();

// download .csv file
InventorySearchAndFilter.saveUUIDs();
Expand Down
Expand Up @@ -153,6 +153,18 @@ describe('Data Import', () => {
const createdAuthorityIDs = [];

before('Creating user and test data', () => {
// make sure there are no duplicate records in the system
cy.getAdminToken();
MarcAuthorities.getMarcAuthoritiesViaApi({
limit: 100,
query: 'keyword="C377006*" and (authRefType==("Authorized" or "Auth/Ref"))',
}).then((authorities) => {
if (authorities) {
authorities.forEach(({ id }) => {
MarcAuthority.deleteViaAPI(id, true);
});
}
});
cy.createTempUser([
Permissions.moduleDataImportEnabled.gui,
Permissions.inventoryAll.gui,
Expand Down
Expand Up @@ -20,8 +20,8 @@ describe('Inventory', () => {
numOfRecords: 1,
};
let createdAuthorityID;
const notExactSearchName = '"Giuseppe"';
const exactSearchName = 'Dalla Torre, "Giuseppe"';
const notExactSearchName = '"C397324 Giuseppe"';
const exactSearchName = 'C397324 Dalla Torre, "Giuseppe"';

before('Creating user and test data', () => {
cy.createTempUser([Permissions.inventoryAll.gui])
Expand Down
Expand Up @@ -31,6 +31,18 @@ describe('Inventory', () => {

before('Creating data', () => {
cy.getAdminToken()
.then(() => {
InventoryInstances.getInstancesViaApi({
limit: 100,
query: 'title="Roma council*"',
}).then((instances) => {
if (instances) {
instances.forEach(({ id }) => {
InventoryInstances.deleteInstanceAndItsHoldingsAndItemsViaApi(id);
});
}
});
})
.then(() => {
cy.getInstanceTypes({ limit: 1 }).then((instanceTypes) => {
testData.instanceTypeId = instanceTypes[0].id;
Expand Down
27 changes: 20 additions & 7 deletions cypress/e2e/inventory/search/advanced-search-in-inventory.cy.js
Expand Up @@ -14,21 +14,22 @@ describe('Inventory', () => {
describe('Advanced search', () => {
const testData = {
advSearchOption: 'Advanced search',
expectedSearchResult: 'The Beatles in mono. Adv search 001',
expectedSearchResult: 'C400610 The Beatles in mono. Adv search 001',
callNumberValue: 'YCN002003400616',
itemBarcode: 'ITBRCC400616',
expectedSearchResultsC400616: [
'Humans and machines Adv Search 003',
'Mediterranean conference on medical and biological engineering and computing 2013 Adv Search 003',
'C400616 Humans and machines Adv Search 003',
'C400616 Mediterranean conference on medical and biological engineering and computing 2013 Adv Search 003',
],
expectedFirstSearchResultsC414977: [
'Queer comrades : gay identity and Tongzhi activism in postsocialist China / Hongwei Bao.',
'Queer festivals : challenging collective identities in a transnational europe / Konstantinos Eleftheriadis.',
'Sexuality, iconography, and fiction in French : queering the martyr / Jason James Hartford.',
'C414977 Queer comrades : gay identity and Tongzhi activism in postsocialist China / Hongwei Bao.',
'C414977 Queer festivals : challenging collective identities in a transnational europe / Konstantinos Eleftheriadis.',
'C414977 Sexuality, iconography, and fiction in French : queering the martyr / Jason James Hartford.',
],
expectedSecondSearchResultC414977: 'Reckon / Steve McOrmond.',
expectedSecondSearchResultC414977: 'C414977 Reckon / Steve McOrmond.',
};
const createdRecordIDs = [];
const testsIds = ['C400610', 'C400616', 'C414977'];

const marcFiles = [
{
Expand All @@ -55,6 +56,18 @@ describe('Inventory', () => {
];

before('Creating data', () => {
testsIds.forEach((testId) => {
InventoryInstances.getInstancesViaApi({
limit: 100,
query: `title="${testId}*"`,
}).then((instances) => {
if (instances) {
instances.forEach(({ id }) => {
InventoryInstances.deleteInstanceAndItsHoldingsAndItemsViaApi(id);
});
}
});
});
cy.createTempUser([Permissions.inventoryAll.gui]).then((createdUserProperties) => {
testData.userProperties = createdUserProperties;
cy.loginAsAdmin({ path: TopMenu.dataImportPath, waiter: DataImport.waitLoading }).then(
Expand Down
13 changes: 12 additions & 1 deletion cypress/e2e/inventory/search/browse-in-inventory.cy.js
Expand Up @@ -14,7 +14,7 @@ import getRandomPostfix from '../../../support/utils/stringTools';

describe('Browse in Inventory', () => {
const testData = {
contributorName: 'Lee, Stan, 1922-2018',
contributorName: 'C388531 Lee, Stan, 1922-2018',
};

const marcFiles = [
Expand Down Expand Up @@ -44,6 +44,17 @@ describe('Browse in Inventory', () => {
const createdAuthorityIDs = [];

before('Creating data', () => {
// make sure there are no duplicate records in the system
MarcAuthorities.getMarcAuthoritiesViaApi({
limit: 100,
query: 'keyword="C388531" and (authRefType==("Authorized" or "Auth/Ref"))',
}).then((authorities) => {
if (authorities) {
authorities.forEach(({ id }) => {
MarcAuthority.deleteViaAPI(id, true);
});
}
});
cy.createTempUser([Permissions.inventoryAll.gui]).then((createdUserProperties) => {
testData.userProperties = createdUserProperties;

Expand Down

0 comments on commit 020d606

Please sign in to comment.