Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Dec 27, 2024
1 parent 2c59ed5 commit 7304fdc
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 21 deletions.
5 changes: 4 additions & 1 deletion client/src/www/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ function getRootEl() {
return document.querySelector('app-root') as {} as polymer.Base;
}

async function createServerRepo(platform: OutlinePlatform, eventQueue: EventQueue): Promise<ServerRepository> {
async function createServerRepo(
platform: OutlinePlatform,
eventQueue: EventQueue
): Promise<ServerRepository> {
const localize = getLocalizationFunction();
const vpnApi = platform.getVpnApi();
if (vpnApi) {
Expand Down
10 changes: 8 additions & 2 deletions client/src/www/app/outline_server_repository/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ export type ServiceConfig = StaticServiceConfig | DynamicServiceConfig;
* It's the structured representation of a Static Access Key.
*/
export class StaticServiceConfig {
constructor(readonly name: string, readonly tunnelConfig: TunnelConfigJson) {}
constructor(
readonly name: string,
readonly tunnelConfig: TunnelConfigJson
) {}
}

/**
* DynamicServiceConfig is a ServiceConfig that has the location to fetch the tunnel config.
* It's the structured representation of a Dynamic Access Key.
*/
export class DynamicServiceConfig {
constructor(readonly name: string, readonly transportConfigLocation: URL) {}
constructor(
readonly name: string,
readonly transportConfigLocation: URL
) {}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion client/src/www/app/outline_server_repository/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,4 @@ async function loadServersV1(storage: Storage, repo: OutlineServerRepository) {
console.error(e);
}
}
}
}
70 changes: 53 additions & 17 deletions client/src/www/views/contact_view/support_form/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@

import {TextField} from '@material/mwc-textfield';

import {fixture, html, nextFrame, oneEvent, triggerBlurFor, triggerFocusFor} from '@open-wc/testing';
import {
fixture,
html,
nextFrame,
oneEvent,
triggerBlurFor,
triggerFocusFor,
} from '@open-wc/testing';

import {FormValues, SupportForm} from './index';


async function setValue(el: TextField, value: string) {
await triggerFocusFor(el);
el.value = value;
Expand All @@ -42,21 +48,35 @@ describe('SupportForm', () => {
description: 'Test Description',
outreachConsent: false,
};
const el = await fixture(html` <support-form .values=${values}></support-form> `);
const el = await fixture(html`
<support-form .values=${values}></support-form>
`);

const emailInput: TextField = el.shadowRoot!.querySelector('mwc-textfield[name="email"')!;
const emailInput: TextField = el.shadowRoot!.querySelector(
'mwc-textfield[name="email"'
)!;
expect(emailInput.value).toBe('foo@bar.com');
const accessKeySourceInput: TextField = el.shadowRoot!.querySelector('mwc-textfield[name="accessKeySource"')!;
const accessKeySourceInput: TextField = el.shadowRoot!.querySelector(
'mwc-textfield[name="accessKeySource"'
)!;
expect(accessKeySourceInput.value).toBe('a friend');
const subjectInput: TextField = el.shadowRoot!.querySelector('mwc-textfield[name="subject"')!;
const subjectInput: TextField = el.shadowRoot!.querySelector(
'mwc-textfield[name="subject"'
)!;
expect(subjectInput.value).toBe('Test Subject');
const descriptionInput: TextField = el.shadowRoot!.querySelector('mwc-textarea[name="description"')!;
const descriptionInput: TextField = el.shadowRoot!.querySelector(
'mwc-textarea[name="description"'
)!;
expect(descriptionInput.value).toBe('Test Description');
});

it('updating the `values` property updates the form', async () => {
const el: SupportForm = await fixture(html` <support-form></support-form> `);
const emailInput: TextField = el.shadowRoot!.querySelector('mwc-textfield[name="email"')!;
const el: SupportForm = await fixture(html`
<support-form></support-form>
`);
const emailInput: TextField = el.shadowRoot!.querySelector(
'mwc-textfield[name="email"'
)!;
await setValue(emailInput, 'foo@bar.com');

el.values = {};
Expand All @@ -67,7 +87,9 @@ describe('SupportForm', () => {

it('submit button is disabled by default', async () => {
const el = await fixture(html` <support-form></support-form> `);
const submitButton = el.shadowRoot!.querySelectorAll('mwc-button')[1] as HTMLElement;
const submitButton = el.shadowRoot!.querySelectorAll(
'mwc-button'
)[1] as HTMLElement;
expect(submitButton.hasAttribute('disabled')).toBeTrue();
});

Expand All @@ -78,16 +100,26 @@ describe('SupportForm', () => {
beforeEach(async () => {
el = await fixture(html` <support-form></support-form> `);

const emailInput: TextField = el.shadowRoot!.querySelector('mwc-textfield[name="email"')!;
const emailInput: TextField = el.shadowRoot!.querySelector(
'mwc-textfield[name="email"'
)!;
await setValue(emailInput, 'foo@bar.com');
const accessKeySourceInput: TextField = el.shadowRoot!.querySelector('mwc-textfield[name="accessKeySource"')!;
const accessKeySourceInput: TextField = el.shadowRoot!.querySelector(
'mwc-textfield[name="accessKeySource"'
)!;
await setValue(accessKeySourceInput, 'From a friend');
const subjectInput: TextField = el.shadowRoot!.querySelector('mwc-textfield[name="subject"')!;
const subjectInput: TextField = el.shadowRoot!.querySelector(
'mwc-textfield[name="subject"'
)!;
await setValue(subjectInput, 'Test Subject');
const descriptionInput: TextField = el.shadowRoot!.querySelector('mwc-textarea[name="description"')!;
const descriptionInput: TextField = el.shadowRoot!.querySelector(
'mwc-textarea[name="description"'
)!;
await setValue(descriptionInput, 'Test Description');

submitButton = el.shadowRoot!.querySelectorAll('mwc-button')[1] as HTMLElement;
submitButton = el.shadowRoot!.querySelectorAll(
'mwc-button'
)[1] as HTMLElement;
});

it('submit button is enabled', async () => {
Expand All @@ -105,10 +137,14 @@ describe('SupportForm', () => {
});

it('emits form cancel event', async () => {
const el: SupportForm = await fixture(html` <support-form></support-form> `);
const el: SupportForm = await fixture(html`
<support-form></support-form>
`);
const listener = oneEvent(el, 'cancel');

const cancelButton = el.shadowRoot!.querySelectorAll('mwc-button')[0] as HTMLElement;
const cancelButton = el.shadowRoot!.querySelectorAll(
'mwc-button'
)[0] as HTMLElement;
cancelButton.click();

const {detail} = await listener;
Expand Down

0 comments on commit 7304fdc

Please sign in to comment.