From cff8fb67ec9ce7ba64a8d967df2455e2f0d366b4 Mon Sep 17 00:00:00 2001 From: vishnu Date: Wed, 15 Oct 2025 12:49:26 +0530 Subject: [PATCH 1/5] fix tests --- spec/src/modules/quizzes.js | 36 ++++++++++++------------------- src/types/tests/quizzes.test-d.ts | 3 +++ 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/spec/src/modules/quizzes.js b/spec/src/modules/quizzes.js index 7e1c0c00..69262987 100644 --- a/spec/src/modules/quizzes.js +++ b/spec/src/modules/quizzes.js @@ -49,7 +49,7 @@ describe(`ConstructorIO - Quizzes${bundledDescriptionSuffix}`, () => { fetchSpy = null; }); - describe('getQuizAllQuestions', () => { + describe.only('getQuizAllQuestions', () => { it('Should return a result provided a valid apiKey and quizId', () => { const { quizzes } = new ConstructorIO({ apiKey: quizApiKey, @@ -62,7 +62,7 @@ describe(`ConstructorIO - Quizzes${bundledDescriptionSuffix}`, () => { expect(res).to.have.property('quiz_version_id').to.be.an('string'); expect(res).to.have.property('questions').to.be.an('array'); expect(res.questions[0].id).to.equal(1); - expect(res.total_questions).to.equal(1); + expect(res.total_questions).to.equal(4); expect(fetchSpy).to.have.been.called; expect(requestedUrlParams).to.have.property('key'); expect(requestedUrlParams).to.have.property('i'); @@ -89,26 +89,6 @@ describe(`ConstructorIO - Quizzes${bundledDescriptionSuffix}`, () => { }); }); - it('Should return a result provided a valid apiKey, quizId and quizVersionId', () => { - const { quizzes } = new ConstructorIO({ - apiKey: quizApiKey, - fetch: fetchSpy, - }); - - return quizzes.getQuizAllQuestions(validQuizId).then((initialResponse) => { - const quizVersionId = initialResponse.quiz_version_id; - - return quizzes.getQuizAllQuestions(validQuizId, { quizVersionId }).then((res) => { - const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); - - expect(res).to.have.property('questions').to.be.an('array'); - expect(res).to.have.property('quiz_version_id').to.be.an('string').to.equal(quizVersionId); - expect(res.total_questions).to.equal(1); - expect(fetchSpy).to.have.been.called; - expect(requestedUrlParams).to.have.property('quiz_version_id').to.equal(quizVersionId); - }); - }); - }); it('Should error when fetching quiz questions with an invalid quizId', () => { const { quizzes } = new ConstructorIO({ @@ -145,6 +125,18 @@ describe(`ConstructorIO - Quizzes${bundledDescriptionSuffix}`, () => { return expect(quizzes.getQuizAllQuestions(validQuizId, { quizVersionId: 'foo' })).to.eventually.be.rejected; }); + + it('Should return 400 when quiz has jump logic', () => { + const { quizzes } = new ConstructorIO({ + apiKey: quizApiKey, + fetch: fetchSpy, + }); + + return expect(quizzes.getQuizAllQuestions('test-quiz-2')).to.eventually.be.rejected.then((err) => { + expect(err.status).to.equal(400); + expect(err.message).to.equal('The requested quiz does not support question retrieval.'); + }); + }) }); describe('getQuizNextQuestion', () => { diff --git a/src/types/tests/quizzes.test-d.ts b/src/types/tests/quizzes.test-d.ts index 975b3fc1..6a9af0c2 100644 --- a/src/types/tests/quizzes.test-d.ts +++ b/src/types/tests/quizzes.test-d.ts @@ -8,6 +8,7 @@ expectAssignable({ description: 'Sample description', type: 'multiple', cta_text: 'Next', + is_skippable: false, images: { primary_url: 'https://example.com/image', primary_alt: 'Example image', @@ -44,6 +45,7 @@ expectAssignable({ id: 1, title: 'Sample open text question', description: 'Sample description', + is_skippable: false, type: 'open', cta_text: 'Next', images: { @@ -299,4 +301,5 @@ expectAssignable({ }, quiz_version_id: '6bfaa6d5-7272-466b-acd9-4bcf322a2f1e', quiz_id: 'test-quiz', + metadata: null, }); From 923eeb1f217964a72a272fb56ecf60a8a706768f Mon Sep 17 00:00:00 2001 From: vishnu Date: Wed, 15 Oct 2025 12:50:09 +0530 Subject: [PATCH 2/5] fix tests --- spec/src/modules/quizzes.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/src/modules/quizzes.js b/spec/src/modules/quizzes.js index 69262987..1be9aa39 100644 --- a/spec/src/modules/quizzes.js +++ b/spec/src/modules/quizzes.js @@ -89,7 +89,6 @@ describe(`ConstructorIO - Quizzes${bundledDescriptionSuffix}`, () => { }); }); - it('Should error when fetching quiz questions with an invalid quizId', () => { const { quizzes } = new ConstructorIO({ apiKey: quizApiKey, @@ -136,7 +135,7 @@ describe(`ConstructorIO - Quizzes${bundledDescriptionSuffix}`, () => { expect(err.status).to.equal(400); expect(err.message).to.equal('The requested quiz does not support question retrieval.'); }); - }) + }); }); describe('getQuizNextQuestion', () => { From dd70d78976f25fb720a6e4e3194f6ee9261f1cd0 Mon Sep 17 00:00:00 2001 From: vishnu Date: Wed, 15 Oct 2025 12:52:22 +0530 Subject: [PATCH 3/5] remove only --- spec/src/modules/quizzes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/src/modules/quizzes.js b/spec/src/modules/quizzes.js index 1be9aa39..373cbe8e 100644 --- a/spec/src/modules/quizzes.js +++ b/spec/src/modules/quizzes.js @@ -49,7 +49,7 @@ describe(`ConstructorIO - Quizzes${bundledDescriptionSuffix}`, () => { fetchSpy = null; }); - describe.only('getQuizAllQuestions', () => { + describe('getQuizAllQuestions', () => { it('Should return a result provided a valid apiKey and quizId', () => { const { quizzes } = new ConstructorIO({ apiKey: quizApiKey, From 88b243b5ed9e585d281cab1bbd8ee08b4bd9b2da Mon Sep 17 00:00:00 2001 From: vishnu Date: Wed, 15 Oct 2025 17:55:32 +0530 Subject: [PATCH 4/5] readd test --- spec/src/modules/quizzes.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/spec/src/modules/quizzes.js b/spec/src/modules/quizzes.js index 373cbe8e..c6833402 100644 --- a/spec/src/modules/quizzes.js +++ b/spec/src/modules/quizzes.js @@ -49,7 +49,7 @@ describe(`ConstructorIO - Quizzes${bundledDescriptionSuffix}`, () => { fetchSpy = null; }); - describe('getQuizAllQuestions', () => { + describe.only('getQuizAllQuestions', () => { it('Should return a result provided a valid apiKey and quizId', () => { const { quizzes } = new ConstructorIO({ apiKey: quizApiKey, @@ -89,6 +89,27 @@ describe(`ConstructorIO - Quizzes${bundledDescriptionSuffix}`, () => { }); }); + it('Should return a result provided a valid apiKey, quizId and quizVersionId', () => { + const { quizzes } = new ConstructorIO({ + apiKey: quizApiKey, + fetch: fetchSpy, + }); + + return quizzes.getQuizAllQuestions(validQuizId).then((initialResponse) => { + const quizVersionId = initialResponse.quiz_version_id; + + return quizzes.getQuizAllQuestions(validQuizId, { quizVersionId }).then((res) => { + const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); + + expect(res).to.have.property('questions').to.be.an('array'); + expect(res).to.have.property('quiz_version_id').to.be.an('string').to.equal(quizVersionId); + expect(res.total_questions).to.equal(4); + expect(fetchSpy).to.have.been.called; + expect(requestedUrlParams).to.have.property('quiz_version_id').to.equal(quizVersionId); + }); + }); + }); + it('Should error when fetching quiz questions with an invalid quizId', () => { const { quizzes } = new ConstructorIO({ apiKey: quizApiKey, From 9dff4b5bb2c442f183904d3f9871ebaf12229b0b Mon Sep 17 00:00:00 2001 From: Enes Kutay SEZEN Date: Wed, 15 Oct 2025 08:28:15 -0400 Subject: [PATCH 5/5] Update spec/src/modules/quizzes.js --- spec/src/modules/quizzes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/src/modules/quizzes.js b/spec/src/modules/quizzes.js index c6833402..6ccd1201 100644 --- a/spec/src/modules/quizzes.js +++ b/spec/src/modules/quizzes.js @@ -49,7 +49,7 @@ describe(`ConstructorIO - Quizzes${bundledDescriptionSuffix}`, () => { fetchSpy = null; }); - describe.only('getQuizAllQuestions', () => { + describe('getQuizAllQuestions', () => { it('Should return a result provided a valid apiKey and quizId', () => { const { quizzes } = new ConstructorIO({ apiKey: quizApiKey,