From 17da230d729a24c024609832c78a2d42508c10a9 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Thu, 11 Mar 2021 06:53:49 +0000 Subject: [PATCH] fix: remove sort history entries + fix history entries order - fixed #1455 --- components/history/__tests__/History.spec.js | 19 +-- components/history/graphql/Card.vue | 14 +- components/history/index.vue | 151 +++---------------- components/history/rest/Card.vue | 15 +- helpers/__tests__/fb.spec.js | 62 ++++---- pages/graphql.vue | 2 + pages/index.vue | 2 + 7 files changed, 91 insertions(+), 174 deletions(-) diff --git a/components/history/__tests__/History.spec.js b/components/history/__tests__/History.spec.js index 43d2b57a0..a1c8d6c0a 100644 --- a/components/history/__tests__/History.spec.js +++ b/components/history/__tests__/History.spec.js @@ -1,7 +1,6 @@ import History from "../" import { fb } from "~/helpers/fb" import { shallowMount } from "@vue/test-utils" -import HistoryRestCard from "../rest/Card" const restHistory = [ { @@ -141,7 +140,7 @@ describe("Clear History", () => { const wrapper = factory({ page: "rest", }) - expect(wrapper.vm.filteredHistory).toStrictEqual(restHistory) + expect(wrapper.vm.filteredHistory).toStrictEqual(restHistory.slice().reverse()) await wrapper.find("button[data-testid='clear_history']").trigger("click") await wrapper.find("button[data-testid='confirm_clear_history']").trigger("click") expect(fb.clearHistory).not.toHaveBeenCalled() @@ -152,7 +151,7 @@ describe("Clear History", () => { const wrapper = factory({ page: "rest", }) - expect(wrapper.vm.filteredHistory).toStrictEqual(restHistory) + expect(wrapper.vm.filteredHistory).toStrictEqual(restHistory.slice().reverse()) await wrapper.find("button[data-testid='clear_history']").trigger("click") await wrapper.find("button[data-testid='confirm_clear_history']").trigger("click") expect(fb.clearHistory).toHaveBeenCalledTimes(1) @@ -163,7 +162,7 @@ describe("Clear History", () => { const wrapper = factory({ page: "rest", }) - expect(wrapper.vm.filteredHistory).toStrictEqual(restHistory) + expect(wrapper.vm.filteredHistory).toStrictEqual(restHistory.slice().reverse()) await wrapper.find("button[data-testid='clear_history']").trigger("click") await wrapper.find("button[data-testid='reject_clear_history']").trigger("click") expect(fb.clearHistory).not.toHaveBeenCalled() @@ -175,7 +174,7 @@ describe("Clear History", () => { const wrapper = factory({ page: "graphql", }) - expect(wrapper.vm.filteredHistory).toStrictEqual(graphqlHistory) + expect(wrapper.vm.filteredHistory).toStrictEqual(graphqlHistory.slice().reverse()) await wrapper.find("button[data-testid='clear_history']").trigger("click") await wrapper.find("button[data-testid='confirm_clear_history']").trigger("click") expect(fb.clearGraphqlHistory).not.toHaveBeenCalled() @@ -186,7 +185,7 @@ describe("Clear History", () => { const wrapper = factory({ page: "graphql", }) - expect(wrapper.vm.filteredHistory).toStrictEqual(graphqlHistory) + expect(wrapper.vm.filteredHistory).toStrictEqual(graphqlHistory.slice().reverse()) await wrapper.find("button[data-testid='clear_history']").trigger("click") await wrapper.find("button[data-testid='confirm_clear_history']").trigger("click") expect(fb.clearGraphqlHistory).toHaveBeenCalledTimes(1) @@ -197,7 +196,7 @@ describe("Clear History", () => { const wrapper = factory({ page: "graphql", }) - expect(wrapper.vm.filteredHistory).toStrictEqual(graphqlHistory) + expect(wrapper.vm.filteredHistory).toStrictEqual(graphqlHistory.slice().reverse()) await wrapper.find("button[data-testid='clear_history']").trigger("click") await wrapper.find("button[data-testid='reject_clear_history']").trigger("click") expect(window.localStorage.setItem).not.toHaveBeenCalledWith( @@ -217,7 +216,7 @@ describe("Use History", () => { var index = restHistory.length - 1 wrapper.findAll("div[data-testid='rest_card']").at(index).vm.$emit("use-entry") expect(wrapper.emitted("useHistory")).toBeTruthy() - expect(wrapper.emitted("useHistory")[0]).toStrictEqual([restHistory[index]]) + expect(wrapper.emitted("useHistory")[0]).toStrictEqual([restHistory.slice().reverse()[index]]) }) test("use graphql history", async () => { @@ -229,7 +228,9 @@ describe("Use History", () => { var index = restHistory.length - 1 wrapper.findAll("div[data-testid='graphql_card']").at(index).vm.$emit("use-entry") expect(wrapper.emitted("useHistory")).toBeTruthy() - expect(wrapper.emitted("useHistory")[0]).toStrictEqual([graphqlHistory[index]]) + expect(wrapper.emitted("useHistory")[0]).toStrictEqual([ + graphqlHistory.slice().reverse()[index], + ]) }) }) diff --git a/components/history/graphql/Card.vue b/components/history/graphql/Card.vue index 7a5302c71..4d3c55e28 100644 --- a/components/history/graphql/Card.vue +++ b/components/history/graphql/Card.vue @@ -99,12 +99,12 @@ :aria-label="$t('duration')" type="text" readonly - :value="entry.duration" + :value="`Duration: ${entry.duration}ms`" :placeholder="$t('no_duration')" class="pt-0 mt-0 text-sm bg-transparent text-fgLightColor" /> -
  • + @@ -123,6 +123,14 @@ .stared { color: #f8e81c !important; } +.fade-enter-active, +.fade-leave-active { + transition: all 0.2s; +} +.fade-enter, +.fade-leave-to { + opacity: 0; +}