Skip to content

Commit a92f2bc

Browse files
committed
Merge branch 'main' into telemetry
2 parents 1625ee1 + e6415dd commit a92f2bc

File tree

6 files changed

+36
-14
lines changed

6 files changed

+36
-14
lines changed

.changeset/thin-sheep-smoke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/firestore': patch
3+
---
4+
5+
Fix: Corrected misleading error message when doc() is called with undefined.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ Before you file this pull request, please read these guidelines:
1414

1515
### API Changes
1616

17-
* At this time we cannot accept changes that affect the public API. If you'd like to help
18-
us make Firebase APIs better, please propose your change in an issue so that we
19-
can discuss it together.
17+
* Changes that affect the public API will require internal review. Before making a
18+
PR that changes the public API, we would suggest first proposing your change in an
19+
issue so that we can discuss it together.

packages/ai/integration/constants.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,22 @@ export const liveTestConfigs: readonly TestConfig[] = backends.flatMap(
9494
}
9595
);
9696

97+
/**
98+
* Test configurations used for server prompt templates integration tests.
99+
* Server prompt templates don't define the model name from the client, so these test configs
100+
* do not define a model string.
101+
* These tests should only run once per backend, rather than once per backend *per model*.
102+
*/
103+
export const promptTemplatesTestConfigs: readonly TestConfig[] =
104+
backends.flatMap(backend => {
105+
const ai = getAI(app, { backend });
106+
return {
107+
ai,
108+
model: '', // Unused by prompt templates tests
109+
toString: () => formatConfigAsString({ ai, model: '' }).trim()
110+
};
111+
});
112+
97113
export const TINY_IMG_BASE64 =
98114
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=';
99115
export const IMAGE_MIME_TYPE = 'image/png';

packages/ai/integration/prompt-templates.test.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import {
2121
getTemplateGenerativeModel,
2222
getTemplateImagenModel
2323
} from '../src';
24-
import { testConfigs } from './constants';
25-
import { STAGING_URL } from '../src/constants';
24+
import { promptTemplatesTestConfigs } from './constants';
2625

2726
const templateBackendSuffix = (
2827
backendType: BackendType
@@ -31,13 +30,11 @@ const templateBackendSuffix = (
3130

3231
describe('Prompt templates', function () {
3332
this.timeout(20_000);
34-
testConfigs.forEach(testConfig => {
33+
promptTemplatesTestConfigs.forEach(testConfig => {
3534
describe(`${testConfig.toString()}`, () => {
3635
describe('Generative Model', () => {
3736
it('successfully generates content', async () => {
38-
const model = getTemplateGenerativeModel(testConfig.ai, {
39-
baseUrl: STAGING_URL
40-
});
37+
const model = getTemplateGenerativeModel(testConfig.ai);
4138
const { response } = await model.generateContent(
4239
`sassy-greeting-${templateBackendSuffix(
4340
testConfig.ai.backend.backendType
@@ -49,16 +46,14 @@ describe('Prompt templates', function () {
4946
});
5047
describe('Imagen model', async () => {
5148
it('successfully generates images', async () => {
52-
const model = getTemplateImagenModel(testConfig.ai, {
53-
baseUrl: STAGING_URL
54-
});
49+
const model = getTemplateImagenModel(testConfig.ai);
5550
const { images } = await model.generateImages(
5651
`portrait-${templateBackendSuffix(
5752
testConfig.ai.backend.backendType
5853
)}`,
5954
{ animal: 'Rhino' }
6055
);
61-
expect(images.length).to.equal(2); // We ask for two images in the prompt template
56+
expect(images.length).to.equal(1); // The template is configured to generate one image.
6257
});
6358
});
6459
});

packages/firestore/src/lite-api/reference.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ export function doc<AppModelType, DbModelType extends DocumentData>(
651651
) {
652652
throw new FirestoreError(
653653
Code.INVALID_ARGUMENT,
654-
'Expected first argument to collection() to be a CollectionReference, ' +
654+
'Expected first argument to doc() to be a CollectionReference, ' +
655655
'a DocumentReference or FirebaseFirestore'
656656
);
657657
}

packages/firestore/test/lite/integration.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@ describe('doc', () => {
285285

286286
it('validates path', () => {
287287
return withTestDb(db => {
288+
expect(() =>
289+
// @ts-expect-error
290+
doc({}, 'coll/doc')
291+
).to.throw(
292+
'Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore'
293+
);
288294
expect(() => doc(db, 'coll')).to.throw(
289295
'Invalid document reference. Document references must have an even ' +
290296
'number of segments, but coll has 1.'

0 commit comments

Comments
 (0)