From 575210aa0368853ab42c90e104596e2ff6697c6e Mon Sep 17 00:00:00 2001 From: Link Date: Fri, 25 Dec 2020 15:13:01 +0800 Subject: [PATCH] test: try. The local test is passed, what is the problem with the online test --- src/api/index.ts | 6 ++++-- src/pages/footer/api/index.ts | 3 ++- src/pages/footer/sage.ts | 3 +-- src/utils/http.ts | 6 ------ tests/e2e/integration/news.spec.js | 8 +++----- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index cc8067b3..67a44799 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -4,7 +4,8 @@ import { SongsDetail, SongState, Albums } from '@/interface/index' export const getSongUrl = async (id: number | number[]): Promise => { const data = await get<{ data: T }>('/api/song/url', { id: Array.isArray(id) ? id.join(',') : id, - br: 9.99e5 + br: 9.99e5, + timestamp: Date.now() }) return data.data } @@ -13,7 +14,8 @@ export const getSongDetail = async ( id: number | number[] ): Promise => { const data = await get<{ songs: SongsDetail[] }>('/api/song/detail', { - ids: typeof id === 'number' ? id : id.join(',') + ids: typeof id === 'number' ? id : id.join(','), + timestamp: Date.now() }) return data.songs } diff --git a/src/pages/footer/api/index.ts b/src/pages/footer/api/index.ts index a691208f..5f3e9ea6 100644 --- a/src/pages/footer/api/index.ts +++ b/src/pages/footer/api/index.ts @@ -4,7 +4,8 @@ export { getSongDetail, getSongUrl } from '@/api/index' export const getLyric = async (id: number): Promise => { const data = await get('/api/lyric', { - id + id, + timestamp: Date.now() }) return data.lrc.lyric } diff --git a/src/pages/footer/sage.ts b/src/pages/footer/sage.ts index f40f2285..47bc2086 100644 --- a/src/pages/footer/sage.ts +++ b/src/pages/footer/sage.ts @@ -185,14 +185,13 @@ export const mutations: MutationTree = { }, [FooterMutations.SET_MUSIC_URL](state, payload: string | SongsDetail) { if (state.sourceElement && state.audioElement && state.music) { - let music = toRaw(state.music) + const music = toRaw(state.music) if (typeof payload === 'string') { state.sourceElement.src = payload music.url = payload } else { state.sourceElement.src = payload.url state.music = payload - music = toRaw(state.music) } state.audioElement.load() const isRepeatHistory = findMusicIndex(state.musciHistory, music) === -1 diff --git a/src/utils/http.ts b/src/utils/http.ts index 2ebc70ac..fdea1b53 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -17,12 +17,6 @@ const http: AxiosInstance = Axios.create({ timeout: 20000 }) -http.defaults.headers = { - 'Cache-Control': 'no-cache', - Pragma: 'no-cache', - Expires: '0' -} - http.interceptors.request.use( config => { return config diff --git a/tests/e2e/integration/news.spec.js b/tests/e2e/integration/news.spec.js index d92a095b..ac5410f2 100644 --- a/tests/e2e/integration/news.spec.js +++ b/tests/e2e/integration/news.spec.js @@ -64,14 +64,12 @@ context('News Music Basic', () => { // https://github.com/cypress-io/cypress/issues/14269 // Found it is a cache problem // Solution: Use a timestamp to ensure that the URL cannot hit the browser cache - - cy.get( - '.toplist-expansion-contanier:first-child .none-select:nth-child(2)' - ).dblclick() - cy.intercept(/\/api\/song\/url/).as('getUrl') cy.intercept(/\/api\/song\/detail/).as('getDetail') cy.intercept(/\/api\/lyric/).as('getLyric') + cy.get( + '.toplist-expansion-contanier:first-child .none-select:first-child' + ).dblclick() cy.wait(['@getUrl', '@getDetail', '@getLyric'], { requestTimeout: 20 * 1000