fix: Fixing test suite
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a647ea1485
commit
83937bd78d
@ -4,7 +4,7 @@ describe('Dark Mode Toggle', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.window()
|
cy.window()
|
||||||
.its("sessionStorage")
|
.its("sessionStorage")
|
||||||
.invoke("removeItem", "items.sp-tarkov.com-locales");
|
.invoke("removeItem", "db.sp-tarkov.com-locales");
|
||||||
|
|
||||||
cy.intercept(
|
cy.intercept(
|
||||||
'**/api/locales',
|
'**/api/locales',
|
||||||
@ -35,7 +35,7 @@ describe('Dark Mode Toggle', () => {
|
|||||||
before(() => {
|
before(() => {
|
||||||
cy.visit('/', {
|
cy.visit('/', {
|
||||||
onBeforeLoad: function (window) {
|
onBeforeLoad: function (window) {
|
||||||
window.localStorage.removeItem('items.sp-tarkov.com-prefered-color-scheme')
|
window.localStorage.removeItem('db.sp-tarkov.com-prefered-color-scheme')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -55,7 +55,7 @@ describe('Dark Mode Toggle', () => {
|
|||||||
before(() => {
|
before(() => {
|
||||||
cy.visit('/', {
|
cy.visit('/', {
|
||||||
onBeforeLoad: function (window) {
|
onBeforeLoad: function (window) {
|
||||||
window.localStorage.setItem('items.sp-tarkov.com-prefered-color-scheme', 'light')
|
window.localStorage.setItem('db.sp-tarkov.com-prefered-color-scheme', 'light')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -74,7 +74,7 @@ describe('Dark Mode Toggle', () => {
|
|||||||
before(() => {
|
before(() => {
|
||||||
cy.visit('/', {
|
cy.visit('/', {
|
||||||
onBeforeLoad: function (window) {
|
onBeforeLoad: function (window) {
|
||||||
window.localStorage.setItem('items.sp-tarkov.com-prefered-color-scheme', 'dark')
|
window.localStorage.setItem('db.sp-tarkov.com-prefered-color-scheme', 'dark')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -94,7 +94,7 @@ describe('Dark Mode Toggle', () => {
|
|||||||
before(() => {
|
before(() => {
|
||||||
cy.visit('/', {
|
cy.visit('/', {
|
||||||
onBeforeLoad: function (window) {
|
onBeforeLoad: function (window) {
|
||||||
window.localStorage.setItem('items.sp-tarkov.com-prefered-color-scheme', 'light')
|
window.localStorage.setItem('db.sp-tarkov.com-prefered-color-scheme', 'light')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -123,7 +123,7 @@ describe('Dark Mode Toggle', () => {
|
|||||||
before(() => {
|
before(() => {
|
||||||
cy.visit('/', {
|
cy.visit('/', {
|
||||||
onBeforeLoad: function (window) {
|
onBeforeLoad: function (window) {
|
||||||
window.localStorage.setItem('items.sp-tarkov.com-prefered-color-scheme', 'dark')
|
window.localStorage.setItem('db.sp-tarkov.com-prefered-color-scheme', 'dark')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -4,7 +4,7 @@ describe('Header', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.window()
|
cy.window()
|
||||||
.its("sessionStorage")
|
.its("sessionStorage")
|
||||||
.invoke("removeItem", "items.sp-tarkov.com-locales");
|
.invoke("removeItem", "db.sp-tarkov.com-locales");
|
||||||
|
|
||||||
cy.intercept(
|
cy.intercept(
|
||||||
'**/api/locales',
|
'**/api/locales',
|
||||||
|
@ -4,7 +4,7 @@ describe('Json Theme', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.window()
|
cy.window()
|
||||||
.its("sessionStorage")
|
.its("sessionStorage")
|
||||||
.invoke("removeItem", "items.sp-tarkov.com-locales");
|
.invoke("removeItem", "db.sp-tarkov.com-locales");
|
||||||
|
|
||||||
cy.intercept(
|
cy.intercept(
|
||||||
'**/api/locales',
|
'**/api/locales',
|
||||||
@ -35,7 +35,7 @@ describe('Json Theme', () => {
|
|||||||
before(() => {
|
before(() => {
|
||||||
cy.visit('/', {
|
cy.visit('/', {
|
||||||
onBeforeLoad: function (window) {
|
onBeforeLoad: function (window) {
|
||||||
window.localStorage.removeItem('items.sp-tarkov.com-prefered-json-theme')
|
window.localStorage.removeItem('db.sp-tarkov.com-prefered-json-theme')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@ -54,7 +54,7 @@ describe('Json Theme', () => {
|
|||||||
before(() => {
|
before(() => {
|
||||||
cy.visit('/', {
|
cy.visit('/', {
|
||||||
onBeforeLoad: function (window) {
|
onBeforeLoad: function (window) {
|
||||||
window.localStorage.setItem('items.sp-tarkov.com-prefered-json-theme', 'eighties')
|
window.localStorage.setItem('db.sp-tarkov.com-prefered-json-theme', 'eighties')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -4,7 +4,7 @@ describe('Locale select', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.window()
|
cy.window()
|
||||||
.its("sessionStorage")
|
.its("sessionStorage")
|
||||||
.invoke("removeItem", "items.sp-tarkov.com-locales");
|
.invoke("removeItem", "db.sp-tarkov.com-locales");
|
||||||
|
|
||||||
cy.intercept(
|
cy.intercept(
|
||||||
'**/api/locales',
|
'**/api/locales',
|
||||||
@ -31,7 +31,7 @@ describe('Locale select', () => {
|
|||||||
[]).as('getLocalesWithoutData');
|
[]).as('getLocalesWithoutData');
|
||||||
cy.visit('/', {
|
cy.visit('/', {
|
||||||
onBeforeLoad: function (window) {
|
onBeforeLoad: function (window) {
|
||||||
window.localStorage.removeItem('items.sp-tarkov.com-prefered-locale')
|
window.localStorage.removeItem('db.sp-tarkov.com-prefered-locale')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -60,7 +60,7 @@ describe('Locale select', () => {
|
|||||||
before(() => {
|
before(() => {
|
||||||
cy.visit('/', {
|
cy.visit('/', {
|
||||||
onBeforeLoad: function (window) {
|
onBeforeLoad: function (window) {
|
||||||
window.localStorage.removeItem('items.sp-tarkov.com-prefered-locale')
|
window.localStorage.removeItem('db.sp-tarkov.com-prefered-locale')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -77,7 +77,7 @@ describe('Locale select', () => {
|
|||||||
before(() => {
|
before(() => {
|
||||||
cy.visit('/', {
|
cy.visit('/', {
|
||||||
onBeforeLoad: function (window) {
|
onBeforeLoad: function (window) {
|
||||||
window.localStorage.setItem('items.sp-tarkov.com-prefered-locale', 'locale2')
|
window.localStorage.setItem('db.sp-tarkov.com-prefered-locale', 'locale2')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -20,6 +20,14 @@ describe('Search area', ()=>{
|
|||||||
body: condensedMilk
|
body: condensedMilk
|
||||||
})
|
})
|
||||||
|
|
||||||
|
cy.intercept({
|
||||||
|
method: 'POST',
|
||||||
|
url: '**/api/search*'
|
||||||
|
}, {
|
||||||
|
statusCode: 200,
|
||||||
|
body: []
|
||||||
|
})
|
||||||
|
|
||||||
cy.intercept({
|
cy.intercept({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: '**/api/item/hierarchy*'
|
url: '**/api/item/hierarchy*'
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
export {};
|
|
||||||
|
|
||||||
import condensedMilk from '../fixtures/condensed_milk.json'
|
import condensedMilk from '../fixtures/condensed_milk.json'
|
||||||
|
|
||||||
|
export {};
|
||||||
|
|
||||||
describe('Url check', () => {
|
describe('Url check', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.window()
|
cy.window()
|
||||||
.its("sessionStorage")
|
.its("sessionStorage")
|
||||||
.invoke("removeItem", "items.sp-tarkov.com-locales");
|
.invoke("removeItem", "db.sp-tarkov.com-locales");
|
||||||
|
|
||||||
cy.intercept({
|
cy.intercept({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@ -24,6 +24,15 @@ describe('Url check', () => {
|
|||||||
body: condensedMilk
|
body: condensedMilk
|
||||||
})
|
})
|
||||||
|
|
||||||
|
cy.intercept({
|
||||||
|
method: 'POST',
|
||||||
|
url: '**/api/search*'
|
||||||
|
}, {
|
||||||
|
statusCode: 200,
|
||||||
|
body: []
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
cy.intercept({
|
cy.intercept({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: '**/api/item/hierarchy*'
|
url: '**/api/item/hierarchy*'
|
||||||
|
@ -4,12 +4,16 @@ import { ItemData } from '../dto/ItemData';
|
|||||||
import { useGlobalState } from '../state/GlobalState';
|
import { useGlobalState } from '../state/GlobalState';
|
||||||
|
|
||||||
const handleFetch = async (url: string, init?: RequestInit | undefined): Promise<any | null> => {
|
const handleFetch = async (url: string, init?: RequestInit | undefined): Promise<any | null> => {
|
||||||
|
try {
|
||||||
const resp = await fetch(url, { ...init, mode: 'cors' })
|
const resp = await fetch(url, { ...init, mode: 'cors' })
|
||||||
if (resp.status === 200) {
|
if (resp.status === 200) {
|
||||||
const jsonResponse = await resp.json();
|
const jsonResponse = await resp.json();
|
||||||
return jsonResponse !== undefined ? jsonResponse : null;
|
return jsonResponse !== undefined ? jsonResponse : null;
|
||||||
} else if (resp.status >= 400) {
|
} else if (resp.status >= 400) {
|
||||||
console.error(resp)
|
console.warn(resp)
|
||||||
|
}
|
||||||
|
}catch (e) {
|
||||||
|
console.warn(e)
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
export enum LocalStorageKeys {
|
export enum LocalStorageKeys {
|
||||||
PREFERED_COLOR_SCHEME = 'items.sp-tarkov.com-prefered-color-scheme',
|
PREFERED_COLOR_SCHEME = 'db.sp-tarkov.com-prefered-color-scheme',
|
||||||
PREFERED_JSON_THEME = 'items.sp-tarkov.com-prefered-json-theme',
|
PREFERED_JSON_THEME = 'db.sp-tarkov.com-prefered-json-theme',
|
||||||
PREFERED_LOCALE = 'items.sp-tarkov.com-prefered-locale'
|
PREFERED_LOCALE = 'db.sp-tarkov.com-prefered-locale'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SessionStorageKeys {
|
export enum SessionStorageKeys {
|
||||||
LOCALES = 'items.sp-tarkov.com-locales',
|
LOCALES = 'db.sp-tarkov.com-locales',
|
||||||
ITEMS_HIERARCHY = 'items.sp-tarkov.com-items-hierarchy',
|
ITEMS_HIERARCHY = 'db.sp-tarkov.com-items-hierarchy',
|
||||||
}
|
}
|
@ -26,11 +26,11 @@ export const MainPage = () => {
|
|||||||
<Header/>
|
<Header/>
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/search" element={<InteractiveArea/>}>
|
<Route path="/search" element={<InteractiveArea/>}/>
|
||||||
<Route path=":id" element={<InteractiveArea/>}/>
|
<Route path="/search/:id" element={<InteractiveArea/>}/>
|
||||||
</Route>
|
<Route path="/404" element={<PageNotFound />}/>
|
||||||
<Route path="/" element={<Navigate replace to="/search"/>}/>
|
<Route path="/" element={<Navigate replace to="/search"/>}/>
|
||||||
<Route path="*" element={<PageNotFound/>}/>
|
<Route path="*" element={<Navigate replace to="/404" />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
<Footer/>
|
<Footer/>
|
||||||
|
@ -57,7 +57,7 @@ export const useGlobalState = create<GlobalState>((set) => ({
|
|||||||
localesList: [],
|
localesList: [],
|
||||||
refreshLocalesList: async () => {
|
refreshLocalesList: async () => {
|
||||||
const locales = sessionStorage.getItem(SessionStorageKeys.LOCALES);
|
const locales = sessionStorage.getItem(SessionStorageKeys.LOCALES);
|
||||||
const localesList = locales !== null && locales !== undefined && locales !== 'undefined' ? JSON.parse(locales) : await getLocaleList()
|
const localesList = locales !== null && locales !== undefined && locales !== 'undefined' && locales !== 'null' ? JSON.parse(locales) : await getLocaleList()
|
||||||
if (!locales) sessionStorage.setItem(SessionStorageKeys.LOCALES, JSON.stringify(localesList ? localesList : null))
|
if (!locales) sessionStorage.setItem(SessionStorageKeys.LOCALES, JSON.stringify(localesList ? localesList : null))
|
||||||
set((_state) => ({ localesList: localesList ? localesList : [] }))
|
set((_state) => ({ localesList: localesList ? localesList : [] }))
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user