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-16557
  • Loading branch information
TetianaParanich committed Sep 23, 2024
2 parents e8440a0 + a34edec commit 6fc073f
Show file tree
Hide file tree
Showing 11 changed files with 333 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { Permissions } from '../../../../support/dictionary';
import Users from '../../../../support/fragments/users/users';
import getRandomPostfix from '../../../../support/utils/stringTools';

describe('Inventory', () => {
describe('Settings', () => {
describe('Classification browse', () => {
let user;
let originalDateType;

const testData = {
totalAmountOfDateTypes: 15,
dateTypeSource: 'folio',
keyToUpdate: 'name',
newName: `Fortlaufende Ressource - Update zur Einstellung der Veröffentlichung ${getRandomPostfix()}`,
};

before('Create user, get data', () => {
cy.getAdminToken();
cy.getInstanceDateTypesViaAPI().then((response) => {
originalDateType = response.instanceDateTypes[response.instanceDateTypes.length - 1];
});
cy.createTempUser([
Permissions.uiInventorySettingsConfigureClassificationBrowse.gui,
Permissions.crudClassificationIdentifierTypes.gui,
]).then((userProperties) => {
user = userProperties;
});
});

after('Delete user', () => {
cy.getAdminToken();
// restore the original instance date type name
cy.patchInstanceDateTypeViaAPI(
originalDateType.id,
testData.keyToUpdate,
originalDateType.name,
);
Users.deleteViaApi(user.userId);
});

it(
'C506694 Update of Date type\'s "name" (spitfire)',
{ tags: ['criticalPath', 'spitfire'] },
() => {
cy.patchInstanceDateTypeViaAPI(
originalDateType.id,
testData.keyToUpdate,
testData.newName,
).then(({ status }) => {
expect(status).to.eq(204);
cy.getInstanceDateTypesViaAPI().then((response) => {
expect(response.status).to.eq(200);
expect(response.instanceDateTypes).to.have.lengthOf(testData.totalAmountOfDateTypes);
expect(
response.instanceDateTypes.every((type) => type.source === testData.dateTypeSource),
).to.eq(true);
const updatedDateType = response.instanceDateTypes.filter(
(type) => type.id === originalDateType.id,
)[0];
expect(updatedDateType.name).to.eq(testData.newName);
});
});
},
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Users', () => {
UsersSearchPane.searchByUsername(testData.userB.username);
UsersCard.waitLoading();
UserEdit.openEdit();
UserEdit.verifyProfileCardIsPresent();
UserEdit.verifyProfileCardIsPresented();
UserEdit.verifyButtonsStateForProfilePicture([{ value: 'Delete' }]);
UserEdit.deleteProfilePicture(testData.userB);
UserEdit.verifyPictureIsRemoved(testData.externalPictureUrl);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import Permissions from '../../../support/dictionary/permissions';
import TopMenu from '../../../support/fragments/topMenu';
import UserEdit from '../../../support/fragments/users/userEdit';
import Users from '../../../support/fragments/users/users';
import UsersCard from '../../../support/fragments/users/usersCard';
import UsersSearchPane from '../../../support/fragments/users/usersSearchPane';

describe('Users', () => {
describe('Profile pictures', () => {
const testData = {
externalPictureUrl:
'https://png.pngtree.com/png-vector/20191101/ourmid/pngtree-cartoon-color-simple-male-avatar-png-image_1934459.jpg',
};

before('Create test data and login', () => {
cy.getAdminToken();
cy.getConfigurationsEntry().then((respBody) => {
const id = respBody.id;
respBody.enabled = true;

cy.updateConfigurationsEntry(id, respBody);
});

// create user B
cy.createTempUser().then((userProperties) => {
testData.userB = userProperties;
UserEdit.addProfilePictureViaApi(testData.userB.userId, testData.externalPictureUrl);
});

// create user C
cy.createTempUser().then((userProperties) => {
testData.userC = userProperties;
});

// create user A
cy.createTempUser([Permissions.uiUsersView.gui]).then((userProperties) => {
testData.userA = userProperties;

cy.login(testData.userA.username, testData.userA.password, {
path: TopMenu.usersPath,
waiter: UsersSearchPane.waitLoading,
});
});
});

after('Deleting created entities', () => {
cy.getAdminToken();
Users.deleteViaApi(testData.userA.userId);
Users.deleteViaApi(testData.userB.userId);
Users.deleteViaApi(testData.userC.userId);
});

it(
"C442807 Verify that profile pictures don't display on user record without Users: Can view profile pictures (volaris)",
{ tags: ['smoke', 'volaris'] },
() => {
UsersSearchPane.searchByUsername(testData.userB.username);
UsersCard.waitLoading();
UsersCard.verifyProfilePictureIsAbsent();

UsersSearchPane.resetAllFilters();
UsersSearchPane.searchByUsername(testData.userC.username);
UsersCard.waitLoading();
UsersCard.verifyProfilePictureIsAbsent();
},
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import Permissions from '../../../support/dictionary/permissions';
import TopMenu from '../../../support/fragments/topMenu';
import UserEdit from '../../../support/fragments/users/userEdit';
import Users from '../../../support/fragments/users/users';
import UsersCard from '../../../support/fragments/users/usersCard';
import UsersSearchPane from '../../../support/fragments/users/usersSearchPane';

describe('Users', () => {
describe('Profile pictures', () => {
const testData = {
externalPictureUrl:
'https://hips.hearstapps.com/hmg-prod/images/bright-forget-me-nots-royalty-free-image-1677788394.jpg?crop=0.535xw:1.00xh;0.359xw,0&resize=980:*',
newExternalPictureUrl:
'https://hips.hearstapps.com/hmg-prod/images/bright-me-nots-royalty-free-image-1677788394.jpg?crop=0.535xw:1.00xh;0.359xw,0&resize=980:*',
invalidExternalPictureUrl:
'https//hips.hearstapps.com/hmg-prod/images/bright-forget-me-nots-royalty-free-image-1677788394.jpg?crop=0.535xw:1.00xh;0.359xw,0&resize=980:*',
validExternalPictureUrl:
'https://kidlingoo.com/wp-content/uploads/flowers_name_in_english.jpg',
};

before('Create test data and login', () => {
cy.getAdminToken();
cy.getConfigurationsEntry().then((respBody) => {
respBody.enabled = true;

cy.updateConfigurationsEntry(respBody.id, respBody);
});

// create user B
cy.createTempUser().then((userProperties) => {
testData.userB = userProperties;
});

// create user A
cy.createTempUser([Permissions.uiUserViewEditDeliteProfilePictores.gui]).then(
(userProperties) => {
testData.userA = userProperties;

cy.login(testData.userA.username, testData.userA.password, {
path: TopMenu.usersPath,
waiter: UsersSearchPane.waitLoading,
});
},
);
});

after('Deleting created entities', () => {
cy.getAdminToken();
Users.deleteViaApi(testData.userA.userId);
Users.deleteViaApi(testData.userB.userId);
});

it(
'C442797 Verify that profile picture can be updated via URL (volaris)',
{ tags: ['criticalPath', 'volaris'] },
() => {
UsersSearchPane.searchByUsername(testData.userB.username);
UsersCard.waitLoading();
UserEdit.openEdit();
UserEdit.verifyProfileCardIsPresented();
UserEdit.verifyButtonsStateForProfilePicture([{ value: 'External URL' }]);
UserEdit.setPictureFromExternalUrl(testData.externalPictureUrl);
UserEdit.verifyProfilePictureIsPresent(testData.externalPictureUrl);
UserEdit.saveAndClose();
UsersCard.waitLoading();
UsersCard.verifyProfilePictureIsPresent(testData.externalPictureUrl);

UserEdit.openEdit();
UserEdit.verifyProfileCardIsPresented();
UserEdit.verifyButtonsStateForProfilePicture([{ value: 'External URL' }]);
UserEdit.setPictureFromExternalUrl(testData.newExternalPictureUrl, false);
UserEdit.verifyModalWithInvalidUrl(
'The provided URL is valid but does not point to an image file',
);
UserEdit.fillInExternalImageUrlTextField(testData.invalidExternalPictureUrl);
UserEdit.clickSaveButton();
UserEdit.verifyModalWithInvalidUrl('Invalid image URL');

UserEdit.clearExternalImageUrlTextField();
UserEdit.fillInExternalImageUrlTextField(testData.validExternalPictureUrl);
UserEdit.clickSaveButton();
cy.wait(3000);
UserEdit.saveAndClose();
UsersCard.waitLoading();
UsersCard.verifyProfilePictureIsPresent(testData.validExternalPictureUrl);
},
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('Users', () => {
UserEdit.verifyButtonsStateForProfilePicture([{ value: 'Local file' }]);
// steps 10-11 we can't automate
UserEdit.setPictureFromExternalUrl(testData.externalPictureUrl);
UserEdit.verifyProfilePictureIsPresent(testData.externalPictureUrl);
cy.wait(3000);
UserEdit.saveAndClose();
UsersCard.waitLoading();
Expand Down
26 changes: 26 additions & 0 deletions cypress/support/api/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,3 +478,29 @@ Cypress.Commands.add('getHoldingNoteTypeIdViaAPI', (holdingNoteTypeName) => {
})
.then(({ body }) => body.holdingsNoteTypes[0].id);
});

Cypress.Commands.add('getInstanceDateTypesViaAPI', (limit = 20) => {
return cy
.okapiRequest({
method: 'GET',
path: `instance-date-types?limit=${limit}`,
isDefaultSearchParamsRequired: false,
})
.then(({ status, body }) => {
return {
status,
instanceDateTypes: body.instanceDateTypes,
};
});
});

Cypress.Commands.add('patchInstanceDateTypeViaAPI', (dateTypeId, keyToUpdate, value) => {
const patchBody = {};
patchBody[keyToUpdate] = value;
return cy.okapiRequest({
method: 'PATCH',
path: `instance-date-types/${dateTypeId}`,
body: patchBody,
isDefaultSearchParamsRequired: false,
});
});
34 changes: 25 additions & 9 deletions cypress/support/fragments/data_import/dataImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function getCreatedRecordInfoWithSplitFiles(jobExecutionId, recordId) {
});
}

function getJodStatus(jobExecutionId) {
function getJobStatus(jobExecutionId) {
return cy.okapiRequest({
path: `change-manager/jobExecutions/${jobExecutionId}`,
isDefaultSearchParamsRequired: false,
Expand Down Expand Up @@ -298,7 +298,7 @@ function uploadDefinitionWithAssembleStorageFile(
});
}

function getParentJobExecutionId() {
function getParentJobExecutions() {
// splitting process creates additional job executions for parent/child
// so we need to query to get the correct job execution ID COMPOSITE_PARENT
return cy.okapiRequest({
Expand All @@ -307,6 +307,26 @@ function getParentJobExecutionId() {
});
}

function getParentJobExecutionId(sourcePath) {
function filterResponseBySourcePath(response) {
const {
body: { jobExecutions },
} = response;
return jobExecutions.find((jobExecution) => {
return jobExecution.sourcePath === sourcePath;
});
}
return recurse(
() => getParentJobExecutions(),
(response) => filterResponseBySourcePath(response) !== undefined,
{
limit: 5,
},
).then((response) => {
return filterResponseBySourcePath(response).id;
});
}

function getChildJobExecutionId(jobExecutionId) {
return cy.okapiRequest({
path: `change-manager/jobExecutions/${jobExecutionId}/children`,
Expand Down Expand Up @@ -354,7 +374,7 @@ function uploadFileWithoutSplitFilesViaApi(filePathName, fileName, profileName)
);

recurse(
() => getJodStatus(jobExecutionId),
() => getJobStatus(jobExecutionId),
(resp) => resp.body.status === 'COMMITTED' && resp.body.uiStatus === 'RUNNING_COMPLETE',
{
limit: 16,
Expand Down Expand Up @@ -430,20 +450,16 @@ function uploadFileWithSplitFilesViaApi(filePathName, fileName, profileName) {
},
);

getParentJobExecutionId().then((jobExecutionResponse) => {
const parentJobExecutionId = jobExecutionResponse.body.jobExecutions.find(
(exec) => exec.sourcePath === sourcePath,
).id;
getParentJobExecutionId(sourcePath).then((parentJobExecutionId) => {
recurse(
() => getJodStatus(parentJobExecutionId),
() => getJobStatus(parentJobExecutionId),
(resp) => resp.body.status === 'COMMITTED' && resp.body.uiStatus === 'RUNNING_COMPLETE',
{
limit: 16,
timeout: 80000,
delay: 5000,
},
);

getChildJobExecutionId(parentJobExecutionId).then((resp2) => {
const childJobExecutionId = resp2.body.jobExecutions[0].id;

Expand Down
Loading

0 comments on commit 6fc073f

Please sign in to comment.