Skip to content

Commit

Permalink
test(functions, ios)!: disable custom HttpsError testing
Browse files Browse the repository at this point in the history
This was a regression between firebase-ios-sdk < v9 and >= v9.1.0

can revert with firebase-ios-sdk > 9.1.0 - firebase/firebase-ios-sdk#9862

BREAKING CHANGE: if your firebase functions return custom HttpsError instances, you must not upgrade yet,
custom errors suffered a regression in firebase-ios-sdk 9.0.0 and 9.1.0. The next firebase-ios-sdk release
fixes this regression, at which point you may safely use this release in combination with overriding the firebase-ios-sdk
version in your Podfile
  • Loading branch information
mikehardy committed Jun 20, 2022
1 parent 93aeed7 commit a56dc9f
Showing 1 changed file with 127 additions and 112 deletions.
239 changes: 127 additions & 112 deletions packages/functions/e2e/functions.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,130 +173,145 @@ describe('functions()', function () {

describe('HttpsError', function () {
it('errors return instance of HttpsError', async function () {
const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion');
if (device.getPlatform() !== 'ios') {
const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion');

try {
await functionRunner({});
return Promise.reject(new Error('Function did not reject with error.'));
} catch (e) {
should.equal(e.details, null);
e.code.should.equal('invalid-argument');
e.message.should.equal('Invalid test requested.');
}

try {
await functionRunner({});
return Promise.reject(new Error('Function did not reject with error.'));
} catch (e) {
should.equal(e.details, null);
e.code.should.equal('invalid-argument');
e.message.should.equal('Invalid test requested.');
return Promise.resolve();
} else {
// TODO waiting on firebase-ios-sdk > 9.1.0 - https://github.com/firebase/firebase-ios-sdk/pull/9862
this.skip();
}

return Promise.resolve();
});

it('HttpsError.details -> allows returning complex data', async function () {
let type = 'deepObject';
let inputData = SAMPLE_DATA[type];
const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion');
try {
await functionRunner({
type,
inputData,
asError: true,
});
return Promise.reject(new Error('Function did not reject with error.'));
} catch (e) {
should.deepEqual(e.details, inputData);
e.code.should.equal('cancelled');
e.message.should.equal(
'Response data was requested to be sent as part of an Error payload, so here we are!',
);
}
if (device.getPlatform() !== 'ios') {
let type = 'deepObject';
let inputData = SAMPLE_DATA[type];
const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion');
try {
await functionRunner({
type,
inputData,
asError: true,
});
return Promise.reject(new Error('Function did not reject with error.'));
} catch (e) {
should.deepEqual(e.details, inputData);
e.code.should.equal('cancelled');
e.message.should.equal(
'Response data was requested to be sent as part of an Error payload, so here we are!',
);
}

type = 'deepArray';
inputData = SAMPLE_DATA[type];
try {
await functionRunner({
type,
inputData,
asError: true,
});
return Promise.reject(new Error('Function did not reject with error.'));
} catch (e) {
should.deepEqual(e.details, inputData);
e.code.should.equal('cancelled');
e.message.should.equal(
'Response data was requested to be sent as part of an Error payload, so here we are!',
);
}

type = 'deepArray';
inputData = SAMPLE_DATA[type];
try {
await functionRunner({
type,
inputData,
asError: true,
});
return Promise.reject(new Error('Function did not reject with error.'));
} catch (e) {
should.deepEqual(e.details, inputData);
e.code.should.equal('cancelled');
e.message.should.equal(
'Response data was requested to be sent as part of an Error payload, so here we are!',
);
return Promise.resolve();
} else {
// TODO waiting on firebase-ios-sdk > 9.1.0 - https://github.com/firebase/firebase-ios-sdk/pull/9862
this.skip();
}

return Promise.resolve();
});

it('HttpsError.details -> allows returning primitives', async function () {
let type = 'number';
let inputData = SAMPLE_DATA[type];
const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion');
try {
await functionRunner({
type,
inputData,
asError: true,
});
return Promise.reject(new Error('Function did not reject with error.'));
} catch (e) {
e.code.should.equal('cancelled');
e.message.should.equal(
'Response data was requested to be sent as part of an Error payload, so here we are!',
);
should.deepEqual(e.details, inputData);
}

type = 'string';
inputData = SAMPLE_DATA[type];
try {
await functionRunner({
type,
inputData,
asError: true,
});
return Promise.reject(new Error('Function did not reject with error.'));
} catch (e) {
should.deepEqual(e.details, inputData);
e.code.should.equal('cancelled');
e.message.should.equal(
'Response data was requested to be sent as part of an Error payload, so here we are!',
);
}
if (device.getPlatform() !== 'ios') {
let type = 'number';
let inputData = SAMPLE_DATA[type];
const functionRunner = firebase.functions().httpsCallable('testFunctionDefaultRegion');
try {
await functionRunner({
type,
inputData,
asError: true,
});
return Promise.reject(new Error('Function did not reject with error.'));
} catch (e) {
e.code.should.equal('cancelled');
e.message.should.equal(
'Response data was requested to be sent as part of an Error payload, so here we are!',
);
should.deepEqual(e.details, inputData);
}

type = 'string';
inputData = SAMPLE_DATA[type];
try {
await functionRunner({
type,
inputData,
asError: true,
});
return Promise.reject(new Error('Function did not reject with error.'));
} catch (e) {
should.deepEqual(e.details, inputData);
e.code.should.equal('cancelled');
e.message.should.equal(
'Response data was requested to be sent as part of an Error payload, so here we are!',
);
}

type = 'boolean';
inputData = SAMPLE_DATA[type];
try {
await functionRunner({
type,
inputData,
asError: true,
});
return Promise.reject(new Error('Function did not reject with error.'));
} catch (e) {
should.deepEqual(e.details, inputData);
e.code.should.equal('cancelled');
e.message.should.equal(
'Response data was requested to be sent as part of an Error payload, so here we are!',
);
}

type = 'null';
inputData = SAMPLE_DATA[type];
try {
await functionRunner({
type,
inputData,
asError: true,
});
return Promise.reject(new Error('Function did not reject with error.'));
} catch (e) {
should.deepEqual(e.details, inputData);
e.code.should.equal('cancelled');
e.message.should.equal(
'Response data was requested to be sent as part of an Error payload, so here we are!',
);
}

type = 'boolean';
inputData = SAMPLE_DATA[type];
try {
await functionRunner({
type,
inputData,
asError: true,
});
return Promise.reject(new Error('Function did not reject with error.'));
} catch (e) {
should.deepEqual(e.details, inputData);
e.code.should.equal('cancelled');
e.message.should.equal(
'Response data was requested to be sent as part of an Error payload, so here we are!',
);
}

type = 'null';
inputData = SAMPLE_DATA[type];
try {
await functionRunner({
type,
inputData,
asError: true,
});
return Promise.reject(new Error('Function did not reject with error.'));
} catch (e) {
should.deepEqual(e.details, inputData);
e.code.should.equal('cancelled');
e.message.should.equal(
'Response data was requested to be sent as part of an Error payload, so here we are!',
);
return Promise.resolve();
} else {
// TODO waiting on firebase-ios-sdk > 9.1.0 - https://github.com/firebase/firebase-ios-sdk/pull/9862
this.skip();
}

return Promise.resolve();
});

it('HttpsCallableOptions.timeout will error when timeout is exceeded', async function () {
Expand Down

1 comment on commit a56dc9f

@vercel
Copy link

@vercel vercel bot commented on a56dc9f Jun 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.