Browse Source

Update origin selector in tests

simov 7 years ago
parent
commit
958eb09906
5 changed files with 39 additions and 39 deletions
  1. 5 5
      test/origin-add.js
  2. 15 15
      test/origin-csp.js
  3. 8 8
      test/origin-encoding.js
  4. 6 6
      test/origin-match.js
  5. 5 5
      test/utils/defaults.js

+ 5 - 5
test/origin-add.js

@@ -20,35 +20,35 @@ module.exports = ({popup, advanced, content}) => {
       )
       t.equal(
         await advanced.evaluate(() =>
-          document.querySelector('.m-list li:nth-of-type(2) .m-origin').innerText
+          document.querySelector('.m-list li:nth-of-type(1) .m-origin').innerText
         ),
         'http://localhost:3000',
         'origin name should be http://localhost:3000'
       )
       t.strictEqual(
         await advanced.evaluate(() =>
-          document.querySelector('.m-list li:nth-of-type(2) .m-switch').classList.contains('is-checked')
+          document.querySelector('.m-list li:nth-of-type(1) .m-switch').classList.contains('is-checked')
         ),
         false,
         'csp checkbox should be disabled'
       )
       t.equal(
         await advanced.evaluate(() =>
-          document.querySelector('.m-list li:nth-of-type(2) .m-encoding select').value
+          document.querySelector('.m-list li:nth-of-type(1) .m-encoding select').value
         ),
         '',
         'encoding should be set to auto'
       )
       t.strictEqual(
         await advanced.evaluate(() =>
-          document.querySelectorAll('.m-list li:nth-of-type(2) .m-footer .m-button').length
+          document.querySelectorAll('.m-list li:nth-of-type(1) .m-footer .m-button').length
         ),
         1,
         'only one button should be visible in the origin footer'
       )
       t.equal(
         await advanced.evaluate(() =>
-          document.querySelector('.m-list li:nth-of-type(2) .m-footer .m-button').innerText.toLowerCase()
+          document.querySelector('.m-list li:nth-of-type(1) .m-footer .m-button').innerText.toLowerCase()
         ),
         'remove',
         'remove origin button should be rendered'

+ 15 - 15
test/origin-csp.js

@@ -10,8 +10,8 @@ module.exports = ({extensions, popup, advanced, content}) => {
 
     // enable path matching
     await advanced.evaluate(() => {
-      document.querySelector('.m-list li:nth-of-type(2) input').value = 'csp-match-path'
-      document.querySelector('.m-list li:nth-of-type(2) input').dispatchEvent(new Event('keyup'))
+      document.querySelector('.m-list li:nth-of-type(1) input').value = 'csp-match-path'
+      document.querySelector('.m-list li:nth-of-type(1) input').dispatchEvent(new Event('keyup'))
     })
     // there is debounce timeout of 750ms in the options UI
     await advanced.waitFor(800)
@@ -23,7 +23,7 @@ module.exports = ({extensions, popup, advanced, content}) => {
 
       // enable csp
       if (!await advanced.evaluate(() => state.origins['http://localhost:3000'].csp)) {
-        await advanced.click('.m-list li:nth-of-type(2) .m-switch')
+        await advanced.click('.m-list li:nth-of-type(1) .m-switch')
       }
 
       // go to page serving content with strict csp
@@ -53,7 +53,7 @@ module.exports = ({extensions, popup, advanced, content}) => {
 
       // enable csp
       if (!await advanced.evaluate(() => state.origins['http://localhost:3000'].csp)) {
-        await advanced.click('.m-list li:nth-of-type(2) .m-switch')
+        await advanced.click('.m-list li:nth-of-type(1) .m-switch')
       }
 
       // go to page serving content with strict csp
@@ -83,7 +83,7 @@ module.exports = ({extensions, popup, advanced, content}) => {
 
       // enable csp
       if (!await advanced.evaluate(() => state.origins['http://localhost:3000'].csp)) {
-        await advanced.click('.m-list li:nth-of-type(2) .m-switch')
+        await advanced.click('.m-list li:nth-of-type(1) .m-switch')
       }
 
       // go to page serving content with strict csp
@@ -109,7 +109,7 @@ module.exports = ({extensions, popup, advanced, content}) => {
 
       // disable csp
       if (await advanced.evaluate(() => state.origins['http://localhost:3000'].csp)) {
-        await advanced.click('.m-list li:nth-of-type(2) .m-switch')
+        await advanced.click('.m-list li:nth-of-type(1) .m-switch')
       }
       await advanced.waitFor(300)
 
@@ -136,7 +136,7 @@ module.exports = ({extensions, popup, advanced, content}) => {
 
       // enable csp
       if (!await advanced.evaluate(() => state.origins['http://localhost:3000'].csp)) {
-        await advanced.click('.m-list li:nth-of-type(2) .m-switch')
+        await advanced.click('.m-list li:nth-of-type(1) .m-switch')
       }
       await advanced.waitFor(300)
 
@@ -158,7 +158,7 @@ module.exports = ({extensions, popup, advanced, content}) => {
 
       // disable csp
       if (await advanced.evaluate(() => state.origins['http://localhost:3000'].csp)) {
-        await advanced.click('.m-list li:nth-of-type(2) .m-switch')
+        await advanced.click('.m-list li:nth-of-type(1) .m-switch')
       }
       await advanced.waitFor(300)
 
@@ -188,17 +188,17 @@ module.exports = ({extensions, popup, advanced, content}) => {
 
       // enable csp
       if (!await advanced.evaluate(() => state.origins['http://localhost:3000'].csp)) {
-        await advanced.click('.m-list li:nth-of-type(2) .m-switch')
+        await advanced.click('.m-list li:nth-of-type(1) .m-switch')
       }
       await advanced.reload()
       await advanced.waitFor(300)
 
       // expand origin
-      await advanced.click('.m-list li:nth-of-type(2)')
+      await advanced.click('.m-list li:nth-of-type(1)')
 
       t.strictEqual(
         await advanced.evaluate(() =>
-          document.querySelector('.m-list li:nth-of-type(2) .m-switch').classList.contains('is-checked')
+          document.querySelector('.m-list li:nth-of-type(1) .m-switch').classList.contains('is-checked')
         ),
         true,
         'csp checkbox should be enabled'
@@ -209,17 +209,17 @@ module.exports = ({extensions, popup, advanced, content}) => {
 
       // disable csp
       if (await advanced.evaluate(() => state.origins['http://localhost:3000'].csp)) {
-        await advanced.click('.m-list li:nth-of-type(2) .m-switch')
+        await advanced.click('.m-list li:nth-of-type(1) .m-switch')
       }
       await advanced.reload()
       await advanced.waitFor(300)
 
       // expand origin
-      await advanced.click('.m-list li:nth-of-type(2)')
+      await advanced.click('.m-list li:nth-of-type(1)')
 
       t.strictEqual(
         await advanced.evaluate(() =>
-          document.querySelector('.m-list li:nth-of-type(2) .m-switch').classList.contains('is-checked')
+          document.querySelector('.m-list li:nth-of-type(1) .m-switch').classList.contains('is-checked')
         ),
         false,
         'csp checkbox should be disabled'
@@ -233,7 +233,7 @@ module.exports = ({extensions, popup, advanced, content}) => {
 
       // enable csp
       if (!await advanced.evaluate(() => state.origins['http://localhost:3000'].csp)) {
-        await advanced.click('.m-list li:nth-of-type(2) .m-switch')
+        await advanced.click('.m-list li:nth-of-type(1) .m-switch')
       }
 
       // chrome://extensions

+ 8 - 8
test/origin-encoding.js

@@ -10,8 +10,8 @@ module.exports = ({popup, advanced, content}) => {
 
     // enable path matching
     await advanced.evaluate(() => {
-      document.querySelector('.m-list li:nth-of-type(2) input').value = 'encoding-.*'
-      document.querySelector('.m-list li:nth-of-type(2) input').dispatchEvent(new Event('keyup'))
+      document.querySelector('.m-list li:nth-of-type(1) input').value = 'encoding-.*'
+      document.querySelector('.m-list li:nth-of-type(1) input').dispatchEvent(new Event('keyup'))
     })
     // there is debounce timeout of 750ms in the options UI
     await advanced.waitFor(800)
@@ -20,7 +20,7 @@ module.exports = ({popup, advanced, content}) => {
   describe('no content-type header set', () => {
     before(async () => {
       // set wrong encoding
-      await advanced.select('.m-list li:nth-of-type(2) .m-encoding select', 'Shift_JIS')
+      await advanced.select('.m-list li:nth-of-type(1) .m-encoding select', 'Shift_JIS')
 
       // go to page serving Big5 encoded string
       // with no content-type header set
@@ -45,7 +45,7 @@ module.exports = ({popup, advanced, content}) => {
   describe('no charset in content-type header', () => {
     before(async () => {
       // set wrong encoding
-      await advanced.select('.m-list li:nth-of-type(2) .m-encoding select', 'Shift_JIS')
+      await advanced.select('.m-list li:nth-of-type(1) .m-encoding select', 'Shift_JIS')
 
       // go to page serving Big5 encoded string
       // with no charset set in the content-type header
@@ -70,7 +70,7 @@ module.exports = ({popup, advanced, content}) => {
   describe('wrong charset in content-type header', () => {
     before(async () => {
       // detect encoding automatically
-      await advanced.select('.m-list li:nth-of-type(2) .m-encoding select', '')
+      await advanced.select('.m-list li:nth-of-type(1) .m-encoding select', '')
 
       // go to page serving windows-1251 encoded string
       // with UTF-8 charset set in content-type header
@@ -97,7 +97,7 @@ module.exports = ({popup, advanced, content}) => {
       await advanced.bringToFront()
 
       // override encoding
-      await advanced.select('.m-list li:nth-of-type(2) .m-encoding select', 'Windows-1251')
+      await advanced.select('.m-list li:nth-of-type(1) .m-encoding select', 'Windows-1251')
 
       // go to page serving windows-1251 encoded string
       // with UTF-8 charset set in content-type header
@@ -125,12 +125,12 @@ module.exports = ({popup, advanced, content}) => {
       await advanced.reload()
       await advanced.waitFor(300)
       // expand origin
-      await advanced.click('.m-list li:nth-of-type(2)')
+      await advanced.click('.m-list li:nth-of-type(1)')
     })
     it('reload', async () => {
       t.equal(
         await advanced.evaluate(() =>
-          document.querySelector('.m-list li:nth-of-type(2) .m-encoding select').value
+          document.querySelector('.m-list li:nth-of-type(1) .m-encoding select').value
         ),
         'Windows-1251',
         'should persist the selected encoding'

+ 6 - 6
test/origin-match.js

@@ -20,8 +20,8 @@ module.exports = ({popup, advanced, content}) => {
 
       // disable path matching
       await advanced.evaluate(() => {
-        document.querySelector('.m-list li:nth-of-type(2) input').value = ''
-        document.querySelector('.m-list li:nth-of-type(2) input').dispatchEvent(new Event('keyup'))
+        document.querySelector('.m-list li:nth-of-type(1) input').value = ''
+        document.querySelector('.m-list li:nth-of-type(1) input').dispatchEvent(new Event('keyup'))
       })
       // there is debounce timeout of 750ms in the options UI
       await advanced.waitFor(800)
@@ -53,8 +53,8 @@ module.exports = ({popup, advanced, content}) => {
 
       // disable path matching
       await advanced.evaluate(() => {
-        document.querySelector('.m-list li:nth-of-type(2) input').value = ''
-        document.querySelector('.m-list li:nth-of-type(2) input').dispatchEvent(new Event('keyup'))
+        document.querySelector('.m-list li:nth-of-type(1) input').value = ''
+        document.querySelector('.m-list li:nth-of-type(1) input').dispatchEvent(new Event('keyup'))
       })
       // there is debounce timeout of 750ms in the options UI
       await advanced.waitFor(800)
@@ -100,8 +100,8 @@ module.exports = ({popup, advanced, content}) => {
 
       // enable path matching
       await advanced.evaluate(() => {
-        document.querySelector('.m-list li:nth-of-type(2) input').value = 'wrong-content-type'
-        document.querySelector('.m-list li:nth-of-type(2) input').dispatchEvent(new Event('keyup'))
+        document.querySelector('.m-list li:nth-of-type(1) input').value = 'wrong-content-type'
+        document.querySelector('.m-list li:nth-of-type(1) input').dispatchEvent(new Event('keyup'))
       })
       // there is debounce timeout of 750ms in the options UI
       await advanced.waitFor(800)

+ 5 - 5
test/utils/defaults.js

@@ -17,10 +17,10 @@ module.exports = async ({popup, advanced, content}) => {
   // remove origin
   if (await advanced.evaluate(() => Object.keys(state.origins).length > 1)) {
     // expand origin
-    if (!await advanced.evaluate(() => document.querySelector('.m-list li:nth-of-type(2)').classList.contains('m-expanded'))) {
-      await advanced.click('.m-list li:nth-of-type(2)')
+    if (!await advanced.evaluate(() => document.querySelector('.m-list li:nth-of-type(1)').classList.contains('m-expanded'))) {
+      await advanced.click('.m-list li:nth-of-type(1)')
     }
-    await advanced.click('.m-list li:nth-of-type(2) .m-footer .m-button')
+    await advanced.click('.m-list li:nth-of-type(1) .m-footer .m-button')
   }
 
   // add origin
@@ -30,8 +30,8 @@ module.exports = async ({popup, advanced, content}) => {
   await advanced.waitFor(300)
 
   // expand origin
-  if (!await advanced.evaluate(() => document.querySelector('.m-list li:nth-of-type(2)').classList.contains('m-expanded'))) {
-    await advanced.click('.m-list li:nth-of-type(2)')
+  if (!await advanced.evaluate(() => document.querySelector('.m-list li:nth-of-type(1)').classList.contains('m-expanded'))) {
+    await advanced.click('.m-list li:nth-of-type(1)')
   }
 
   // content