Skip to content

Commit

Permalink
FAT-7708-C1304-ideyaLabs (#2528)
Browse files Browse the repository at this point in the history
* FAT-7708: steps added

* FAT-7708: more steps added

* FAT-7708: test finished

* FAT-7708: additional waiters added

* FAT-7708: increased timeout for note type save

* FAT-7708: test updated

* FAT-7708: updated method

* FAT-7708: removed file

* file restored

* FAT-7708: added test in a new file

* FAT-7708: refactored test

* FAT-7708: test updated
  • Loading branch information
zentestuken committed Nov 30, 2023
1 parent f96aa3a commit 4743edf
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 6 deletions.
91 changes: 91 additions & 0 deletions cypress/e2e/notes/note-types-edit.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import uuid from 'uuid';
import { Permissions } from '../../support/dictionary';
import TopMenu from '../../support/fragments/topMenu';
import Users from '../../support/fragments/users/users';
import NoteTypes from '../../support/fragments/settings/notes/noteTypes';
import UsersSearchPane from '../../support/fragments/users/usersSearchPane';
import UsersCard from '../../support/fragments/users/usersCard';
import AgreementsDetails from '../../support/fragments/agreements/agreementViewDetails';
import getRandomPostfix, { randomFourDigitNumber } from '../../support/utils/stringTools';
import { NOTE_TYPES } from '../../support/constants';
import NewNote from '../../support/fragments/notes/newNote';
import ExistingNoteEdit from '../../support/fragments/notes/existingNoteEdit';

describe('Notes', () => {
const testData = {
customNoteTypeName: `C1304NoteType_${getRandomPostfix()}`,
updatedNoteTypeName: `C1304NoteTypeUPD_${getRandomPostfix()}`,
};
const noteTypeC1304 = NOTE_TYPES.GENERAL;
const noteC1304 = { title: `Note C1304 ${randomFourDigitNumber()}`, details: 'This is Note 1' };

before('Creating data', () => {
cy.getAdminToken();
NoteTypes.createNoteTypeViaApi({ id: uuid(), name: testData.customNoteTypeName }).then(
(newNoteType) => {
testData.customNoteTypeId = newNoteType.id;

cy.createTempUser([
Permissions.uiUsersView.gui,
Permissions.uiAgreementsSearchAndView.gui,
Permissions.moduleeHoldingsEnabled.gui,
Permissions.licensesSearchAndView.gui,
Permissions.uiRequestsView.gui,
Permissions.coursesAll.gui,
Permissions.uiNotesAssignUnassign.gui,
Permissions.uiNotesItemCreate.gui,
Permissions.uiNotesItemView.gui,
Permissions.uiNotesItemEdit.gui,
Permissions.uiNotesSettingsEdit.gui,
]).then((userC1304Properties) => {
testData.userC1304Properties = userC1304Properties;

cy.loginAsAdmin().then(() => {
cy.visit(TopMenu.usersPath);
UsersSearchPane.waitLoading();
UsersSearchPane.searchByUsername(testData.userC1304Properties.username);
UsersSearchPane.waitLoading();
UsersCard.openNotesSection();
AgreementsDetails.createNote({ ...noteC1304, checkoutApp: false }, noteTypeC1304);
UsersCard.waitLoading();
// wait for all requests on page to finish
cy.wait(3000);
});
});
},
);
});

after('Deleting created entities', () => {
cy.getAdminToken();
Users.deleteViaApi(testData.userC1304Properties.userId);
NoteTypes.deleteNoteTypeViaApi(testData.customNoteTypeId);
});

it('C1304 Settings | Edit a note type (spitfire)', { tags: ['extendedPath', 'spitfire'] }, () => {
cy.login(testData.userC1304Properties.username, testData.userC1304Properties.password).then(
() => {
cy.visit(TopMenu.notesPath);
NoteTypes.waitLoading();
NoteTypes.checkNewButtonState();
NoteTypes.clickEditNoteType(testData.customNoteTypeName);
NoteTypes.checkNoteButtonsState();
NoteTypes.fillInNoteType(testData.updatedNoteTypeName);
NoteTypes.saveNoteType(testData.updatedNoteTypeName);

cy.visit(TopMenu.usersPath);
UsersSearchPane.waitLoading();
UsersSearchPane.searchByUsername(testData.userC1304Properties.username);
UsersSearchPane.waitLoading();
UsersCard.openNotesSection();
UsersCard.clickNewNoteButton();
NewNote.verifyNoteTypeExists(testData.updatedNoteTypeName);
NewNote.close();
UsersCard.openNotesSection();
UsersCard.openNoteForEdit(noteC1304.title);
ExistingNoteEdit.waitLoading();
NewNote.verifyNoteTypeExists(testData.updatedNoteTypeName);
},
);
});
});
12 changes: 12 additions & 0 deletions cypress/support/dictionary/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -892,4 +892,16 @@ export default {
internal: 'module.lists.all',
gui: 'Lists (Admin): All permissions',
},

// Licenses
licensesSearchAndView: {
internal: 'ui-licenses.licenses.view',
gui: 'Licenses: Search & view licenses',
},

// Courses
coursesAll: {
internal: 'ui-courses.all',
gui: 'Courses: All permissions',
},
};
16 changes: 15 additions & 1 deletion cypress/support/fragments/notes/newNote.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { RichEditor, TextField, Button, Select, Label, including } from '../../../../interactors';
import {
RichEditor,
TextField,
Button,
Select,
Label,
including,
PaneHeader,
} from '../../../../interactors';
import getRandomPostfix from '../../utils/stringTools';

const titleTextField = TextField('Note title*');
Expand All @@ -12,6 +20,8 @@ const defaultNote = {
return this.details.substring(0, 255);
},
};
const paneHeader = PaneHeader('New note');
const closeButton = paneHeader.find(Button({ icon: 'times' }));

function getDefaultNote() {
return defaultNote;
Expand Down Expand Up @@ -53,4 +63,8 @@ export default {
verifyNewNoteIsNotDisplayed() {
cy.expect(titleTextField.absent());
},

close() {
cy.do(closeButton.click());
},
};
28 changes: 23 additions & 5 deletions cypress/support/fragments/settings/notes/noteTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ import getRandomPostfix from '../../../utils/stringTools';

const noteTypeRootPane = Pane({ id: 'controlled-vocab-pane' });
const newNoteTypeButton = Button({ id: 'clickable-add-noteTypes', disabled: false });
const cancelNoteTypeCreationButton = Button({ id: 'clickable-cancel-noteTypes-0' });
const saveNoteTypeButton = Button({ id: 'clickable-save-noteTypes-0' });
const cancelNoteTypeCreationButton = Button({ id: including('clickable-cancel-noteTypes-') });
const saveNoteTypeButton = Button({ id: including('clickable-save-noteTypes-') });
const editIcon = Button({ id: including('clickable-edit-noteTypes-') });
const deleteIcon = Button({ id: including('clickable-delete-noteTypes-') });
const noteTypeInput = TextField();
const noteTypePane = PaneSet({ id: 'noteTypes' });
const rowWithText = (noteType) => MultiColumnListRow({ content: including(noteType) });
const newButton = Button({ id: 'clickable-add-noteTypes' });

export default {
createNoteTypeViaApi({
Expand Down Expand Up @@ -91,14 +92,14 @@ export default {
},

fillInNoteType: (noteTypeName) => {
cy.do(noteTypeInput.fillIn(noteTypeName));
cy.do([noteTypeInput.focus(), noteTypeInput.fillIn(noteTypeName)]);
cy.expect(saveNoteTypeButton.has({ disabled: false }));
},

saveNoteType(noteType) {
cy.do(saveNoteTypeButton.click());
// need to wait for note type to appear after creation
cy.wait(2000);
cy.wait(3000);
this.checkNoteTypeIsDisplayed(noteType);
},

Expand All @@ -110,7 +111,10 @@ export default {
ConfirmDelete.confirmDelete();
},

clickEditNoteType: (noteType) => cy.do(rowWithText(noteType).find(editIcon).click()),
clickEditNoteType: (noteType) => {
cy.expect(rowWithText(noteType).exists());
cy.do(rowWithText(noteType).find(editIcon).click());
},

clickDeleteNoteType: (noteType) => cy.do(rowWithText(noteType).find(deleteIcon).click()),

Expand All @@ -132,4 +136,18 @@ export default {
rowWithText(noteType).find(deleteIcon).absent(),
]);
},

checkNewButtonState(isEnabled = true) {
cy.expect(newButton.has({ disabled: !isEnabled }));
},

getNoteTypeIdViaAPI(noteTypeName) {
return cy
.okapiRequest({
method: REQUEST_METHOD.GET,
path: `note-types?query=(name="${noteTypeName}")`,
isDefaultSearchParamsRequired: false,
})
.then(({ body }) => body.noteTypes[0].id);
},
};
11 changes: 11 additions & 0 deletions cypress/support/fragments/users/usersCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
Modal,
} from '../../../../interactors';
import DateTools from '../../utils/dateTools';
import NewNote from '../notes/newNote';

const rootSection = Section({ id: 'pane-userdetails' });
const loansSection = rootSection.find(Accordion({ id: 'loansSection' }));
Expand All @@ -32,6 +33,7 @@ const errors = {
patronHasBlocksInPlace: 'Patron has block(s) in place',
};
const feesFinesAccordion = rootSection.find(Accordion({ id: 'accountsSection' }));
const newNoteButton = notesSection.find(Button({ id: 'note-create-button' }));
const newBlockPane = Pane('New Block');
const saveAndCloseButton = Button({ id: 'patron-block-save-close' });
const cancelButton = Button({ id: 'expirationDate-modal-cancel-btn' });
Expand Down Expand Up @@ -373,4 +375,13 @@ export default {
.has({ text: including(`${count.toString()} open` && `Total: ${totalAmount.toString()}`) }),
);
},

clickNewNoteButton() {
cy.do(newNoteButton.click());
NewNote.verifyNewNoteIsDisplayed();
},

openNoteForEdit(noteTitle) {
cy.do(MultiColumnListCell(including(noteTitle)).find(Button('Edit')).click());
},
};

0 comments on commit 4743edf

Please sign in to comment.