Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
Added a way to differentiate SAC local testing vs Github testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-015 committed Nov 19, 2020
1 parent a1faadb commit fed29ef
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ jobs:
run: pub run test
env:
FIG_API_KEY: ${{ secrets.FIG_API_KEY }}
PB_IS_GITHUB_TEST: true
2 changes: 1 addition & 1 deletion test/lib/input_services/input_to_pbdl_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void main() {
});
test('Sketch Test', () {
var sketchNodeTree = SketchController().generateSketchNodeTree(
ids, ids.metaFileJson['pagesAndArtboards'], outputPath);
ids.archive, ids.metaFileJson['pagesAndArtboards'], outputPath);

expect(sketchNodeTree != null, true);
expect(sketchNodeTree is SketchNodeTree, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,16 @@ void main() {

for (var i = 0; i < 2; i++) {
var masterParameter = PBSharedParameterProp(
'masterParam',
parameterAlternator ? String : PBSharedInstanceIntermediateNode,
parameterAlternator ? null : instanceNode0,
true,
parameterAlternator ? 'test0' : 'test1',
parameterAlternator ? 'uuid0' : INSTANCE0_UUID,
null,
);
var instaceParameter = PBSharedParameterValue(
parameterAlternator ? String : PBSharedInstanceIntermediateNode,
parameterAlternator ? 'test' : instanceNode0,
null,
'instanceParam',
);

instaceValues.add(instaceParameter);
Expand Down
49 changes: 47 additions & 2 deletions test/lib/output_services/png_gen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,52 @@ void main() async {
var process;
var uuids;

group('Sketch PNG Testing', () {
/// This boolean is used to differentiate between local testing and github testing.
/// This environment variable should only be set in github and the test will fail
/// if this environment variable is enabled locally
var isGithub = Platform.environment.containsKey('PB_IS_GITHUB_TEST') &&
Platform.environment['PB_IS_GITHUB_TEST'].contains('true');

group('Local Sketch PNG Testing:', () {
setUpAll(() async {
MainInfo().sketchPath =
'${Directory.current.path}/test/assets/parabeac_demo_alt.sketch';
uuids = [
'85D93FCD-5A69-4DAF-AE90-351CD9B64554', // Shape Group
'B12B62C2-D7E3-452E-963E-A24216DD0942', // Shape Path
];

/// Need to ensure Sketch Asset Converter is installed and running
var install = await Process.start('bash', [
'${Directory.current.path}/pb-scripts/install.sh',
]);
var exitCode = await install.exitCode;
if (exitCode != 0) {
throw 'install.sh finished with exit code $exitCode';
}
process = await Process.start('npm', ['run', 'prod'],
workingDirectory: '${Directory.current.path}/SketchAssetConverter');

await for (var event in process.stdout.transform(utf8.decoder)) {
if (event.toLowerCase().contains('server is listening on port')) {
break;
}
}
});

test('Testing Image Conversion', () async {
for (var uuid in uuids) {
var image = await convertImageLocal(uuid, 23, 21);
expect(image, isNot(null));
}
});

tearDownAll(() {
process.kill();
});
}, skip: isGithub);

group('Github Sketch PNG Testing:', () {
setUpAll(() async {
MainInfo().sketchPath =
'${Directory.current.path}/test/assets/parabeac_demo_alt.sketch';
Expand All @@ -26,7 +71,7 @@ void main() async {
expect(image, isNot(null));
}
});
});
}, skip: !isGithub);

group('Figma PNG Testing', () {
setUpAll(() {
Expand Down

0 comments on commit fed29ef

Please sign in to comment.