tests: Add test suite
This commit is contained in:
parent
a045a6010f
commit
d8af80c0dc
84
items/frontend/cypress/fixtures/condensed_milk.json
Normal file
84
items/frontend/cypress/fixtures/condensed_milk.json
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
{
|
||||||
|
"item": {
|
||||||
|
"_id": "5734773724597737fd047c14",
|
||||||
|
"_name": "condensed_milk",
|
||||||
|
"_parent": "5448e8d04bdc2ddf718b4569",
|
||||||
|
"_props": {
|
||||||
|
"AllowSpawnOnLocations": [],
|
||||||
|
"AnimationVariantsNumber": 0,
|
||||||
|
"BackgroundColor": "orange",
|
||||||
|
"CanRequireOnRagfair": true,
|
||||||
|
"CanSellOnRagfair": true,
|
||||||
|
"ChangePriceCoef": 1,
|
||||||
|
"ConflictingItems": [],
|
||||||
|
"CreditsPrice": 24943,
|
||||||
|
"Description": "Condensed milk",
|
||||||
|
"DiscardingBlock": false,
|
||||||
|
"ExamineExperience": 20,
|
||||||
|
"ExamineTime": 1,
|
||||||
|
"ExaminedByDefault": false,
|
||||||
|
"ExtraSizeDown": 0,
|
||||||
|
"ExtraSizeForceAdd": false,
|
||||||
|
"ExtraSizeLeft": 0,
|
||||||
|
"ExtraSizeRight": 0,
|
||||||
|
"ExtraSizeUp": 0,
|
||||||
|
"FixedPrice": false,
|
||||||
|
"Height": 1,
|
||||||
|
"HideEntrails": false,
|
||||||
|
"IsAlwaysAvailableForInsurance": false,
|
||||||
|
"IsLockedafterEquip": false,
|
||||||
|
"IsUnbuyable": false,
|
||||||
|
"IsUndiscardable": false,
|
||||||
|
"IsUngivable": false,
|
||||||
|
"IsUnsaleable": false,
|
||||||
|
"ItemSound": "food_tin_can",
|
||||||
|
"LootExperience": 50,
|
||||||
|
"MaxResource": 1,
|
||||||
|
"MergesWithChildren": false,
|
||||||
|
"Name": "Condensed milk",
|
||||||
|
"NotShownInSlot": false,
|
||||||
|
"Prefab": {
|
||||||
|
"path": "assets/content/weapons/usable_items/item_food_condensed_milk/item_food_condensed_milk_loot.bundle",
|
||||||
|
"rcid": ""
|
||||||
|
},
|
||||||
|
"QuestItem": false,
|
||||||
|
"RagFairCommissionModifier": 1,
|
||||||
|
"Rarity": "Rare",
|
||||||
|
"RepairCost": 0,
|
||||||
|
"RepairSpeed": 0,
|
||||||
|
"SendToClient": false,
|
||||||
|
"ShortName": "Condensed milk",
|
||||||
|
"SpawnChance": 9,
|
||||||
|
"StackMaxSize": 1,
|
||||||
|
"StackObjectsCount": 1,
|
||||||
|
"StimulatorBuffs": "Buffs_food_condensed_milk",
|
||||||
|
"Unlootable": false,
|
||||||
|
"UnlootableFromSide": [],
|
||||||
|
"UnlootableFromSlot": "FirstPrimaryWeapon",
|
||||||
|
"UsePrefab": {
|
||||||
|
"path": "assets/content/weapons/usable_items/item_food_condensed_milk/item_food_condensed_milk_container.bundle",
|
||||||
|
"rcid": ""
|
||||||
|
},
|
||||||
|
"Weight": 0.4,
|
||||||
|
"Width": 1,
|
||||||
|
"effects_damage": [],
|
||||||
|
"effects_health": {
|
||||||
|
"Energy": {
|
||||||
|
"value": 75
|
||||||
|
},
|
||||||
|
"Hydration": {
|
||||||
|
"value": -65
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"foodEffectType": "afterUse",
|
||||||
|
"foodUseTime": 4
|
||||||
|
},
|
||||||
|
"_proto": "5734770f24597738025ee254",
|
||||||
|
"_type": "Item"
|
||||||
|
},
|
||||||
|
"locale": {
|
||||||
|
"Description": "Condensed milk, also called \"Sguschyonka\" in Russia, once was a part of field ration for the Union soldiers in Civil War, but later reached unprecedented popularity in post-Soviet countries, becoming almost a staple product. Canned, it can be stored for decades and remain just as sweet, tasty and nutritious.",
|
||||||
|
"Name": "Condensed milk",
|
||||||
|
"ShortName": "Cond. milk"
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "Using fixtures to represent data",
|
|
||||||
"email": "hello@cypress.io",
|
|
||||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
|
||||||
}
|
|
@ -1,11 +1,32 @@
|
|||||||
|
import condensedMilk from "../../../cypress/fixtures/condensed_milk.json";
|
||||||
|
|
||||||
export {};
|
export {};
|
||||||
|
|
||||||
describe('Search area', ()=>{
|
describe('Search area', ()=>{
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.intercept('GET','**/api/locales', {
|
cy.intercept({
|
||||||
|
method: 'GET',
|
||||||
|
url: '**/api/locales'
|
||||||
|
}, {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
body: ['locale1', 'locale2']
|
body: ['locale1', 'locale2']
|
||||||
});
|
}).as('getLocalesWithoutData');
|
||||||
|
|
||||||
|
cy.intercept({
|
||||||
|
method: 'GET',
|
||||||
|
url: '**/api/item?*'
|
||||||
|
}, {
|
||||||
|
statusCode: 200,
|
||||||
|
body: condensedMilk
|
||||||
|
})
|
||||||
|
|
||||||
|
cy.intercept({
|
||||||
|
method: 'GET',
|
||||||
|
url: '**/api/item/hierarchy*'
|
||||||
|
}, {
|
||||||
|
statusCode: 200,
|
||||||
|
body: condensedMilk
|
||||||
|
})
|
||||||
|
|
||||||
cy.visit('/');
|
cy.visit('/');
|
||||||
})
|
})
|
||||||
@ -31,4 +52,19 @@ describe('Search area', ()=>{
|
|||||||
.should('be.visible')
|
.should('be.visible')
|
||||||
.contains('p', 'No data to display');
|
.contains('p', 'No data to display');
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('Searching', () => {
|
||||||
|
it('Search using ID displays the json with locale', () => {
|
||||||
|
cy.get('#search-autocomplete').type(condensedMilk.item._id);
|
||||||
|
setTimeout(() => {
|
||||||
|
cy.get('#search-autocomplete').should('have.value', condensedMilk.locale.Name)
|
||||||
|
}, 5000)
|
||||||
|
cy.get(`.react-json-view .object-key-val > .pushed-content > .object-content > .variable-row > .variable-value > div > .string-value:contains("${condensedMilk.item._id}")`)
|
||||||
|
.should('have.length', 1)
|
||||||
|
.invoke('text')
|
||||||
|
.should('eq', `"${condensedMilk.item._id}"`);
|
||||||
|
cy.get(`.react-json-view .object-key-val > .pushed-content > .object-content > .variable-row > .variable-value > div > .string-value:contains("${condensedMilk.locale.Name}")`)
|
||||||
|
.should('have.length.above', 0);
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
73
items/frontend/src/cypress/integration/url-check.spec.tsx
Normal file
73
items/frontend/src/cypress/integration/url-check.spec.tsx
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
export {};
|
||||||
|
|
||||||
|
import condensedMilk from '../../../cypress/fixtures/condensed_milk.json'
|
||||||
|
|
||||||
|
describe('Dark Mode Toggle', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.window()
|
||||||
|
.its("sessionStorage")
|
||||||
|
.invoke("removeItem", "items.sp-tarkov.com-locales");
|
||||||
|
|
||||||
|
cy.intercept({
|
||||||
|
method: 'GET',
|
||||||
|
url: '**/api/locales'
|
||||||
|
}, {
|
||||||
|
statusCode: 200,
|
||||||
|
body: []
|
||||||
|
}).as('getLocalesWithoutData');
|
||||||
|
|
||||||
|
cy.intercept({
|
||||||
|
method: 'GET',
|
||||||
|
url: '**/api/item?*'
|
||||||
|
}, {
|
||||||
|
statusCode: 200,
|
||||||
|
body: condensedMilk
|
||||||
|
})
|
||||||
|
|
||||||
|
cy.intercept({
|
||||||
|
method: 'GET',
|
||||||
|
url: '**/api/item/hierarchy*'
|
||||||
|
}, {
|
||||||
|
statusCode: 200,
|
||||||
|
body: condensedMilk
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
cy.clearLocalStorage();
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('Check page not found', () => {
|
||||||
|
it('Invalid url should redirect to page not found', () => {
|
||||||
|
cy.visit('/ABC')
|
||||||
|
cy.get('#not-found-message').contains("This page does not exist !");
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('Check root redirection', () => {
|
||||||
|
it('Root should redirect to search', () => {
|
||||||
|
cy.visit('/')
|
||||||
|
cy.url().should("include", "/search");
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('Check url changes with search input', () => {
|
||||||
|
it('ID in url applies search', () => {
|
||||||
|
cy.visit(`/search/${condensedMilk.item._id}`);
|
||||||
|
cy.get('#search-autocomplete').should('have.value', condensedMilk.locale.Name)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Search reflects in url', () => {
|
||||||
|
cy.visit(`/`);
|
||||||
|
cy.get('#search-autocomplete').type(condensedMilk.item._id);
|
||||||
|
setTimeout(() => {
|
||||||
|
cy.get('#search-autocomplete').should('have.value', condensedMilk.locale.Name)
|
||||||
|
}, 5000)
|
||||||
|
cy.url().should("include", `/search/${condensedMilk.item._id}`);
|
||||||
|
cy.get(`.react-json-view .object-key-val > .pushed-content > .object-content > .variable-row > .variable-value > div > .string-value:contains("${condensedMilk.item._id}")`)
|
||||||
|
.should('have.length', 1)
|
||||||
|
.invoke('text')
|
||||||
|
.should('eq', `"${condensedMilk.item._id}"`);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user