From ecbc37fc2bd68856608106b43c0a11fbd52d5e37 Mon Sep 17 00:00:00 2001 From: Sander Bruens Date: Mon, 2 Oct 2023 15:49:25 -0400 Subject: [PATCH] Add test cases for the issue type list. --- src/www/views/contact_view/index.spec.ts | 36 +++++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/www/views/contact_view/index.spec.ts b/src/www/views/contact_view/index.spec.ts index b9a2c777c36..d5efbd71d23 100644 --- a/src/www/views/contact_view/index.spec.ts +++ b/src/www/views/contact_view/index.spec.ts @@ -20,8 +20,9 @@ import {fixture, html, nextFrame, oneEvent} from '@open-wc/testing'; import {SupportForm} from './support_form'; import {OutlineErrorReporter, SentryErrorReporter} from '../../shared/error_reporter'; import {localize} from '../../testing/localize'; +import {ListItem} from '@material/mwc-list'; -describe('ContactView', () => { +describe('ContactView client variant', () => { let el: ContactView; let mockErrorReporter: jasmine.SpyObj; @@ -30,7 +31,9 @@ describe('ContactView', () => { 'SentryErrorReporter', Object.getOwnPropertyNames(SentryErrorReporter.prototype) ); - el = await fixture(html` `); + el = await fixture( + html` ` + ); }); it('is defined', async () => { @@ -61,8 +64,11 @@ describe('ContactView', () => { radioButton.click(); await nextFrame(); - const issueSelector = el.shadowRoot!.querySelector('mwc-select'); - expect(issueSelector?.hasAttribute('hidden')).toBeFalse(); + const issueSelector = el.shadowRoot!.querySelector('mwc-select')!; + expect(issueSelector.hasAttribute('hidden')).toBeFalse(); + const issueItemEls = issueSelector.querySelectorAll('mwc-list-item'); + const issueTypes = Array.from(issueItemEls).map((el: ListItem) => el.value); + expect(issueTypes).toEqual(['no-server', 'cannot-add-server', 'connection', 'performance', 'general']); }); describe('when the user selects issue', () => { @@ -150,3 +156,25 @@ describe('ContactView', () => { }); }); }); + +describe('ContactView manager variant', () => { + it('shows issue selector if the user selects that they have no open tickets', async () => { + const mockErrorReporter: jasmine.SpyObj = jasmine.createSpyObj( + 'SentryErrorReporter', + Object.getOwnPropertyNames(SentryErrorReporter.prototype) + ); + const el = await fixture( + html` ` + ); + + const radioButton = el.shadowRoot!.querySelectorAll('mwc-formfield mwc-radio')[1] as HTMLElement; + radioButton.click(); + await nextFrame(); + + const issueSelector = el.shadowRoot!.querySelector('mwc-select')!; + expect(issueSelector.hasAttribute('hidden')).toBeFalse(); + const issueItemEls = issueSelector.querySelectorAll('mwc-list-item'); + const issueTypes = Array.from(issueItemEls).map((el: ListItem) => el.value); + expect(issueTypes).toEqual(['cannot-add-server', 'connection', 'managing', 'general']); + }); +});