test: front and e2e
gitea/salix-front/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2023-02-24 12:51:29 +01:00
parent 648697c065
commit c1059bdb2d
5 changed files with 34 additions and 28 deletions

View File

@ -11,20 +11,6 @@ const state = useState();
<claim-descriptor /> <claim-descriptor />
<q-separator /> <q-separator />
<left-menu source="card" /> <left-menu source="card" />
<q-separator />
<q-list>
<q-item
active-class="text-primary"
href="http://localhost:5000/#!/claim/1/detail"
clickable
v-ripple
>
<q-item-section avatar>
<q-icon name="disabled_by_default" />
</q-item-section>
<q-item-section> Detalles </q-item-section>
</q-item>
</q-list>
</q-scroll-area> </q-scroll-area>
</q-drawer> </q-drawer>
<q-page-container> <q-page-container>

View File

@ -13,6 +13,7 @@ import FetchData from 'components/FetchData.vue';
const router = useRouter(); const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const session = useSession(); const session = useSession();
const token = session.getToken(); const token = session.getToken();
const quasar = useQuasar(); const quasar = useQuasar();
@ -131,7 +132,7 @@ async function create() {
type: 'positive', type: 'positive',
icon: 'check', icon: 'check',
}); });
console.log(claimDmsRef);
claimDmsRef.value.fetch(); claimDmsRef.value.fetch();
} }
@ -269,7 +270,17 @@ function onDrag() {
@click="inputFile.nativeEl.click()" @click="inputFile.nativeEl.click()"
icon="add_circle" icon="add_circle"
:label="t('globals.add')" :label="t('globals.add')"
>
<q-input
ref="inputFile"
type="file"
style="display: none"
multiple
v-model="files"
@update:model-value="create()"
/> />
<q-tooltip bottom> {{ t('globals.add') }} </q-tooltip>
</q-tab>
</q-tabs> </q-tabs>
</teleport-slot> </teleport-slot>

View File

@ -2,11 +2,9 @@
describe('ClaimPhoto', () => { describe('ClaimPhoto', () => {
beforeEach(() => { beforeEach(() => {
const claimId = 1; const claimId = 1;
cy.viewport(1280, 720); cy.login('developer');
cy.login('developer').then(() => {
cy.visit(`/#/claim/${claimId}/photos`); cy.visit(`/#/claim/${claimId}/photos`);
}); });
});
it('should add new file', () => { it('should add new file', () => {
cy.get('label > .q-btn').click(); cy.get('label > .q-btn').click();
@ -41,9 +39,15 @@ describe('ClaimPhoto', () => {
); );
}); });
it('should remove first file', () => { it('should remove third and fourth file', () => {
cy.get( cy.get(
'.multimediaParent > :nth-child(1) > .q-btn > .q-btn__content > .q-icon' '.multimediaParent > :nth-child(3) > .q-btn > .q-btn__content > .q-icon'
).click();
cy.get('.q-btn--standard > .q-btn__content > .block').click();
cy.get('.q-notification__message').should('have.text', 'Data deleted');
cy.get(
'.multimediaParent > :nth-child(3) > .q-btn > .q-btn__content > .q-icon'
).click(); ).click();
cy.get('.q-btn--standard > .q-btn__content > .block').click(); cy.get('.q-btn--standard > .q-btn__content > .block').click();
cy.get('.q-notification__message').should('have.text', 'Data deleted'); cy.get('.q-notification__message').should('have.text', 'Data deleted');

View File

@ -28,7 +28,7 @@
// Imports Quasar Cypress AE predefined commands // Imports Quasar Cypress AE predefined commands
// import { registerCommands } from '@quasar/quasar-app-extension-testing-e2e-cypress'; // import { registerCommands } from '@quasar/quasar-app-extension-testing-e2e-cypress';
Cypress.Commands.add('login', (user) => { Cypress.Commands.add('login', (user) => {
cy.visit('/#/login'); //cy.visit('/#/login');
cy.request({ cy.request({
method: 'POST', method: 'POST',
url: '/api/accounts/login', url: '/api/accounts/login',

View File

@ -21,10 +21,9 @@ describe('ClaimPhoto', () => {
beforeAll(() => { beforeAll(() => {
vm = createWrapper(ClaimPhoto, { vm = createWrapper(ClaimPhoto, {
global: { global: {
stubs: ['FetchData', 'TeleportSlot'], stubs: ['FetchData', 'TeleportSlot', 'vue-i18n'],
mocks: { mocks: {
claimDms: [{ dmsFk: 1 }], fetch: vi.fn(),
claimDmsRef: { hola: 'hola' },
}, },
}, },
}).vm; }).vm;
@ -91,18 +90,24 @@ describe('ClaimPhoto', () => {
it('should upload file and call quasar notify', async () => { it('should upload file and call quasar notify', async () => {
const files = [{ name: 'firstFile' }]; const files = [{ name: 'firstFile' }];
vi.mock('claimDmsRef', {});
vi.spyOn(axios, 'post').mockResolvedValue({ data: true }); vi.spyOn(axios, 'post').mockResolvedValue({ data: true });
vi.spyOn(vm.quasar, 'notify'); vi.spyOn(vm.quasar, 'notify');
vi.spyOn(vm.claimDmsRef, 'fetch');
await vm.create(files); await vm.create(files);
expect(axios.post).toHaveBeenCalledWith( expect(axios.post).toHaveBeenCalledWith(
expect.objectContaining({ type: 'positive' }) 'claims/1/uploadFile',
new FormData(),
expect.objectContaining({
params: expect.objectContaining({ hasFile: false }),
})
); );
expect(vm.quasar.notify).toHaveBeenCalledWith( expect(vm.quasar.notify).toHaveBeenCalledWith(
expect.objectContaining({ type: 'positive' }) expect.objectContaining({ type: 'positive' })
); );
expect(vm.claimDmsRef.fetch).toHaveBeenCalledOnce();
}); });
}); });
}); });