-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.e2e.browserstack.ts
80 lines (68 loc) · 3.09 KB
/
test.e2e.browserstack.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { expect } from "chai";
import { Orientation } from "./base";
import * as webdriver from "selenium-webdriver";
import { FileDetector } from "selenium-webdriver/remote";
const TARGET_BROWSERS = [
{ name: "IE", version: "10.0" },
{ name: "IE", version: "11.0" },
{ name: "Firefox" },
{ name: "Chrome" },
];
const bundled = [
{ filename: "corrupted.jpg", value: Orientation.TOP_LEFT },
{ filename: "landscape_1.jpg", value: Orientation.TOP_LEFT },
{ filename: "landscape_2.jpg", value: Orientation.TOP_RIGHT },
{ filename: "landscape_3.jpg", value: Orientation.BOTTOM_RIGHT },
{ filename: "landscape_4.jpg", value: Orientation.BOTTOM_LEFT },
{ filename: "landscape_5.jpg", value: Orientation.LEFT_TOP },
{ filename: "landscape_6.jpg", value: Orientation.RIGHT_TOP },
{ filename: "landscape_7.jpg", value: Orientation.RIGHT_BOTTOM },
{ filename: "landscape_8.jpg", value: Orientation.LEFT_BOTTOM },
{ filename: "mooyoul.jpg", value: Orientation.TOP_LEFT },
{ filename: "portrait_1.jpg", value: Orientation.TOP_LEFT },
{ filename: "portrait_2.jpg", value: Orientation.TOP_RIGHT },
{ filename: "portrait_3.jpg", value: Orientation.BOTTOM_RIGHT },
{ filename: "portrait_4.jpg", value: Orientation.BOTTOM_LEFT },
{ filename: "portrait_5.jpg", value: Orientation.LEFT_TOP },
{ filename: "portrait_6.jpg", value: Orientation.RIGHT_TOP },
{ filename: "portrait_7.jpg", value: Orientation.RIGHT_BOTTOM },
{ filename: "portrait_8.jpg", value: Orientation.LEFT_BOTTOM },
{ filename: "rgb.tiff", value: Orientation.TOP_LEFT },
{ filename: "tless0.tiff", value: Orientation.TOP_LEFT },
{ filename: "error-origin-connectivity.png", value: Orientation.TOP_LEFT },
];
const FIXTURES = [...bundled];
describe("get-image-orientation", () => {
TARGET_BROWSERS.forEach((browser) => {
let driver: webdriver.WebDriver;
context(`on ${browser.name} ${browser.version || "latest"}`, () => {
before(async () => {
driver = new webdriver.Builder()
.usingServer("http://hub-cloud.browserstack.com/wd/hub")
.withCapabilities({
"project": "get-orientation",
"browserName": browser.name,
"browser_version": browser.version,
"resolution" : "1024x768",
"browserstack.local" : "true",
"browserstack.user" : process.env.BROWSERSTACK_USERNAME,
"browserstack.key" : process.env.BROWSERSTACK_ACCESS_KEY,
})
.build();
driver.setFileDetector(new FileDetector());
await driver.get("http://127.0.0.1:8080/test.es5.html");
});
after(async () => {
await driver.quit();
});
FIXTURES.forEach((fixture) => {
it(`should return orientation of ${fixture.filename}`, async () => {
await driver.findElement(webdriver.By.id("input")).sendKeys(`fixtures/${fixture.filename}`);
await new Promise((resolve) => setTimeout(resolve, 100));
const result = await driver.findElement(webdriver.By.id("orientation")).getText();
expect(result).to.be.eq(fixture.value.toString());
});
});
});
});
});