48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
|
|
// info-box
|
|
|
|
import { Page } from "playwright";
|
|
import forms from "../forms.ts";
|
|
import login from "../login.ts";
|
|
|
|
// span.info-box-title has-text /moduleName/
|
|
// span.fa-cog[title="Configuration"]
|
|
|
|
async function configureModule(
|
|
globalCtx: {
|
|
page: Page;
|
|
dolibarrAddress: string;
|
|
adminCredentials: { username: string; password: string };
|
|
},
|
|
{
|
|
moduleName,
|
|
enabled,
|
|
onConfiguration,
|
|
}: {
|
|
moduleName: string;
|
|
enabled: boolean;
|
|
onConfiguration?: CallableFunction;
|
|
}
|
|
): Promise<void> {
|
|
const {page, dolibarrAddress}= globalCtx;
|
|
await login.doAdminLogin(globalCtx);
|
|
|
|
await page.goto(`${dolibarrAddress}/admin/modules.php?mode=commonkanban`);
|
|
|
|
const moduleDiv = page.locator('.info-box', {
|
|
has: page.locator('.info-box-title',{
|
|
hasText: new RegExp('^'+moduleName+'\n?$','i')
|
|
})
|
|
});
|
|
|
|
await forms.toggleOnOff(moduleDiv, enabled);
|
|
if(enabled && onConfiguration!==undefined) {
|
|
await moduleDiv.locator(`span.fa-cog[title="Configuration"]`).click();
|
|
await onConfiguration();
|
|
}
|
|
}
|
|
|
|
export default {
|
|
configureModule,
|
|
}
|