Skip to content
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

[csl-3140] - Remove hardcoded versionId from Quizzes tests #188

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Changes from all 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
53 changes: 30 additions & 23 deletions spec/src/modules/quizzes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const clientId = '2b23dd74-5672-4379-878c-9182938d2710';
const sessionId = '2';
const clientVersion = 'cio-mocha';
const skipNetworkTimeoutTests = process.env.SKIP_NETWORK_TIMEOUT_TESTS === 'true';
const quizVersionId = 'e03210db-0cc6-459c-8f17-bf014c4f554d';
const quizSessionId = 'session-id';

describe('ConstructorIO - Quizzes', () => {
Expand Down Expand Up @@ -88,17 +87,21 @@ describe('ConstructorIO - Quizzes', () => {
fetch: fetchSpy,
});

return quizzes.getQuizNextQuestion(validQuizId, { quizVersionId, quizSessionId }).then((res) => {
const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy);
return quizzes.getQuizNextQuestion(validQuizId).then((initialResponse) => {
const { quiz_version_id: quizVersionId } = initialResponse;

expect(res).to.have.property('quiz_version_id').to.be.an('string').to.equal(quizVersionId);
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(res.next_question.id).to.equal(1);
expect(res.next_question.options[0].id).to.equal(1);
expect(requestedUrlParams).to.have.property('quiz_version_id').to.equal(quizVersionId);
expect(requestedUrlParams).to.have.property('quiz_session_id').to.equal(quizSessionId);
return quizzes.getQuizNextQuestion(validQuizId, { quizSessionId, quizVersionId }).then((res) => {
const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy);

expect(res).to.have.property('quiz_version_id').to.be.an('string').to.equal(quizVersionId);
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(res.next_question.id).to.equal(1);
expect(res.next_question.options[0].id).to.equal(1);
expect(requestedUrlParams).to.have.property('quiz_version_id').to.equal(quizVersionId);
expect(requestedUrlParams).to.have.property('quiz_session_id').to.equal(quizSessionId);
});
});
});

Expand Down Expand Up @@ -268,19 +271,23 @@ describe('ConstructorIO - Quizzes', () => {
fetch: fetchSpy,
});

// eslint-disable-next-line max-len
return quizzes.getQuizResults(validQuizId, { answers: validAnswers, quizVersionId, quizSessionId }).then((res) => {
const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy);
return quizzes.getQuizResults(validQuizId, { answers: validAnswers }).then((initialResponse) => {
const { quiz_version_id: quizVersionId } = initialResponse;

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.equal(quizVersionId);
expect(res).to.have.property('quiz_session_id').to.equal(quizSessionId);
expect(res).to.have.property('quiz_id').to.be.an('string').to.equal(validQuizId);
expect(requestedUrlParams).to.have.property('quiz_version_id').to.equal(quizVersionId);
expect(requestedUrlParams).to.have.property('quiz_session_id').to.equal(quizSessionId);
// eslint-disable-next-line max-len
return quizzes.getQuizResults(validQuizId, { answers: validAnswers, quizVersionId, 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.equal(quizVersionId);
expect(res).to.have.property('quiz_session_id').to.equal(quizSessionId);
expect(res).to.have.property('quiz_id').to.be.an('string').to.equal(validQuizId);
expect(requestedUrlParams).to.have.property('quiz_version_id').to.equal(quizVersionId);
expect(requestedUrlParams).to.have.property('quiz_session_id').to.equal(quizSessionId);
});
});
});

Expand Down
Loading