-
-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce Chrome for testing (#2278)
* Introduce Chrome for testing * Fix some tests * Fix some tests * code factor * Fix firefox * More firefox fixes * cache versions * Refactor Firefox buildId * add some logging * add -v n to github actions * Improve error reporting * Fix firefox download * unflake * self review * Add chrome data tests * Add chrome cli test * Improve the test * Code factor * Fix tests * Add more data an cli tests * cleanup csproj * cr * cr
- Loading branch information
Showing
36 changed files
with
1,063 additions
and
647 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
lib/PuppeteerSharp.Tests/Browsers/Chrome/ChromeDataTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using System; | ||
using System.IO; | ||
using NUnit.Framework; | ||
using PuppeteerSharp.BrowserData; | ||
using PuppeteerSharp.Nunit; | ||
using PuppeteerSharp.Tests.Attributes; | ||
|
||
namespace PuppeteerSharp.Tests.Browsers.Chrome | ||
{ | ||
public class ChromeDataTests | ||
{ | ||
[PuppeteerTest("chrome-data.spec.ts", "Chrome", "should resolve download URLs")] | ||
public void ShouldResolveDownloadUrls() | ||
{ | ||
Assert.AreEqual( | ||
"https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/113.0.5672.0/linux64/chrome-linux64.zip", | ||
BrowserData.Chrome.ResolveDownloadUrl(Platform.Linux, "113.0.5672.0", null)); | ||
Assert.AreEqual( | ||
"https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/113.0.5672.0/mac-x64/chrome-mac-x64.zip", | ||
BrowserData.Chrome.ResolveDownloadUrl(Platform.MacOS, "113.0.5672.0", null)); | ||
Assert.AreEqual( | ||
"https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/113.0.5672.0/mac-arm64/chrome-mac-arm64.zip", | ||
BrowserData.Chrome.ResolveDownloadUrl(Platform.MacOSArm64, "113.0.5672.0", null)); | ||
Assert.AreEqual( | ||
"https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/113.0.5672.0/win32/chrome-win32.zip", | ||
BrowserData.Chrome.ResolveDownloadUrl(Platform.Win32, "113.0.5672.0", null)); | ||
Assert.AreEqual( | ||
"https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/113.0.5672.0/win64/chrome-win64.zip", | ||
BrowserData.Chrome.ResolveDownloadUrl(Platform.Win64, "113.0.5672.0", null)); | ||
} | ||
|
||
[PuppeteerTest("chrome-data.spec.ts", "Chrome", "should resolve executable paths")] | ||
public void ShouldResolveExecutablePath() | ||
{ | ||
Assert.AreEqual( | ||
Path.Combine("chrome-linux64", "chrome"), | ||
BrowserData.Chrome.RelativeExecutablePath(Platform.Linux, "12372323")); | ||
|
||
Assert.AreEqual( | ||
Path.Combine( | ||
"chrome-mac-x64", | ||
"Google Chrome for Testing.app", | ||
"Contents", | ||
"MacOS", | ||
"Google Chrome for Testing" | ||
), | ||
BrowserData.Chrome.RelativeExecutablePath(Platform.MacOS, "12372323")); | ||
|
||
Assert.AreEqual( | ||
Path.Combine( | ||
"chrome-mac-arm64", | ||
"Google Chrome for Testing.app", | ||
"Contents", | ||
"MacOS", | ||
"Google Chrome for Testing" | ||
), | ||
BrowserData.Chrome.RelativeExecutablePath(Platform.MacOSArm64, "12372323")); | ||
|
||
Assert.AreEqual( | ||
Path.Combine("chrome-win32", "chrome.exe"), | ||
BrowserData.Chrome.RelativeExecutablePath(Platform.Win32, "12372323")); | ||
|
||
Assert.AreEqual( | ||
BrowserData.Chrome.RelativeExecutablePath(Platform.Win64, "12372323"), | ||
Path.Combine("chrome-win64", "chrome.exe")); | ||
} | ||
|
||
[PuppeteerTest("chrome-data.spec.ts", "Chrome", "should resolve system executable path")] | ||
[Skip(SkipAttribute.Targets.Linux, SkipAttribute.Targets.OSX)] | ||
public void ShouldResolveSystemExecutablePathWindows() | ||
{ | ||
Assert.AreEqual( | ||
"C:\\Program Files\\Google\\Chrome Dev\\Application\\chrome.exe", | ||
BrowserData.Chrome.ResolveSystemExecutablePath( | ||
Platform.Win32, | ||
ChromeReleaseChannel.Dev)); | ||
} | ||
|
||
[PuppeteerTest("chrome-data.spec.ts", "Chrome", "should resolve system executable path")] | ||
public void ShouldResolveSystemExecutablePath() | ||
{ | ||
Assert.AreEqual( | ||
"/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta", | ||
BrowserData.Chrome.ResolveSystemExecutablePath( | ||
Platform.MacOS, | ||
ChromeReleaseChannel.Beta)); | ||
|
||
var ex = Assert.Throws<PuppeteerException>(() => { | ||
BrowserData.Chrome.ResolveSystemExecutablePath( | ||
Platform.Linux, | ||
ChromeReleaseChannel.Canary); | ||
}); | ||
|
||
Assert.AreEqual("Canary is not supported", ex.Message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using PuppeteerSharp.BrowserData; | ||
using PuppeteerSharp.Nunit; | ||
|
||
namespace PuppeteerSharp.Tests.Browsers.Chrome | ||
{ | ||
/// <summary> | ||
/// Puppeteer sharp doesn't have a CLI per se. But it matches the test we have upstream. | ||
/// </summary> | ||
public class CliTests | ||
{ | ||
private readonly string _cacheDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); | ||
|
||
[SetUp] | ||
public void CreateDir() | ||
=> new DirectoryInfo(_cacheDir).Create(); | ||
|
||
[TearDown] | ||
public void DeleteDir() | ||
=> new Cache(_cacheDir).Clear(); | ||
|
||
[PuppeteerTest("CLI.spec.ts", "Chrome CLI", "should download Chrome binaries")] | ||
public async Task ShouldDownloadChromeBinaries() | ||
{ | ||
using var fetcher = new BrowserFetcher(SupportedBrowser.Chrome) | ||
{ | ||
CacheDir = _cacheDir, | ||
Platform = Platform.Linux | ||
}; | ||
await fetcher.DownloadAsync(BrowserData.Chrome.DefaultBuildId); | ||
|
||
Assert.True(new FileInfo(Path.Combine( | ||
_cacheDir, | ||
"Chrome", | ||
$"Linux-{BrowserData.Chrome.DefaultBuildId}", | ||
"chrome-linux64", | ||
"chrome")).Exists); | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
lib/PuppeteerSharp.Tests/Browsers/Chromium/ChromiumDataTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using System.IO; | ||
using NUnit.Framework; | ||
using PuppeteerSharp.Nunit; | ||
|
||
namespace PuppeteerSharp.Tests.Browsers.Chromium | ||
{ | ||
public class ChromiumDataTests | ||
{ | ||
[PuppeteerTest("chromium-data.spec.ts", "Chromium", "should resolve download URLs")] | ||
public void ShouldResolveDownloadUrls() | ||
{ | ||
Assert.AreEqual( | ||
"https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/1083080/chrome-linux.zip", | ||
BrowserData.Chromium.ResolveDownloadUrl(Platform.Linux, "1083080", null)); | ||
Assert.AreEqual( | ||
"https://storage.googleapis.com/chromium-browser-snapshots/Mac/1083080/chrome-mac.zip", | ||
BrowserData.Chromium.ResolveDownloadUrl(Platform.MacOS, "1083080", null)); | ||
Assert.AreEqual( | ||
"https://storage.googleapis.com/chromium-browser-snapshots/Mac_Arm/1083080/chrome-mac.zip", | ||
BrowserData.Chromium.ResolveDownloadUrl(Platform.MacOSArm64, "1083080", null)); | ||
Assert.AreEqual( | ||
"https://storage.googleapis.com/chromium-browser-snapshots/Win/1083080/chrome-win.zip", | ||
BrowserData.Chromium.ResolveDownloadUrl(Platform.Win32, "1083080", null)); | ||
Assert.AreEqual( | ||
"https://storage.googleapis.com/chromium-browser-snapshots/Win_x64/1083080/chrome-win.zip", | ||
BrowserData.Chromium.ResolveDownloadUrl(Platform.Win64, "1083080", null)); | ||
} | ||
|
||
[PuppeteerTest("chromium-data.spec.ts", "Chromium", "should resolve executable paths")] | ||
public void ShouldResolveExecutablePath() | ||
{ | ||
Assert.AreEqual( | ||
Path.Combine("chrome-linux", "chrome"), | ||
BrowserData.Chromium.RelativeExecutablePath(Platform.Linux, "12372323")); | ||
|
||
Assert.AreEqual( | ||
Path.Combine( | ||
"chrome-mac", | ||
"Chromium.app", | ||
"Contents", | ||
"MacOS", | ||
"Chromium" | ||
), | ||
BrowserData.Chromium.RelativeExecutablePath(Platform.MacOS, "12372323")); | ||
|
||
Assert.AreEqual( | ||
Path.Combine( | ||
"chrome-mac", | ||
"Chromium.app", | ||
"Contents", | ||
"MacOS", | ||
"Chromium" | ||
), | ||
BrowserData.Chromium.RelativeExecutablePath(Platform.MacOSArm64, "12372323")); | ||
|
||
Assert.AreEqual( | ||
Path.Combine("chrome-win", "chrome.exe"), | ||
BrowserData.Chromium.RelativeExecutablePath(Platform.Win32, "12372323")); | ||
|
||
Assert.AreEqual( | ||
BrowserData.Chromium.RelativeExecutablePath(Platform.Win64, "12372323"), | ||
Path.Combine("chrome-win", "chrome.exe")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using PuppeteerSharp.BrowserData; | ||
using PuppeteerSharp.Nunit; | ||
|
||
namespace PuppeteerSharp.Tests.Browsers.Firefox | ||
{ | ||
/// <summary> | ||
/// Puppeteer sharp doesn't have a CLI per se. But it matches the test we have upstream. | ||
/// </summary> | ||
public class CliTests | ||
{ | ||
private readonly string _cacheDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); | ||
|
||
[SetUp] | ||
public void CreateDir() | ||
=> new DirectoryInfo(_cacheDir).Create(); | ||
|
||
[TearDown] | ||
public void DeleteDir() | ||
=> new Cache(_cacheDir).Clear(); | ||
|
||
[PuppeteerTest("CLI.spec.ts", "Chrome CLI", "should download Chrome binaries")] | ||
public async Task ShouldDownloadChromeBinaries() | ||
{ | ||
using var fetcher = new BrowserFetcher(SupportedBrowser.Chrome) | ||
{ | ||
CacheDir = _cacheDir, | ||
Platform = Platform.Linux | ||
}; | ||
await fetcher.DownloadAsync(BrowserData.Chrome.DefaultBuildId); | ||
|
||
Assert.True(new FileInfo(Path.Combine( | ||
_cacheDir, | ||
"Chrome", | ||
$"Linux-{BrowserData.Chrome.DefaultBuildId}", | ||
"chrome-linux64", | ||
"chrome")).Exists); | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
lib/PuppeteerSharp.Tests/Browsers/Firefox/FirefoxDataTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using System.IO; | ||
using NUnit.Framework; | ||
using PuppeteerSharp.BrowserData; | ||
using PuppeteerSharp.Nunit; | ||
using PuppeteerSharp.Tests.Attributes; | ||
|
||
namespace PuppeteerSharp.Tests.Browsers.Firefox | ||
{ | ||
public class FirefoxDataTests | ||
{ | ||
[PuppeteerTest("firefox-data.spec.ts", "Firefox", "should resolve download URLs")] | ||
public void ShouldResolveDownloadUrls() | ||
{ | ||
Assert.AreEqual( | ||
"https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/firefox-111.0a1.en-US.linux-x86_64.tar.bz2", | ||
BrowserData.Firefox.ResolveDownloadUrl(Platform.Linux, "111.0a1", null)); | ||
Assert.AreEqual( | ||
"https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/firefox-111.0a1.en-US.mac.dmg", | ||
BrowserData.Firefox.ResolveDownloadUrl(Platform.MacOS, "111.0a1", null)); | ||
Assert.AreEqual( | ||
"https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/firefox-111.0a1.en-US.mac.dmg", | ||
BrowserData.Firefox.ResolveDownloadUrl(Platform.MacOSArm64, "111.0a1", null)); | ||
Assert.AreEqual( | ||
"https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/firefox-111.0a1.en-US.win32.zip", | ||
BrowserData.Firefox.ResolveDownloadUrl(Platform.Win32, "111.0a1", null)); | ||
Assert.AreEqual( | ||
"https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/firefox-111.0a1.en-US.win64.zip", | ||
BrowserData.Firefox.ResolveDownloadUrl(Platform.Win64, "111.0a1", null)); | ||
} | ||
|
||
[PuppeteerTest("firefox-data.spec.ts", "Firefox", "should resolve executable paths")] | ||
public void ShouldResolveExecutablePath() | ||
{ | ||
Assert.AreEqual( | ||
Path.Combine("firefox", "firefox"), | ||
BrowserData.Firefox.RelativeExecutablePath(Platform.Linux, "111.0a1")); | ||
|
||
Assert.AreEqual( | ||
Path.Combine( | ||
"Firefox Nightly.app", | ||
"Contents", | ||
"MacOS", | ||
"firefox" | ||
), | ||
BrowserData.Firefox.RelativeExecutablePath(Platform.MacOS, "111.0a1")); | ||
|
||
Assert.AreEqual( | ||
Path.Combine( | ||
"Firefox Nightly.app", | ||
"Contents", | ||
"MacOS", | ||
"firefox" | ||
), | ||
BrowserData.Firefox.RelativeExecutablePath(Platform.MacOSArm64, "111.0a1")); | ||
|
||
Assert.AreEqual( | ||
Path.Combine("firefox", "firefox.exe"), | ||
BrowserData.Firefox.RelativeExecutablePath(Platform.Win32, "111.0a1")); | ||
|
||
Assert.AreEqual( | ||
BrowserData.Firefox.RelativeExecutablePath(Platform.Win64, "111.0a1"), | ||
Path.Combine("firefox", "firefox.exe")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.