-
Notifications
You must be signed in to change notification settings - Fork 7
[CDX-441] Add support for origin_referrer in SABR #254
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
Changes from all commits
05676c0
4a68564
9e8a994
b8446b8
dc3a1dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -285,6 +285,24 @@ describe('ConstructorIO - Browse', () => { | |
| }); | ||
| }); | ||
|
|
||
| it('Should return a response with a valid filterName, filterValue, and origin referrer', (done) => { | ||
| const originReferrer = 'https://localhost'; | ||
| const { browse } = new ConstructorIO({ | ||
| ...validOptions, | ||
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| browse.getBrowseResults(filterName, filterValue, {}, { originReferrer }).then((res) => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(res).to.have.property('request').to.be.an('object'); | ||
| expect(res).to.have.property('response').to.be.an('object'); | ||
| expect(res).to.have.property('result_id').to.be.an('string'); | ||
| expect(requestedUrlParams).to.have.property('origin_referrer').to.equal(originReferrer); | ||
| done(); | ||
| }).catch(done); | ||
| }); | ||
|
|
||
| it('Should return a response with a valid filterName, filterValue, and security token', (done) => { | ||
| const securityToken = 'cio-node-test'; | ||
| const { browse } = new ConstructorIO({ | ||
|
|
@@ -958,6 +976,24 @@ describe('ConstructorIO - Browse', () => { | |
| }); | ||
| }); | ||
|
|
||
| it('Should return a response with valid ids and origin referrer', (done) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Important Issue: The test description "Should return a response with valid ids and origin referrer" (used for |
||
| const originReferrer = 'https://localhost'; | ||
| const { browse } = new ConstructorIO({ | ||
| ...validOptions, | ||
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| browse.getBrowseResultsForItemIds(ids, null, { originReferrer }).then((res) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: |
||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(res).to.have.property('request').to.be.an('object'); | ||
| expect(res).to.have.property('response').to.be.an('object'); | ||
| expect(res).to.have.property('result_id').to.be.an('string'); | ||
| expect(requestedUrlParams).to.have.property('origin_referrer').to.equal(originReferrer); | ||
| done(); | ||
| }).catch(done); | ||
| }); | ||
|
|
||
| it('Should return a response with valid ids and page', (done) => { | ||
| const page = 1; | ||
| const { browse } = new ConstructorIO({ | ||
|
|
@@ -1426,6 +1462,24 @@ describe('ConstructorIO - Browse', () => { | |
| }); | ||
| }); | ||
|
|
||
| it('Should return a response with valid ids and origin referrer', (done) => { | ||
| const originReferrer = 'https://localhost'; | ||
| const { browse } = new ConstructorIO({ | ||
| ...validOptions, | ||
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| browse.getBrowseGroups({}, { originReferrer }).then((res) => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(res).to.have.property('request').to.be.an('object'); | ||
| expect(res).to.have.property('response').to.be.an('object'); | ||
| expect(res).to.have.property('result_id').to.be.an('string'); | ||
| expect(requestedUrlParams).to.have.property('origin_referrer').to.equal(originReferrer); | ||
| done(); | ||
| }).catch(done); | ||
| }); | ||
|
|
||
| it('Should return a response with valid ids and additional filters', (done) => { | ||
| const filters = { group_id: ['drill_collection'] }; | ||
| const { browse } = new ConstructorIO({ | ||
|
|
@@ -1737,6 +1791,24 @@ describe('ConstructorIO - Browse', () => { | |
| }); | ||
| }); | ||
|
|
||
| it('Should return a response with origin referrer', (done) => { | ||
| const originReferrer = 'https://localhost'; | ||
| const { browse } = new ConstructorIO({ | ||
| ...validOptions, | ||
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| browse.getBrowseFacets({}, { originReferrer }).then((res) => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(res).to.have.property('request').to.be.an('object'); | ||
| expect(res).to.have.property('response').to.be.an('object'); | ||
| expect(res).to.have.property('result_id').to.be.an('string'); | ||
| expect(requestedUrlParams).to.have.property('origin_referrer').to.equal(originReferrer); | ||
| done(); | ||
| }).catch(done); | ||
| }); | ||
|
|
||
| it('Should combine custom headers from function networkParameters and global networkParameters', (done) => { | ||
| const { browse } = new ConstructorIO({ | ||
| ...validOptions, | ||
|
|
@@ -1930,6 +2002,24 @@ describe('ConstructorIO - Browse', () => { | |
| }); | ||
| }); | ||
|
|
||
| it('Should return a response with origin referrer', (done) => { | ||
| const originReferrer = 'https://localhost'; | ||
| const { browse } = new ConstructorIO({ | ||
| ...validOptions, | ||
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| browse.getBrowseFacetOptions(facetName, {}, { originReferrer }).then((res) => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(res).to.have.property('request').to.be.an('object'); | ||
| expect(res).to.have.property('response').to.be.an('object'); | ||
| expect(res).to.have.property('result_id').to.be.an('string'); | ||
| expect(requestedUrlParams).to.have.property('origin_referrer').to.equal(originReferrer); | ||
| done(); | ||
| }).catch(done); | ||
| }); | ||
|
|
||
| it('Should combine custom headers from function networkParameters and global networkParameters', (done) => { | ||
| const { browse } = new ConstructorIO({ | ||
| ...validOptions, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,13 +145,31 @@ describe('ConstructorIO - Quizzes', () => { | |
| }); | ||
| }); | ||
|
|
||
| it('Should return a result provided a valid apiKey, quizId and origin referrer', () => { | ||
|
constructor-claude-bedrock[bot] marked this conversation as resolved.
|
||
| const originReferrer = 'https://localhost'; | ||
| const { quizzes } = new ConstructorIO({ | ||
| apiKey: quizApiKey, | ||
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| return quizzes.getQuizNextQuestion(validQuizId, {}, { originReferrer }).then((res) => { | ||
|
constructor-claude-bedrock[bot] marked this conversation as resolved.
|
||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(res).to.have.property('quiz_version_id').to.be.an('string'); | ||
| expect(res).to.have.property('quiz_session_id').to.be.an('string'); | ||
| expect(res).to.have.property('quiz_id').to.be.an('string').to.equal(validQuizId); | ||
| expect(res).to.have.property('next_question').to.be.an('object'); | ||
| expect(requestedUrlParams).to.have.property('origin_referrer').to.equal(originReferrer); | ||
| }); | ||
| }); | ||
|
|
||
| it('Should return result given answers parameter', () => { | ||
| const { quizzes } = new ConstructorIO({ | ||
| apiKey: quizApiKey, | ||
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| return quizzes.getQuizNextQuestion(validQuizId, { answers: validAnswers }).then((res) => { | ||
| return quizzes.getQuizNextQuestion(validQuizId, { answers: validAnswers, quizSessionId }).then((res) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Several existing quiz tests were modified to add |
||
| expect(res).to.have.property('quiz_version_id').to.be.an('string'); | ||
| expect(res).to.have.property('quiz_session_id').to.be.an('string'); | ||
| expect(res).to.have.property('quiz_id').to.be.an('string').to.equal(validQuizId); | ||
|
|
@@ -166,11 +184,19 @@ describe('ConstructorIO - Quizzes', () => { | |
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| return quizzes.getQuizNextQuestion(validQuizId, { answers: validAnswers, skipTracking: true }).then(() => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
| return quizzes | ||
| .getQuizNextQuestion(validQuizId, { | ||
| answers: validAnswers, | ||
| skipTracking: true, | ||
| quizSessionId, | ||
| }) | ||
| .then(() => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(requestedUrlParams).to.have.property('skip_tracking').to.equal('true'); | ||
| }); | ||
| expect(requestedUrlParams) | ||
| .to.have.property('skip_tracking') | ||
| .to.equal('true'); | ||
| }); | ||
| }); | ||
|
|
||
| it('Should be rejected if an invalid quizId is provided', () => { | ||
|
|
@@ -248,23 +274,29 @@ describe('ConstructorIO - Quizzes', () => { | |
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| return quizzes.getQuizResults(validQuizId, { answers: validAnswers }, { clientId, sessionId }).then((res) => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
| return quizzes | ||
| .getQuizResults( | ||
| validQuizId, | ||
| { answers: validAnswers, quizSessionId }, | ||
| { clientId, sessionId }, | ||
| ) | ||
| .then((res) => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(res).to.have.property('request').to.be.an('object'); | ||
| expect(res).to.have.property('response').to.be.an('object'); | ||
| expect(res).to.have.property('result_id').to.be.an('string'); | ||
| expect(res.response).to.have.property('results').to.be.an('array'); | ||
| expect(res).to.have.property('quiz_version_id').to.be.an('string'); | ||
| expect(res).to.have.property('quiz_session_id').to.be.an('string'); | ||
| expect(res).to.have.property('quiz_id').to.be.an('string').to.equal(validQuizId); | ||
| expect(fetchSpy).to.have.been.called; | ||
| expect(requestedUrlParams).to.have.property('key'); | ||
| expect(requestedUrlParams).to.have.property('i'); | ||
| expect(requestedUrlParams).to.have.property('s'); | ||
| expect(requestedUrlParams).to.have.property('c').to.equal(clientVersion); | ||
| expect(requestedUrlParams).to.have.property('_dt'); | ||
| }); | ||
| expect(res).to.have.property('request').to.be.an('object'); | ||
| expect(res).to.have.property('response').to.be.an('object'); | ||
| expect(res).to.have.property('result_id').to.be.an('string'); | ||
| expect(res.response).to.have.property('results').to.be.an('array'); | ||
| expect(res).to.have.property('quiz_version_id').to.be.an('string'); | ||
| expect(res).to.have.property('quiz_session_id').to.be.an('string'); | ||
| expect(res).to.have.property('quiz_id').to.be.an('string').to.equal(validQuizId); | ||
| expect(fetchSpy).to.have.been.called; | ||
| expect(requestedUrlParams).to.have.property('key'); | ||
| expect(requestedUrlParams).to.have.property('i'); | ||
| expect(requestedUrlParams).to.have.property('s'); | ||
| expect(requestedUrlParams).to.have.property('c').to.equal(clientVersion); | ||
| expect(requestedUrlParams).to.have.property('_dt'); | ||
| }); | ||
| }); | ||
|
|
||
| it('Should return a result given valid API key, answers and page parameters', () => { | ||
|
|
@@ -274,7 +306,7 @@ describe('ConstructorIO - Quizzes', () => { | |
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| return quizzes.getQuizResults(validQuizId, { answers: validAnswers, page }).then((res) => { | ||
| return quizzes.getQuizResults(validQuizId, { answers: validAnswers, page, quizSessionId }).then((res) => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(res).to.have.property('request').to.be.an('object'); | ||
|
|
@@ -295,18 +327,29 @@ describe('ConstructorIO - Quizzes', () => { | |
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| return quizzes.getQuizResults(validQuizId, { answers: validAnswers, resultsPerPage }).then((res) => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
| return quizzes | ||
| .getQuizResults(validQuizId, { | ||
| answers: validAnswers, | ||
| resultsPerPage, | ||
| quizSessionId, | ||
| }) | ||
| .then((res) => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(res).to.have.property('request').to.be.an('object'); | ||
| expect(res).to.have.property('response').to.be.an('object'); | ||
| expect(res).to.have.property('result_id').to.be.an('string'); | ||
| expect(res.response).to.have.property('results').to.be.an('array'); | ||
| expect(res).to.have.property('quiz_version_id').to.be.an('string'); | ||
| expect(res).to.have.property('quiz_session_id').to.be.an('string'); | ||
| expect(res).to.have.property('quiz_id').to.be.an('string').to.equal(validQuizId); | ||
| expect(requestedUrlParams).to.have.property('num_results_per_page').to.equal(resultsPerPage); | ||
| }); | ||
| expect(res).to.have.property('request').to.be.an('object'); | ||
| expect(res).to.have.property('response').to.be.an('object'); | ||
| expect(res).to.have.property('result_id').to.be.an('string'); | ||
| expect(res.response).to.have.property('results').to.be.an('array'); | ||
| expect(res).to.have.property('quiz_version_id').to.be.an('string'); | ||
| expect(res).to.have.property('quiz_session_id').to.be.an('string'); | ||
| expect(res) | ||
| .to.have.property('quiz_id') | ||
| .to.be.an('string') | ||
| .to.equal(validQuizId); | ||
| expect(requestedUrlParams) | ||
| .to.have.property('num_results_per_page') | ||
| .to.equal(resultsPerPage); | ||
| }); | ||
| }); | ||
|
|
||
| it('Should return a result given valid API key, answers and filters parameters', () => { | ||
|
|
@@ -316,7 +359,7 @@ describe('ConstructorIO - Quizzes', () => { | |
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| return quizzes.getQuizResults(validQuizId, { answers: validAnswers, filters }).then((res) => { | ||
| return quizzes.getQuizResults(validQuizId, { answers: validAnswers, filters, quizSessionId }).then((res) => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(res).to.have.property('request').to.be.an('object'); | ||
|
|
@@ -337,7 +380,7 @@ describe('ConstructorIO - Quizzes', () => { | |
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| return quizzes.getQuizResults(validQuizId, { answers: validAnswers, section }).then((res) => { | ||
| return quizzes.getQuizResults(validQuizId, { answers: validAnswers, section, quizSessionId }).then((res) => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(res).to.have.property('request').to.be.an('object'); | ||
|
|
@@ -357,7 +400,7 @@ describe('ConstructorIO - Quizzes', () => { | |
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| return quizzes.getQuizResults(validQuizId, { answers: validAnswers }).then((initialResponse) => { | ||
| return quizzes.getQuizResults(validQuizId, { answers: validAnswers, quizSessionId }).then((initialResponse) => { | ||
| const { quiz_version_id: quizVersionId } = initialResponse; | ||
|
|
||
| // eslint-disable-next-line max-len | ||
|
|
@@ -384,7 +427,7 @@ describe('ConstructorIO - Quizzes', () => { | |
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| return quizzes.getQuizResults(validQuizId, { answers: validAnswers }, { userId }).then((res) => { | ||
| return quizzes.getQuizResults(validQuizId, { answers: validAnswers, quizSessionId }, { userId }).then((res) => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(res).to.have.property('request').to.be.an('object'); | ||
|
|
@@ -405,7 +448,7 @@ describe('ConstructorIO - Quizzes', () => { | |
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| return quizzes.getQuizResults(validQuizId, { answers: validAnswers }, { segments }).then((res) => { | ||
| return quizzes.getQuizResults(validQuizId, { answers: validAnswers, quizSessionId }, { segments }).then((res) => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(res).to.have.property('request').to.be.an('object'); | ||
|
|
@@ -419,6 +462,38 @@ describe('ConstructorIO - Quizzes', () => { | |
| }); | ||
| }); | ||
|
|
||
| it('Should return a result provided a valid apiKey, quizId and origin referrer', () => { | ||
| const originReferrer = 'https://localhost'; | ||
| const { quizzes } = new ConstructorIO({ | ||
| apiKey: quizApiKey, | ||
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| return quizzes | ||
| .getQuizResults( | ||
| validQuizId, | ||
| { answers: validAnswers, quizSessionId }, | ||
| { originReferrer }, | ||
| ) | ||
| .then((res) => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(res).to.have.property('request').to.be.an('object'); | ||
| expect(res).to.have.property('response').to.be.an('object'); | ||
| expect(res).to.have.property('result_id').to.be.an('string'); | ||
| expect(res.response).to.have.property('results').to.be.an('array'); | ||
| expect(res).to.have.property('quiz_version_id').to.be.an('string'); | ||
| expect(res).to.have.property('quiz_session_id').to.be.an('string'); | ||
| expect(res) | ||
| .to.have.property('quiz_id') | ||
| .to.be.an('string') | ||
| .to.equal(validQuizId); | ||
| expect(requestedUrlParams) | ||
| .to.have.property('origin_referrer') | ||
| .to.equal(originReferrer); | ||
| }); | ||
| }); | ||
|
|
||
| it('Should be rejected if no quizId is provided', () => { | ||
| const { quizzes } = new ConstructorIO({ | ||
| apiKey: quizApiKey, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.