Skip to content

Commit 73a7654

Browse files
committed
tests: Preload TEST_URL
to get the correct title and follow redirects Signed-off-by: Marcel Klehr <[email protected]>
1 parent 2c6f6ad commit 73a7654

File tree

1 file changed

+83
-55
lines changed

1 file changed

+83
-55
lines changed

src/test/test.js

Lines changed: 83 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5360,6 +5360,20 @@ describe('Floccus', function() {
53605360
return
53615361
}
53625362
let account
5363+
let TEST_URL_TITLE
5364+
before(async function() {
5365+
// Set up TEST_URL and TEST_URL_TITLE
5366+
await browser.tabs.create({
5367+
index: 1,
5368+
url: TEST_URL
5369+
})
5370+
await awaitTabsUpdated()
5371+
const tabs = await browser.tabs.query()
5372+
const tab = tabs.filter(tab => tab.url.startsWith('http'))[0]
5373+
TEST_URL = tab.url
5374+
TEST_URL_TITLE = tab.title
5375+
await browser.tabs.remove(tab.id)
5376+
})
53635377
beforeEach('set up account', async function() {
53645378
account = await Account.create(ACCOUNT_DATA)
53655379
if (ACCOUNT_DATA.type === 'fake') {
@@ -5443,8 +5457,8 @@ describe('Floccus', function() {
54435457
new Folder({
54445458
title: 'Window 0',
54455459
children: [
5446-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
5447-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
5460+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
5461+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
54485462
]
54495463
})
54505464
]
@@ -5463,7 +5477,7 @@ describe('Floccus', function() {
54635477
location: ItemLocation.SERVER
54645478
}))
54655479
serverMark = {
5466-
title: 'Example Domain',
5480+
title: TEST_URL_TITLE,
54675481
url: TEST_URL + '',
54685482
parentId: windowFolderId,
54695483
location: ItemLocation.SERVER
@@ -5488,7 +5502,7 @@ describe('Floccus', function() {
54885502
new Folder({
54895503
title: 'Window 0',
54905504
children: [
5491-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '' }),
5505+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '' }),
54925506
]
54935507
})
54945508
]
@@ -5521,8 +5535,8 @@ describe('Floccus', function() {
55215535
new Folder({
55225536
title: 'Window 0',
55235537
children: [
5524-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
5525-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
5538+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
5539+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
55265540
]
55275541
})
55285542
]
@@ -5545,8 +5559,8 @@ describe('Floccus', function() {
55455559
new Folder({
55465560
title: 'Window 0',
55475561
children: [
5548-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
5549-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test3' })
5562+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
5563+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test3' })
55505564
]
55515565
})
55525566
]
@@ -5565,7 +5579,7 @@ describe('Floccus', function() {
55655579
location: ItemLocation.SERVER
55665580
}))
55675581
serverMark = {
5568-
title: 'Example Domain',
5582+
title: TEST_URL_TITLE,
55695583
url: TEST_URL + '#test1',
55705584
parentId: windowFolderId,
55715585
location: ItemLocation.SERVER
@@ -5590,7 +5604,7 @@ describe('Floccus', function() {
55905604
new Folder({
55915605
title: 'Window 0',
55925606
children: [
5593-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
5607+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
55945608
]
55955609
})
55965610
]
@@ -5601,7 +5615,7 @@ describe('Floccus', function() {
56015615
let serverMark2
56025616
await withSyncConnection(account, async() => {
56035617
serverMark2 = {
5604-
title: 'Example Domain',
5618+
title: TEST_URL_TITLE,
56055619
url: TEST_URL + '#test3',
56065620
parentId: tree.children[0].id,
56075621
location: ItemLocation.SERVER
@@ -5610,7 +5624,7 @@ describe('Floccus', function() {
56105624
new Bookmark(serverMark2)
56115625
)
56125626

5613-
await adapter.updateBookmark({ ...serverMark, id: serverMarkId, url: TEST_URL + '#test2', title: 'Example Domain', parentId: tree.children[0].id })
5627+
await adapter.updateBookmark({ ...serverMark, id: serverMarkId, url: TEST_URL + '#test2', title: TEST_URL_TITLE, parentId: tree.children[0].id })
56145628
})
56155629

56165630
await account.setData({ strategy: 'slave'})
@@ -5629,8 +5643,8 @@ describe('Floccus', function() {
56295643
new Folder({
56305644
title: 'Window 0',
56315645
children: [
5632-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' }),
5633-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test3' }),
5646+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' }),
5647+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test3' }),
56345648
]
56355649
})
56365650
]
@@ -5652,7 +5666,7 @@ describe('Floccus', function() {
56525666
location: ItemLocation.SERVER
56535667
}))
56545668
serverMark = {
5655-
title: 'Example Domain',
5669+
title: TEST_URL_TITLE,
56565670
url: TEST_URL + '#test1',
56575671
parentId: windowFolderId,
56585672
location: ItemLocation.SERVER
@@ -5677,7 +5691,7 @@ describe('Floccus', function() {
56775691
new Folder({
56785692
title: 'Window 0',
56795693
children: [
5680-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
5694+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
56815695
]
56825696
})
56835697
]
@@ -5688,7 +5702,7 @@ describe('Floccus', function() {
56885702
let serverMark2
56895703
await withSyncConnection(account, async() => {
56905704
serverMark2 = {
5691-
title: 'Example Domain',
5705+
title: TEST_URL_TITLE,
56925706
url: TEST_URL + '#test3',
56935707
parentId: tree.children[0].id,
56945708
location: ItemLocation.SERVER
@@ -5697,7 +5711,7 @@ describe('Floccus', function() {
56975711
new Bookmark(serverMark2)
56985712
)
56995713

5700-
await adapter.updateBookmark({ ...serverMark, id: serverMarkId, url: TEST_URL + '#test2', title: 'Example Domain', parentId: tree.children[0].id })
5714+
await adapter.updateBookmark({ ...serverMark, id: serverMarkId, url: TEST_URL + '#test2', title: TEST_URL_TITLE, parentId: tree.children[0].id })
57015715
})
57025716

57035717
await browser.tabs.create({url: TEST_URL + '#test4'})
@@ -5717,9 +5731,9 @@ describe('Floccus', function() {
57175731
new Folder({
57185732
title: 'Window 0',
57195733
children: [
5720-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' }),
5721-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test3' }),
5722-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test4' }),
5734+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' }),
5735+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test3' }),
5736+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test4' }),
57235737
]
57245738
})
57255739
]
@@ -5733,6 +5747,20 @@ describe('Floccus', function() {
57335747
if (ACCOUNT_DATA.type === 'linkwarden' || ACCOUNT_DATA.type === 'karakeep') {
57345748
return
57355749
}
5750+
let TEST_URL_TITLE
5751+
before(async function() {
5752+
// Set up TEST_URL and TEST_URL_TITLE
5753+
await browser.tabs.create({
5754+
index: 1,
5755+
url: TEST_URL
5756+
})
5757+
await awaitTabsUpdated()
5758+
const tabs = await browser.tabs.query()
5759+
const tab = tabs.filter(tab => tab.url.startsWith('http'))[0]
5760+
TEST_URL = tab.url
5761+
TEST_URL_TITLE = tab.title
5762+
await browser.tabs.remove(tab.id)
5763+
})
57365764
let account
57375765
beforeEach('set up account', async function() {
57385766
account = await Account.create(ACCOUNT_DATA)
@@ -5838,8 +5866,8 @@ describe('Floccus', function() {
58385866
new Folder({
58395867
title: 'Test Group',
58405868
children: [
5841-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
5842-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
5869+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
5870+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
58435871
]
58445872
})
58455873
]
@@ -5879,8 +5907,8 @@ describe('Floccus', function() {
58795907
new Folder({
58805908
title: 'Window 0',
58815909
children: [
5882-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
5883-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
5910+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
5911+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
58845912
]
58855913
})
58865914
]
@@ -5916,8 +5944,8 @@ describe('Floccus', function() {
59165944
new Folder({
59175945
title: 'Test Group',
59185946
children: [
5919-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
5920-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
5947+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
5948+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
59215949
]
59225950
})
59235951
]
@@ -5971,8 +5999,8 @@ describe('Floccus', function() {
59715999
new Folder({
59726000
title: 'Test Group',
59736001
children: [
5974-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
5975-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
6002+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
6003+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
59766004
]
59776005
})
59786006
]
@@ -6000,11 +6028,11 @@ describe('Floccus', function() {
60006028
new Folder({
60016029
title: 'Window 0',
60026030
children: [
6003-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
6031+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
60046032
new Folder({
60056033
title: 'Test Group',
60066034
children: [
6007-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
6035+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
60086036
]
60096037
})
60106038
]
@@ -6067,16 +6095,16 @@ describe('Floccus', function() {
60676095
new Folder({
60686096
title: 'Group 1',
60696097
children: [
6070-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' })
6098+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' })
60716099
]
60726100
}),
60736101
new Folder({
60746102
title: 'Group 2',
60756103
children: [
6076-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
6104+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
60776105
]
60786106
}),
6079-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test3' })
6107+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test3' })
60806108
]
60816109
})
60826110
]
@@ -6105,17 +6133,17 @@ describe('Floccus', function() {
61056133
new Folder({
61066134
title: 'Window 0',
61076135
children: [
6108-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test3' }),
6136+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test3' }),
61096137
new Folder({
61106138
title: 'Group 2',
61116139
children: [
6112-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
6140+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
61136141
]
61146142
}),
61156143
new Folder({
61166144
title: 'Group 1',
61176145
children: [
6118-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' })
6146+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' })
61196147
]
61206148
})
61216149
]
@@ -6155,8 +6183,8 @@ describe('Floccus', function() {
61556183
new Folder({
61566184
title: 'Window 0',
61576185
children: [
6158-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
6159-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
6186+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
6187+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
61606188
]
61616189
})
61626190
]
@@ -6210,8 +6238,8 @@ describe('Floccus', function() {
62106238
new Folder({
62116239
title: 'Server Group',
62126240
children: [
6213-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
6214-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
6241+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
6242+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
62156243
]
62166244
})
62176245
]
@@ -6235,8 +6263,8 @@ describe('Floccus', function() {
62356263
new Folder({
62366264
title: 'Server Group',
62376265
children: [
6238-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
6239-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
6266+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
6267+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
62406268
]
62416269
})
62426270
]
@@ -6290,8 +6318,8 @@ describe('Floccus', function() {
62906318
new Folder({
62916319
title: 'Original Group',
62926320
children: [
6293-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
6294-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
6321+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
6322+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
62956323
]
62966324
})
62976325
]
@@ -6337,8 +6365,8 @@ describe('Floccus', function() {
63376365
new Folder({
63386366
title: 'Renamed Group',
63396367
children: [
6340-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
6341-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
6368+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
6369+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
63426370
]
63436371
})
63446372
]
@@ -6361,8 +6389,8 @@ describe('Floccus', function() {
63616389
new Folder({
63626390
title: 'Renamed Group',
63636391
children: [
6364-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
6365-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
6392+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
6393+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
63666394
]
63676395
})
63686396
]
@@ -6416,8 +6444,8 @@ describe('Floccus', function() {
64166444
new Folder({
64176445
title: 'Test Group',
64186446
children: [
6419-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
6420-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
6447+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
6448+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
64216449
]
64226450
})
64236451
]
@@ -6465,8 +6493,8 @@ describe('Floccus', function() {
64656493
new Folder({
64666494
title: 'Window 0',
64676495
children: [
6468-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
6469-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
6496+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
6497+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
64706498
]
64716499
})
64726500
]
@@ -6484,8 +6512,8 @@ describe('Floccus', function() {
64846512
new Folder({
64856513
title: 'Window 0',
64866514
children: [
6487-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test1' }),
6488-
new Bookmark({ title: 'Example Domain', url: TEST_URL + '#test2' })
6515+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test1' }),
6516+
new Bookmark({ title: TEST_URL_TITLE, url: TEST_URL + '#test2' })
64896517
]
64906518
})
64916519
]

0 commit comments

Comments
 (0)