How to use grantPermissions method in Playwright Internal

Best JavaScript code snippet using playwright-internal

relations-test.js

Source:relations-test.js Github

copy

Full Screen

...42 });43 describe('POST /rest/relations', async function () {44 before(async function () {45 await Promise.all([46 h.grantPermissions(47 [48 h.PERMISSION_RELATIONS_ATTRIBUTE_CREATE,49 h.PERMISSION_RELATIONS_ATTRIBUTE_DELETE,50 h.PERMISSION_RELATIONS_ATTRIBUTE_UPDATE,51 h.PERMISSION_RELATIONS_ATTRIBUTE_VIEW,52 h.PERMISSION_METADATA_PERIOD_VIEW,53 h.PERMISSION_METADATA_PLACE_VIEW,54 h.PERMISSION_METADATA_SCOPE_VIEW,55 ],56 USER_KEY57 ),58 ]);59 });60 after(async function () {61 await h.revertChanges();62 });63 const tests = [64 {65 name: 'cols with permissions without permissions',66 headers: new fetch.Headers({67 Authorization: createUserToken(),68 'Content-Type': 'application/json',69 }),70 body: JSON.stringify({71 data: {72 attribute: [73 {74 key: 'e896b814-47f9-4f56-b4bb-552d9d912134',75 data: {76 scopeKey: scopeKey,77 placeKey: placeKey,78 },79 },80 ],81 },82 }),83 expectedResult: {84 status: 403,85 body: {86 success: false,87 },88 },89 },90 {91 name: 'cols with permissions',92 before: async function () {93 const permissions = [94 '3c93904f-2cf8-4f57-9fbf-58079a9ae854',95 'd5ec756f-60c3-427d-ba36-c6599de5b9b4',96 ];97 await Promise.all([98 helper.createRecord('"user"."permissions"', {99 key: permissions[0],100 resourceGroup: 'metadata',101 resourceType: 'scopes',102 permission: 'create',103 resourceKey: scopeKey,104 }),105 helper.createRecord('"user"."permissions"', {106 key: permissions[1],107 resourceGroup: 'metadata',108 resourceType: 'places',109 permission: 'create',110 resourceKey: placeKey,111 }),112 ]);113 await helper.grantPermissions(permissions, USER_KEY);114 },115 headers: new fetch.Headers({116 Authorization: createUserToken(),117 'Content-Type': 'application/json',118 }),119 body: JSON.stringify({120 data: {121 attribute: [122 {123 key: 'e896b814-47f9-4f56-b4bb-552d9d912134',124 data: {125 scopeKey: scopeKey,126 placeKey: placeKey,127 },128 },129 ],130 },131 }),132 expectedResult: {133 status: 201,134 body: {135 data: {136 attribute: [137 {138 key: 'e896b814-47f9-4f56-b4bb-552d9d912134',139 data: {140 applicationKey: null,141 areaTreeLevelKey: null,142 attributeDataSourceKey: null,143 attributeKey: null,144 attributeSetKey: null,145 caseKey: null,146 layerTemplateKey: null,147 periodKey: null,148 placeKey: placeKey,149 scenarioKey: null,150 scopeKey: scopeKey,151 },152 permissions: {153 activeUser: {154 create: true,155 delete: false,156 update: false,157 view: true,158 },159 guest: {160 create: false,161 delete: false,162 update: false,163 view: false,164 },165 },166 },167 ],168 },169 success: true,170 total: 1,171 },172 },173 },174 ];175 tests.forEach((test) => {176 it(test.name, async function () {177 test.before && (await test.before());178 const response = await fetch(url('/rest/relations'), {179 method: 'POST',180 headers: test.headers,181 body: test.body,182 });183 assert.strictEqual(response.status, test.expectedResult.status);184 const data = await response.json();185 assert.deepStrictEqual(data, test.expectedResult.body);186 });187 });188 });189 describe('POST /rest/relations/filtered/attribute', async function () {190 beforeEach(async function () {191 await h.createRecord('"user"."hashes"', {192 key: HASH_KEY,193 })194 await Promise.all([195 h.grantPermissions(196 [197 h.PERMISSION_RELATIONS_ATTRIBUTE_CREATE,198 h.PERMISSION_RELATIONS_ATTRIBUTE_DELETE,199 h.PERMISSION_RELATIONS_ATTRIBUTE_UPDATE,200 h.PERMISSION_RELATIONS_ATTRIBUTE_VIEW,201 ],202 USER_KEY203 ),204 h.grantHashPermission(h.PERMISSION_RELATIONS_ATTRIBUTE_VIEW, HASH_KEY)205 ]);206 });207 afterEach(async function () {208 await h.revertChanges();209 });210 const tests = [211 {212 name: 'cols with permissions without permission',213 before: async function () {214 const permissions = [215 '3c93904f-2cf8-4f57-9fbf-58079a9ae854',216 ];217 await Promise.all([218 helper.createRecord('"user"."permissions"', {219 key: permissions[0],220 resourceGroup: 'metadata',221 resourceType: 'scopes',222 permission: 'view',223 resourceKey: scopeKey,224 }),225 ]);226 await helper.grantPermissions(permissions, USER_KEY);227 },228 headers: new fetch.Headers({229 Authorization: createUserToken(),230 'Content-Type': 'application/json',231 }),232 body: JSON.stringify({}),233 expectedResult: {234 status: 200,235 body: {236 data: {237 attribute: [],238 },239 limit: 100,240 offset: 0,241 success: true,242 total: 0,243 },244 },245 },246 {247 name: 'cols with permissions',248 before: async function () {249 const permissions = [250 '3c93904f-2cf8-4f57-9fbf-58079a9ae854',251 'd5ec756f-60c3-427d-ba36-c6599de5b9b4',252 ];253 await Promise.all([254 helper.createRecord('"user"."permissions"', {255 key: permissions[0],256 resourceGroup: 'metadata',257 resourceType: 'scopes',258 permission: 'view',259 resourceKey: scopeKey,260 }),261 helper.createRecord('"user"."permissions"', {262 key: permissions[1],263 resourceGroup: 'metadata',264 resourceType: 'places',265 permission: 'view',266 resourceKey: placeKey,267 }),268 ]);269 await helper.grantPermissions(permissions, USER_KEY);270 },271 headers: new fetch.Headers({272 Authorization: createUserToken(),273 'Content-Type': 'application/json',274 }),275 body: JSON.stringify({}),276 expectedResult: {277 status: 200,278 body: {279 data: {280 attribute: [281 {282 key: 'e896b814-47f9-4f56-b4bb-552d9d912134',283 data: {284 applicationKey: null,285 areaTreeLevelKey: null,286 attributeDataSourceKey: null,287 attributeKey: null,288 attributeSetKey: null,289 caseKey: null,290 layerTemplateKey: null,291 periodKey: null,292 placeKey: placeKey,293 scenarioKey: null,294 scopeKey: scopeKey,295 },296 permissions: {297 activeUser: {298 create: true,299 delete: false,300 update: false,301 view: true,302 },303 guest: {304 create: false,305 delete: false,306 update: false,307 view: false,308 },309 },310 },311 ],312 },313 limit: 100,314 offset: 0,315 success: true,316 total: 1,317 },318 },319 },320 {321 name: 'cols with permissions without permission with hash',322 before: async function () {323 const permissions = [324 '3c93904f-2cf8-4f57-9fbf-58079a9ae854',325 ];326 await Promise.all([327 helper.createRecord('"user"."permissions"', {328 key: permissions[0],329 resourceGroup: 'metadata',330 resourceType: 'scopes',331 permission: 'view',332 resourceKey: scopeKey,333 }),334 ]);335 await helper.grantHashPermissions(permissions, HASH_KEY);336 },337 headers: new fetch.Headers({338 Hash: HASH_KEY,339 'Content-Type': 'application/json',340 }),341 body: JSON.stringify({}),342 expectedResult: {343 status: 200,344 body: {345 data: {346 attribute: [],347 },348 limit: 100,349 offset: 0,350 success: true,351 total: 0,352 },353 },354 },355 {356 name: 'cols with permissions with hash',357 before: async function () {358 const permissions = [359 '3c93904f-2cf8-4f57-9fbf-58079a9ae854',360 'd5ec756f-60c3-427d-ba36-c6599de5b9b4',361 ];362 await Promise.all([363 helper.createRecord('"user"."permissions"', {364 key: permissions[0],365 resourceGroup: 'metadata',366 resourceType: 'scopes',367 permission: 'view',368 resourceKey: scopeKey,369 }),370 helper.createRecord('"user"."permissions"', {371 key: permissions[1],372 resourceGroup: 'metadata',373 resourceType: 'places',374 permission: 'view',375 resourceKey: placeKey,376 }),377 ]);378 await helper.grantHashPermissions(permissions, HASH_KEY);379 },380 headers: new fetch.Headers({381 Hash: HASH_KEY,382 'Content-Type': 'application/json',383 }),384 body: JSON.stringify({}),385 expectedResult: {386 status: 200,387 body: {388 data: {389 attribute: [390 {391 key: 'e896b814-47f9-4f56-b4bb-552d9d912134',392 data: {393 applicationKey: null,394 areaTreeLevelKey: null,395 attributeDataSourceKey: null,396 attributeKey: null,397 attributeSetKey: null,398 caseKey: null,399 layerTemplateKey: null,400 periodKey: null,401 placeKey: placeKey,402 scenarioKey: null,403 scopeKey: scopeKey,404 },405 permissions: {406 activeUser: {407 create: false,408 delete: false,409 update: false,410 view: false,411 },412 guest: {413 create: false,414 delete: false,415 update: false,416 view: false,417 },418 },419 },420 ],421 },422 limit: 100,423 offset: 0,424 success: true,425 total: 1,426 },427 },428 },429 ];430 tests.forEach((test) => {431 it(test.name, async function () {432 test.before && (await test.before());433 const response = await fetch(434 url('/rest/relations/filtered/attribute'),435 {436 method: 'POST',437 headers: test.headers,438 body: test.body,439 }440 );441 assert.strictEqual(response.status, test.expectedResult.status);442 const data = await response.json();443 delete data.changes;444 assert.deepStrictEqual(data, test.expectedResult.body);445 });446 });447 });448 describe('PUT /rest/relations', async function () {449 beforeEach(async function () {450 await Promise.all([451 h.grantPermissions(452 [453 h.PERMISSION_RELATIONS_ATTRIBUTE_CREATE,454 h.PERMISSION_RELATIONS_ATTRIBUTE_DELETE,455 h.PERMISSION_RELATIONS_ATTRIBUTE_UPDATE,456 h.PERMISSION_RELATIONS_ATTRIBUTE_VIEW,457 h.PERMISSION_METADATA_PERIOD_VIEW,458 h.PERMISSION_METADATA_PLACE_VIEW,459 h.PERMISSION_METADATA_SCOPE_VIEW,460 ],461 USER_KEY462 ),463 ]);464 });465 afterEach(async function () {466 await h.revertChanges();467 });468 const tests = [469 {470 name: 'cols with permissions without old col permission',471 before: async function () {472 const permissions = [473 'd5ec756f-60c3-427d-ba36-c6599de5b9b4',474 '6a6a40a7-a944-4db8-8f74-672ef011dec7',475 ];476 await Promise.all([477 helper.createRecord('"user"."permissions"', {478 key: permissions[0],479 resourceGroup: 'metadata',480 resourceType: 'places',481 permission: 'update',482 resourceKey: placeKey,483 }),484 helper.createRecord('"user"."permissions"', {485 key: permissions[1],486 resourceGroup: 'metadata',487 resourceType: 'periods',488 permission: 'update',489 resourceKey: periodKey,490 }),491 ]);492 await helper.grantPermissions(permissions, USER_KEY);493 },494 headers: new fetch.Headers({495 Authorization: createUserToken(),496 'Content-Type': 'application/json',497 }),498 body: JSON.stringify({499 data: {500 attribute: [501 {502 key: 'e896b814-47f9-4f56-b4bb-552d9d912134',503 data: {504 periodKey: periodKey,505 },506 },507 ],508 },509 }),510 expectedResult: {511 status: 403,512 body: {513 success: false,514 },515 },516 },517 {518 name: 'cols with permissions without new col permission',519 before: async function () {520 const permissions = [521 '3c93904f-2cf8-4f57-9fbf-58079a9ae854',522 'd5ec756f-60c3-427d-ba36-c6599de5b9b4',523 ];524 await Promise.all([525 helper.createRecord('"user"."permissions"', {526 key: permissions[0],527 resourceGroup: 'metadata',528 resourceType: 'scopes',529 permission: 'update',530 resourceKey: scopeKey,531 }),532 helper.createRecord('"user"."permissions"', {533 key: permissions[1],534 resourceGroup: 'metadata',535 resourceType: 'places',536 permission: 'update',537 resourceKey: placeKey,538 }),539 ]);540 await helper.grantPermissions(permissions, USER_KEY);541 },542 headers: new fetch.Headers({543 Authorization: createUserToken(),544 'Content-Type': 'application/json',545 }),546 body: JSON.stringify({547 data: {548 attribute: [549 {550 key: 'e896b814-47f9-4f56-b4bb-552d9d912134',551 data: {552 periodKey: periodKey,553 },554 },555 ],556 },557 }),558 expectedResult: {559 status: 403,560 body: {561 success: false,562 },563 },564 },565 {566 name: 'cols with permissions',567 before: async function () {568 const permissions = [569 '3c93904f-2cf8-4f57-9fbf-58079a9ae854',570 'd5ec756f-60c3-427d-ba36-c6599de5b9b4',571 '6a6a40a7-a944-4db8-8f74-672ef011dec7',572 ];573 await Promise.all([574 helper.createRecord('"user"."permissions"', {575 key: permissions[0],576 resourceGroup: 'metadata',577 resourceType: 'scopes',578 permission: 'update',579 resourceKey: scopeKey,580 }),581 helper.createRecord('"user"."permissions"', {582 key: permissions[1],583 resourceGroup: 'metadata',584 resourceType: 'places',585 permission: 'update',586 resourceKey: placeKey,587 }),588 helper.createRecord('"user"."permissions"', {589 key: permissions[2],590 resourceGroup: 'metadata',591 resourceType: 'periods',592 permission: 'update',593 resourceKey: periodKey,594 }),595 ]);596 await helper.grantPermissions(permissions, USER_KEY);597 },598 headers: new fetch.Headers({599 Authorization: createUserToken(),600 'Content-Type': 'application/json',601 }),602 body: JSON.stringify({603 data: {604 attribute: [605 {606 key: 'e896b814-47f9-4f56-b4bb-552d9d912134',607 data: {608 periodKey: periodKey,609 },610 },611 ],612 },613 }),614 expectedResult: {615 status: 200,616 body: {617 data: {618 attribute: [619 {620 key: 'e896b814-47f9-4f56-b4bb-552d9d912134',621 data: {622 applicationKey: null,623 areaTreeLevelKey: null,624 attributeDataSourceKey: null,625 attributeKey: null,626 attributeSetKey: null,627 caseKey: null,628 layerTemplateKey: null,629 periodKey: periodKey,630 placeKey: placeKey,631 scenarioKey: null,632 scopeKey: scopeKey,633 },634 permissions: {635 activeUser: {636 create: true,637 delete: true,638 update: true,639 view: true,640 },641 guest: {642 create: false,643 delete: false,644 update: false,645 view: false,646 },647 },648 },649 ],650 },651 success: true,652 total: 1,653 },654 },655 },656 ];657 tests.forEach((test) => {658 it(test.name, async function () {659 test.before && (await test.before());660 const response = await fetch(url('/rest/relations'), {661 method: 'PUT',662 headers: test.headers,663 body: test.body,664 });665 assert.strictEqual(response.status, test.expectedResult.status);666 const data = await response.json();667 assert.deepStrictEqual(data, test.expectedResult.body);668 });669 });670 });671 describe('PUT /rest/relations', async function () {672 const scopeKey = 'a789c87a-d222-4550-bd29-0750353ae496';673 const placeKey = '208d7232-a50c-4e90-abf6-2593e35a2384';674 const periodKey = 'fbd64b2b-fe71-4f18-9759-9971b45048b2';675 beforeEach(async function () {676 await Promise.all([677 h.grantPermissions(678 [679 h.PERMISSION_RELATIONS_ATTRIBUTE_CREATE,680 h.PERMISSION_RELATIONS_ATTRIBUTE_DELETE,681 h.PERMISSION_RELATIONS_ATTRIBUTE_UPDATE,682 h.PERMISSION_RELATIONS_ATTRIBUTE_VIEW,683 h.PERMISSION_METADATA_PERIOD_VIEW,684 h.PERMISSION_METADATA_PLACE_VIEW,685 h.PERMISSION_METADATA_SCOPE_VIEW,686 ],687 USER_KEY688 ),689 ]);690 });691 afterEach(async function () {692 await h.revertChanges();693 });694 const tests = [695 {696 name: 'cols with permissions without col permission',697 before: async function () {698 const permissions = [699 '3c93904f-2cf8-4f57-9fbf-58079a9ae854',700 'd5ec756f-60c3-427d-ba36-c6599de5b9b4',701 ];702 await Promise.all([703 helper.createRecord('"user"."permissions"', {704 key: permissions[0],705 resourceGroup: 'metadata',706 resourceType: 'scopes',707 permission: 'update',708 resourceKey: scopeKey,709 }),710 helper.createRecord('"user"."permissions"', {711 key: permissions[1],712 resourceGroup: 'metadata',713 resourceType: 'places',714 permission: 'update',715 resourceKey: placeKey,716 }),717 ]);718 await helper.grantPermissions(permissions, USER_KEY);719 },720 headers: new fetch.Headers({721 Authorization: createUserToken(),722 'Content-Type': 'application/json',723 }),724 body: JSON.stringify({725 data: {726 attribute: [727 {728 key: 'e896b814-47f9-4f56-b4bb-552d9d912134',729 },730 ],731 },732 }),733 expectedResult: {734 status: 403,735 body: {736 success: false,737 },738 },739 },740 {741 name: 'cols with permissions',742 before: async function () {743 const permissions = [744 '3c93904f-2cf8-4f57-9fbf-58079a9ae854',745 'd5ec756f-60c3-427d-ba36-c6599de5b9b4',746 '6a6a40a7-a944-4db8-8f74-672ef011dec7',747 ];748 await Promise.all([749 helper.createRecord('"user"."permissions"', {750 key: permissions[0],751 resourceGroup: 'metadata',752 resourceType: 'scopes',753 permission: 'update',754 resourceKey: scopeKey,755 }),756 helper.createRecord('"user"."permissions"', {757 key: permissions[1],758 resourceGroup: 'metadata',759 resourceType: 'places',760 permission: 'update',761 resourceKey: placeKey,762 }),763 helper.createRecord('"user"."permissions"', {764 key: permissions[2],765 resourceGroup: 'metadata',766 resourceType: 'periods',767 permission: 'update',768 resourceKey: periodKey,769 }),770 ]);771 await helper.grantPermissions(permissions, USER_KEY);772 },773 headers: new fetch.Headers({774 Authorization: createUserToken(),775 'Content-Type': 'application/json',776 }),777 body: JSON.stringify({778 data: {779 attribute: [780 {781 key: 'e896b814-47f9-4f56-b4bb-552d9d912134',782 },783 ],784 },785 }),...

Full Screen

Full Screen

apk-utils-e2e-specs.js

Source:apk-utils-e2e-specs.js Github

copy

Full Screen

1import chai from 'chai';2import chaiAsPromised from 'chai-as-promised';3import ADB from '../..';4import path from 'path';5import { rootDir } from '../../lib/helpers.js';6import { retryInterval } from 'asyncbox';7import { MOCHA_TIMEOUT, MOCHA_LONG_TIMEOUT, apiLevel } from './setup';8const START_APP_WAIT_DURATION = 60000;9const START_APP_WAIT_DURATION_FAIL = process.env.CI ? 20000 : 10000;10chai.should();11chai.use(chaiAsPromised);12describe('apk utils', function () {13 this.timeout(MOCHA_TIMEOUT);14 let adb;15 const contactManagerPath = path.resolve(rootDir, 'test',16 'fixtures', 'ContactManager.apk');17 const apiDemosPath = path.resolve(rootDir, 'test',18 'fixtures', 'ApiDemos-debug.apk');19 const deviceTempPath = '/data/local/tmp/';20 const assertPackageAndActivity = async () => {21 let {appPackage, appActivity} = await adb.getFocusedPackageAndActivity();22 appPackage.should.equal('com.example.android.contactmanager');23 appActivity.should.equal('.ContactManager');24 };25 before(async function () {26 adb = await ADB.createADB({27 adbExecTimeout: process.env.CI ? 60000 : 40000,28 });29 });30 it('should be able to check status of third party app', async function () {31 (await adb.isAppInstalled('com.android.phone')).should.be.true;32 });33 it('should be able to install/remove app and detect its status', async function () {34 (await adb.isAppInstalled('foo')).should.be.false;35 await adb.install(contactManagerPath, {36 grantPermissions: true37 });38 (await adb.isAppInstalled('com.example.android.contactmanager')).should.be.true;39 (await adb.uninstallApk('com.example.android.contactmanager')).should.be.true;40 (await adb.isAppInstalled('com.example.android.contactmanager')).should.be.false;41 (await adb.uninstallApk('com.example.android.contactmanager')).should.be.false;42 await adb.rimraf(deviceTempPath + 'ContactManager.apk');43 await adb.push(contactManagerPath, deviceTempPath);44 await adb.installFromDevicePath(deviceTempPath + 'ContactManager.apk');45 });46 describe('startUri', function () {47 it('should be able to start a uri', async function () {48 if (apiLevel < 23 || apiLevel > 28) {49 return this.skip();50 }51 await adb.goToHome();52 let res = await adb.getFocusedPackageAndActivity();53 res.appPackage.should.not.equal('com.android.contacts');54 await adb.install(contactManagerPath, {55 grantPermissions: true,56 });57 await adb.startUri('content://contacts/people', 'com.android.contacts');58 await retryInterval(10, 500, async () => {59 res = await adb.dumpWindows();60 // depending on apilevel, app might show up as active in one of these61 // two dumpsys output formats62 let focusRe1 = '(mCurrentFocus.+\\.PeopleActivity)';63 let focusRe2 = '(mFocusedApp.+\\.PeopleActivity)';64 res.should.match(new RegExp(`${focusRe1}|${focusRe2}`));65 });66 await adb.goToHome();67 });68 });69 describe('startApp', function () {70 it('should be able to start with normal package and activity', async function () {71 await adb.install(contactManagerPath, {72 grantPermissions: true73 });74 await adb.startApp({75 pkg: 'com.example.android.contactmanager',76 activity: 'ContactManager',77 waitDuration: START_APP_WAIT_DURATION,78 });79 await assertPackageAndActivity();80 });81 it('should be able to start with an intent and no activity', async function () {82 this.timeout(MOCHA_LONG_TIMEOUT);83 await adb.install(contactManagerPath, {84 grantPermissions: true85 });86 await adb.startApp({87 action: 'android.intent.action.WEB_SEARCH',88 pkg: 'com.google.android.googlequicksearchbox',89 optionalIntentArguments: '-e query foo',90 waitDuration: START_APP_WAIT_DURATION,91 stopApp: false92 });93 let {appPackage} = await adb.getFocusedPackageAndActivity();94 const expectedPkgPossibilities = [95 'com.android.browser',96 'org.chromium.webview_shell',97 'com.google.android.googlequicksearchbox'98 ];99 expectedPkgPossibilities.should.include(appPackage);100 });101 it('should throw an error for unknown activity for intent', async function () {102 this.timeout(MOCHA_LONG_TIMEOUT);103 await adb.install(contactManagerPath, {104 grantPermissions: true105 });106 await adb.startApp({107 action: 'android.intent.action.DEFAULT',108 pkg: 'com.google.android.telephony',109 optionalIntentArguments: '-d tel:555-5555',110 waitDuration: START_APP_WAIT_DURATION,111 stopApp: false112 }).should.eventually.be.rejectedWith(/Cannot start the .* application/);113 });114 it('should throw error for wrong activity', async function () {115 await adb.install(contactManagerPath, {116 grantPermissions: true117 });118 await adb.startApp({119 pkg: 'com.example.android.contactmanager',120 activity: 'ContactManage',121 waitDuration: START_APP_WAIT_DURATION_FAIL,122 }).should.eventually.be.rejectedWith('Activity');123 });124 it('should throw error for wrong wait activity', async function () {125 await adb.install(contactManagerPath, {126 grantPermissions: true127 });128 await adb.startApp({129 pkg: 'com.example.android.contactmanager',130 activity: 'ContactManager',131 waitActivity: 'foo',132 waitDuration: START_APP_WAIT_DURATION_FAIL,133 }).should.eventually.be.rejectedWith('foo');134 });135 it('should start activity with wait activity', async function () {136 await adb.install(contactManagerPath, {137 grantPermissions: true138 });139 await adb.startApp({140 pkg: 'com.example.android.contactmanager',141 activity: 'ContactManager',142 waitActivity: '.ContactManager',143 waitDuration: START_APP_WAIT_DURATION,144 });145 await assertPackageAndActivity();146 });147 it('should start activity when wait activity is a wildcard', async function () {148 await adb.install(contactManagerPath, {149 grantPermissions: true150 });151 await adb.startApp({152 pkg: 'com.example.android.contactmanager',153 activity: 'ContactManager',154 waitActivity: '*',155 waitDuration: START_APP_WAIT_DURATION,156 });157 await assertPackageAndActivity();158 });159 it('should start activity when wait activity contains a wildcard', async function () {160 await adb.install(contactManagerPath, {161 grantPermissions: true162 });163 await adb.startApp({164 pkg: 'com.example.android.contactmanager',165 activity: 'ContactManager',166 waitActivity: '*.ContactManager',167 waitDuration: START_APP_WAIT_DURATION,168 });169 await assertPackageAndActivity();170 });171 it('should throw error for wrong activity when wait activity contains a wildcard', async function () {172 await adb.install(contactManagerPath, {173 grantPermissions: true174 });175 await adb.startApp({176 pkg: 'com.example.android.contactmanager',177 activity: 'SuperManager',178 waitActivity: '*.ContactManager',179 waitDuration: START_APP_WAIT_DURATION_FAIL,180 }).should.eventually.be.rejectedWith('Activity');181 });182 it('should throw error for wrong wait activity which contains wildcard', async function () {183 await adb.install(contactManagerPath, {184 grantPermissions: true185 });186 await adb.startApp({187 pkg: 'com.example.android.contactmanager',188 activity: 'ContactManager',189 waitActivity: '*.SuperManager',190 waitDuration: START_APP_WAIT_DURATION_FAIL,191 }).should.eventually.be.rejectedWith('SuperManager');192 });193 it('should start activity with comma separated wait packages list', async function () {194 await adb.install(contactManagerPath, {195 grantPermissions: true196 });197 await adb.startApp({198 pkg: 'com.example.android.contactmanager',199 waitPkg: 'com.android.settings, com.example.android.contactmanager',200 activity: 'ContactManager',201 waitActivity: '.ContactManager',202 waitDuration: START_APP_WAIT_DURATION,203 });204 await assertPackageAndActivity();205 });206 it('should throw error for wrong activity when packages provided as comma separated list', async function () {207 await adb.install(contactManagerPath, {208 grantPermissions: true209 });210 await adb.startApp({211 pkg: 'com.example.android.contactmanager',212 waitPkg: 'com.android.settings, com.example.somethingelse',213 activity: 'SuperManager',214 waitActivity: '*.ContactManager',215 waitDuration: START_APP_WAIT_DURATION_FAIL,216 }).should.eventually.be.rejectedWith('Activity');217 });218 });219 it('should start activity when start activity is an inner class', async function () {220 await adb.install(contactManagerPath, {221 grantPermissions: true222 });223 await adb.startApp({224 pkg: 'com.android.settings',225 activity: '.Settings$NotificationAppListActivity',226 waitDuration: START_APP_WAIT_DURATION,227 });228 let {appPackage, appActivity} = await adb.getFocusedPackageAndActivity();229 appPackage.should.equal('com.android.settings');230 appActivity.should.equal('.Settings$NotificationAppListActivity');231 });232 it('getFocusedPackageAndActivity should be able get package and activity', async function () {233 // The test sometimes fails due to Emulator slowness on Travis234 this.retries(2);235 await adb.install(contactManagerPath, {236 grantPermissions: true237 });238 await adb.startApp({239 pkg: 'com.example.android.contactmanager',240 activity: 'ContactManager',241 waitDuration: START_APP_WAIT_DURATION,242 });243 await assertPackageAndActivity();244 });245 it('extractStringsFromApk should get strings for default language', async function () {246 let {apkStrings} = await adb.extractStringsFromApk(contactManagerPath, null, '/tmp');247 apkStrings.save.should.equal('Save');248 });249 it('extractStringsFromApk should get strings for non-default language', async function () {250 let {apkStrings} = await adb.extractStringsFromApk(apiDemosPath, 'fr', '/tmp');251 apkStrings.linear_layout_8_horizontal.should.equal('Horizontal');252 });253 it('extractStringsFromApk should get strings for en language', async function () {254 let {apkStrings} = await adb.extractStringsFromApk(apiDemosPath, 'en', '/tmp');255 apkStrings.linear_layout_8_horizontal.should.equal('Horizontal');256 });...

Full Screen

Full Screen

grantPermissions.spec.js

Source:grantPermissions.spec.js Github

copy

Full Screen

...58 event.removeAllListeners();59 });60 const permissionId = PERMISSION_ID_CAMERA;61 it('should resolve with TRUE when the permissions are granted', async () => {62 const granted = await grantPermissions({ permissionId })(dispatch);63 expect(granted).toBe(true);64 expect(getAppPermissions).toHaveBeenCalledWith([permissionId]);65 expect(requestAppPermissions).not.toHaveBeenCalled();66 expect(dispatch).not.toHaveBeenCalled();67 expect(openAppSettings).not.toHaveBeenCalled();68 expect(event.addCallbackSpy).not.toHaveBeenCalled();69 });70 it('should resolve with FALSE when called with an invalid permissionId', async () => {71 const granted = await grantPermissions({ permissionId: 'unknownId' })(dispatch);72 expect(granted).toBe(false);73 expect(getAppPermissions).not.toHaveBeenCalled();74 expect(requestAppPermissions).not.toHaveBeenCalled();75 expect(dispatch).not.toHaveBeenCalled();76 expect(openAppSettings).not.toHaveBeenCalled();77 expect(event.addCallbackSpy).not.toHaveBeenCalled();78 expect(logger.error).toHaveBeenCalledTimes(1);79 });80 it('should resolve with FALSE when the permissions are not supported', async () => {81 getAppPermissions.mockResolvedValueOnce(getPermissionsResponse(STATUS_NOT_SUPPORTED));82 const granted = await grantPermissions({ permissionId })(dispatch);83 expect(granted).toBe(false);84 expect(getAppPermissions).toHaveBeenCalledWith([permissionId]);85 expect(requestAppPermissions).not.toHaveBeenCalled();86 expect(dispatch).not.toHaveBeenCalled();87 expect(openAppSettings).not.toHaveBeenCalled();88 expect(event.addCallbackSpy).not.toHaveBeenCalled();89 expect(logger.error).not.toHaveBeenCalled();90 });91 it('should resolve with TRUE when the permissions where not determined, but the user granted them', async () => {92 getAppPermissions.mockResolvedValueOnce(getPermissionsResponse(STATUS_NOT_DETERMINED));93 const granted = await grantPermissions({ permissionId })(dispatch);94 expect(granted).toBe(true);95 expect(getAppPermissions).toHaveBeenCalledWith([permissionId]);96 expect(requestAppPermissions).toHaveBeenCalledWith([{ permissionId }]);97 expect(dispatch).not.toHaveBeenCalled();98 expect(openAppSettings).not.toHaveBeenCalled();99 expect(event.addCallbackSpy).not.toHaveBeenCalled();100 expect(logger.error).not.toHaveBeenCalled();101 });102 it('should resolve with FALSE when the permissions where not determined, and the user denied them', async () => {103 getAppPermissions.mockResolvedValueOnce(getPermissionsResponse(STATUS_NOT_DETERMINED));104 requestAppPermissions.mockResolvedValue(getPermissionsResponse(STATUS_DENIED));105 const granted = await grantPermissions({ permissionId })(dispatch);106 expect(granted).toBe(false);107 expect(dispatch).not.toHaveBeenCalled();108 expect(openAppSettings).not.toHaveBeenCalled();109 expect(event.addCallbackSpy).not.toHaveBeenCalled();110 expect(logger.error).not.toHaveBeenCalled();111 });112 it('should resolve with FALSE when the permissions where not determined, and the user denied them temporary', async () => {113 getAppPermissions.mockResolvedValueOnce(getPermissionsResponse(STATUS_NOT_DETERMINED));114 requestAppPermissions.mockResolvedValue(getPermissionsResponse(STATUS_NOT_DETERMINED));115 const granted = await grantPermissions({ permissionId })(dispatch);116 expect(granted).toBe(false);117 expect(dispatch).not.toHaveBeenCalled();118 expect(openAppSettings).not.toHaveBeenCalled();119 expect(event.addCallbackSpy).not.toHaveBeenCalled();120 expect(logger.error).not.toHaveBeenCalled();121 });122 it('should resolve with FALSE when the permissions are denied, and no settings modal is about to be shown', async () => {123 getAppPermissions.mockResolvedValueOnce(getPermissionsResponse(STATUS_DENIED));124 const granted = await grantPermissions({ permissionId })(dispatch);125 expect(granted).toBe(false);126 expect(dispatch).not.toHaveBeenCalled();127 expect(openAppSettings).not.toHaveBeenCalled();128 expect(event.addCallbackSpy).not.toHaveBeenCalled();129 expect(logger.error).not.toHaveBeenCalled();130 });131 it('should resolve with FALSE when the user denied to open the app settings', async () => {132 getAppPermissions.mockResolvedValueOnce(getPermissionsResponse(STATUS_DENIED));133 showModal.mockResolvedValueOnce(false);134 const granted = await grantPermissions({135 permissionId,136 useSettingsModal: true,137 modal: customModalOptions,138 })(dispatch);139 expect(granted).toBe(false);140 expect(dispatch).toHaveBeenCalledTimes(1);141 expect(showModal).toHaveBeenCalledWith({142 title: null,143 ...customModalOptions,144 });145 expect(openAppSettings).not.toHaveBeenCalled();146 expect(event.addCallbackSpy).not.toHaveBeenCalled();147 });148 it('should resolve with FALSE when the user opened the settings, but did not grant permissions', (done) => {149 getAppPermissions.mockResolvedValueOnce(getPermissionsResponse(STATUS_DENIED));150 getAppPermissions.mockResolvedValueOnce(getPermissionsResponse(STATUS_DENIED));151 grantPermissions({152 permissionId,153 useSettingsModal: true,154 })(dispatch)155 .then((granted) => {156 expect(granted).toBe(false);157 expect(dispatch).toHaveBeenCalledTimes(1);158 expect(openAppSettings).toHaveBeenCalledTimes(1);159 expect(event.removeCallbackSpy).toHaveBeenCalledWith(160 APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,161 expect.any(Function)162 );163 done();164 });165 // Flush the promise queue, so that the code inside of promise from the action is executed.166 flushPromises().then(() => {167 event.call(APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND);168 jest.runAllTimers();169 });170 });171 it('should resolve with TRUE when the user opened the settings, and granted permissions', (done) => {172 getAppPermissions.mockResolvedValueOnce(getPermissionsResponse(STATUS_DENIED));173 getAppPermissions.mockResolvedValueOnce(getPermissionsResponse(STATUS_GRANTED));174 grantPermissions({175 permissionId,176 useSettingsModal: true,177 })(dispatch)178 .then((granted) => {179 expect(granted).toBe(true);180 expect(dispatch).toHaveBeenCalledTimes(1);181 expect(openAppSettings).toHaveBeenCalledTimes(1);182 expect(event.removeCallbackSpy).toHaveBeenCalledWith(183 APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,184 expect.any(Function)185 );186 done();187 });188 // Flush the promise queue, so that the code inside of promise from the action is executed....

Full Screen

Full Screen

permissionReducer.spec.js

Source:permissionReducer.spec.js Github

copy

Full Screen

...34describe('(Reducer/Action Creator) permission', () => {35// grantPermissions reducer36 it('should handle REQUEST_GET_GRANT_PERMISSION', () => {37 expect(38 grantPermissions(undefined, requestGetGrantPermissions())39 ).to.deep.equal({40 ...initialState.grantPermissions,41 isGetting: true42 });43 });44 it('should handle COMPLETE_GET_GRANT_PERMISSION', () => {45 const mockPayload = 'something';46 expect(47 grantPermissions(undefined, completeGetGrantPermissions(mockPayload))48 ).to.deep.equal({49 ...initialState.grantPermissions,50 isGetting: false,51 grantedPermissions: mockPayload52 });53 });54 it('should handle REQUEST_POST_GRANT_PERMISSION', () => {55 expect(56 grantPermissions(undefined, requestPostGrantPermission())57 ).to.deep.equal({58 ...initialState.grantPermissions,59 isPosting: true60 });61 });62 it('should handle COMPLETE_POST_GRANT_PERMISSION', () => {63 const mockPayload = 'something';64 expect(65 grantPermissions(undefined, completePostGrantPermission(mockPayload))66 ).to.deep.equal({67 ...initialState.grantPermissions,68 isPosting: false,69 response: mockPayload70 });71 });72 it('should handle REQUEST_DELETE_GRANT_PERMISSION', () => {73 expect(74 grantPermissions(undefined, requestDeleteGrantPermission())75 ).to.deep.equal({76 ...initialState.grantPermissions77 });78 });79 it('should handle COMPLETE_DELETE_GRANT_PERMISSION', () => {80 const mockPayload = 'something';81 expect(82 grantPermissions(undefined, completeDeleteGrantPermission(mockPayload))83 ).to.deep.equal({84 ...initialState.grantPermissions,85 grantedPermissions: mockPayload86 });87 });88// receivedPermissionOffers reducer89 it('should handle REQUEST_GET_RECEIVED_PERMISSION_OFFERS', () => {90 expect(91 receivedPermissionOffers(undefined, requestGetReceivedPermissionOffers())92 ).to.deep.equal({93 ...initialState.receivedPermissionOffers,94 isGetting: true95 });96 });...

Full Screen

Full Screen

grantPermissions.js

Source:grantPermissions.js Github

copy

Full Screen

1const test = require('tape')2const CapabilitiesController = require('../dist').CapabilitiesController3const equal = require('fast-deep-equal')4const uuid = require('uuid/v4')5// TODO: Standardize!6// Maybe submit to https://github.com/ethereum/wiki/wiki/JSON-RPC-Error-Codes-Improvement-Proposal7const USER_REJECTION_CODE = 58test('grantPermissions with no permission creates no permissions', async (t) => {9 const expected = []10 const ctrl = new CapabilitiesController({11 requestUserApproval: noop,12 })13 const domain = 'login.metamask.io'14 const otherDomain = 'other.domain.com'15 let req = {16 method: 'grantPermissions',17 params: [18 otherDomain,19 [20 {21 method: 'restricted',22 },23 ],24 ]25 }26 let res = {}27 ctrl.providerMiddlewareFunction(domain, req, res, next, end)28 function next() {29 t.ok(false, 'next should not be called')30 t.end()31 }32 function end(reason) {33 t.ok(reason, 'error thrown')34 t.equal(reason.code, 1, 'Auth error returned')35 t.ok(equal(ctrl.getPermissionsForDomain(otherDomain), expected), 'should have no permissions still')36 t.ok(equal(ctrl.getPermissionsForDomain(domain), expected), 'should have no permissions still')37 t.end()38 }39})40test('grantPermissions with permission creates permission', async (t) => {41 const expected = {42 domains: {43 'login.metamask.io': {44 permissions: [45 {46 method: 'restricted',47 date: '0',48 }49 ]50 },51 'other.domain.com': {52 permissions: [53 {54 method: 'restricted',55 granter: 'login.metamask.io',56 }57 ]58 }59 }60 }61 const ctrl = new CapabilitiesController({62 requestUserApproval: noop,63 },64 {65 domains: {66 'login.metamask.io': {67 permissions: [68 {69 method: 'restricted',70 date: '0',71 }72 ],73 }74 }75 })76 const granter = 'login.metamask.io'77 const grantee = 'other.domain.com'78 let req = {79 method: 'grantPermissions',80 params: [81 grantee,82 [83 {84 method: 'restricted',85 },86 ],87 ]88 }89 let res = {}90 ctrl.providerMiddlewareFunction(granter, req, res, next, end)91 function next() {92 t.ok(false, 'next should not be called')93 t.end()94 }95 function end(reason) {96 t.error(reason, 'error should not be thrown')97 t.notOk(reason, 'should throw no error')98 t.notOk(res.error, 'should assign no error')99 const granteePerms = ctrl.getPermissionsForDomain(grantee)100 t.ok(granteePerms[0].method === req.params[1][0].method, 'The requested permission was created.')101 t.end()102 }103})104test('grantPermissions with permission whose granter does not exist results in auth error', async (t) => {105 const ctrl = new CapabilitiesController({106 requestUserApproval: noop,107 },108 {109 domains: {110 'login.metamask.io': {111 permissions: [112 {113 method: 'restricted',114 granter: 'other.granter2.io',115 date: '0',116 }117 ],118 }119 }120 })121 const domain = 'login.metamask.io'122 const otherDomain = 'other.domain.com'123 let req = {124 method: 'grantPermissions',125 params: [126 otherDomain,127 [128 {129 method: 'restricted',130 },131 ],132 ]133 }134 let res = {}135 ctrl.providerMiddlewareFunction(domain, req, res, next, end)136 function next() {137 t.ok(false, 'next should not be called')138 t.end()139 }140 function end(reason) {141 t.ok(reason, 'error thrown')142 t.equal(reason.code, 1, 'Auth error returned')143 t.end()144 }145})146test('grantPermissions accumulates the same permission from different granters', async (t) => {147 const grantee = 'login.metamask.io'148 const granter1 = 'xyz.co.uk'149 const granter2 = 'abc.se'150 const expected = [151 {152 method: 'restricted',153 date: '0',154 granter: granter1,155 },156 {157 method: 'restricted',158 date: '0',159 granter: granter2,160 }161 ]162 const ctrl = new CapabilitiesController({163 requestUserApproval: noop,164 },165 {166 domains: {167 [grantee]: {168 permissions: [169 {170 method: 'restricted',171 date: '0',172 granter: granter1,173 }174 ],175 },176 [granter2]: {177 permissions: [178 {179 method: 'restricted',180 date: '0',181 }182 ],183 },184 }185 })186 let req = {187 method: 'grantPermissions',188 params: [189 grantee,190 [191 {192 method: 'restricted',193 },194 ],195 ]196 }197 let res = {}198 ctrl.providerMiddlewareFunction(granter2, req, res, next, end)199 function next() {200 t.ok(false, 'next should not be called')201 t.end()202 }203 function end(reason) {204 t.error(reason, 'error should not be thrown')205 t.notOk(reason, 'should throw no error')206 t.notOk(res.error, 'should assign no error')207 const otherPerms = ctrl.getPermissionsForDomain(grantee)208 let result209 for (let perm of otherPerms) {210 result = perm.method === 'restricted' && (211 perm.granter === granter1 ||212 perm.granter === granter2213 )214 }215 t.ok(result, 'the requested permission was created')216 t.end()217 }218})219test('grantPermissions replaces duplicate permissions', async (t) => {220 const grantee = 'login.metamask.io'221 const granter = 'xyz.co.uk'222 const oldPerm = {223 method: 'restricted',224 id: uuid(),225 date: Date.now(),226 granter: granter,227 }228 const ctrl = new CapabilitiesController({229 requestUserApproval: noop,230 },231 {232 domains: {233 [grantee]: {234 permissions: [235 oldPerm236 ],237 },238 [granter]: {239 permissions: [240 {241 method: 'restricted',242 date: '0',243 id: uuid(),244 }245 ],246 },247 }248 })249 let req = {250 method: 'grantPermissions',251 params: [252 grantee,253 [254 {255 method: 'restricted'256 },257 ],258 ]259 }260 let res = {}261 ctrl.providerMiddlewareFunction(granter, req, res, next, end)262 function next() {263 t.ok(false, 'next should not be called')264 t.end()265 }266 function end(reason) {267 t.error(reason, 'error should not be thrown')268 t.notOk(reason, 'should throw no error')269 t.notOk(res.error, 'should assign no error')270 const granteePerms = ctrl.getPermissionsForDomain(grantee)271 t.ok(granteePerms.length === 1, 'grantee domain has a single permission')272 const newPerm = granteePerms[0]273 t.ok(274 (275 newPerm.method === oldPerm.method &&276 newPerm.granter === oldPerm.granter &&277 // newPerm.date > oldPerm.date && // becomes identical in test278 newPerm.id !== oldPerm.id279 ), 'the requested permission was created'280 )281 t.end()282 }283})...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import Vue from 'vue'2import Router from 'vue-router'3import HelloWorld from '@/components/HelloWorld'4import index from '@/components/index'5import login from '@/components/login'6import blog from '@/components/blog/blog'7import blogTheme from '@/components/blog/components/blogTheme'8import about from '@/components/about'9import notice from '@/components/notice/index'10import getNotice from '@/components/notice/components/notice'11import getLike from '@/components/notice/components/getLike'12import getRemark from '@/components/notice/components/remark'13import friendsAccept from '@/components/notice/components/friendsAccept'14import manager from '@/components/managerPermissions/index'15import sendNotice from '@/components/managerPermissions/sendNotice'16import grantPermissions from '@/components/managerPermissions/grantPermissions' 17import dataAnalysis from '@/components/managerPermissions/dataAnalysis'18import schoolData from '@/components/managerPermissions/schoolData'19import onlinePersonData from '@/components/managerPermissions/onlinePersonData'20import chat from '@/components/chat/chat'21import friendChat from '@/components/chat/friendChat'22import collection from '@/components/chat/collection' 23import fileChat from '@/components/chat/fileChat' 24import groupChat from '@/components/chat/groupChat' 25import school from '@/components/school/index'26import examInfo from '@/components/school/components/examInfo'27import examScore from '@/components/school/components/examScore'28import schedule from '@/components/school/components/schedule'29Vue.use(Router)30export default new Router({31 routes: [32 {33 path: '/',34 name: 'index',35 meta: {36 title: '首页'37 },38 component: index39 },40 {41 path: '/login',42 name: 'login',43 meta: {44 title: '登录页面'45 },46 component: login47 },48 {49 path: '/blog',50 name: 'blog',51 meta: {52 title: '动态'53 },54 component: blog,55 children:[]56 },57 {58 path: '/about',59 name: 'about',60 meta: {61 title: '关于'62 },63 component: about64 },65 {66 path: '/notice',67 name: 'notice',68 meta: {69 title: '通知'70 },71 component: notice,72 children:[{73 path:'/getNotice',74 name:'getNotice',75 meta:{76 title:'收到通知'77 },78 component:getNotice79 },80 {81 path:'/getLike',82 name:'getLike',83 meta:{84 title:'收到的赞'85 },86 component:getLike87 },88 {89 path:'/getRemark',90 name:'getRemark',91 meta:{92 title:'收到评论'93 },94 component:getRemark95 },96 {97 path:'/friendsAccept',98 name:'friendsAccept',99 meta:{100 title:'好友验证通知'101 },102 component:friendsAccept103 },104 ]105 },106 {107 path: '/manager',108 name: 'manager',109 meta: {110 title: '管理员权限'111 },112 component: manager,113 children:[{114 path: '/sendNotice',115 name: 'sendNotice',116 meta: {117 title: '发送通知'118 },119 component: sendNotice120 },121 {122 path: '/grantPermissions',123 name: 'grantPermissions',124 meta: {125 title: '授予权限'126 },127 component: grantPermissions128 },129 {130 path: '/dataAnalysis',131 name: 'dataAnalysis',132 meta: {133 title: '用户分布图'134 },135 component: dataAnalysis136 },137 {138 path: '/schoolData',139 name: 'schoolData',140 meta: {141 title: '学校数据柱状图'142 },143 component: schoolData144 },145 {146 path: '/onlinePersonData',147 name: 'onlinePersonData',148 meta: {149 title: '在线人数折线图'150 },151 component: onlinePersonData152 },153 ]154 },155 {156 path:'/blogTheme',157 name:'blogTheme',158 meta:{159 title:'动态背景'160 },161 component: blogTheme 162 },163 {164 path:'/chat',165 name:'chat',166 meta:{167 title:'聊天'168 },169 component: chat, 170 children:[171 {172 path:'/friendChat',173 name:'friendChat',174 meta:{175 title:'好友聊天'176 },177 component: friendChat 178 }, 179 {180 path:'/collection',181 name:'collection',182 meta:{183 title:'收藏'184 },185 component: collection 186 }, 187 {188 path:'/fileChat',189 name:'fileChat',190 meta:{191 title:'文件'192 },193 component: fileChat 194 },195 {196 path:'/groupChat',197 name:'groupChat',198 meta:{199 title:'群聊'200 },201 component: groupChat 202 },203 ] 204 },205 {206 path:'/school',207 name:'school',208 meta:{209 title:'校内服务'210 },211 component: school,212 children:[ 213 {214 path:'/examInfo',215 name:'examInfo',216 meta:{217 title:'考试信息'218 },219 component: examInfo 220 }, 221 {222 path:'/examScore',223 name:'examScore',224 meta:{225 title:'考试成绩'226 },227 component: examScore 228 }, 229 {230 path:'/schedule',231 name:'schedule',232 meta:{233 title:'课程表'234 },235 component: schedule 236 },237 ] 238 },239 240 241 ]...

Full Screen

Full Screen

grantGeolocationPermissions.spec.js

Source:grantGeolocationPermissions.spec.js Github

copy

Full Screen

...8 jest.clearAllMocks();9 });10 it('should dispatch as expected without options', () => {11 const result = grantGeolocationPermissions()(dispatch);12 expect(result).toEqual(grantPermissions());13 expect(dispatch).toHaveBeenCalledTimes(1);14 expect(dispatch).toHaveBeenCalledWith(grantPermissions());15 expect(grantPermissions).toHaveBeenCalledTimes(3);16 expect(grantPermissions).toHaveBeenCalledWith({17 permissionId: PERMISSION_ID_LOCATION,18 useSettingsModal: false,19 modal: {20 title: null,21 message: 'permissions.access_denied.geolocation_message',22 confirm: 'permissions.access_denied.settings_button',23 },24 });25 });26 it('should dispatch as expected with some custom modal options', () => {27 const customModalOptions = {28 title: 'Modal title',29 dismiss: 'Dismiss label',30 };31 const result = grantGeolocationPermissions({32 useSettingsModal: true,33 modal: customModalOptions,34 })(dispatch);35 expect(result).toEqual(grantPermissions());36 expect(dispatch).toHaveBeenCalledTimes(1);37 expect(dispatch).toHaveBeenCalledWith(grantPermissions());38 expect(grantPermissions).toHaveBeenCalledTimes(3);39 expect(grantPermissions).toHaveBeenCalledWith({40 permissionId: PERMISSION_ID_LOCATION,41 useSettingsModal: true,42 modal: {43 title: 'Modal title',44 message: 'permissions.access_denied.geolocation_message',45 confirm: 'permissions.access_denied.settings_button',46 dismiss: 'Dismiss label',47 },48 });49 });50 it('should dispatch as expected with complete custom modal options', () => {51 const customModalOptions = {52 title: 'Modal title',53 message: 'Modal message',54 confirm: 'Confirm label',55 dismiss: 'Dismiss label',56 params: {57 param: 'one',58 },59 };60 const result = grantGeolocationPermissions({61 useSettingsModal: true,62 modal: customModalOptions,63 })(dispatch);64 expect(result).toEqual(grantPermissions());65 expect(dispatch).toHaveBeenCalledTimes(1);66 expect(dispatch).toHaveBeenCalledWith(grantPermissions());67 expect(grantPermissions).toHaveBeenCalledTimes(3);68 expect(grantPermissions).toHaveBeenCalledWith({69 permissionId: PERMISSION_ID_LOCATION,70 useSettingsModal: true,71 modal: customModalOptions,72 });73 });...

Full Screen

Full Screen

grantCameraPermissions.spec.js

Source:grantCameraPermissions.spec.js Github

copy

Full Screen

...8 jest.clearAllMocks();9 });10 it('should dispatch as expected without options', () => {11 const result = grantCameraPermissions()(dispatch);12 expect(result).toEqual(grantPermissions());13 expect(dispatch).toHaveBeenCalledTimes(1);14 expect(dispatch).toHaveBeenCalledWith(grantPermissions());15 expect(grantPermissions).toHaveBeenCalledTimes(3);16 expect(grantPermissions).toHaveBeenCalledWith({17 permissionId: PERMISSION_ID_CAMERA,18 useSettingsModal: false,19 modal: {20 title: null,21 message: 'permissions.access_denied.camera_message',22 confirm: 'permissions.access_denied.settings_button',23 },24 });25 });26 it('should dispatch as expected with some custom modal options', () => {27 const customModalOptions = {28 title: 'Modal title',29 dismiss: 'Dismiss label',30 };31 const result = grantCameraPermissions({32 useSettingsModal: true,33 modal: customModalOptions,34 })(dispatch);35 expect(result).toEqual(grantPermissions());36 expect(dispatch).toHaveBeenCalledTimes(1);37 expect(dispatch).toHaveBeenCalledWith(grantPermissions());38 expect(grantPermissions).toHaveBeenCalledTimes(3);39 expect(grantPermissions).toHaveBeenCalledWith({40 permissionId: PERMISSION_ID_CAMERA,41 useSettingsModal: true,42 modal: {43 title: 'Modal title',44 message: 'permissions.access_denied.camera_message',45 confirm: 'permissions.access_denied.settings_button',46 dismiss: 'Dismiss label',47 },48 });49 });50 it('should dispatch as expected with complete custom modal options', () => {51 const customModalOptions = {52 title: 'Modal title',53 message: 'Modal message',54 confirm: 'Confirm label',55 dismiss: 'Dismiss label',56 params: {57 param: 'one',58 },59 };60 const result = grantCameraPermissions({61 useSettingsModal: true,62 modal: customModalOptions,63 })(dispatch);64 expect(result).toEqual(grantPermissions());65 expect(dispatch).toHaveBeenCalledTimes(1);66 expect(dispatch).toHaveBeenCalledWith(grantPermissions());67 expect(grantPermissions).toHaveBeenCalledTimes(3);68 expect(grantPermissions).toHaveBeenCalledWith({69 permissionId: PERMISSION_ID_CAMERA,70 useSettingsModal: true,71 modal: customModalOptions,72 });73 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const {chromium, webkit, firefox} = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const context = await browser.newContext();5 await context.grantPermissions(['geolocation']);6 const page = await context.newPage();7})();8const {chromium, webkit, firefox} = require('playwright');9(async () => {10 const browser = await chromium.launch({ headless: false });11 const context = await browser.newContext();12 await context.grantPermissions(['geolocation']);13 const page = await context.newPage();14})();15const {chromium, webkit, firefox} = require('playwright');16(async () => {17 const browser = await chromium.launch({ headless: false });18 const context = await browser.newContext();19 await context.grantPermissions(['geolocation']);20 const page = await context.newPage();21})();22const {chromium, webkit, firefox} = require('playwright');23(async () => {24 const browser = await chromium.launch({ headless: false });25 const context = await browser.newContext();26 await context.grantPermissions(['geolocation']);27 const page = await context.newPage();28})();29const {chromium, webkit, firefox} = require('playwright');30(async () => {31 const browser = await chromium.launch({ headless: false });32 const context = await browser.newContext();33 await context.grantPermissions(['geolocation']);34 const page = await context.newPage();35})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { grantPermissions } = require('@playwright/test/lib/server/permissions');2const { chromium } = require('@playwright/test');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 await grantPermissions(['geolocation'], context);7 const page = await context.newPage();8 await page.click('text="Your location"');9 await page.waitForTimeout(10000);10 await browser.close();11})();

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = async function (context, req) {2 context.log('JavaScript HTTP trigger function processed a request.');3 const { chromium } = require('playwright');4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await context.grantPermissions(['geolocation']);8 await page.screenshot({ path: 'geolocation.png' });9 await browser.close();10 context.res = {11 body: "Hello " + (req.query.name || req.body.name)12 };13}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { grantPermissions } = require('playwright/lib/server/chromium/crBrowser');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 const context = await browser.newContext();6 await grantPermissions(context, ['geolocation']);7 await page.waitForTimeout(3000);8 await page.close();9 await context.close();10 await browser.close();11})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2const path = require('path');3const fs = require('fs');4const { devices } = require('playwright');5(async () => {6 const browser = await playwright['chromium'].launch({ headless: false });7 const context = await browser.newContext({8 geolocation: { latitude: 52.5200, longitude: 13.4050 },9 });10 const page = await context.newPage();11 await page.waitForTimeout(5000);12 await browser.close();13})();14const playwright = require('playwright');15const path = require('path');16const fs = require('fs');17const { devices } = require('playwright');18(async () => {19 const browser = await playwright['chromium'].launch({ headless: false });20 const context = await browser.newContext({21 geolocation: { latitude: 52.5200, longitude: 13.4050 },22 });23 const page = await context.newPage();24 await page.waitForTimeout(5000);25 await browser.close();26})();27I think this is a bug, but I’m not sure. I’m trying to use the grantPermissions method of the Playwright internal API to set geolocation permissions for iOS. However, it doesn’t seem to work. I’ve tried a few different things, but I’m not getting any errors. I’ve tried using the permissions: ['geolocation'] option in the context, and I’ve tried using the grantPermissions method. Neither of them seem to work. I’ve also tried using the geolocation option in the context, but that doesn’t seem to work either. I’ve tried using the iPhone 11 Pro, iPhone 11, and iPhone 12 Pro Max. I’ve also tried using the iPad Pro (11-inch) (2nd generation), iPad Pro (12.9-inch) (4th generation), and iPad Pro (12.9-inch) (5th generation). None of them seem to work. Is there something I’m missing? Is this a bug? If so, is there a

Full Screen

Using AI Code Generation

copy

Full Screen

1import { grantPermissions } from '@playwright/test';2await grantPermissions(['clipboard-read', 'clipboard-write']);3import { chromium } from 'playwright';4const browser = await chromium.launch({ headless: false });5const context = await browser.newContext({6});7const page = await context.newPage();8import { chromium } from 'playwright';9const browser = await chromium.launch({ headless: false });10const context = await browser.newContext({11});12const page = await context.newPage();13import { grantPermissions } from '@playwright/test';14await grantPermissions(['clipboard-read', 'clipboard-write']);15import { grantPermissions } from '@playwright/test';16await grantPermissions(['clipboard-read', 'clipboard-write']);17import { chromium } from 'playwright';18const browser = await chromium.launch({ headless: false });19const context = await browser.newContext({20});21const page = await context.newPage();22import { chromium } from 'playwright';23const browser = await chromium.launch({ headless: false });24const context = await browser.newContext({25});26const page = await context.newPage();27import { grantPermissions } from '@playwright/test';28await grantPermissions(['clipboard-read', 'clipboard-write']);29import { grantPermissions } from '@playwright/test';30await grantPermissions(['clipboard-read', 'clipboard-write']);31import { chromium } from 'playwright';32const browser = await chromium.launch({ headless: false });33const context = await browser.newContext({

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const context = await chromium.launchPersistentContext('userDataDir', {3 });4await context.grantPermissions(['geolocation']);5await context.close();6const { chromium } = require('playwright');7const context = await chromium.launchPersistentContext('userDataDir', {8 });9await context.grantPermissions(['geolocation']);10await context.close();11const { chromium } = require('playwright');12const context = await chromium.launchPersistentContext('userDataDir', {13 geolocation: { latitude: 59.95, longitude: 30.31667 },14 });15await context.close();16const { chromium } = require('playwright');17const context = await chromium.launchPersistentContext('userDataDir', {18 geolocation: { latitude: 59.95, longitude: 30.31667 },19 });20await context.close();21const { chromium } = require('playwright');22const context = await chromium.launchPersistentContext('userDataDir', {23 geolocation: { latitude: 59.95, longitude: 30.31667 },24 });25await context.close();26const { chromium } = require('playwright');27const context = await chromium.launchPersistentContext('userDataDir', {28 geolocation: { latitude: 59.95, longitude: 30.31667 },29 });30await context.close();31const { chromium } = require('playwright');32const context = await chromium.launchPersistentContext('userDataDir', {33 geolocation: { latitude: 59.95, longitude: 30.31667 },34 });35await context.close();36const { chromium } = require('playwright');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext({5 });6 const page = await context.newPage();7})();8const { chromium } = require('playwright');9(async () => {10 const browser = await chromium.launch();11 const context = await browser.newContext({12 });13 const page = await context.newPage();14})();15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launch();18 const context = await browser.newContext({19 });20 const page = await context.newPage();21})();22const { chromium } = require('playwright');23(async () => {24 const browser = await chromium.launch();25 const context = await browser.newContext({26 });27 const page = await context.newPage();28})();29const { chromium } = require('playwright');30(async () => {31 const browser = await chromium.launch();32 const context = await browser.newContext({33 });34 const page = await context.newPage();35})();36const { chromium } = require('playwright');37(async () => {38 const browser = await chromium.launch();

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful