Commit 249acdda authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'improve-selection_summary-spec' into 'master'

Improve selection_summary_spec.js tests

See merge request gitlab-org/gitlab!44506
parents bbd469bd ea0f4c6e
......@@ -103,7 +103,7 @@ export default {
<template>
<div class="card">
<form class="card-body d-flex align-items-center" @submit.prevent="handleDismiss">
<span ref="dismiss-message">{{ message }}</span>
<span data-testid="dismiss-message">{{ message }}</span>
<gl-form-select
v-model="dismissalReason"
class="mx-3 w-auto"
......
---
title: Improve selection_summary_spec.js tests
merge_request: 44506
author: Kev @KevSlashNull
type: other
......@@ -23,7 +23,7 @@ describe('Selection Summary component', () => {
};
const dismissButton = () => wrapper.find(GlButton);
const dismissMessage = () => wrapper.find({ ref: 'dismiss-message' });
const dismissMessage = () => wrapper.find('[data-testid="dismiss-message"]');
const formSelect = () => wrapper.find(GlFormSelect);
const createComponent = ({ props = {}, data = defaultData, mocks = defaultMocks } = {}) => {
spyMutate = mocks.$apollo.mutate;
......@@ -62,14 +62,15 @@ describe('Selection Summary component', () => {
it('should have the button enabled if a vulnerability is selected and an option is selected', async () => {
expect(wrapper.vm.dismissalReason).toBe(null);
expect(wrapper.findAll('option')).toHaveLength(4);
formSelect()
const option = formSelect()
.findAll('option')
.at(1)
.setSelected();
.at(1);
option.setSelected();
formSelect().trigger('change');
await wrapper.vm.$nextTick();
expect(wrapper.vm.dismissalReason).toEqual(expect.any(String));
await wrapper.vm.$nextTick();
expect(wrapper.vm.dismissalReason).toEqual(option.attributes('value'));
expect(dismissButton().attributes('disabled')).toBe(undefined);
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment