Dmitrii Filippov | 06117e8 | 2020-06-25 13:26:55 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @license |
Ben Rohlfs | 94fcbbc | 2022-05-27 10:45:03 +0200 | [diff] [blame] | 3 | * Copyright 2018 Google LLC |
| 4 | * SPDX-License-Identifier: Apache-2.0 |
Dmitrii Filippov | 06117e8 | 2020-06-25 13:26:55 +0200 | [diff] [blame] | 5 | */ |
Frank Borden | e1ba821 | 2022-08-29 15:20:01 +0200 | [diff] [blame] | 6 | import {assert} from '@open-wc/testing'; |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 7 | import {AccountDetailInfo, GroupId, RepoName, Timestamp} from '../api/rest-api'; |
Frank Borden | be9451a | 2022-09-12 15:44:29 +0200 | [diff] [blame] | 8 | import '../test/common-test-setup'; |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 9 | import {AdminNavLinksOption, getAdminLinks} from './admin-nav-util'; |
Dmitrii Filippov | 06117e8 | 2020-06-25 13:26:55 +0200 | [diff] [blame] | 10 | |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 11 | suite('gr-admin-nav-behavior tests', () => { |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 12 | let capabilityStub: sinon.SinonStub; |
| 13 | let menuLinkStub: sinon.SinonStub; |
Becky Siegel | cad4bf8 | 2018-04-18 16:43:05 +0200 | [diff] [blame] | 14 | |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 15 | setup(() => { |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 16 | capabilityStub = sinon.stub(); |
| 17 | menuLinkStub = sinon.stub().returns([]); |
| 18 | }); |
| 19 | |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 20 | const testAdminLinks = async ( |
| 21 | account: AccountDetailInfo | undefined, |
| 22 | options: AdminNavLinksOption | undefined, |
| 23 | expected: any |
| 24 | ) => { |
| 25 | const res = await getAdminLinks( |
| 26 | account, |
| 27 | capabilityStub, |
| 28 | menuLinkStub, |
| 29 | options |
| 30 | ); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 31 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 32 | assert.equal(expected.totalLength, res.links.length); |
| 33 | assert.equal(res.links[0].name, 'Repositories'); |
| 34 | // Repos |
| 35 | if (expected.groupListShown) { |
| 36 | assert.equal(res.links[1].name, 'Groups'); |
| 37 | } |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 38 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 39 | if (expected.pluginListShown) { |
| 40 | assert.equal(res.links[2].name, 'Plugins'); |
| 41 | assert.isNotOk(res.links[2].subsection); |
| 42 | } |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 43 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 44 | if (expected.projectPageShown) { |
| 45 | assert.isOk(res.links[0].subsection); |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 46 | assert.equal(res.links[0].subsection!.children!.length, 6); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 47 | } else { |
| 48 | assert.isNotOk(res.links[0].subsection); |
| 49 | } |
| 50 | // Groups |
| 51 | if (expected.groupPageShown) { |
| 52 | assert.isOk(res.links[1].subsection); |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 53 | assert.equal( |
| 54 | res.links[1].subsection!.children!.length, |
| 55 | expected.groupSubpageLength |
| 56 | ); |
| 57 | } else if (expected.totalLength > 1) { |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 58 | assert.isNotOk(res.links[1].subsection); |
| 59 | } |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 60 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 61 | if (expected.pluginGeneratedLinks) { |
| 62 | for (const link of expected.pluginGeneratedLinks) { |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 63 | const linkMatch = res.links.find( |
| 64 | l => l.url === link.url && l.name === link.text |
| 65 | ); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 66 | assert.isTrue(!!linkMatch); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 67 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 68 | // External links should open in new tab. |
| 69 | if (link.url[0] !== '/') { |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 70 | assert.equal(linkMatch!.target, '_blank'); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 71 | } else { |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 72 | assert.isNotOk(linkMatch!.target); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | // Current section |
| 78 | if (expected.projectPageShown || expected.groupPageShown) { |
| 79 | assert.isOk(res.expandedSection); |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 80 | assert.isOk(res.expandedSection!.children); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 81 | } else { |
| 82 | assert.isNotOk(res.expandedSection); |
| 83 | } |
| 84 | if (expected.projectPageShown) { |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 85 | assert.equal(res.expandedSection!.name, 'my-repo'); |
| 86 | assert.equal(res.expandedSection!.children!.length, 6); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 87 | } else if (expected.groupPageShown) { |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 88 | assert.equal(res.expandedSection!.name, 'my-group'); |
| 89 | assert.equal( |
| 90 | res.expandedSection!.children!.length, |
| 91 | expected.groupSubpageLength |
| 92 | ); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 93 | } |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | suite('logged out', () => { |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 97 | let account: AccountDetailInfo; |
| 98 | let expected: any; |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 99 | |
| 100 | setup(() => { |
| 101 | expected = { |
| 102 | groupListShown: false, |
| 103 | groupPageShown: false, |
| 104 | pluginListShown: false, |
| 105 | }; |
| 106 | }); |
| 107 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 108 | test('without a specific repo or group', async () => { |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 109 | let options; |
| 110 | expected = Object.assign(expected, { |
| 111 | totalLength: 1, |
| 112 | projectPageShown: false, |
| 113 | }); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 114 | await testAdminLinks(account, options, expected); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 115 | }); |
| 116 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 117 | test('with a repo', async () => { |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 118 | const options = {repoName: 'my-repo' as RepoName}; |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 119 | expected = Object.assign(expected, { |
| 120 | totalLength: 1, |
| 121 | projectPageShown: true, |
| 122 | }); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 123 | await testAdminLinks(account, options, expected); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 124 | }); |
| 125 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 126 | test('with plugin generated links', async () => { |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 127 | let options; |
| 128 | const generatedLinks = [ |
| 129 | {text: 'internal link text', url: '/internal/link/url'}, |
| 130 | {text: 'external link text', url: 'http://external/link/url'}, |
| 131 | ]; |
| 132 | menuLinkStub.returns(generatedLinks); |
| 133 | expected = Object.assign(expected, { |
| 134 | totalLength: 3, |
| 135 | projectPageShown: false, |
| 136 | pluginGeneratedLinks: generatedLinks, |
| 137 | }); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 138 | await testAdminLinks(account, options, expected); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 139 | }); |
| 140 | }); |
| 141 | |
| 142 | suite('no plugin capability logged in', () => { |
| 143 | const account = { |
| 144 | name: 'test-user', |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 145 | registered_on: '' as Timestamp, |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 146 | }; |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 147 | let expected: any; |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 148 | |
| 149 | setup(() => { |
| 150 | expected = { |
| 151 | totalLength: 2, |
| 152 | pluginListShown: false, |
| 153 | }; |
| 154 | capabilityStub.returns(Promise.resolve({})); |
| 155 | }); |
| 156 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 157 | test('without a specific project or group', async () => { |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 158 | let options; |
| 159 | expected = Object.assign(expected, { |
| 160 | projectPageShown: false, |
| 161 | groupListShown: true, |
| 162 | groupPageShown: false, |
| 163 | }); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 164 | await testAdminLinks(account, options, expected); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 165 | }); |
| 166 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 167 | test('with a repo', async () => { |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 168 | const account = { |
| 169 | name: 'test-user', |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 170 | registered_on: '' as Timestamp, |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 171 | }; |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 172 | const options = {repoName: 'my-repo' as RepoName}; |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 173 | expected = Object.assign(expected, { |
| 174 | projectPageShown: true, |
| 175 | groupListShown: true, |
| 176 | groupPageShown: false, |
| 177 | }); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 178 | await testAdminLinks(account, options, expected); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 179 | }); |
| 180 | }); |
| 181 | |
| 182 | suite('view plugin capability logged in', () => { |
| 183 | const account = { |
| 184 | name: 'test-user', |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 185 | registered_on: '' as Timestamp, |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 186 | }; |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 187 | let expected: any; |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 188 | |
| 189 | setup(() => { |
| 190 | capabilityStub.returns(Promise.resolve({viewPlugins: true})); |
| 191 | expected = { |
| 192 | totalLength: 3, |
| 193 | groupListShown: true, |
| 194 | pluginListShown: true, |
| 195 | }; |
| 196 | }); |
| 197 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 198 | test('without a specific repo or group', async () => { |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 199 | let options; |
| 200 | expected = Object.assign(expected, { |
| 201 | projectPageShown: false, |
| 202 | groupPageShown: false, |
| 203 | }); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 204 | await testAdminLinks(account, options, expected); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 205 | }); |
| 206 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 207 | test('with a repo', async () => { |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 208 | const options = {repoName: 'my-repo' as RepoName}; |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 209 | expected = Object.assign(expected, { |
| 210 | projectPageShown: true, |
| 211 | groupPageShown: false, |
| 212 | }); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 213 | await testAdminLinks(account, options, expected); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 214 | }); |
| 215 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 216 | test('admin with internal group', async () => { |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 217 | const options = { |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 218 | groupId: 'a15262' as GroupId, |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 219 | groupName: 'my-group', |
| 220 | groupIsInternal: true, |
| 221 | isAdmin: true, |
| 222 | groupOwner: false, |
| 223 | }; |
| 224 | expected = Object.assign(expected, { |
| 225 | projectPageShown: false, |
| 226 | groupPageShown: true, |
| 227 | groupSubpageLength: 2, |
| 228 | }); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 229 | await testAdminLinks(account, options, expected); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 230 | }); |
| 231 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 232 | test('group owner with internal group', async () => { |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 233 | const options = { |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 234 | groupId: 'a15262' as GroupId, |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 235 | groupName: 'my-group', |
| 236 | groupIsInternal: true, |
| 237 | isAdmin: false, |
| 238 | groupOwner: true, |
| 239 | }; |
| 240 | expected = Object.assign(expected, { |
| 241 | projectPageShown: false, |
| 242 | groupPageShown: true, |
| 243 | groupSubpageLength: 2, |
| 244 | }); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 245 | await testAdminLinks(account, options, expected); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 246 | }); |
| 247 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 248 | test('non owner or admin with internal group', async () => { |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 249 | const options = { |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 250 | groupId: 'a15262' as GroupId, |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 251 | groupName: 'my-group', |
| 252 | groupIsInternal: true, |
| 253 | isAdmin: false, |
| 254 | groupOwner: false, |
| 255 | }; |
| 256 | expected = Object.assign(expected, { |
| 257 | projectPageShown: false, |
| 258 | groupPageShown: true, |
| 259 | groupSubpageLength: 1, |
| 260 | }); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 261 | await testAdminLinks(account, options, expected); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 262 | }); |
| 263 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 264 | test('admin with external group', async () => { |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 265 | const options = { |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 266 | groupId: 'a15262' as GroupId, |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 267 | groupName: 'my-group', |
| 268 | groupIsInternal: false, |
| 269 | isAdmin: true, |
| 270 | groupOwner: true, |
| 271 | }; |
| 272 | expected = Object.assign(expected, { |
| 273 | projectPageShown: false, |
| 274 | groupPageShown: true, |
| 275 | groupSubpageLength: 0, |
| 276 | }); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 277 | await testAdminLinks(account, options, expected); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 278 | }); |
| 279 | }); |
| 280 | |
| 281 | suite('view plugin screen with plugin capability', () => { |
| 282 | const account = { |
| 283 | name: 'test-user', |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 284 | registered_on: '' as Timestamp, |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 285 | }; |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 286 | let expected: any; |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 287 | |
| 288 | setup(() => { |
| 289 | capabilityStub.returns(Promise.resolve({pluginCapability: true})); |
| 290 | expected = {}; |
| 291 | }); |
| 292 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 293 | test('with plugin with capabilities', async () => { |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 294 | let options; |
| 295 | const generatedLinks = [ |
| 296 | {text: 'without capability', url: '/without'}, |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 297 | {text: 'with capability', url: '/with', capability: 'pluginCapability'}, |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 298 | ]; |
| 299 | menuLinkStub.returns(generatedLinks); |
| 300 | expected = Object.assign(expected, { |
| 301 | totalLength: 4, |
| 302 | pluginGeneratedLinks: generatedLinks, |
| 303 | }); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 304 | await testAdminLinks(account, options, expected); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 305 | }); |
| 306 | }); |
| 307 | |
| 308 | suite('view plugin screen without plugin capability', () => { |
| 309 | const account = { |
| 310 | name: 'test-user', |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 311 | registered_on: '' as Timestamp, |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 312 | }; |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 313 | let expected: any; |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 314 | |
| 315 | setup(() => { |
| 316 | capabilityStub.returns(Promise.resolve({})); |
| 317 | expected = {}; |
| 318 | }); |
| 319 | |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 320 | test('with plugin with capabilities', async () => { |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 321 | let options; |
| 322 | const generatedLinks = [ |
| 323 | {text: 'without capability', url: '/without'}, |
paladox | 914529e | 2022-03-02 15:16:35 +0000 | [diff] [blame] | 324 | {text: 'with capability', url: '/with', capability: 'pluginCapability'}, |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 325 | ]; |
| 326 | menuLinkStub.returns(generatedLinks); |
| 327 | expected = Object.assign(expected, { |
| 328 | totalLength: 3, |
| 329 | pluginGeneratedLinks: [generatedLinks[0]], |
| 330 | }); |
Chris Poucet | a2e173e | 2021-08-31 01:04:04 +0000 | [diff] [blame] | 331 | await testAdminLinks(account, options, expected); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 332 | }); |
| 333 | }); |
| 334 | }); |