Skip to content

Commit

Permalink
Add test cases for the issue type list.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruens committed Oct 4, 2023
1 parent e6e2ba8 commit ecbc37f
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions src/www/views/contact_view/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<OutlineErrorReporter>;

Expand All @@ -30,7 +31,9 @@ describe('ContactView', () => {
'SentryErrorReporter',
Object.getOwnPropertyNames(SentryErrorReporter.prototype)
);
el = await fixture(html` <contact-view .localize=${localize} .errorReporter=${mockErrorReporter}></contact-view> `);
el = await fixture(
html` <contact-view .localize=${localize} variant="client" .errorReporter=${mockErrorReporter}></contact-view> `
);
});

it('is defined', async () => {
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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<OutlineErrorReporter> = jasmine.createSpyObj(
'SentryErrorReporter',
Object.getOwnPropertyNames(SentryErrorReporter.prototype)
);
const el = await fixture(
html` <contact-view .localize=${localize} variant="manager" .errorReporter=${mockErrorReporter}></contact-view> `
);

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']);
});
});

0 comments on commit ecbc37f

Please sign in to comment.