[PLT-7574] Update and Simplify Compatibility Check and Replace UA Dependency (#7427)
* Add fix to not run browser check on Mobile Browsers or the App * remove non safari and IE checks * Replace useragent checking dependency and update UA tests * change some wording * change dependancy again to one with compatible licence * Fix typos and clarify wording * fix typo and comvert tests to use array
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
6b3c9a480a
Коммит
309594cedf
@@ -166,4 +166,35 @@ func TestMain(m *testing.M) {
|
||||
}()
|
||||
|
||||
status = m.Run()
|
||||
|
||||
}
|
||||
|
||||
func TestCheckClientCompatability(t *testing.T) {
|
||||
//Browser Name, UA String, expected result (if the browser should fail the test false and if it should pass the true)
|
||||
type uaTest struct {
|
||||
Name string // Name of Browser
|
||||
UserAgent string // Useragent of Browser
|
||||
Result bool // Expected result (true if browser should be compatible, false if browser shouldn't be compatible)
|
||||
}
|
||||
var uaTestParameters = []uaTest{
|
||||
{"Mozilla 40.1", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1", true},
|
||||
{"Chrome 60", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36", true},
|
||||
{"Chrome Mobile", "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Mobile Safari/537.36", true},
|
||||
{"MM Classic App", "Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR6.170623.013; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.81 Mobile Safari/537.36 Web-Atoms-Mobile-WebView", true},
|
||||
{"MM App 3.7.1", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Mattermost/3.7.1 Chrome/56.0.2924.87 Electron/1.6.11 Safari/537.36", true},
|
||||
{"Franz 4.0.4", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Franz/4.0.4 Chrome/52.0.2743.82 Electron/1.3.1 Safari/537.36", true},
|
||||
{"Edge 14", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393", true},
|
||||
{"Internet Explorer 11", "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko", true},
|
||||
{"Internet Explorer 9", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0", false},
|
||||
{"Safari 9", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Safari/604.1.38", true},
|
||||
{"Safari 8", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/8.0.7 Safari/600.7.12", false},
|
||||
{"Safari Mobile", "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B137 Safari/601.1", true},
|
||||
}
|
||||
for _, browser := range uaTestParameters {
|
||||
if result := CheckClientCompatability(browser.UserAgent); result == browser.Result {
|
||||
t.Logf("Pass: %s passed browser test.", browser.Name)
|
||||
} else {
|
||||
t.Errorf("Fail: %s User Agent Test failed!", browser.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user