-
Notifications
You must be signed in to change notification settings - Fork 13
chore: Update unit tests to run on multiple Expo versions #235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
76a31fc
Update Android tests to parse XML and Gradle files instead of snapshots
mahmoud-elmorabea dd60d73
Update iOS common tests to work with dynamic test app path
mahmoud-elmorabea 8e5ae46
Update iOS APN tests to more concise assertions instead of snapshots
mahmoud-elmorabea 30a39a0
Update iOS FCM tests to more concise assertions instead of snapshots
mahmoud-elmorabea add6fb7
Update validation script to pass env vars to tests
mahmoud-elmorabea 7c848d6
Fix default test app path
mahmoud-elmorabea dabf06f
Move Gradle to JS to a dev dependency
mahmoud-elmorabea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
182 changes: 0 additions & 182 deletions
182
__tests__/android/__snapshots__/app-gradle-build.test.js.snap
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
__tests__/android/__snapshots__/main-gradle-build.test.js.snap
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -1,12 +1,14 @@ | ||
| const fs = require("fs-extra"); | ||
| const { testAppPath } = require("../utils"); | ||
| const path = require("path"); | ||
| const g2js = require('gradle-to-js/lib/parser'); | ||
|
|
||
| const testProjectPath = path.join(__dirname, "../../test-app"); | ||
| const testProjectPath = testAppPath(); | ||
| const androidPath = path.join(testProjectPath, "android"); | ||
| const appBuildGradlePath = path.join(androidPath, "app/build.gradle"); | ||
|
|
||
| test("Plugin applies Google Services plugin in the app Gradle build file", async () => { | ||
| const content = await fs.readFile(appBuildGradlePath, "utf8"); | ||
| const gradleFileAsJson = await g2js.parseFile(appBuildGradlePath); | ||
|
|
||
| expect(content).toMatchSnapshot(); | ||
| const hasPlugin = gradleFileAsJson.apply.some(plugin => plugin.includes('com.google.gms.google-services')); | ||
| expect(hasPlugin).toBe(true); | ||
| }); |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,14 +1,36 @@ | ||
| const { testAppPath } = require("../utils"); | ||
| const fs = require("fs-extra"); | ||
| const path = require("path"); | ||
| const { parseString } = require('xml2js'); | ||
|
|
||
| const testProjectPath = path.join(__dirname, "../../test-app"); | ||
| const testProjectPath = testAppPath(); | ||
| const androidPath = path.join(testProjectPath, "android"); | ||
| const appManifestPath = path.join(androidPath, "app/src/main/AndroidManifest.xml"); | ||
|
|
||
| test("Plugin injects CustomerIOFirebaseMessagingService in the app manifest", async () => { | ||
| // When setHighPriorityPushHandler config is set to true when setting up the plugin | ||
| // an intent filter for CustomerIOFirebaseMessagingService is added to the app Manifest file | ||
| const content = await fs.readFile(appManifestPath, "utf8"); | ||
| const manifestContent = await fs.readFile(appManifestPath, "utf8"); | ||
|
|
||
| expect(content).toMatchSnapshot(); | ||
| parseString(manifestContent, (err, manifest) => { | ||
| if (err) throw err; | ||
|
|
||
| const expectedServiceName = 'io.customer.messagingpush.CustomerIOFirebaseMessagingService'; | ||
| const expectedAction = 'com.google.firebase.MESSAGING_EVENT'; | ||
|
|
||
| const application = manifest?.manifest?.application?.[0]; | ||
| expect(application).toBeDefined(); | ||
|
|
||
| const services = application.service || []; | ||
| const service = services.find(service => service['$']['android:name'] === expectedServiceName); | ||
| expect(service).toBeDefined(); | ||
|
|
||
| expect(service['$']['android:exported']).toBe('false'); | ||
| expect(service['intent-filter']).toBeDefined(); | ||
| expect(service['intent-filter'].length).toBeGreaterThan(0); | ||
|
|
||
| const actions = service['intent-filter'][0].action || []; | ||
| const hasExpectedAction = actions.some(action => action['$']['android:name'] === expectedAction); | ||
| expect(hasExpectedAction).toBe(true); | ||
| }); | ||
| }); |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,12 +1,23 @@ | ||
| const fs = require("fs-extra"); | ||
| const path = require("path"); | ||
| const { testAppPath } = require("../utils"); | ||
| const fs = require('fs-extra'); | ||
| const path = require('path'); | ||
| const g2js = require('gradle-to-js/lib/parser'); | ||
|
|
||
| const testProjectPath = path.join(__dirname, "../../test-app"); | ||
| const androidPath = path.join(testProjectPath, "android"); | ||
| const mainBuildGradlePath = path.join(androidPath, "build.gradle"); | ||
| const testProjectPath = testAppPath(); | ||
| const androidPath = path.join(testProjectPath, 'android'); | ||
| const mainBuildGradlePath = path.join(androidPath, 'build.gradle'); | ||
|
|
||
| test("Plugin injects expted dependencies in the main Gradle build file", async () => { | ||
| const content = await fs.readFile(mainBuildGradlePath, "utf8"); | ||
| test('Plugin injects expted dependencies in the main Gradle build file', async () => { | ||
| const mainBuildGradleContent = await fs.readFile(mainBuildGradlePath, "utf8"); | ||
| const gradleFileAsJson = await g2js.parseFile(mainBuildGradlePath); | ||
|
|
||
| expect(content).toMatchSnapshot(); | ||
| const hasBuildScriptDependency = gradleFileAsJson.buildscript.dependencies.some( | ||
| (dependency) => | ||
| dependency.group === 'com.google.gms' && | ||
| dependency.name === 'google-services' && | ||
| dependency.type === 'classpath' && | ||
| dependency.version === '4.3.13' | ||
| ); | ||
| expect(hasBuildScriptDependency).toBe(true); | ||
| expect(mainBuildGradleContent).toContain('maven { url "https://maven.gist.build" }'); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in the test description: 'expted' should be corrected to 'expected'.