Best JavaScript code snippet using stryker-parent
check_privileges.test.ts
Source:check_privileges.test.ts
1/*2 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one3 * or more contributor license agreements. Licensed under the Elastic License;4 * you may not use this file except in compliance with the Elastic License.5 */6import { callWithRequestProvider } from './__mocks__/call_with_request';7import { privilegesProvider } from './check_privileges';8import { mlPrivileges } from './privileges';9const xpackMainPluginWithSecurity = {10 info: {11 isAvailable: () => true,12 feature: (f: string) => {13 switch (f) {14 case 'ml':15 return { isEnabled: () => true };16 case 'security':17 return { isEnabled: () => true };18 }19 },20 license: {21 isOneOf: () => true,22 isActive: () => true,23 getType: () => 'platinum',24 },25 },26} as any;27const xpackMainPluginWithOutSecurity = {28 info: {29 isAvailable: () => true,30 feature: (f: string) => {31 switch (f) {32 case 'ml':33 return { isEnabled: () => true };34 case 'security':35 return { isEnabled: () => false };36 }37 },38 license: {39 isOneOf: () => true,40 isActive: () => true,41 getType: () => 'platinum',42 },43 },44} as any;45const xpackMainPluginWithOutSecurityBasicLicense = {46 info: {47 isAvailable: () => true,48 feature: (f: string) => {49 switch (f) {50 case 'ml':51 return { isEnabled: () => true };52 case 'security':53 return { isEnabled: () => false };54 }55 },56 license: {57 isOneOf: () => false,58 isActive: () => true,59 getType: () => 'basic',60 },61 },62} as any;63const xpackMainPluginWithSecurityBasicLicense = {64 info: {65 isAvailable: () => true,66 feature: (f: string) => {67 switch (f) {68 case 'ml':69 return { isEnabled: () => true };70 case 'security':71 return { isEnabled: () => true };72 }73 },74 license: {75 isOneOf: () => false,76 isActive: () => true,77 getType: () => 'basic',78 },79 },80} as any;81const mlIsEnabled = async () => true;82const mlIsNotEnabled = async () => false;83describe('check_privileges', () => {84 describe('getPrivileges() - right number of capabilities', () => {85 test('es capabilities count', async done => {86 const count = mlPrivileges.cluster.length;87 expect(count).toBe(35);88 done();89 });90 test('kibana capabilities count', async done => {91 const callWithRequest = callWithRequestProvider('partialPrivileges');92 const { getPrivileges } = privilegesProvider(93 callWithRequest,94 xpackMainPluginWithSecurity,95 mlIsEnabled96 );97 const { capabilities } = await getPrivileges();98 const count = Object.keys(capabilities).length;99 expect(count).toBe(23);100 done();101 });102 });103 describe('getPrivileges() with security', () => {104 test('ml_user capabilities only', async done => {105 const callWithRequest = callWithRequestProvider('partialPrivileges');106 const { getPrivileges } = privilegesProvider(107 callWithRequest,108 xpackMainPluginWithSecurity,109 mlIsEnabled110 );111 const { capabilities, upgradeInProgress, mlFeatureEnabledInSpace } = await getPrivileges();112 expect(upgradeInProgress).toBe(false);113 expect(mlFeatureEnabledInSpace).toBe(true);114 expect(capabilities.canGetJobs).toBe(true);115 expect(capabilities.canCreateJob).toBe(false);116 expect(capabilities.canDeleteJob).toBe(false);117 expect(capabilities.canOpenJob).toBe(false);118 expect(capabilities.canCloseJob).toBe(false);119 expect(capabilities.canForecastJob).toBe(false);120 expect(capabilities.canGetDatafeeds).toBe(true);121 expect(capabilities.canStartStopDatafeed).toBe(false);122 expect(capabilities.canUpdateJob).toBe(false);123 expect(capabilities.canUpdateDatafeed).toBe(false);124 expect(capabilities.canPreviewDatafeed).toBe(false);125 expect(capabilities.canGetCalendars).toBe(true);126 expect(capabilities.canCreateCalendar).toBe(false);127 expect(capabilities.canDeleteCalendar).toBe(false);128 expect(capabilities.canGetFilters).toBe(false);129 expect(capabilities.canCreateFilter).toBe(false);130 expect(capabilities.canDeleteFilter).toBe(false);131 expect(capabilities.canFindFileStructure).toBe(true);132 expect(capabilities.canGetDataFrame).toBe(false);133 expect(capabilities.canDeleteDataFrame).toBe(false);134 expect(capabilities.canPreviewDataFrame).toBe(false);135 expect(capabilities.canCreateDataFrame).toBe(false);136 expect(capabilities.canStartStopDataFrame).toBe(false);137 done();138 });139 test('full capabilities', async done => {140 const callWithRequest = callWithRequestProvider('fullPrivileges');141 const { getPrivileges } = privilegesProvider(142 callWithRequest,143 xpackMainPluginWithSecurity,144 mlIsEnabled145 );146 const { capabilities, upgradeInProgress, mlFeatureEnabledInSpace } = await getPrivileges();147 expect(upgradeInProgress).toBe(false);148 expect(mlFeatureEnabledInSpace).toBe(true);149 expect(capabilities.canGetJobs).toBe(true);150 expect(capabilities.canCreateJob).toBe(true);151 expect(capabilities.canDeleteJob).toBe(true);152 expect(capabilities.canOpenJob).toBe(true);153 expect(capabilities.canCloseJob).toBe(true);154 expect(capabilities.canForecastJob).toBe(true);155 expect(capabilities.canGetDatafeeds).toBe(true);156 expect(capabilities.canStartStopDatafeed).toBe(true);157 expect(capabilities.canUpdateJob).toBe(true);158 expect(capabilities.canUpdateDatafeed).toBe(true);159 expect(capabilities.canPreviewDatafeed).toBe(true);160 expect(capabilities.canGetCalendars).toBe(true);161 expect(capabilities.canCreateCalendar).toBe(true);162 expect(capabilities.canDeleteCalendar).toBe(true);163 expect(capabilities.canGetFilters).toBe(true);164 expect(capabilities.canCreateFilter).toBe(true);165 expect(capabilities.canDeleteFilter).toBe(true);166 expect(capabilities.canFindFileStructure).toBe(true);167 expect(capabilities.canGetDataFrame).toBe(true);168 expect(capabilities.canDeleteDataFrame).toBe(true);169 expect(capabilities.canPreviewDataFrame).toBe(true);170 expect(capabilities.canCreateDataFrame).toBe(true);171 expect(capabilities.canStartStopDataFrame).toBe(true);172 done();173 });174 test('upgrade in progress with full capabilities', async done => {175 const callWithRequest = callWithRequestProvider('upgradeWithFullPrivileges');176 const { getPrivileges } = privilegesProvider(177 callWithRequest,178 xpackMainPluginWithSecurity,179 mlIsEnabled180 );181 const { capabilities, upgradeInProgress, mlFeatureEnabledInSpace } = await getPrivileges();182 expect(upgradeInProgress).toBe(true);183 expect(mlFeatureEnabledInSpace).toBe(true);184 expect(capabilities.canGetJobs).toBe(true);185 expect(capabilities.canCreateJob).toBe(false);186 expect(capabilities.canDeleteJob).toBe(false);187 expect(capabilities.canOpenJob).toBe(false);188 expect(capabilities.canCloseJob).toBe(false);189 expect(capabilities.canForecastJob).toBe(false);190 expect(capabilities.canGetDatafeeds).toBe(true);191 expect(capabilities.canStartStopDatafeed).toBe(false);192 expect(capabilities.canUpdateJob).toBe(false);193 expect(capabilities.canUpdateDatafeed).toBe(false);194 expect(capabilities.canPreviewDatafeed).toBe(false);195 expect(capabilities.canGetCalendars).toBe(true);196 expect(capabilities.canCreateCalendar).toBe(false);197 expect(capabilities.canDeleteCalendar).toBe(false);198 expect(capabilities.canGetFilters).toBe(true);199 expect(capabilities.canCreateFilter).toBe(false);200 expect(capabilities.canDeleteFilter).toBe(false);201 expect(capabilities.canFindFileStructure).toBe(true);202 expect(capabilities.canGetDataFrame).toBe(true);203 expect(capabilities.canDeleteDataFrame).toBe(false);204 expect(capabilities.canPreviewDataFrame).toBe(false);205 expect(capabilities.canCreateDataFrame).toBe(false);206 expect(capabilities.canStartStopDataFrame).toBe(false);207 done();208 });209 test('upgrade in progress with partial capabilities', async done => {210 const callWithRequest = callWithRequestProvider('upgradeWithPartialPrivileges');211 const { getPrivileges } = privilegesProvider(212 callWithRequest,213 xpackMainPluginWithSecurity,214 mlIsEnabled215 );216 const { capabilities, upgradeInProgress, mlFeatureEnabledInSpace } = await getPrivileges();217 expect(upgradeInProgress).toBe(true);218 expect(mlFeatureEnabledInSpace).toBe(true);219 expect(capabilities.canGetJobs).toBe(true);220 expect(capabilities.canCreateJob).toBe(false);221 expect(capabilities.canDeleteJob).toBe(false);222 expect(capabilities.canOpenJob).toBe(false);223 expect(capabilities.canCloseJob).toBe(false);224 expect(capabilities.canForecastJob).toBe(false);225 expect(capabilities.canGetDatafeeds).toBe(true);226 expect(capabilities.canStartStopDatafeed).toBe(false);227 expect(capabilities.canUpdateJob).toBe(false);228 expect(capabilities.canUpdateDatafeed).toBe(false);229 expect(capabilities.canPreviewDatafeed).toBe(false);230 expect(capabilities.canGetCalendars).toBe(true);231 expect(capabilities.canCreateCalendar).toBe(false);232 expect(capabilities.canDeleteCalendar).toBe(false);233 expect(capabilities.canGetFilters).toBe(false);234 expect(capabilities.canCreateFilter).toBe(false);235 expect(capabilities.canDeleteFilter).toBe(false);236 expect(capabilities.canFindFileStructure).toBe(true);237 expect(capabilities.canGetDataFrame).toBe(false);238 expect(capabilities.canDeleteDataFrame).toBe(false);239 expect(capabilities.canPreviewDataFrame).toBe(false);240 expect(capabilities.canCreateDataFrame).toBe(false);241 expect(capabilities.canStartStopDataFrame).toBe(false);242 done();243 });244 test('ml_user capabilities with security with basic license', async done => {245 const callWithRequest = callWithRequestProvider('partialPrivileges');246 const { getPrivileges } = privilegesProvider(247 callWithRequest,248 xpackMainPluginWithSecurityBasicLicense,249 mlIsEnabled250 );251 const { capabilities, upgradeInProgress, mlFeatureEnabledInSpace } = await getPrivileges();252 expect(upgradeInProgress).toBe(false);253 expect(mlFeatureEnabledInSpace).toBe(true);254 expect(capabilities.canGetJobs).toBe(false);255 expect(capabilities.canCreateJob).toBe(false);256 expect(capabilities.canDeleteJob).toBe(false);257 expect(capabilities.canOpenJob).toBe(false);258 expect(capabilities.canCloseJob).toBe(false);259 expect(capabilities.canForecastJob).toBe(false);260 expect(capabilities.canGetDatafeeds).toBe(false);261 expect(capabilities.canStartStopDatafeed).toBe(false);262 expect(capabilities.canUpdateJob).toBe(false);263 expect(capabilities.canUpdateDatafeed).toBe(false);264 expect(capabilities.canPreviewDatafeed).toBe(false);265 expect(capabilities.canGetCalendars).toBe(false);266 expect(capabilities.canCreateCalendar).toBe(false);267 expect(capabilities.canDeleteCalendar).toBe(false);268 expect(capabilities.canGetFilters).toBe(false);269 expect(capabilities.canCreateFilter).toBe(false);270 expect(capabilities.canDeleteFilter).toBe(false);271 expect(capabilities.canFindFileStructure).toBe(true);272 expect(capabilities.canGetDataFrame).toBe(false);273 expect(capabilities.canDeleteDataFrame).toBe(false);274 expect(capabilities.canPreviewDataFrame).toBe(false);275 expect(capabilities.canCreateDataFrame).toBe(false);276 expect(capabilities.canStartStopDataFrame).toBe(false);277 done();278 });279 test('full user with security with basic license', async done => {280 const callWithRequest = callWithRequestProvider('fullPrivileges');281 const { getPrivileges } = privilegesProvider(282 callWithRequest,283 xpackMainPluginWithSecurityBasicLicense,284 mlIsEnabled285 );286 const { capabilities, upgradeInProgress, mlFeatureEnabledInSpace } = await getPrivileges();287 expect(upgradeInProgress).toBe(false);288 expect(mlFeatureEnabledInSpace).toBe(true);289 expect(capabilities.canGetJobs).toBe(false);290 expect(capabilities.canCreateJob).toBe(false);291 expect(capabilities.canDeleteJob).toBe(false);292 expect(capabilities.canOpenJob).toBe(false);293 expect(capabilities.canCloseJob).toBe(false);294 expect(capabilities.canForecastJob).toBe(false);295 expect(capabilities.canGetDatafeeds).toBe(false);296 expect(capabilities.canStartStopDatafeed).toBe(false);297 expect(capabilities.canUpdateJob).toBe(false);298 expect(capabilities.canUpdateDatafeed).toBe(false);299 expect(capabilities.canPreviewDatafeed).toBe(false);300 expect(capabilities.canGetCalendars).toBe(false);301 expect(capabilities.canCreateCalendar).toBe(false);302 expect(capabilities.canDeleteCalendar).toBe(false);303 expect(capabilities.canGetFilters).toBe(false);304 expect(capabilities.canCreateFilter).toBe(false);305 expect(capabilities.canDeleteFilter).toBe(false);306 expect(capabilities.canFindFileStructure).toBe(true);307 expect(capabilities.canGetDataFrame).toBe(true);308 expect(capabilities.canDeleteDataFrame).toBe(true);309 expect(capabilities.canPreviewDataFrame).toBe(true);310 expect(capabilities.canCreateDataFrame).toBe(true);311 expect(capabilities.canStartStopDataFrame).toBe(true);312 done();313 });314 test('full capabilities, ml disabled in space', async done => {315 const callWithRequest = callWithRequestProvider('fullPrivileges');316 const { getPrivileges } = privilegesProvider(317 callWithRequest,318 xpackMainPluginWithSecurity,319 mlIsNotEnabled320 );321 const { capabilities, upgradeInProgress, mlFeatureEnabledInSpace } = await getPrivileges();322 expect(upgradeInProgress).toBe(false);323 expect(mlFeatureEnabledInSpace).toBe(false);324 expect(capabilities.canGetJobs).toBe(false);325 expect(capabilities.canCreateJob).toBe(false);326 expect(capabilities.canDeleteJob).toBe(false);327 expect(capabilities.canOpenJob).toBe(false);328 expect(capabilities.canCloseJob).toBe(false);329 expect(capabilities.canForecastJob).toBe(false);330 expect(capabilities.canGetDatafeeds).toBe(false);331 expect(capabilities.canStartStopDatafeed).toBe(false);332 expect(capabilities.canUpdateJob).toBe(false);333 expect(capabilities.canUpdateDatafeed).toBe(false);334 expect(capabilities.canPreviewDatafeed).toBe(false);335 expect(capabilities.canGetCalendars).toBe(false);336 expect(capabilities.canCreateCalendar).toBe(false);337 expect(capabilities.canDeleteCalendar).toBe(false);338 expect(capabilities.canGetFilters).toBe(false);339 expect(capabilities.canCreateFilter).toBe(false);340 expect(capabilities.canDeleteFilter).toBe(false);341 expect(capabilities.canFindFileStructure).toBe(false);342 expect(capabilities.canGetDataFrame).toBe(false);343 expect(capabilities.canDeleteDataFrame).toBe(false);344 expect(capabilities.canPreviewDataFrame).toBe(false);345 expect(capabilities.canCreateDataFrame).toBe(false);346 expect(capabilities.canStartStopDataFrame).toBe(false);347 done();348 });349 });350 describe('getPrivileges() without security', () => {351 test('ml_user capabilities only', async done => {352 const callWithRequest = callWithRequestProvider('partialPrivileges');353 const { getPrivileges } = privilegesProvider(354 callWithRequest,355 xpackMainPluginWithOutSecurity,356 mlIsEnabled357 );358 const { capabilities, upgradeInProgress, mlFeatureEnabledInSpace } = await getPrivileges();359 expect(upgradeInProgress).toBe(false);360 expect(mlFeatureEnabledInSpace).toBe(true);361 expect(capabilities.canGetJobs).toBe(true);362 expect(capabilities.canCreateJob).toBe(true);363 expect(capabilities.canDeleteJob).toBe(true);364 expect(capabilities.canOpenJob).toBe(true);365 expect(capabilities.canCloseJob).toBe(true);366 expect(capabilities.canForecastJob).toBe(true);367 expect(capabilities.canGetDatafeeds).toBe(true);368 expect(capabilities.canStartStopDatafeed).toBe(true);369 expect(capabilities.canUpdateJob).toBe(true);370 expect(capabilities.canUpdateDatafeed).toBe(true);371 expect(capabilities.canPreviewDatafeed).toBe(true);372 expect(capabilities.canGetCalendars).toBe(true);373 expect(capabilities.canCreateCalendar).toBe(true);374 expect(capabilities.canDeleteCalendar).toBe(true);375 expect(capabilities.canGetFilters).toBe(true);376 expect(capabilities.canCreateFilter).toBe(true);377 expect(capabilities.canDeleteFilter).toBe(true);378 expect(capabilities.canFindFileStructure).toBe(true);379 expect(capabilities.canGetDataFrame).toBe(true);380 expect(capabilities.canDeleteDataFrame).toBe(true);381 expect(capabilities.canPreviewDataFrame).toBe(true);382 expect(capabilities.canCreateDataFrame).toBe(true);383 expect(capabilities.canStartStopDataFrame).toBe(true);384 done();385 });386 test('upgrade in progress with full capabilities', async done => {387 const callWithRequest = callWithRequestProvider('upgradeWithFullPrivileges');388 const { getPrivileges } = privilegesProvider(389 callWithRequest,390 xpackMainPluginWithOutSecurity,391 mlIsEnabled392 );393 const { capabilities, upgradeInProgress, mlFeatureEnabledInSpace } = await getPrivileges();394 expect(upgradeInProgress).toBe(true);395 expect(mlFeatureEnabledInSpace).toBe(true);396 expect(capabilities.canGetJobs).toBe(true);397 expect(capabilities.canCreateJob).toBe(false);398 expect(capabilities.canDeleteJob).toBe(false);399 expect(capabilities.canOpenJob).toBe(false);400 expect(capabilities.canCloseJob).toBe(false);401 expect(capabilities.canForecastJob).toBe(false);402 expect(capabilities.canGetDatafeeds).toBe(true);403 expect(capabilities.canStartStopDatafeed).toBe(false);404 expect(capabilities.canUpdateJob).toBe(false);405 expect(capabilities.canUpdateDatafeed).toBe(false);406 expect(capabilities.canPreviewDatafeed).toBe(false);407 expect(capabilities.canGetCalendars).toBe(true);408 expect(capabilities.canCreateCalendar).toBe(false);409 expect(capabilities.canDeleteCalendar).toBe(false);410 expect(capabilities.canGetFilters).toBe(true);411 expect(capabilities.canCreateFilter).toBe(false);412 expect(capabilities.canDeleteFilter).toBe(false);413 expect(capabilities.canFindFileStructure).toBe(true);414 expect(capabilities.canGetDataFrame).toBe(true);415 expect(capabilities.canDeleteDataFrame).toBe(false);416 expect(capabilities.canPreviewDataFrame).toBe(false);417 expect(capabilities.canCreateDataFrame).toBe(false);418 expect(capabilities.canStartStopDataFrame).toBe(false);419 done();420 });421 test('upgrade in progress with partial capabilities', async done => {422 const callWithRequest = callWithRequestProvider('upgradeWithPartialPrivileges');423 const { getPrivileges } = privilegesProvider(424 callWithRequest,425 xpackMainPluginWithOutSecurity,426 mlIsEnabled427 );428 const { capabilities, upgradeInProgress, mlFeatureEnabledInSpace } = await getPrivileges();429 expect(upgradeInProgress).toBe(true);430 expect(mlFeatureEnabledInSpace).toBe(true);431 expect(capabilities.canGetJobs).toBe(true);432 expect(capabilities.canCreateJob).toBe(false);433 expect(capabilities.canDeleteJob).toBe(false);434 expect(capabilities.canOpenJob).toBe(false);435 expect(capabilities.canCloseJob).toBe(false);436 expect(capabilities.canForecastJob).toBe(false);437 expect(capabilities.canGetDatafeeds).toBe(true);438 expect(capabilities.canStartStopDatafeed).toBe(false);439 expect(capabilities.canUpdateJob).toBe(false);440 expect(capabilities.canUpdateDatafeed).toBe(false);441 expect(capabilities.canPreviewDatafeed).toBe(false);442 expect(capabilities.canGetCalendars).toBe(true);443 expect(capabilities.canCreateCalendar).toBe(false);444 expect(capabilities.canDeleteCalendar).toBe(false);445 expect(capabilities.canGetFilters).toBe(true);446 expect(capabilities.canCreateFilter).toBe(false);447 expect(capabilities.canDeleteFilter).toBe(false);448 expect(capabilities.canFindFileStructure).toBe(true);449 expect(capabilities.canGetDataFrame).toBe(true);450 expect(capabilities.canDeleteDataFrame).toBe(false);451 expect(capabilities.canPreviewDataFrame).toBe(false);452 expect(capabilities.canCreateDataFrame).toBe(false);453 expect(capabilities.canStartStopDataFrame).toBe(false);454 done();455 });456 test('ml_user capabilities without security with basic license', async done => {457 const callWithRequest = callWithRequestProvider('partialPrivileges');458 const { getPrivileges } = privilegesProvider(459 callWithRequest,460 xpackMainPluginWithOutSecurityBasicLicense,461 mlIsEnabled462 );463 const { capabilities, upgradeInProgress, mlFeatureEnabledInSpace } = await getPrivileges();464 expect(upgradeInProgress).toBe(false);465 expect(mlFeatureEnabledInSpace).toBe(true);466 expect(capabilities.canGetJobs).toBe(false);467 expect(capabilities.canCreateJob).toBe(false);468 expect(capabilities.canDeleteJob).toBe(false);469 expect(capabilities.canOpenJob).toBe(false);470 expect(capabilities.canCloseJob).toBe(false);471 expect(capabilities.canForecastJob).toBe(false);472 expect(capabilities.canGetDatafeeds).toBe(false);473 expect(capabilities.canStartStopDatafeed).toBe(false);474 expect(capabilities.canUpdateJob).toBe(false);475 expect(capabilities.canUpdateDatafeed).toBe(false);476 expect(capabilities.canPreviewDatafeed).toBe(false);477 expect(capabilities.canGetCalendars).toBe(false);478 expect(capabilities.canCreateCalendar).toBe(false);479 expect(capabilities.canDeleteCalendar).toBe(false);480 expect(capabilities.canGetFilters).toBe(false);481 expect(capabilities.canCreateFilter).toBe(false);482 expect(capabilities.canDeleteFilter).toBe(false);483 expect(capabilities.canFindFileStructure).toBe(true);484 expect(capabilities.canGetDataFrame).toBe(true);485 expect(capabilities.canDeleteDataFrame).toBe(true);486 expect(capabilities.canPreviewDataFrame).toBe(true);487 expect(capabilities.canCreateDataFrame).toBe(true);488 expect(capabilities.canStartStopDataFrame).toBe(true);489 done();490 });491 test('full user without security with basic license', async done => {492 const callWithRequest = callWithRequestProvider('fullPrivileges');493 const { getPrivileges } = privilegesProvider(494 callWithRequest,495 xpackMainPluginWithOutSecurityBasicLicense,496 mlIsEnabled497 );498 const { capabilities, upgradeInProgress, mlFeatureEnabledInSpace } = await getPrivileges();499 expect(upgradeInProgress).toBe(false);500 expect(mlFeatureEnabledInSpace).toBe(true);501 expect(capabilities.canGetJobs).toBe(false);502 expect(capabilities.canCreateJob).toBe(false);503 expect(capabilities.canDeleteJob).toBe(false);504 expect(capabilities.canOpenJob).toBe(false);505 expect(capabilities.canCloseJob).toBe(false);506 expect(capabilities.canForecastJob).toBe(false);507 expect(capabilities.canGetDatafeeds).toBe(false);508 expect(capabilities.canStartStopDatafeed).toBe(false);509 expect(capabilities.canUpdateJob).toBe(false);510 expect(capabilities.canUpdateDatafeed).toBe(false);511 expect(capabilities.canPreviewDatafeed).toBe(false);512 expect(capabilities.canGetCalendars).toBe(false);513 expect(capabilities.canCreateCalendar).toBe(false);514 expect(capabilities.canDeleteCalendar).toBe(false);515 expect(capabilities.canGetFilters).toBe(false);516 expect(capabilities.canCreateFilter).toBe(false);517 expect(capabilities.canDeleteFilter).toBe(false);518 expect(capabilities.canFindFileStructure).toBe(true);519 expect(capabilities.canGetDataFrame).toBe(true);520 expect(capabilities.canDeleteDataFrame).toBe(true);521 expect(capabilities.canPreviewDataFrame).toBe(true);522 expect(capabilities.canCreateDataFrame).toBe(true);523 expect(capabilities.canStartStopDataFrame).toBe(true);524 done();525 });526 test('ml_user capabilities only, ml disabled in space', async done => {527 const callWithRequest = callWithRequestProvider('partialPrivileges');528 const { getPrivileges } = privilegesProvider(529 callWithRequest,530 xpackMainPluginWithOutSecurity,531 mlIsNotEnabled532 );533 const { capabilities, upgradeInProgress, mlFeatureEnabledInSpace } = await getPrivileges();534 expect(upgradeInProgress).toBe(false);535 expect(mlFeatureEnabledInSpace).toBe(false);536 expect(capabilities.canGetJobs).toBe(false);537 expect(capabilities.canCreateJob).toBe(false);538 expect(capabilities.canDeleteJob).toBe(false);539 expect(capabilities.canOpenJob).toBe(false);540 expect(capabilities.canCloseJob).toBe(false);541 expect(capabilities.canForecastJob).toBe(false);542 expect(capabilities.canGetDatafeeds).toBe(false);543 expect(capabilities.canStartStopDatafeed).toBe(false);544 expect(capabilities.canUpdateJob).toBe(false);545 expect(capabilities.canUpdateDatafeed).toBe(false);546 expect(capabilities.canPreviewDatafeed).toBe(false);547 expect(capabilities.canGetCalendars).toBe(false);548 expect(capabilities.canCreateCalendar).toBe(false);549 expect(capabilities.canDeleteCalendar).toBe(false);550 expect(capabilities.canGetFilters).toBe(false);551 expect(capabilities.canCreateFilter).toBe(false);552 expect(capabilities.canDeleteFilter).toBe(false);553 expect(capabilities.canFindFileStructure).toBe(false);554 expect(capabilities.canGetDataFrame).toBe(false);555 expect(capabilities.canDeleteDataFrame).toBe(false);556 expect(capabilities.canPreviewDataFrame).toBe(false);557 expect(capabilities.canCreateDataFrame).toBe(false);558 expect(capabilities.canStartStopDataFrame).toBe(false);559 done();560 });561 });...
check_capabilities.test.ts
Source:check_capabilities.test.ts
1/*2 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one3 * or more contributor license agreements. Licensed under the Elastic License;4 * you may not use this file except in compliance with the Elastic License.5 */6import { getAdminCapabilities, getUserCapabilities } from './__mocks__/ml_capabilities';7import { capabilitiesProvider } from './check_capabilities';8import { MlLicense } from '../../../common/license';9import { getDefaultCapabilities } from '../../../common/types/capabilities';10const mlLicense = {11 isSecurityEnabled: () => true,12 isFullLicense: () => true,13} as MlLicense;14const mlLicenseBasic = {15 isSecurityEnabled: () => true,16 isFullLicense: () => false,17} as MlLicense;18const mlIsEnabled = async () => true;19const mlIsNotEnabled = async () => false;20const callWithRequestNonUpgrade = async () => ({ upgrade_mode: false });21const callWithRequestUpgrade = async () => ({ upgrade_mode: true });22describe('check_capabilities', () => {23 describe('getCapabilities() - right number of capabilities', () => {24 test('kibana capabilities count', async (done) => {25 const { getCapabilities } = capabilitiesProvider(26 callWithRequestNonUpgrade,27 getAdminCapabilities(),28 mlLicense,29 mlIsEnabled30 );31 const { capabilities } = await getCapabilities();32 const count = Object.keys(capabilities).length;33 expect(count).toBe(28);34 done();35 });36 });37 describe('getCapabilities() with security', () => {38 test('ml_user capabilities only', async (done) => {39 const { getCapabilities } = capabilitiesProvider(40 callWithRequestNonUpgrade,41 getUserCapabilities(),42 mlLicense,43 mlIsEnabled44 );45 const {46 capabilities,47 upgradeInProgress,48 mlFeatureEnabledInSpace,49 isPlatinumOrTrialLicense,50 } = await getCapabilities();51 expect(upgradeInProgress).toBe(false);52 expect(mlFeatureEnabledInSpace).toBe(true);53 expect(isPlatinumOrTrialLicense).toBe(true);54 expect(capabilities.canAccessML).toBe(true);55 expect(capabilities.canGetJobs).toBe(true);56 expect(capabilities.canGetDatafeeds).toBe(true);57 expect(capabilities.canGetCalendars).toBe(true);58 expect(capabilities.canFindFileStructure).toBe(true);59 expect(capabilities.canGetDataFrameAnalytics).toBe(true);60 expect(capabilities.canGetAnnotations).toBe(true);61 expect(capabilities.canCreateAnnotation).toBe(true);62 expect(capabilities.canDeleteAnnotation).toBe(true);63 expect(capabilities.canCreateJob).toBe(false);64 expect(capabilities.canDeleteJob).toBe(false);65 expect(capabilities.canOpenJob).toBe(false);66 expect(capabilities.canCloseJob).toBe(false);67 expect(capabilities.canForecastJob).toBe(false);68 expect(capabilities.canStartStopDatafeed).toBe(false);69 expect(capabilities.canUpdateJob).toBe(false);70 expect(capabilities.canCreateDatafeed).toBe(false);71 expect(capabilities.canDeleteDatafeed).toBe(false);72 expect(capabilities.canUpdateDatafeed).toBe(false);73 expect(capabilities.canPreviewDatafeed).toBe(false);74 expect(capabilities.canGetFilters).toBe(false);75 expect(capabilities.canCreateCalendar).toBe(false);76 expect(capabilities.canDeleteCalendar).toBe(false);77 expect(capabilities.canCreateFilter).toBe(false);78 expect(capabilities.canDeleteFilter).toBe(false);79 expect(capabilities.canDeleteDataFrameAnalytics).toBe(false);80 expect(capabilities.canCreateDataFrameAnalytics).toBe(false);81 expect(capabilities.canStartStopDataFrameAnalytics).toBe(false);82 done();83 });84 test('full capabilities', async (done) => {85 const { getCapabilities } = capabilitiesProvider(86 callWithRequestNonUpgrade,87 getAdminCapabilities(),88 mlLicense,89 mlIsEnabled90 );91 const {92 capabilities,93 upgradeInProgress,94 mlFeatureEnabledInSpace,95 isPlatinumOrTrialLicense,96 } = await getCapabilities();97 expect(upgradeInProgress).toBe(false);98 expect(mlFeatureEnabledInSpace).toBe(true);99 expect(isPlatinumOrTrialLicense).toBe(true);100 expect(capabilities.canAccessML).toBe(true);101 expect(capabilities.canGetJobs).toBe(true);102 expect(capabilities.canGetDatafeeds).toBe(true);103 expect(capabilities.canGetCalendars).toBe(true);104 expect(capabilities.canFindFileStructure).toBe(true);105 expect(capabilities.canGetDataFrameAnalytics).toBe(true);106 expect(capabilities.canGetAnnotations).toBe(true);107 expect(capabilities.canCreateAnnotation).toBe(true);108 expect(capabilities.canDeleteAnnotation).toBe(true);109 expect(capabilities.canCreateJob).toBe(true);110 expect(capabilities.canDeleteJob).toBe(true);111 expect(capabilities.canOpenJob).toBe(true);112 expect(capabilities.canCloseJob).toBe(true);113 expect(capabilities.canForecastJob).toBe(true);114 expect(capabilities.canStartStopDatafeed).toBe(true);115 expect(capabilities.canUpdateJob).toBe(true);116 expect(capabilities.canCreateDatafeed).toBe(true);117 expect(capabilities.canDeleteDatafeed).toBe(true);118 expect(capabilities.canUpdateDatafeed).toBe(true);119 expect(capabilities.canPreviewDatafeed).toBe(true);120 expect(capabilities.canGetFilters).toBe(true);121 expect(capabilities.canCreateCalendar).toBe(true);122 expect(capabilities.canDeleteCalendar).toBe(true);123 expect(capabilities.canCreateFilter).toBe(true);124 expect(capabilities.canDeleteFilter).toBe(true);125 expect(capabilities.canDeleteDataFrameAnalytics).toBe(true);126 expect(capabilities.canCreateDataFrameAnalytics).toBe(true);127 expect(capabilities.canStartStopDataFrameAnalytics).toBe(true);128 done();129 });130 test('upgrade in progress with full capabilities', async (done) => {131 const { getCapabilities } = capabilitiesProvider(132 callWithRequestUpgrade,133 getAdminCapabilities(),134 mlLicense,135 mlIsEnabled136 );137 const {138 capabilities,139 upgradeInProgress,140 mlFeatureEnabledInSpace,141 isPlatinumOrTrialLicense,142 } = await getCapabilities();143 expect(upgradeInProgress).toBe(true);144 expect(mlFeatureEnabledInSpace).toBe(true);145 expect(isPlatinumOrTrialLicense).toBe(true);146 expect(capabilities.canAccessML).toBe(true);147 expect(capabilities.canGetJobs).toBe(true);148 expect(capabilities.canGetDatafeeds).toBe(true);149 expect(capabilities.canGetCalendars).toBe(true);150 expect(capabilities.canFindFileStructure).toBe(true);151 expect(capabilities.canGetDataFrameAnalytics).toBe(true);152 expect(capabilities.canGetAnnotations).toBe(true);153 expect(capabilities.canCreateAnnotation).toBe(false);154 expect(capabilities.canDeleteAnnotation).toBe(false);155 expect(capabilities.canCreateJob).toBe(false);156 expect(capabilities.canDeleteJob).toBe(false);157 expect(capabilities.canOpenJob).toBe(false);158 expect(capabilities.canCloseJob).toBe(false);159 expect(capabilities.canForecastJob).toBe(false);160 expect(capabilities.canStartStopDatafeed).toBe(false);161 expect(capabilities.canUpdateJob).toBe(false);162 expect(capabilities.canCreateDatafeed).toBe(false);163 expect(capabilities.canDeleteDatafeed).toBe(false);164 expect(capabilities.canGetFilters).toBe(false);165 expect(capabilities.canUpdateDatafeed).toBe(false);166 expect(capabilities.canPreviewDatafeed).toBe(false);167 expect(capabilities.canCreateCalendar).toBe(false);168 expect(capabilities.canDeleteCalendar).toBe(false);169 expect(capabilities.canCreateFilter).toBe(false);170 expect(capabilities.canDeleteFilter).toBe(false);171 expect(capabilities.canDeleteDataFrameAnalytics).toBe(false);172 expect(capabilities.canCreateDataFrameAnalytics).toBe(false);173 expect(capabilities.canStartStopDataFrameAnalytics).toBe(false);174 done();175 });176 test('upgrade in progress with partial capabilities', async (done) => {177 const { getCapabilities } = capabilitiesProvider(178 callWithRequestUpgrade,179 getUserCapabilities(),180 mlLicense,181 mlIsEnabled182 );183 const {184 capabilities,185 upgradeInProgress,186 mlFeatureEnabledInSpace,187 isPlatinumOrTrialLicense,188 } = await getCapabilities();189 expect(upgradeInProgress).toBe(true);190 expect(mlFeatureEnabledInSpace).toBe(true);191 expect(isPlatinumOrTrialLicense).toBe(true);192 expect(capabilities.canAccessML).toBe(true);193 expect(capabilities.canGetJobs).toBe(true);194 expect(capabilities.canGetDatafeeds).toBe(true);195 expect(capabilities.canGetCalendars).toBe(true);196 expect(capabilities.canFindFileStructure).toBe(true);197 expect(capabilities.canGetDataFrameAnalytics).toBe(true);198 expect(capabilities.canGetAnnotations).toBe(true);199 expect(capabilities.canCreateAnnotation).toBe(false);200 expect(capabilities.canDeleteAnnotation).toBe(false);201 expect(capabilities.canCreateJob).toBe(false);202 expect(capabilities.canDeleteJob).toBe(false);203 expect(capabilities.canOpenJob).toBe(false);204 expect(capabilities.canCloseJob).toBe(false);205 expect(capabilities.canForecastJob).toBe(false);206 expect(capabilities.canStartStopDatafeed).toBe(false);207 expect(capabilities.canUpdateJob).toBe(false);208 expect(capabilities.canCreateDatafeed).toBe(false);209 expect(capabilities.canDeleteDatafeed).toBe(false);210 expect(capabilities.canUpdateDatafeed).toBe(false);211 expect(capabilities.canPreviewDatafeed).toBe(false);212 expect(capabilities.canGetFilters).toBe(false);213 expect(capabilities.canCreateCalendar).toBe(false);214 expect(capabilities.canDeleteCalendar).toBe(false);215 expect(capabilities.canCreateFilter).toBe(false);216 expect(capabilities.canDeleteFilter).toBe(false);217 expect(capabilities.canDeleteDataFrameAnalytics).toBe(false);218 expect(capabilities.canCreateDataFrameAnalytics).toBe(false);219 expect(capabilities.canStartStopDataFrameAnalytics).toBe(false);220 done();221 });222 test('full capabilities, ml disabled in space', async (done) => {223 const { getCapabilities } = capabilitiesProvider(224 callWithRequestNonUpgrade,225 getDefaultCapabilities(),226 mlLicense,227 mlIsNotEnabled228 );229 const {230 capabilities,231 upgradeInProgress,232 mlFeatureEnabledInSpace,233 isPlatinumOrTrialLicense,234 } = await getCapabilities();235 expect(upgradeInProgress).toBe(false);236 expect(mlFeatureEnabledInSpace).toBe(false);237 expect(isPlatinumOrTrialLicense).toBe(true);238 expect(capabilities.canAccessML).toBe(false);239 expect(capabilities.canGetJobs).toBe(false);240 expect(capabilities.canGetDatafeeds).toBe(false);241 expect(capabilities.canGetCalendars).toBe(false);242 expect(capabilities.canFindFileStructure).toBe(false);243 expect(capabilities.canGetDataFrameAnalytics).toBe(false);244 expect(capabilities.canGetAnnotations).toBe(false);245 expect(capabilities.canCreateAnnotation).toBe(false);246 expect(capabilities.canDeleteAnnotation).toBe(false);247 expect(capabilities.canCreateJob).toBe(false);248 expect(capabilities.canDeleteJob).toBe(false);249 expect(capabilities.canOpenJob).toBe(false);250 expect(capabilities.canCloseJob).toBe(false);251 expect(capabilities.canForecastJob).toBe(false);252 expect(capabilities.canStartStopDatafeed).toBe(false);253 expect(capabilities.canUpdateJob).toBe(false);254 expect(capabilities.canCreateDatafeed).toBe(false);255 expect(capabilities.canDeleteDatafeed).toBe(false);256 expect(capabilities.canUpdateDatafeed).toBe(false);257 expect(capabilities.canPreviewDatafeed).toBe(false);258 expect(capabilities.canGetFilters).toBe(false);259 expect(capabilities.canCreateCalendar).toBe(false);260 expect(capabilities.canDeleteCalendar).toBe(false);261 expect(capabilities.canCreateFilter).toBe(false);262 expect(capabilities.canDeleteFilter).toBe(false);263 expect(capabilities.canDeleteDataFrameAnalytics).toBe(false);264 expect(capabilities.canCreateDataFrameAnalytics).toBe(false);265 expect(capabilities.canStartStopDataFrameAnalytics).toBe(false);266 done();267 });268 });269 test('full capabilities, basic license, ml disabled in space', async (done) => {270 const { getCapabilities } = capabilitiesProvider(271 callWithRequestNonUpgrade,272 getDefaultCapabilities(),273 mlLicenseBasic,274 mlIsNotEnabled275 );276 const {277 capabilities,278 upgradeInProgress,279 mlFeatureEnabledInSpace,280 isPlatinumOrTrialLicense,281 } = await getCapabilities();282 expect(upgradeInProgress).toBe(false);283 expect(mlFeatureEnabledInSpace).toBe(false);284 expect(isPlatinumOrTrialLicense).toBe(false);285 expect(capabilities.canAccessML).toBe(false);286 expect(capabilities.canGetJobs).toBe(false);287 expect(capabilities.canGetDatafeeds).toBe(false);288 expect(capabilities.canGetCalendars).toBe(false);289 expect(capabilities.canFindFileStructure).toBe(false);290 expect(capabilities.canGetDataFrameAnalytics).toBe(false);291 expect(capabilities.canGetAnnotations).toBe(false);292 expect(capabilities.canCreateAnnotation).toBe(false);293 expect(capabilities.canDeleteAnnotation).toBe(false);294 expect(capabilities.canCreateJob).toBe(false);295 expect(capabilities.canDeleteJob).toBe(false);296 expect(capabilities.canOpenJob).toBe(false);297 expect(capabilities.canCloseJob).toBe(false);298 expect(capabilities.canForecastJob).toBe(false);299 expect(capabilities.canStartStopDatafeed).toBe(false);300 expect(capabilities.canUpdateJob).toBe(false);301 expect(capabilities.canCreateDatafeed).toBe(false);302 expect(capabilities.canDeleteDatafeed).toBe(false);303 expect(capabilities.canUpdateDatafeed).toBe(false);304 expect(capabilities.canPreviewDatafeed).toBe(false);305 expect(capabilities.canGetFilters).toBe(false);306 expect(capabilities.canCreateCalendar).toBe(false);307 expect(capabilities.canDeleteCalendar).toBe(false);308 expect(capabilities.canCreateFilter).toBe(false);309 expect(capabilities.canDeleteFilter).toBe(false);310 expect(capabilities.canDeleteDataFrameAnalytics).toBe(false);311 expect(capabilities.canCreateDataFrameAnalytics).toBe(false);312 expect(capabilities.canStartStopDataFrameAnalytics).toBe(false);313 done();314 });...
capabilities-edit.component.js
Source:capabilities-edit.component.js
1/*!2 * Matomo - free/libre analytics platform3 *4 * @link https://matomo.org5 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later6 */7/**8 * Usage:9 * <piwik-capabilities-edit>10 */11(function () {12 angular.module('piwikApp').component('piwikCapabilitiesEdit', {13 templateUrl: 'plugins/UsersManager/angularjs/capabilities-edit/capabilities-edit.component.html?cb=' + piwik.cacheBuster,14 bindings: {15 idsite: '<',16 siteName: '<',17 userLogin: '<',18 userRole: '<',19 capabilities: '<',20 onCapabilitiesChange: '&',21 },22 controller: CapabilitiesEditController23 });24 CapabilitiesEditController.$inject = ['piwikApi', 'permissionsMetadataService', 'piwik', '$element'];25 function CapabilitiesEditController(piwikApi, permissionsMetadataService, piwik, $element) {26 var vm = this;27 vm.isBusy = false;28 vm.availableCapabilities = [];29 vm.availableCapabilitiesGrouped = [];30 vm.capabilitiesSet = {};31 // intermediate state32 vm.isAddingCapability = false;33 vm.capabilityToAddOrRemoveId = null;34 vm.capabilityToAddOrRemove = null;35 vm.$onInit = $onInit;36 vm.$onChanges = $onChanges;37 vm.onToggleCapability = onToggleCapability;38 vm.toggleCapability = toggleCapability;39 vm.isIncludedInRole = isIncludedInRole;40 function $onInit() {41 fetchAvailableCapabilities();42 if (typeof vm.capabilities === 'undefined') {43 fetchCapabilities();44 }45 }46 function $onChanges() {47 setCapabilitiesSet();48 }49 function isIncludedInRole(capability) {50 return capability.includedInRoles.indexOf(vm.userRole) !== -1;51 }52 function fetchAvailableCapabilities() {53 permissionsMetadataService.getAllCapabilities()54 .then(function (capabilities) {55 vm.availableCapabilities = capabilities;56 setCapabilitiesSet();57 setAvailableCapabilitiesDropdown();58 });59 }60 function fetchCapabilities() {61 vm.isBusy = true;62 piwikApi.fetch({63 method: 'UsersManager.getUsersPlusRole',64 limit: '1',65 filter_search: vm.userLogin,66 }).then(function (user) {67 if (!user || !user.capabilities) {68 return [];69 }70 return user.capabilities;71 }).then(function (capabilities) {72 vm.capabilities = capabilities;73 setCapabilitiesSet();74 setAvailableCapabilitiesDropdown();75 })['finally'](function () {76 vm.isBusy = false;77 });78 }79 function setCapabilitiesSet() {80 vm.capabilitiesSet = {};81 (vm.capabilities || []).forEach(function (capability) {82 vm.capabilitiesSet[capability] = true;83 });84 (vm.availableCapabilities || []).forEach(function (capability) {85 if (vm.isIncludedInRole(capability)) {86 vm.capabilitiesSet[capability.id] = true;87 }88 });89 }90 function setAvailableCapabilitiesDropdown() {91 var availableCapabilitiesGrouped = [];92 vm.availableCapabilities.forEach(function (capability) {93 if (vm.capabilitiesSet[capability.id]) {94 return;95 }96 availableCapabilitiesGrouped.push({97 group: capability.category,98 key: capability.id,99 value: capability.name,100 tooltip: capability.description,101 });102 });103 vm.availableCapabilitiesGrouped = availableCapabilitiesGrouped;104 vm.availableCapabilitiesGrouped.sort(function (lhs, rhs) {105 if (lhs.group === rhs.group) {106 if (lhs.value === rhs.value) {107 return 0;108 }109 return lhs.value < rhs.value ? -1 : 1;110 }111 return lhs.group < rhs.group ? -1 : 1;112 });113 }114 function onToggleCapability(isAdd) {115 vm.isAddingCapability = isAdd;116 vm.capabilityToAddOrRemove = null;117 vm.availableCapabilities.forEach(function (capability) {118 if (capability.id === vm.capabilityToAddOrRemoveId) {119 vm.capabilityToAddOrRemove = capability;120 }121 });122 $element.find('.confirmCapabilityToggle').modal({123 dismissible: false,124 yes: function () {125 },126 }).modal('open');127 }128 function toggleCapability() {129 if (vm.isAddingCapability) {130 addCapability(vm.capabilityToAddOrRemove);131 } else {132 removeCapability(vm.capabilityToAddOrRemove);133 }134 }135 function addCapability(capability) {136 vm.isBusy = true;137 piwikApi.post({138 method: 'UsersManager.addCapabilities',139 }, {140 userLogin: vm.userLogin,141 capabilities: capability.id,142 idSites: vm.idsite143 }).then(function () {144 vm.onCapabilitiesChange.call({145 capabilities: getCapabilitiesList(),146 });147 setCapabilitiesSet();148 setAvailableCapabilitiesDropdown();149 })['finally'](function () {150 vm.isBusy = false;151 vm.capabilityToAddOrRemove = null;152 vm.capabilityToAddOrRemoveId = null;153 });154 }155 function removeCapability(capability) {156 vm.isBusy = true;157 piwikApi.post({158 method: 'UsersManager.removeCapabilities',159 }, {160 userLogin: vm.userLogin,161 capabilities: capability.id,162 idSites: vm.idsite163 }).then(function () {164 vm.onCapabilitiesChange.call({165 capabilities: getCapabilitiesList(),166 });167 setCapabilitiesSet();168 setAvailableCapabilitiesDropdown();169 })['finally'](function () {170 vm.isBusy = false;171 vm.capabilityToAddOrRemove = null;172 vm.capabilityToAddOrRemoveId = null;173 });174 }175 function getCapabilitiesList() {176 var result = [];177 vm.availableCapabilities.forEach(function (capability) {178 if (vm.isIncludedInRole(capability)) {179 return;180 }181 if (vm.capabilitiesSet[capability.id]) {182 result.push(capability.id);183 }184 });185 return result;186 }187 }...
Using AI Code Generation
1const { capabilities } = require('stryker-parent');2const { capabilities } = require('stryker');3const { capabilities } = require('stryker-api');4const { capabilities } = require('stryker-cli');5const { capabilities } = require('stryker-html-reporter');6const { capabilities } = require('stryker-jest-runner');7const { capabilities } = require('stryker-jasmine-runner');8const { capabilities } = require('stryker-mocha-runner');9const { capabilities } = require('stryker-typescript');10const config = {11 plugins: [capabilities('stryker-jest-runner')]12};13module.exports = config;14dryRun(): a method that is called when the dryRun is executed. This method is optional and
Using AI Code Generation
1const { capabilities } = require('stryker-parent');2const { capabilities } = require('stryker-parent');3const { capabilities } = require('stryker-parent');4const { capabilities } = require('stryker-parent');5const { capabilities } = require('stryker-parent');6const { capabilities } = require('stryker-parent');7const { capabilities } = require('stryker-parent');8const { capabilities } = require('stryker-parent');9const { capabilities } = require('stryker-parent');10const { capabilities } = require('stryker-parent');11const { capabilities } = require('stryker-parent');12const { capabilities } = require('stryker-parent');13const { capabilities } = require('stryker-parent');14const { capabilities } = require('stryker-parent');15const { capabilities } = require('stryker-parent');16const { capabilities } = require('stryker-parent');17const { capabilities } = require('stryker-parent');18const { capabilities } = require('stryker-parent');19const { capabilities } = require('stryker-parent');20const { capabilities } = require('stry
Using AI Code Generation
1const { capabilities } = require('stryker-parent');2module.exports = function(config) {3 config.set({4 jest: {5 config: require('./jest.config.js'),6 },
Using AI Code Generation
1const { capabilities } = require('stryker-parent');2console.log(capabilities);3module.exports = function (config) {4 config.set({5 });6};
Using AI Code Generation
1const stryker = require('stryker-parent');2const capabilities = stryker.capabilities;3console.log(capabilities);4module.exports = function(config) {5 config.set({6 });7};8function greeting(name) {9 return `Hello ${name}!`;10}11module.exports = greeting;12const greeting = require('../src/greeting');13describe('greeting', () => {14 it('should greet the person by name', () => {15 const result = greeting('John');16 expect(result).toBe('Hello John!');17 });18});
Using AI Code Generation
1var strykerParent = require('stryker-parent');2var capabilities = strykerParent.getCapabilities();3var childProcess = require('child_process');4var child = childProcess.fork('./child.js', [], {5 env: {6 STRYKER_CAPABILITIES: JSON.stringify(capabilities)7 }8});9var strykerParent = require('stryker-parent');10var capabilities = strykerParent.getCapabilities();11console.log('Capabilities from parent process: ', capabilities);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!