0
0
Fork 0

test: refs #8039 add hasNotify and, refactor: agencyWorkCenter test

This commit is contained in:
Alex Moreno 2024-10-22 13:21:16 +02:00
parent 9db1c4f721
commit a732ec05fb
3 changed files with 24 additions and 22 deletions

View File

@ -61,6 +61,7 @@ defineExpose({
:loading="isLoading"
@click="emit('onDataCanceled')"
v-close-popup
data-cy="FormModelPopup_cancel"
/>
<QBtn
:label="t('globals.save')"
@ -70,6 +71,7 @@ defineExpose({
class="q-ml-sm"
:disabled="isLoading"
:loading="isLoading"
data-cy="FormModelPopup_save"
/>
</div>
</template>

View File

@ -7,31 +7,20 @@ describe('AgencyWorkCenter', () => {
const createButton = '.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon';
const workCenterCombobox = 'input[role="combobox"]';
it('assign workCenter', () => {
it('check workCenter crud', () => {
// create
cy.get(createButton).click();
cy.get(workCenterCombobox).type('workCenterOne{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created');
});
cy.hasNotify('Data created');
it('delete workCenter', () => {
// expect error when duplicate
cy.get(createButton).click();
cy.get('[data-cy="FormModelPopup_save"]').click();
cy.hasNotify('This workCenter is already assigned to this agency');
cy.get('[data-cy="FormModelPopup_cancel"]').click();
// delete
cy.get('.q-item__section--side > .q-btn > .q-btn__content > .q-icon').click();
cy.get('.q-notification__message').should(
'have.text',
'WorkCenter removed successfully'
);
});
it('error on duplicate workCenter', () => {
cy.get(createButton).click();
cy.get(workCenterCombobox).type('workCenterOne{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created');
cy.get(createButton).click();
cy.get(
'.vn-row > .q-field > .q-field__inner > .q-field__control > .q-field__control-container'
).type('workCenterOne{enter}');
cy.get(
':nth-child(2) > .q-notification__wrapper > .q-notification__content > .q-notification__message'
).should('have.text', 'This workCenter is already assigned to this agency');
cy.hasNotify('WorkCenter removed successfully');
});
});

View File

@ -254,3 +254,14 @@ Cypress.Commands.add('openUserPanel', () => {
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
).click();
});
Cypress.Commands.add('hasNotify', (text) => {
//last
cy.get('.q-notification')
.should('be.visible')
.last()
.then(($lastNotification) => {
if (!Cypress.$($lastNotification).text().includes(text))
throw new Error(`Notification not found: "${text}"`);
});
});