Formatting and better type definitions
This commit is contained in:
parent
97d8837d0a
commit
f90318205e
|
|
@ -107,7 +107,9 @@ export class CurrentUser {
|
||||||
await axios
|
await axios
|
||||||
.get(config.get('url') + 'client')
|
.get(config.get('url') + 'client')
|
||||||
.then((resp: AxiosResponse<IClient[]>) => {
|
.then((resp: AxiosResponse<IClient[]>) => {
|
||||||
resp.data.filter((client) => client.token === this.tokenCache).forEach((client) => {
|
resp.data
|
||||||
|
.filter((client) => client.token === this.tokenCache)
|
||||||
|
.forEach((client) => {
|
||||||
return axios.delete(config.get('url') + 'client/' + client.id);
|
return axios.delete(config.get('url') + 'client/' + client.id);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ describe('Messages', () => {
|
||||||
it('has no applications', async () => {
|
it('has no applications', async () => {
|
||||||
expect(await count(page, `${naviId} .item`)).toBe(0);
|
expect(await count(page, `${naviId} .item`)).toBe(0);
|
||||||
});
|
});
|
||||||
describe('create apps', async () => {
|
describe('create apps', () => {
|
||||||
it('Windows', async () => {
|
it('Windows', async () => {
|
||||||
windowsServerToken = await createApp('Windows');
|
windowsServerToken = await createApp('Windows');
|
||||||
await page.reload();
|
await page.reload();
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ const hasReceivedMessage = async (title: RegExp, content: RegExp) => {
|
||||||
await waitForExists(page, selector.heading(), 'Plugins');
|
await waitForExists(page, selector.heading(), 'Plugins');
|
||||||
};
|
};
|
||||||
|
|
||||||
const inDetailPage = async (id: number, callback: (() => Promise<void>)) => {
|
const inDetailPage = async (id: number, callback: () => Promise<void>) => {
|
||||||
const name = await innerText(page, $table.cell(id, Col.Name));
|
const name = await innerText(page, $table.cell(id, Col.Name));
|
||||||
await page.click($table.cell(id, Col.Details));
|
await page.click($table.cell(id, Col.Details));
|
||||||
await waitForExists(page, '.plugin-info .name > span', name);
|
await waitForExists(page, '.plugin-info .name > span', name);
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ export const newTest = async (pluginsDir = ''): Promise<GotifyTest> => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const testPluginDir = (): {dir: string; generator: (() => string)} => {
|
const testPluginDir = (): {dir: string; generator: () => string} => {
|
||||||
const random = Math.random()
|
const random = Math.random()
|
||||||
.toString(36)
|
.toString(36)
|
||||||
.substring(2, 15);
|
.substring(2, 15);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import {ElementHandle, Page} from 'puppeteer';
|
import {ElementHandle, JSHandle, Page} from 'puppeteer';
|
||||||
|
|
||||||
export const innerText = async (page: ElementHandle | Page, selector: string): Promise<string> => {
|
export const innerText = async (page: ElementHandle | Page, selector: string): Promise<string> => {
|
||||||
const element = await page.$(selector);
|
const element = await page.$(selector);
|
||||||
|
|
@ -25,7 +25,7 @@ export const count = async (page: Page, selector: string): Promise<number> => {
|
||||||
return page.$$(selector).then((elements) => elements.length);
|
return page.$$(selector).then((elements) => elements.length);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const waitToDisappear = async (page: Page, selector: string): Promise<void> => {
|
export const waitToDisappear = async (page: Page, selector: string): Promise<JSHandle> => {
|
||||||
return page.waitForFunction(
|
return page.waitForFunction(
|
||||||
(_selector: string) => !document.querySelector(_selector),
|
(_selector: string) => !document.querySelector(_selector),
|
||||||
{},
|
{},
|
||||||
|
|
@ -33,7 +33,11 @@ export const waitToDisappear = async (page: Page, selector: string): Promise<voi
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const waitForCount = async (page: Page, selector: string, amount: number): Promise<void> => {
|
export const waitForCount = async (
|
||||||
|
page: Page,
|
||||||
|
selector: string,
|
||||||
|
amount: number
|
||||||
|
): Promise<JSHandle> => {
|
||||||
return page.waitForFunction(
|
return page.waitForFunction(
|
||||||
(_selector: string, _amount: number) =>
|
(_selector: string, _amount: number) =>
|
||||||
document.querySelectorAll(_selector).length === _amount,
|
document.querySelectorAll(_selector).length === _amount,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue