From d15fbae93e784ae4dd23c1d9a77073dd304979f7 Mon Sep 17 00:00:00 2001 From: Daniel Rozenberg Date: Mon, 20 May 2024 13:12:17 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Fix=20tests=20broken=20by=20changes?= =?UTF-8?q?=20from=20https://twitter.com/=20to=20https://x.com/=20(#40016)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1.0/test-e2e/test-amp-social-share.js | 2 +- test/unit/test-document-info.js | 28 +++--- test/unit/test-url.js | 88 +++++++++---------- 3 files changed, 54 insertions(+), 64 deletions(-) diff --git a/extensions/amp-social-share/1.0/test-e2e/test-amp-social-share.js b/extensions/amp-social-share/1.0/test-e2e/test-amp-social-share.js index 84059114e27e..db169ada0c6b 100644 --- a/extensions/amp-social-share/1.0/test-e2e/test-amp-social-share.js +++ b/extensions/amp-social-share/1.0/test-e2e/test-amp-social-share.js @@ -101,7 +101,7 @@ describes.endtoend( await controller.switchToWindow(windows[1]); await expect(controller.getCurrentUrl()).to.have.string( - 'https://twitter.com/' + 'https://x.com/' ); }); diff --git a/test/unit/test-document-info.js b/test/unit/test-document-info.js index cab40d9c55b6..4fa60cd2f460 100644 --- a/test/unit/test-document-info.js +++ b/test/unit/test-document-info.js @@ -45,9 +45,9 @@ describes.sandboxed('document-info', {}, (env) => { } it('should provide the canonicalUrl', () => { - return getWin({'canonical': ['https://twitter.com/']}).then((win) => { + return getWin({'canonical': ['https://x.com/']}).then((win) => { expect(Services.documentInfoForDoc(win.document).canonicalUrl).to.equal( - 'https://twitter.com/' + 'https://x.com/' ); }); }); @@ -133,7 +133,7 @@ describes.sandboxed('document-info', {}, (env) => { }); it('should provide the pageViewId', () => { - return getWin({'canonical': ['https://twitter.com/']}).then((win) => { + return getWin({'canonical': ['https://x.com/']}).then((win) => { expect(Services.documentInfoForDoc(win.document).pageViewId).to.equal( '1234' ); @@ -144,7 +144,7 @@ describes.sandboxed('document-info', {}, (env) => { }); it('should provide the pageViewId64', () => { - return getWin({'canonical': ['https://twitter.com/']}).then((win) => { + return getWin({'canonical': ['https://x.com/']}).then((win) => { expect(Services.documentInfoForDoc(win.document).pageViewId64).to.equal( 'abcdef' ); @@ -164,12 +164,12 @@ describes.sandboxed('document-info', {}, (env) => { it('should provide the linkRels containing link tag rels', () => { return getWin({ - 'canonical': ['https://twitter.com/'], + 'canonical': ['https://x.com/'], 'icon': ['https://foo.html/bar.gif'], }).then((win) => { expect( Services.documentInfoForDoc(win.document).linkRels['canonical'] - ).to.equal('https://twitter.com/'); + ).to.equal('https://x.com/'); expect( Services.documentInfoForDoc(win.document).linkRels['icon'] ).to.equal('https://foo.html/bar.gif'); @@ -201,15 +201,15 @@ describes.sandboxed('document-info', {}, (env) => { 'space in rel', () => { return getWin({ - 'sharelink canonical': ['https://twitter.com/'], + 'sharelink canonical': ['https://x.com/'], 'icon': ['https://foo.html/bar.gif'], }).then((win) => { expect( Services.documentInfoForDoc(win.document).linkRels['sharelink'] - ).to.equal('https://twitter.com/'); + ).to.equal('https://x.com/'); expect( Services.documentInfoForDoc(win.document).linkRels['canonical'] - ).to.equal('https://twitter.com/'); + ).to.equal('https://x.com/'); expect( Services.documentInfoForDoc(win.document).linkRels['icon'] ).to.equal('https://foo.html/bar.gif'); @@ -222,7 +222,7 @@ describes.sandboxed('document-info', {}, (env) => { 'hrefs', () => { return getWin({ - 'canonical': ['https://twitter.com/'], + 'canonical': ['https://x.com/'], 'icon': ['https://foo.html/bar.gif'], 'stylesheet': [ 'https://foo.html/style1.css', @@ -230,9 +230,7 @@ describes.sandboxed('document-info', {}, (env) => { ], }).then((win) => { const documentInfo = Services.documentInfoForDoc(win.document); - expect(documentInfo.linkRels['canonical']).to.equal( - 'https://twitter.com/' - ); + expect(documentInfo.linkRels['canonical']).to.equal('https://x.com/'); expect(documentInfo.linkRels['icon']).to.equal( 'https://foo.html/bar.gif' ); @@ -252,7 +250,7 @@ describes.sandboxed('document-info', {}, (env) => { 'prefetch/preload/preconnect rels', () => { return getWin({ - 'canonical': ['https://twitter.com/'], + 'canonical': ['https://x.com/'], 'icon': ['https://foo.html/bar.gif'], 'prefetch': ['https://foo1.com'], 'preload': ['https://foo2.com'], @@ -260,7 +258,7 @@ describes.sandboxed('document-info', {}, (env) => { }).then((win) => { expect( Services.documentInfoForDoc(win.document).linkRels['canonical'] - ).to.equal('https://twitter.com/'); + ).to.equal('https://x.com/'); expect( Services.documentInfoForDoc(win.document).linkRels['icon'] ).to.equal('https://foo.html/bar.gif'); diff --git a/test/unit/test-url.js b/test/unit/test-url.js index 0dd8fde0dcd7..eeac0087801d 100644 --- a/test/unit/test-url.js +++ b/test/unit/test-url.js @@ -225,9 +225,9 @@ describes.sandboxed('parseUrlDeprecated', {}, () => { origin: 'http://foo.com:123', }); }); - it('should parse origin https://twitter.com/path#abc', () => { - expect(parseUrlDeprecated('https://twitter.com/path#abc').origin).to.equal( - 'https://twitter.com' + it('should parse origin https://x.com/path#abc', () => { + expect(parseUrlDeprecated('https://x.com/path#abc').origin).to.equal( + 'https://x.com' ); }); @@ -285,13 +285,13 @@ describes.sandboxed('assertHttpsUrl/isSecureUrl', {}, () => { assertHttpsUrl('', referenceElement); }); it('should allow https', () => { - assertHttpsUrl('https://twitter.com', referenceElement); - expect(isSecureUrlDeprecated('https://twitter.com')).to.be.true; + assertHttpsUrl('https://x.com', referenceElement); + expect(isSecureUrlDeprecated('https://x.com')).to.be.true; }); it('should allow protocol relative', () => { - assertHttpsUrl('//twitter.com', referenceElement); + assertHttpsUrl('//x.com', referenceElement); // `isSecureUrl` always resolves relative URLs. - expect(isSecureUrlDeprecated('//twitter.com')).to.be.equal( + expect(isSecureUrlDeprecated('//x.com')).to.be.equal( window.location.protocol == 'https:' ); }); @@ -308,10 +308,10 @@ describes.sandboxed('assertHttpsUrl/isSecureUrl', {}, () => { it('should fail on http', () => { allowConsoleError(() => { expect(() => { - assertHttpsUrl('http://twitter.com', referenceElement); + assertHttpsUrl('http://x.com', referenceElement); }).to.throw(/source must start with/); }); - expect(isSecureUrlDeprecated('http://twitter.com')).to.be.false; + expect(isSecureUrlDeprecated('http://x.com')).to.be.false; }); it('should fail on http with localhost in the name', () => { allowConsoleError(() => { @@ -325,25 +325,25 @@ describes.sandboxed('assertHttpsUrl/isSecureUrl', {}, () => { describes.sandboxed('assertAbsoluteHttpOrHttpsUrl', {}, () => { it('should allow http', () => { - expect(assertAbsoluteHttpOrHttpsUrl('http://twitter.com/')).to.equal( - 'http://twitter.com/' + expect(assertAbsoluteHttpOrHttpsUrl('http://x.com/')).to.equal( + 'http://x.com/' ); - expect(assertAbsoluteHttpOrHttpsUrl('HTTP://twitter.com/')).to.equal( - 'http://twitter.com/' + expect(assertAbsoluteHttpOrHttpsUrl('HTTP://x.com/')).to.equal( + 'http://x.com/' ); }); it('should allow https', () => { - expect(assertAbsoluteHttpOrHttpsUrl('https://twitter.com/')).to.equal( - 'https://twitter.com/' + expect(assertAbsoluteHttpOrHttpsUrl('https://x.com/')).to.equal( + 'https://x.com/' ); - expect(assertAbsoluteHttpOrHttpsUrl('HTTPS://twitter.com/')).to.equal( - 'https://twitter.com/' + expect(assertAbsoluteHttpOrHttpsUrl('HTTPS://x.com/')).to.equal( + 'https://x.com/' ); }); it('should fail on relative protocol', () => { allowConsoleError(() => { expect(() => { - assertAbsoluteHttpOrHttpsUrl('//twitter.com/'); + assertAbsoluteHttpOrHttpsUrl('//x.com/'); }).to.throw(/URL must start with/); }); }); @@ -367,69 +367,61 @@ describes.sandboxed('assertAbsoluteHttpOrHttpsUrl', {}, () => { describes.sandboxed('removeFragment', {}, () => { it('should remove fragment', () => { - expect(removeFragment('https://twitter.com/path#abc')).to.equal( - 'https://twitter.com/path' + expect(removeFragment('https://x.com/path#abc')).to.equal( + 'https://x.com/path' ); }); it('should remove empty fragment', () => { - expect(removeFragment('https://twitter.com/path#')).to.equal( - 'https://twitter.com/path' + expect(removeFragment('https://x.com/path#')).to.equal( + 'https://x.com/path' ); }); it('should ignore when no fragment', () => { - expect(removeFragment('https://twitter.com/path')).to.equal( - 'https://twitter.com/path' - ); + expect(removeFragment('https://x.com/path')).to.equal('https://x.com/path'); }); }); describes.sandboxed('removeSearch', {}, () => { it('should remove search', () => { - expect(removeSearch('https://twitter.com/path?abc')).to.equal( - 'https://twitter.com/path' + expect(removeSearch('https://x.com/path?abc')).to.equal( + 'https://x.com/path' ); }); it('should remove search with value', () => { - expect(removeSearch('https://twitter.com/path?abc=123')).to.equal( - 'https://twitter.com/path' + expect(removeSearch('https://x.com/path?abc=123')).to.equal( + 'https://x.com/path' ); }); it('should remove multiple params', () => { - expect(removeSearch('https://twitter.com/path?abc=123&d&e=4')).to.equal( - 'https://twitter.com/path' + expect(removeSearch('https://x.com/path?abc=123&d&e=4')).to.equal( + 'https://x.com/path' ); }); it('should remove empty search', () => { - expect(removeSearch('https://twitter.com/path?')).to.equal( - 'https://twitter.com/path' - ); + expect(removeSearch('https://x.com/path?')).to.equal('https://x.com/path'); }); it('should ignore when no search', () => { - expect(removeSearch('https://twitter.com/path')).to.equal( - 'https://twitter.com/path' - ); + expect(removeSearch('https://x.com/path')).to.equal('https://x.com/path'); }); it('should preserve fragment', () => { - expect(removeSearch('https://twitter.com/path?abc#f')).to.equal( - 'https://twitter.com/path#f' + expect(removeSearch('https://x.com/path?abc#f')).to.equal( + 'https://x.com/path#f' ); }); it('should preserve fragment with multiple params', () => { - expect(removeSearch('https://twitter.com/path?a&d=1&e=5#f=x')).to.equal( - 'https://twitter.com/path#f=x' + expect(removeSearch('https://x.com/path?a&d=1&e=5#f=x')).to.equal( + 'https://x.com/path#f=x' ); }); it('should preserve fragment when no search', () => { - expect(removeSearch('https://twitter.com/path#f')).to.equal( - 'https://twitter.com/path#f' + expect(removeSearch('https://x.com/path#f')).to.equal( + 'https://x.com/path#f' ); }); it('should handle empty fragment', () => { - expect(removeSearch('https://twitter.com/path#')).to.equal( - 'https://twitter.com/path#' - ); - expect(removeSearch('https://twitter.com/path?#')).to.equal( - 'https://twitter.com/path#' + expect(removeSearch('https://x.com/path#')).to.equal('https://x.com/path#'); + expect(removeSearch('https://x.com/path?#')).to.equal( + 'https://x.com/path#' ); }); });