fix: history order on cloud sync
This commit is contained in:
@@ -140,7 +140,7 @@ describe("Clear History", () => {
|
|||||||
const wrapper = factory({
|
const wrapper = factory({
|
||||||
page: "rest",
|
page: "rest",
|
||||||
})
|
})
|
||||||
expect(wrapper.vm.filteredHistory).toStrictEqual(restHistory.slice().reverse())
|
expect(wrapper.vm.filteredHistory).toStrictEqual(restHistory)
|
||||||
await wrapper.find("button[data-testid='clear_history']").trigger("click")
|
await wrapper.find("button[data-testid='clear_history']").trigger("click")
|
||||||
await wrapper.find("button[data-testid='confirm_clear_history']").trigger("click")
|
await wrapper.find("button[data-testid='confirm_clear_history']").trigger("click")
|
||||||
expect(fb.clearHistory).not.toHaveBeenCalled()
|
expect(fb.clearHistory).not.toHaveBeenCalled()
|
||||||
@@ -151,7 +151,7 @@ describe("Clear History", () => {
|
|||||||
const wrapper = factory({
|
const wrapper = factory({
|
||||||
page: "rest",
|
page: "rest",
|
||||||
})
|
})
|
||||||
expect(wrapper.vm.filteredHistory).toStrictEqual(restHistory.slice().reverse())
|
expect(wrapper.vm.filteredHistory).toStrictEqual(restHistory)
|
||||||
await wrapper.find("button[data-testid='clear_history']").trigger("click")
|
await wrapper.find("button[data-testid='clear_history']").trigger("click")
|
||||||
await wrapper.find("button[data-testid='confirm_clear_history']").trigger("click")
|
await wrapper.find("button[data-testid='confirm_clear_history']").trigger("click")
|
||||||
expect(fb.clearHistory).toHaveBeenCalledTimes(1)
|
expect(fb.clearHistory).toHaveBeenCalledTimes(1)
|
||||||
@@ -162,7 +162,7 @@ describe("Clear History", () => {
|
|||||||
const wrapper = factory({
|
const wrapper = factory({
|
||||||
page: "rest",
|
page: "rest",
|
||||||
})
|
})
|
||||||
expect(wrapper.vm.filteredHistory).toStrictEqual(restHistory.slice().reverse())
|
expect(wrapper.vm.filteredHistory).toStrictEqual(restHistory)
|
||||||
await wrapper.find("button[data-testid='clear_history']").trigger("click")
|
await wrapper.find("button[data-testid='clear_history']").trigger("click")
|
||||||
await wrapper.find("button[data-testid='reject_clear_history']").trigger("click")
|
await wrapper.find("button[data-testid='reject_clear_history']").trigger("click")
|
||||||
expect(fb.clearHistory).not.toHaveBeenCalled()
|
expect(fb.clearHistory).not.toHaveBeenCalled()
|
||||||
@@ -174,7 +174,7 @@ describe("Clear History", () => {
|
|||||||
const wrapper = factory({
|
const wrapper = factory({
|
||||||
page: "graphql",
|
page: "graphql",
|
||||||
})
|
})
|
||||||
expect(wrapper.vm.filteredHistory).toStrictEqual(graphqlHistory.slice().reverse())
|
expect(wrapper.vm.filteredHistory).toStrictEqual(graphqlHistory)
|
||||||
await wrapper.find("button[data-testid='clear_history']").trigger("click")
|
await wrapper.find("button[data-testid='clear_history']").trigger("click")
|
||||||
await wrapper.find("button[data-testid='confirm_clear_history']").trigger("click")
|
await wrapper.find("button[data-testid='confirm_clear_history']").trigger("click")
|
||||||
expect(fb.clearGraphqlHistory).not.toHaveBeenCalled()
|
expect(fb.clearGraphqlHistory).not.toHaveBeenCalled()
|
||||||
@@ -185,7 +185,7 @@ describe("Clear History", () => {
|
|||||||
const wrapper = factory({
|
const wrapper = factory({
|
||||||
page: "graphql",
|
page: "graphql",
|
||||||
})
|
})
|
||||||
expect(wrapper.vm.filteredHistory).toStrictEqual(graphqlHistory.slice().reverse())
|
expect(wrapper.vm.filteredHistory).toStrictEqual(graphqlHistory)
|
||||||
await wrapper.find("button[data-testid='clear_history']").trigger("click")
|
await wrapper.find("button[data-testid='clear_history']").trigger("click")
|
||||||
await wrapper.find("button[data-testid='confirm_clear_history']").trigger("click")
|
await wrapper.find("button[data-testid='confirm_clear_history']").trigger("click")
|
||||||
expect(fb.clearGraphqlHistory).toHaveBeenCalledTimes(1)
|
expect(fb.clearGraphqlHistory).toHaveBeenCalledTimes(1)
|
||||||
@@ -196,7 +196,7 @@ describe("Clear History", () => {
|
|||||||
const wrapper = factory({
|
const wrapper = factory({
|
||||||
page: "graphql",
|
page: "graphql",
|
||||||
})
|
})
|
||||||
expect(wrapper.vm.filteredHistory).toStrictEqual(graphqlHistory.slice().reverse())
|
expect(wrapper.vm.filteredHistory).toStrictEqual(graphqlHistory)
|
||||||
await wrapper.find("button[data-testid='clear_history']").trigger("click")
|
await wrapper.find("button[data-testid='clear_history']").trigger("click")
|
||||||
await wrapper.find("button[data-testid='reject_clear_history']").trigger("click")
|
await wrapper.find("button[data-testid='reject_clear_history']").trigger("click")
|
||||||
expect(window.localStorage.setItem).not.toHaveBeenCalledWith(
|
expect(window.localStorage.setItem).not.toHaveBeenCalledWith(
|
||||||
@@ -216,7 +216,7 @@ describe("Use History", () => {
|
|||||||
var index = restHistory.length - 1
|
var index = restHistory.length - 1
|
||||||
wrapper.findAll("div[data-testid='rest_card']").at(index).vm.$emit("use-entry")
|
wrapper.findAll("div[data-testid='rest_card']").at(index).vm.$emit("use-entry")
|
||||||
expect(wrapper.emitted("useHistory")).toBeTruthy()
|
expect(wrapper.emitted("useHistory")).toBeTruthy()
|
||||||
expect(wrapper.emitted("useHistory")[0]).toStrictEqual([restHistory.slice().reverse()[index]])
|
expect(wrapper.emitted("useHistory")[0]).toStrictEqual([restHistory[index]])
|
||||||
})
|
})
|
||||||
|
|
||||||
test("use graphql history", async () => {
|
test("use graphql history", async () => {
|
||||||
@@ -228,9 +228,7 @@ describe("Use History", () => {
|
|||||||
var index = restHistory.length - 1
|
var index = restHistory.length - 1
|
||||||
wrapper.findAll("div[data-testid='graphql_card']").at(index).vm.$emit("use-entry")
|
wrapper.findAll("div[data-testid='graphql_card']").at(index).vm.$emit("use-entry")
|
||||||
expect(wrapper.emitted("useHistory")).toBeTruthy()
|
expect(wrapper.emitted("useHistory")).toBeTruthy()
|
||||||
expect(wrapper.emitted("useHistory")[0]).toStrictEqual([
|
expect(wrapper.emitted("useHistory")[0]).toStrictEqual([graphqlHistory[index]])
|
||||||
graphqlHistory.slice().reverse()[index],
|
|
||||||
])
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -140,17 +140,14 @@ export default {
|
|||||||
: JSON.parse(
|
: JSON.parse(
|
||||||
window.localStorage.getItem(this.page == "rest" ? "history" : "graphqlHistory")
|
window.localStorage.getItem(this.page == "rest" ? "history" : "graphqlHistory")
|
||||||
) || []
|
) || []
|
||||||
return this.history
|
return this.history.filter((entry) => {
|
||||||
.slice()
|
const filterText = this.filterText.toLowerCase()
|
||||||
.reverse()
|
return Object.keys(entry).some((key) => {
|
||||||
.filter((entry) => {
|
let value = entry[key]
|
||||||
const filterText = this.filterText.toLowerCase()
|
value = typeof value !== "string" ? value.toString() : value
|
||||||
return Object.keys(entry).some((key) => {
|
return value.toLowerCase().includes(filterText)
|
||||||
let value = entry[key]
|
|
||||||
value = typeof value !== "string" ? value.toString() : value
|
|
||||||
return value.toLowerCase().includes(filterText)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ export class FirebaseInstance {
|
|||||||
this.usersCollection
|
this.usersCollection
|
||||||
.doc(this.currentUser.uid)
|
.doc(this.currentUser.uid)
|
||||||
.collection("history")
|
.collection("history")
|
||||||
|
.orderBy("updatedOn", "desc")
|
||||||
.onSnapshot((historyRef) => {
|
.onSnapshot((historyRef) => {
|
||||||
const history = []
|
const history = []
|
||||||
historyRef.forEach((doc) => {
|
historyRef.forEach((doc) => {
|
||||||
@@ -101,6 +102,7 @@ export class FirebaseInstance {
|
|||||||
this.usersCollection
|
this.usersCollection
|
||||||
.doc(this.currentUser.uid)
|
.doc(this.currentUser.uid)
|
||||||
.collection("graphqlHistory")
|
.collection("graphqlHistory")
|
||||||
|
.orderBy("updatedOn", "desc")
|
||||||
.onSnapshot((historyRef) => {
|
.onSnapshot((historyRef) => {
|
||||||
const history = []
|
const history = []
|
||||||
historyRef.forEach((doc) => {
|
historyRef.forEach((doc) => {
|
||||||
|
|||||||
20912
package-lock.json
generated
20912
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user