Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 0 additions & 182 deletions __tests__/android/__snapshots__/app-gradle-build.test.js.snap

This file was deleted.

46 changes: 0 additions & 46 deletions __tests__/android/__snapshots__/app-manifest.test.js.snap

This file was deleted.

48 changes: 0 additions & 48 deletions __tests__/android/__snapshots__/main-gradle-build.test.js.snap

This file was deleted.

10 changes: 6 additions & 4 deletions __tests__/android/app-gradle-build.test.js
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);
});
28 changes: 25 additions & 3 deletions __tests__/android/app-manifest.test.js
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);
});
});
27 changes: 19 additions & 8 deletions __tests__/android/main-gradle-build.test.js
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 () => {
Copy link

Copilot AI Mar 24, 2025

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'.

Suggested change
test('Plugin injects expted dependencies in the main Gradle build file', async () => {
test('Plugin injects expected dependencies in the main Gradle build file', async () => {

Copilot uses AI. Check for mistakes.
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" }');
});
Loading