Merge pull request #4100 from rlr/Bug1454743/fix-spocs
Fix Bug 1454743 - fix section fetching in spocs experiment
This commit is contained in:
Коммит
e3d1716c70
|
@ -309,8 +309,8 @@ this.TopStoriesFeed = class TopStoriesFeed {
|
|||
}
|
||||
|
||||
// Create a new array with a spoc inserted at index 2
|
||||
const position = SectionsManager.sections.get(SECTION_ID).order;
|
||||
let rows = this.store.getState().Sections[position].rows.slice(0, this.stories.length);
|
||||
const section = this.store.getState().Sections.find(s => s.id === SECTION_ID);
|
||||
let rows = section.rows.slice(0, this.stories.length);
|
||||
rows.splice(2, 0, Object.assign(spocs[0], {pinned: true}));
|
||||
|
||||
// Send a content update to the target tab
|
||||
|
|
|
@ -40,7 +40,7 @@ describe("Top Stories Feed", () => {
|
|||
enableSection: sinon.spy(),
|
||||
disableSection: sinon.spy(),
|
||||
updateSection: sinon.spy(),
|
||||
sections: new Map([["topstories", {order: 0, options: FAKE_OPTIONS}]])
|
||||
sections: new Map([["topstories", {options: FAKE_OPTIONS}]])
|
||||
};
|
||||
|
||||
class FakeUserDomainAffinityProvider {
|
||||
|
@ -483,7 +483,7 @@ describe("Top Stories Feed", () => {
|
|||
fetchStub.resolves({ok: true, status: 200, json: () => Promise.resolve(response)});
|
||||
await instance.fetchStories();
|
||||
|
||||
instance.store.getState = () => ({Sections: [{rows: response.recommendations}], Prefs: {values: {showSponsored: true}}});
|
||||
instance.store.getState = () => ({Sections: [{id: "topstories", rows: response.recommendations}], Prefs: {values: {showSponsored: true}}});
|
||||
|
||||
globals.set("Math", {random: () => 0.4});
|
||||
instance.onAction({type: at.NEW_TAB_REHYDRATED, meta: {fromTarget: {}}});
|
||||
|
@ -531,14 +531,14 @@ describe("Top Stories Feed", () => {
|
|||
instance.show_spocs = true;
|
||||
instance.spocsPerNewTabs = 0.5;
|
||||
instance.stories_endpoint = "stories-endpoint";
|
||||
instance.store.getState = () => ({Sections: [{rows: response.recommendations}], Prefs: {values: {showSponsored: true}}});
|
||||
instance.store.getState = () => ({Sections: [{id: "topstories", rows: response.recommendations}], Prefs: {values: {showSponsored: true}}});
|
||||
fetchStub.resolves({ok: true, status: 200, json: () => Promise.resolve(response)});
|
||||
|
||||
instance.onAction({type: at.NEW_TAB_REHYDRATED, meta: {fromTarget: {}}});
|
||||
assert.notCalled(instance.store.dispatch);
|
||||
assert.equal(instance.contentUpdateQueue.length, 1);
|
||||
|
||||
instance.store.getState = () => ({Sections: [{rows: response.recommendations}]});
|
||||
instance.store.getState = () => ({Sections: [{id: "topstories", rows: response.recommendations}]});
|
||||
|
||||
await instance.fetchStories();
|
||||
assert.equal(instance.contentUpdateQueue.length, 0);
|
||||
|
@ -578,7 +578,7 @@ describe("Top Stories Feed", () => {
|
|||
instance.personalized = true;
|
||||
instance.show_spocs = true;
|
||||
instance.stories_endpoint = "stories-endpoint";
|
||||
instance.store.getState = () => ({Sections: [{rows: response.recommendations}], Prefs: {values: {showSponsored: false}}});
|
||||
instance.store.getState = () => ({Sections: [{id: "topstories", rows: response.recommendations}], Prefs: {values: {showSponsored: false}}});
|
||||
fetchStub.resolves({ok: true, status: 200, json: () => Promise.resolve(response)});
|
||||
await instance.fetchStories();
|
||||
|
||||
|
@ -715,7 +715,7 @@ describe("Top Stories Feed", () => {
|
|||
instance.personalized = true;
|
||||
instance.show_spocs = true;
|
||||
instance.stories_endpoint = "stories-endpoint";
|
||||
instance.store.getState = () => ({Sections: [{rows: response.recommendations}], Prefs: {values: {showSponsored: true}}});
|
||||
instance.store.getState = () => ({Sections: [{id: "topstories", rows: response.recommendations}], Prefs: {values: {showSponsored: true}}});
|
||||
fetchStub.resolves({ok: true, status: 200, json: () => Promise.resolve(response)});
|
||||
await instance.fetchStories();
|
||||
instance.spocsPerNewTabs = 1;
|
||||
|
@ -774,7 +774,7 @@ describe("Top Stories Feed", () => {
|
|||
instance.personalized = true;
|
||||
instance.show_spocs = true;
|
||||
instance.stories_endpoint = "stories-endpoint";
|
||||
instance.store.getState = () => ({Sections: [{rows: response.recommendations}], Prefs: {values: {showSponsored: true}}});
|
||||
instance.store.getState = () => ({Sections: [{id: "topstories", rows: response.recommendations}], Prefs: {values: {showSponsored: true}}});
|
||||
fetchStub.resolves({ok: true, status: 200, json: () => Promise.resolve(response)});
|
||||
await instance.fetchStories();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче