Skip to content

Commit

Permalink
test: try. The local test is passed, what is the problem with the onl…
Browse files Browse the repository at this point in the history
…ine test
  • Loading branch information
Linkontoask committed Dec 25, 2020
1 parent a577fb1 commit 575210a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
6 changes: 4 additions & 2 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { SongsDetail, SongState, Albums } from '@/interface/index'
export const getSongUrl = async <T>(id: number | number[]): Promise<T> => {
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
}
Expand All @@ -13,7 +14,8 @@ export const getSongDetail = async (
id: number | number[]
): Promise<SongsDetail[]> => {
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
}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/footer/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ export { getSongDetail, getSongUrl } from '@/api/index'

export const getLyric = async (id: number): Promise<string> => {
const data = await get<SongsDetail>('/api/lyric', {
id
id,
timestamp: Date.now()
})
return data.lrc.lyric
}
3 changes: 1 addition & 2 deletions src/pages/footer/sage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,13 @@ export const mutations: MutationTree<FooterState> = {
},
[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
Expand Down
6 changes: 0 additions & 6 deletions src/utils/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions tests/e2e/integration/news.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 575210a

Please sign in to comment.