Skip to content

issue-5063 changes #5083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,15 @@
<FullNameForm v-model="showFullNameForm" />
<ChangePasswordForm v-model="showPasswordForm" />
<DeleteAccountForm v-model="showDeleteConfirmation" />
<Alert
v-model="showExportDataNotice"
:header="$tr('exportStartedHeader')"
:text="$tr('exportAccountDataModalMessage')"
/>

<KModal
v-if="showExportDataNotice"
:submitText="$tr('exportDataBtn')"
:title="$tr('exportStartedHeader')"
@submit="showExportDataNotice = false"
>
{{ $tr('exportAccountDataModalMessage') }}
</KModal>
</div>

</template>
Expand Down Expand Up @@ -235,6 +239,7 @@
exportAccountDataModalMessage:
"You'll receive an email with your data when the export is completed",
exportFailed: 'Unable to export data. Please try again.',
exportDataBtn: 'OK',
},
};

Expand Down
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for following the guidance and updating these!

Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,13 @@ describe('account tab', () => {
await wrapper.vm.$nextTick();
expect(wrapper.vm.showExportDataNotice).toBe(true);
});

it('export data failure', async () => {
const exportData = jest.spyOn(wrapper.vm, 'exportData');
exportData.mockImplementation(() => Promise.reject('error'));
await wrapper.find('[data-test="export-link"]').trigger('click');
expect(exportData).toHaveBeenCalled();
expect(wrapper.vm.showExportDataNotice).toBe(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing whether a modal is displayed via checking on showExportDataNotice value would be a fragile approach. Imagine a situation when we'd re-implement or removed internal data such as showExportDataNotice. Then this test could pass even if the form weren't visible, or fail if it was. For that reason, it's a good practice to write test as close as possible to actual user experience. Here, we'd want to do something similar to this test - check for KModal presence and make sure that the right modal is displayed via checking its text. Before we merge, let's resolve this.

I realize this is a pattern that is present in other tests around this dialog. If you'd like to fix them too, that'd be welcome, but it's not required as it was pre-existing.

Copy link
Author

@yeshwanth235 yeshwanth235 Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will update

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @yeshwanth235, just mention me in the PR if you had any questions or as soon as all feedback is resolved.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MisRob
Sorry for the deplay. I was busy past few days.
updated the test case for showExportDataNotice.

Can you please elaborate more on other tests around this Dialog. I am not getting it

expect(wrapper.vm.$store.dispatch).toHaveBeenCalledWith('showSnackbar', { text: wrapper.vm.$tr('exportFailed') });
});
});