Skip to content

Commit 5138d19

Browse files
authored
Added Windows Tests (#40)
1 parent 18832ad commit 5138d19

File tree

14 files changed

+4290
-223
lines changed

14 files changed

+4290
-223
lines changed

.eslintignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
node_modules
1+
node_modules
2+
jest-setups/jest.setup.js
3+
jest-setups/jest.setup.windows.js

.github/workflows/windows-ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Windows CI
2+
on: [pull_request]
3+
4+
jobs:
5+
run-windows-tests:
6+
name: Build & run tests
7+
runs-on: windows-2019
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
name: Checkout Code
12+
13+
- name: Setup Node.js
14+
uses: actions/setup-node@v1
15+
with:
16+
node-version: '12.9.1'
17+
18+
- name: Setup MSBuild
19+
uses: microsoft/setup-msbuild@v1.0.0
20+
with:
21+
vs-version: 16.5
22+
23+
- name: Setup NuGet
24+
uses: NuGet/setup-nuget@v1.0.2
25+
26+
- name: Check node modules cache
27+
uses: actions/cache@v1
28+
id: yarn-cache
29+
with:
30+
path: ./node_modules
31+
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
32+
restore-keys: |
33+
${{ runner.os }}-yarn-
34+
- name: Install node modules
35+
if: steps.yarn-cache.outputs.cache-hit != 'true'
36+
run:
37+
yarn add react-native@0.62 --dev
38+
yarn --pure-lockfile
39+
40+
- name: yarn build
41+
if: steps.yarn-cache.outputs.cache-hit == 'true'
42+
run: |
43+
yarn build
44+
yarn tsc
45+
46+
- name: NuGet restore
47+
run: nuget restore example\windows\ProgressViewExample.sln
48+
49+
- name: Build x64 release
50+
run: msbuild .\example\windows\ProgressViewExample.sln /p:Configuration=Release /p:Platform=x64 -m
51+
52+
- name: Deploy
53+
shell: powershell
54+
run: |
55+
cd example
56+
Copy-Item -Path windows\x64\Release -Recurse -Destination windows\
57+
npx react-native run-windows --arch x64 --release --no-build --no-packager
58+
59+
60+
- name: Start Appium server
61+
shell: powershell
62+
run: Start-Process PowerShell -ArgumentList "yarn appium"
63+
64+
- name: Run tests
65+
run: yarn test:windows

__tests__/ProgressViewWindows.test.js

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/**
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License.
4+
*/
5+
6+
import {driver, By2} from 'selenium-appium';
7+
import {until} from 'selenium-webdriver';
8+
9+
const setup = require('../jest-setups/jest.setup');
10+
jest.setTimeout(50000);
11+
12+
beforeAll(() => {
13+
return driver.startWithCapabilities(setup.capabilites);
14+
});
15+
16+
afterAll(() => {
17+
return driver.quit();
18+
});
19+
20+
describe('Windows Tests', () => {
21+
test('Render every windows example app progress bars', async () => {
22+
try {
23+
await driver.wait(
24+
until.elementLocated(
25+
By2.nativeXpath('//ProgressBar[@AutomationId="p1"]'),
26+
),
27+
);
28+
} catch (error) {
29+
throw new Error('Progress Bar 1 failed to render');
30+
}
31+
try {
32+
await driver.wait(
33+
until.elementLocated(
34+
By2.nativeXpath('//ProgressBar[@AutomationId="p2"]'),
35+
),
36+
);
37+
} catch (error) {
38+
throw new Error('Progress Bar 2 failed to render');
39+
}
40+
try {
41+
await driver.wait(
42+
until.elementLocated(
43+
By2.nativeXpath('//ProgressBar[@AutomationId="p3"]'),
44+
),
45+
);
46+
} catch (error) {
47+
throw new Error('Progress Bar 3 failed to render');
48+
}
49+
try {
50+
await driver.wait(
51+
until.elementLocated(
52+
By2.nativeXpath('//ProgressBar[@AutomationId="p4"]'),
53+
),
54+
);
55+
} catch (error) {
56+
throw new Error('Progress Bar 4 failed to render');
57+
}
58+
try {
59+
await driver.wait(
60+
until.elementLocated(
61+
By2.nativeXpath('//ProgressBar[@AutomationId="Indeterminate"]'),
62+
),
63+
);
64+
} catch (error) {
65+
throw new Error('Indeterminate Progress Bar failed to render');
66+
}
67+
try {
68+
await driver.wait(
69+
until.elementLocated(
70+
By2.nativeXpath('//ProgressBar[@AutomationId="localimage"]'),
71+
),
72+
);
73+
} catch (error) {
74+
throw new Error('Local Image Progress Bar failed to render');
75+
}
76+
try {
77+
await driver.wait(
78+
until.elementLocated(
79+
By2.nativeXpath('//ProgressBar[@AutomationId="networkimage"]'),
80+
),
81+
);
82+
} catch (error) {
83+
throw new Error('Network Image Progress Bar failed to render');
84+
}
85+
try {
86+
await driver.wait(
87+
until.elementLocated(
88+
By2.nativeXpath('//ProgressBar[@AutomationId="trackcolor"]'),
89+
),
90+
);
91+
} catch (error) {
92+
throw new Error('Track Color Progress Bar failed to render');
93+
}
94+
try {
95+
await driver.wait(
96+
until.elementLocated(
97+
By2.nativeXpath('//ProgressBar[@AutomationId="bar"]'),
98+
),
99+
);
100+
} catch (error) {
101+
throw new Error('Bar Style Progress Bar failed to render');
102+
}
103+
});
104+
});

example/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#
33
.DS_Store
44

5+
*.binlog
6+
57
# Xcode
68
#
79
build/

example/App.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,45 @@ export class App extends React.Component<Props, State> {
4545
<ProgressView
4646
style={styles.progressView}
4747
progress={this.getProgress(0)}
48+
testID={'p1'}
4849
/>
4950
<ProgressView
5051
style={styles.progressView}
5152
progressTintColor="purple"
5253
progress={this.getProgress(0.2)}
54+
testID={'p2'}
5355
/>
5456
<ProgressView
5557
style={styles.progressView}
5658
progressTintColor="red"
5759
progress={this.getProgress(0.4)}
60+
testID={'p3'}
5861
/>
5962
<ProgressView
6063
style={styles.progressView}
6164
progressTintColor="orange"
6265
progress={this.getProgress(0.6)}
66+
testID={'p4'}
6367
/>
6468
<ProgressView
6569
style={styles.progressView}
6670
progressTintColor="yellow"
6771
progress={this.getProgress(0.8)}
72+
testID={'p5'}
6873
/>
6974

7075
<Text style={styles.text}>isIndeterminate</Text>
71-
<ProgressView style={styles.progressView} isIndeterminate={true} />
76+
<ProgressView
77+
style={styles.progressView}
78+
isIndeterminate={true}
79+
testID={'Indeterminate'}
80+
/>
7281
<Text style={styles.text}>ProgressImage with local image</Text>
7382
<ProgressView
7483
style={styles.progressView}
7584
progress={0.5}
7685
progressImage={require('./test.png')}
86+
testID={'localimage'}
7787
/>
7888
<Text style={styles.text}>TrackImage with network image</Text>
7989
{Platform.OS === 'windows' ? (
@@ -83,6 +93,7 @@ export class App extends React.Component<Props, State> {
8393
trackImage={{
8494
uri: 'https://homepages.cae.wisc.edu/~ece533/images/cat.png',
8595
}}
96+
testID={'networkimage'}
8697
/>
8798
) : (
8899
<Text>Network Images only work on Windows</Text>
@@ -93,12 +104,14 @@ export class App extends React.Component<Props, State> {
93104
progress={0.8}
94105
trackTintColor={'red'}
95106
progressTintColor={'yellow'}
107+
testID={'trackcolor'}
96108
/>
97109
<Text style={styles.text}>Bar Style</Text>
98110
<ProgressView
99111
style={styles.progressView}
100112
progress={0.4}
101113
progressViewStyle={'bar'}
114+
testID={'bar'}
102115
/>
103116
</SafeAreaView>
104117
);
Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,78 @@
1-
/Bundle
1+
*AppPackages*
2+
*BundleArtifacts*
3+
*Bundle
4+
5+
#OS junk files
6+
[Tt]humbs.db
7+
*.DS_Store
8+
#Visual Studio files
9+
*.[Oo]bj
10+
*.user
11+
*.aps
12+
*.pch
13+
*.vspscc
14+
*.vssscc
15+
*_i.c
16+
*_p.c
17+
*.ncb
18+
*.suo
19+
*.tlb
20+
*.tlh
21+
*.bak
22+
*.[Cc]ache
23+
*.ilk
24+
*.log
25+
*.lib
26+
*.sbr
27+
*.sdf
28+
*.opensdf
29+
*.opendb
30+
*.unsuccessfulbuild
31+
ipch/
32+
[Oo]bj/
33+
[Bb]in
34+
[Dd]ebug*/
35+
[Rr]elease*/
36+
Ankh.NoLoad
37+
# Visual C++ cache files
38+
ipch/
39+
*.aps
40+
*.ncb
41+
*.opendb
42+
*.opensdf
43+
*.sdf
44+
*.cachefile
45+
*.VC.db
46+
*.VC.VC.opendb
47+
#MonoDevelop
48+
*.pidb
49+
*.userprefs
50+
#Tooling
51+
_ReSharper*/
52+
*.resharper
53+
[Tt]est[Rr]esult*
54+
*.sass-cache
55+
#Project files
56+
[Bb]uild/
57+
#Subversion files
58+
.svn
59+
# Office Temp Files
60+
~$*
61+
# vim Temp Files
62+
*~
63+
#NuGet
64+
packages/
65+
*.nupkg
66+
#ncrunch
67+
*ncrunch*
68+
*crunch*.local.xml
69+
# visual studio database projects
70+
*.dbmdl
71+
#Test files
72+
*.testsettings
73+
#Other files
74+
*.DotSettings
75+
.vs/
76+
*project.lock.json
77+
#Files generated by the VS build
78+
**/Generated Files/**

example/windows/ProgressViewExample/Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
IgnorableNamespaces="uap mp">
88

99
<Identity
10-
Name="a0fe1646-6d2d-45b5-bd15-05b556266ebe"
10+
Name="ProgressViewExample"
1111
Publisher="CN=t-takapo"
1212
Version="1.0.0.0" />
1313

example/windows/ProgressViewExample/ProgressViewExample.vcxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<PackageCertificateKeyFile>ProgressViewExample_TemporaryKey.pfx</PackageCertificateKeyFile>
1919
<PackageCertificateThumbprint>3A8F3D8AE21263D498BBEFD56EF6908E4B03496F</PackageCertificateThumbprint>
2020
<PackageCertificatePassword>password</PackageCertificatePassword>
21+
<AppxPackageSigningEnabled>true</AppxPackageSigningEnabled>
2122
</PropertyGroup>
2223
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
2324
<ItemGroup Label="ProjectConfigurations">
@@ -143,6 +144,7 @@
143144
<ItemGroup>
144145
<None Include="packages.config" />
145146
<None Include="PropertySheet.props" />
147+
<None Include="ProgressViewExample_TemporaryKey.pfx" />
146148
<Text Include="readme.txt">
147149
<DeploymentContent>false</DeploymentContent>
148150
</Text>
@@ -153,6 +155,12 @@
153155
</ProjectReference>
154156
</ItemGroup>
155157
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
158+
<PropertyGroup>
159+
<BundleEntryFile>index.js</BundleEntryFile>
160+
<BundlerExtraArgs>--use-react-native-windows</BundlerExtraArgs>
161+
</PropertyGroup>
162+
<Import Project="..\..\..\node_modules\react-native-windows\PropertySheets\Bundle.props" />
163+
<Import Project="..\..\..\node_modules\react-native-windows\PropertySheets\Bundle.Cpp.targets" />
156164
<PropertyGroup Label="ReactNativeWindowsNodeProps">
157165
<ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir>
158166
</PropertyGroup>

example/windows/ProgressViewExample/ProgressViewExample.vcxproj.filters

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<ItemGroup>
5454
<None Include="PropertySheet.props" />
5555
<None Include="packages.config" />
56+
<None Include="ProgressViewExample_TemporaryKey.pfx" />
5657
</ItemGroup>
5758
<ItemGroup>
5859
<Text Include="readme.txt" />

jest-setups/jest.setup.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {windowsAppDriverCapabilities} from 'selenium-appium';
2+
3+
switch (platform) {
4+
case 'windows':
5+
const webViewWindowsAppId = 'ProgressViewExample_kvqejeg71e612!App';
6+
module.exports = {
7+
capabilites: windowsAppDriverCapabilities(webViewWindowsAppId),
8+
};
9+
break;
10+
default:
11+
throw 'Unknown platform: ' + platform;
12+
}

0 commit comments

Comments
 (0)