Format
This commit is contained in:
parent
819a881557
commit
a2d44968e5
|
|
@ -23,13 +23,15 @@ export interface StoreMapping {
|
|||
export type AllStores = Extract<keyof StoreMapping, string>;
|
||||
export type Stores<T extends AllStores> = Pick<StoreMapping, T>;
|
||||
|
||||
export const inject =
|
||||
<I extends AllStores>(...stores: I[]) =>
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export const inject = <I extends AllStores>(...stores: I[]) => <P extends {}>(
|
||||
<P extends {}>(
|
||||
node: React.ComponentType<P>
|
||||
): React.ComponentType<Pick<P, Exclude<keyof P, I>>> =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
mobxInject(...stores)(node) as any;
|
||||
|
||||
export const InjectProvider: React.SFC<{stores: StoreMapping}> = ({children, stores}) => (
|
||||
export const InjectProvider: React.FC<{stores: StoreMapping}> = ({children, stores}) => (
|
||||
<Provider {...stores}>{children}</Provider>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -26,20 +26,17 @@ const hiddenToken = '•••••••••••••••';
|
|||
const $table = selector.table('#app-table');
|
||||
const $dialog = selector.form('#app-dialog');
|
||||
|
||||
const hasApp = (
|
||||
name: string,
|
||||
description: string,
|
||||
row: number
|
||||
): (() => Promise<void>) => async () => {
|
||||
const hasApp =
|
||||
(name: string, description: string, row: number): (() => Promise<void>) =>
|
||||
async () => {
|
||||
expect(await innerText(page, $table.cell(row, Col.Name))).toBe(name);
|
||||
expect(await innerText(page, $table.cell(row, Col.Token))).toBe(hiddenToken);
|
||||
expect(await innerText(page, $table.cell(row, Col.Description))).toBe(description);
|
||||
};
|
||||
|
||||
const updateApp = (
|
||||
id: number,
|
||||
data: {name?: string; description?: string}
|
||||
): (() => Promise<void>) => async () => {
|
||||
const updateApp =
|
||||
(id: number, data: {name?: string; description?: string}): (() => Promise<void>) =>
|
||||
async () => {
|
||||
await page.click($table.cell(id, Col.EditUpdate, '.edit'));
|
||||
await page.waitForSelector($dialog.selector());
|
||||
if (data.name) {
|
||||
|
|
@ -56,7 +53,9 @@ const updateApp = (
|
|||
await waitToDisappear(page, $dialog.selector());
|
||||
};
|
||||
|
||||
const createApp = (name: string, description: string): (() => Promise<void>) => async () => {
|
||||
const createApp =
|
||||
(name: string, description: string): (() => Promise<void>) =>
|
||||
async () => {
|
||||
await page.click('#create-app');
|
||||
await page.waitForSelector($dialog.selector());
|
||||
await page.type($dialog.input('.name'), name);
|
||||
|
|
|
|||
|
|
@ -21,11 +21,15 @@ enum Col {
|
|||
Delete = 4,
|
||||
}
|
||||
|
||||
const hasClient = (name: string, row: number): (() => Promise<void>) => async () => {
|
||||
const hasClient =
|
||||
(name: string, row: number): (() => Promise<void>) =>
|
||||
async () => {
|
||||
expect(await innerText(page, $table.cell(row, Col.Name))).toBe(name);
|
||||
};
|
||||
|
||||
const updateClient = (id: number, data: {name?: string}): (() => Promise<void>) => async () => {
|
||||
const updateClient =
|
||||
(id: number, data: {name?: string}): (() => Promise<void>) =>
|
||||
async () => {
|
||||
await page.click($table.cell(id, Col.Edit, '.edit'));
|
||||
await page.waitForSelector($dialog.selector());
|
||||
if (data.name) {
|
||||
|
|
@ -53,7 +57,9 @@ describe('Client', () => {
|
|||
expect(await count(page, $table.rows())).toBe(1);
|
||||
});
|
||||
describe('create clients', () => {
|
||||
const createClient = (name: string): (() => Promise<void>) => async () => {
|
||||
const createClient =
|
||||
(name: string): (() => Promise<void>) =>
|
||||
async () => {
|
||||
await page.click('#create-client');
|
||||
await page.waitForSelector($dialog.selector());
|
||||
await page.type($dialog.input('.name'), name);
|
||||
|
|
|
|||
|
|
@ -205,9 +205,9 @@ describe('Messages', () => {
|
|||
it('deletes a windows message', async () => {
|
||||
await navigate('Windows');
|
||||
await page.evaluate(() =>
|
||||
(document.querySelectorAll(
|
||||
'#messages .message .delete'
|
||||
)[1] as HTMLButtonElement).click()
|
||||
(
|
||||
document.querySelectorAll('#messages .message .delete')[1] as HTMLButtonElement
|
||||
).click()
|
||||
);
|
||||
await expectMessages({
|
||||
all: [linux2, windows3, backup1, linux1, windows1],
|
||||
|
|
|
|||
|
|
@ -35,11 +35,9 @@ describe('User', () => {
|
|||
expect(await count(page, $table.rows())).toBe(1);
|
||||
});
|
||||
describe('create users', () => {
|
||||
const createUser = (
|
||||
name: string,
|
||||
password: string,
|
||||
isAdmin: boolean
|
||||
): (() => Promise<void>) => async () => {
|
||||
const createUser =
|
||||
(name: string, password: string, isAdmin: boolean): (() => Promise<void>) =>
|
||||
async () => {
|
||||
await page.click('#create-user');
|
||||
await page.waitForSelector($dialog.selector());
|
||||
await page.type($dialog.input('.name'), name);
|
||||
|
|
@ -54,11 +52,9 @@ describe('User', () => {
|
|||
it('jmattheis', createUser('jmattheis', 'noice', true));
|
||||
it('dude', createUser('dude', '1', false));
|
||||
});
|
||||
const hasUser = (
|
||||
name: string,
|
||||
isAdmin: boolean,
|
||||
row: number
|
||||
): (() => Promise<void>) => async () => {
|
||||
const hasUser =
|
||||
(name: string, isAdmin: boolean, row: number): (() => Promise<void>) =>
|
||||
async () => {
|
||||
expect(await innerText(page, $table.cell(row, Col.Name))).toBe(name);
|
||||
expect(await innerText(page, $table.cell(row, Col.Admin))).toBe(isAdmin ? 'Yes' : 'No');
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue