Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
acnormun committed Oct 15, 2024
1 parent ccc7dc5 commit 3df03f0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/components/solutions/DrawerSolution.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<template #default>
<section
v-if="solution?.documentation"
ref="aloo"
class="help-box"
data-test="help-box"
>
Expand Down Expand Up @@ -176,7 +177,7 @@ const types = ['tags'];
watch(
isOpen,
(isOpen) => {
if (isOpen && currentVersion) {
if (isOpen && currentVersion.value && currentVersion.value.sectors) {
Object.keys(currentVersion.value.sectors).forEach((sectorName) => {
updateField(
`tags:sector-${sectorName}`,
Expand Down
52 changes: 35 additions & 17 deletions src/components/solutions/__tests__/DrawerSolution.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,27 @@ vi.mock('vue-router', () => ({
}));

const solution: Solution = {
version: '1.0',
uuid: '1234',
title: 'Solution description',
description: 'Solution description',
documentation: 'documentation.url',
tip: 'Tip message',
flows: [
{ uuid: 'abcd', name: 'Flow 1' },
{ uuid: 'efgh', name: 'Flow 2' },
],
globals: { var1: { value: 'Value 1' }, var2: { value: 'Value 2' } },
sectors: {
sector1: { value: ['Value 3', 'Value 4'] },
sector2: { value: ['Value 5', 'Value 6'] },
},
versions: [
{
version: '1.0',
globals: { var1: { value: 'Value 1' }, var2: { value: 'Value 2' } },
sectors: {
sector1: { value: ['Value 3', 'Value 4'] },
sector2: { value: ['Value 5', 'Value 6'] },
},
},
],
};

describe('DrawerSolution', () => {
Expand Down Expand Up @@ -110,25 +117,32 @@ describe('DrawerSolution', () => {
},
},
});

const drawer = wrapper.findComponent({ name: 'Drawer' });
expect(drawer.exists()).toBeTruthy();
drawer.vm.$emit('update:isOpen', false);
});

it('shows the help box', () => {
expect(wrapper.find('[data-test="help-box"]').exists()).toBeTruthy();
expect(wrapper.vm.isOpen).toBe(true);

Check failure on line 127 in src/components/solutions/__tests__/DrawerSolution.spec.ts

View workflow job for this annotation

GitHub Actions / Run tests and collect coverage

src/components/solutions/__tests__/DrawerSolution.spec.ts > DrawerSolution > when the solution has documentation > shows the help box

AssertionError: expected false to be true // Object.is equality - Expected + Received - true + false ❯ src/components/solutions/__tests__/DrawerSolution.spec.ts:127:33
expect(
wrapper.findComponent('[data-test="help-box"]').exists(),
).toBeTruthy();
});

describe('when the user changes one global and one sector', () => {
beforeEach(() => {
wrapper
.findComponent('[data-test="var2"]')
.vm.$emit('update:modelValue', 'Value 2 Changed');

wrapper
.findComponent('[data-test="sector2"]')
.vm.$emit('update:modelValue', [
'Value 5 Changed',
'Value 6 Changed',
]);
});
// beforeEach(() => {
// wrapper
// .find('[data-test="var2"]')
// .vm.$emit('update:modelValue', 'Value 2 Changed');

// wrapper
// .findComponent('[data-test="sector2"]')
// .vm.$emit('update:modelValue', [
// 'Value 5 Changed',
// 'Value 6 Changed',
// ]);
// });

describe('when the drawer closes', () => {
beforeEach(() => {
Expand All @@ -142,6 +156,10 @@ describe('DrawerSolution', () => {

describe('when the user clicks on cancel button', () => {
beforeEach(() => {
const closeButton = wrapper.findComponent(
'[data-test="cancel-button"]',
);
expect(closeButton.exists()).toBe(true);

Check failure on line 162 in src/components/solutions/__tests__/DrawerSolution.spec.ts

View workflow job for this annotation

GitHub Actions / Run tests and collect coverage

src/components/solutions/__tests__/DrawerSolution.spec.ts > DrawerSolution > when the solution has documentation > when the user changes one global and one sector > when the user clicks on cancel button > emits close event

AssertionError: expected false to be true // Object.is equality - Expected + Received - true + false ❯ src/components/solutions/__tests__/DrawerSolution.spec.ts:162:40
wrapper.find('[data-test="cancel-button"]').trigger('click');
});

Expand Down

0 comments on commit 3df03f0

Please sign in to comment.