mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Merge branch 'main' into remove-contact-button-from-selecting-tables
This commit is contained in:
@@ -12,13 +12,13 @@ describe('Getting cross-search data', () => {
|
||||
})
|
||||
describe('without server side pagination works', () => {
|
||||
it('Requesting get all has correct length and status code', async () => {
|
||||
const response = await send<CrossSearch[]>(`crosssearch/all`, 'GET')
|
||||
const response = await send<CrossSearch[]>(`crosssearch/all/999/0/[]/[]`, 'GET')
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.body.length).toEqual(20)
|
||||
})
|
||||
|
||||
it('Get all has some correct fields from locality and species', async () => {
|
||||
const { body: getReqBody } = await send<CrossSearch[]>(`crosssearch/all`, 'GET')
|
||||
const { body: getReqBody } = await send<CrossSearch[]>(`crosssearch/all/999/0/[]/[]`, 'GET')
|
||||
expect(getReqBody[0]).toHaveProperty('lid')
|
||||
expect(getReqBody[0]).toHaveProperty('loc_name')
|
||||
expect(getReqBody[0]).toHaveProperty('subclass_or_superorder_name')
|
||||
@@ -27,7 +27,7 @@ describe('Getting cross-search data', () => {
|
||||
})
|
||||
|
||||
it('Requesting get all has some correct fields', async () => {
|
||||
const { body: getReqBody } = await send<CrossSearch[]>(`crosssearch/all`, 'GET')
|
||||
const { body: getReqBody } = await send<CrossSearch[]>(`crosssearch/all/999/0/[]/[]`, 'GET')
|
||||
expect(getReqBody.map(e => e.lid_now_loc)).toContain(24797)
|
||||
expect(getReqBody.map(e => e.lid_now_loc)).toContain(24750)
|
||||
expect(getReqBody.map(e => e.loc_name)).toContain('Romanyà dEmpordà ')
|
||||
@@ -37,7 +37,7 @@ describe('Getting cross-search data', () => {
|
||||
})
|
||||
|
||||
it("Get all doesn't have a species that doesn't have locality", async () => {
|
||||
const { body: getReqBody } = (await send(`crosssearch/all`, 'GET')) as { body: unknown } as {
|
||||
const { body: getReqBody } = (await send(`crosssearch/all/999/0/[]/[]`, 'GET')) as { body: unknown } as {
|
||||
body: CrossSearch[]
|
||||
}
|
||||
const speciesNameList = getReqBody.map(e => e.species_name)
|
||||
@@ -45,7 +45,7 @@ describe('Getting cross-search data', () => {
|
||||
})
|
||||
|
||||
it("Get all doesn't have a locality that doesn't have species", async () => {
|
||||
const { body: getReqBody } = await send<CrossSearch[]>(`crosssearch/all`, 'GET')
|
||||
const { body: getReqBody } = await send<CrossSearch[]>(`crosssearch/all/999/0/[]/[]`, 'GET')
|
||||
const locNameList = getReqBody.map(e => e.loc_name)
|
||||
expect(locNameList).not.toContain('not in cross search')
|
||||
})
|
||||
@@ -208,7 +208,7 @@ describe('Getting cross-search data', () => {
|
||||
describe('does not show drafts without proper user rights', () => {
|
||||
it('Get all with admin has correct amount of data', async () => {
|
||||
await login()
|
||||
const response = await send<CrossSearch[]>(`crosssearch/all`, 'GET')
|
||||
const response = await send<CrossSearch[]>(`crosssearch/all/999/0/[]/[]`, 'GET')
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.body.length).toEqual(22)
|
||||
const locNameList = response.body.map(e => e.loc_name)
|
||||
@@ -220,7 +220,7 @@ describe('Getting cross-search data', () => {
|
||||
|
||||
it('Get all with user included in a project has correct data', async () => {
|
||||
await login('testPl', 'test')
|
||||
const response = await send<CrossSearch[]>(`crosssearch/all`, 'GET')
|
||||
const response = await send<CrossSearch[]>(`crosssearch/all/999/0/[]/[]`, 'GET')
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.body.length).toEqual(21)
|
||||
const locNameList = response.body.map(e => e.loc_name)
|
||||
@@ -231,7 +231,7 @@ describe('Getting cross-search data', () => {
|
||||
|
||||
it('Get all with anonymous user has correct data', async () => {
|
||||
logout()
|
||||
const response = await send<CrossSearch[]>(`crosssearch/all`, 'GET')
|
||||
const response = await send<CrossSearch[]>(`crosssearch/all/999/0/[]/[]`, 'GET')
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.body.length).toEqual(20)
|
||||
const locNameList = response.body.map(e => e.loc_name)
|
||||
|
||||
@@ -37,9 +37,4 @@ router.get(`/all/:limit/:offset/:columnfilters/:sorting`, async (req, res) => {
|
||||
}
|
||||
})
|
||||
|
||||
router.get(`/all`, async (req, res) => {
|
||||
const result = await getCrossSearchRawSql(req.user)
|
||||
return res.status(200).send(fixBigInt(result))
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
@@ -326,3 +326,23 @@ describe("Locality's coordinate selection map works", () => {
|
||||
cy.contains('24 45 10 E')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Deleting a locality', () => {
|
||||
beforeEach('Login as admin', () => {
|
||||
cy.login('testSu')
|
||||
})
|
||||
|
||||
it('works and returns user to table view', () => {
|
||||
cy.visit(`/locality/20920`)
|
||||
cy.contains('Lantian-Shuijiazui')
|
||||
cy.get('[id=delete-button]').should('exist').click()
|
||||
cy.on('window:confirm', str => {
|
||||
expect(str).to.eq('Are you sure you want to delete this item? This operation cannot be undone.')
|
||||
// this automatically clicks the OK button and returns to table view
|
||||
})
|
||||
cy.contains('Dmanisi') // check that table view has been navigated to
|
||||
cy.contains('Lantian-Shuijiazui').should('not.exist')
|
||||
cy.visit(`/locality/20920`)
|
||||
cy.contains('Error loading data')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -123,7 +123,9 @@ describe('Deleting a region', () => {
|
||||
expect(str).to.eq('Are you sure you want to delete this item? This operation cannot be undone.')
|
||||
// this automatically clicks the OK button and returns to table view
|
||||
})
|
||||
cy.contains('region 44524b6e')
|
||||
cy.contains('region 44524b6e') // check that table view has been navigated to
|
||||
cy.contains('region 4452477e').should('not.exist')
|
||||
cy.visit('/region/1')
|
||||
cy.contains('Error loading data')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -27,3 +27,11 @@ describe('Creating a species', () => {
|
||||
cy.contains('4 Invalid fields')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Deleting a species', () => {
|
||||
beforeEach('Login as admin', () => {
|
||||
cy.login('testSu')
|
||||
})
|
||||
// TODO: Add test for deleting a species (this can be copy pasted from other e2e test files with minimal changes)
|
||||
// Not done because species that have synonyms cannot be deleted currently.
|
||||
})
|
||||
|
||||
@@ -33,3 +33,12 @@ describe('Editing time bound', () => {
|
||||
cy.contains('1 Invalid fields')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Deleting a time bound', () => {
|
||||
beforeEach('Login as admin', () => {
|
||||
cy.login('testSu')
|
||||
})
|
||||
|
||||
// TODO: Add test for deleting a time bound (this can be copy pasted from other e2e test files with minimal changes)
|
||||
// Not done because time bounds that have linked time units cannot be deleted currently.
|
||||
})
|
||||
|
||||
@@ -231,3 +231,12 @@ describe('Editing a time unit', () => {
|
||||
cy.contains('C2N-o')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Deleting a time unit', () => {
|
||||
beforeEach('Login as admin', () => {
|
||||
cy.login('testSu')
|
||||
})
|
||||
|
||||
// TODO: Add test for deleting a time unit (this can be copy pasted from other e2e test files with minimal changes)
|
||||
// Not done because time units that have linked localities cannot be deleted currently.
|
||||
})
|
||||
|
||||
@@ -206,7 +206,7 @@ export const DetailView = <T extends object>({
|
||||
<EditIcon style={{ marginRight: '0.5em' }} /> {mode.read ? 'Edit' : 'Cancel edit'}
|
||||
</Button>
|
||||
)}
|
||||
{editRights.delete && !isNew && (
|
||||
{editRights.delete && !isNew && !isUserPage && (
|
||||
<Button
|
||||
id="delete-button"
|
||||
onClick={onDelete}
|
||||
|
||||
@@ -35,6 +35,8 @@ const localitiesApi = api.injectEndpoints({
|
||||
url: `/locality/${id}`,
|
||||
method: 'DELETE',
|
||||
}),
|
||||
invalidatesTags: (result, _error, lid) =>
|
||||
typeof result !== 'undefined' ? [{ type: 'locality', id: lid }, 'localities'] : [],
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -63,6 +63,8 @@ const referencesApi = api.injectEndpoints({
|
||||
url: `/reference/${id}`,
|
||||
method: 'DELETE',
|
||||
}),
|
||||
invalidatesTags: (result, _error, rid) =>
|
||||
typeof result !== 'undefined' ? [{ type: 'reference', id: rid }, 'references'] : [],
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -29,7 +29,8 @@ const regionsApi = api.injectEndpoints({
|
||||
url: `/region/${id}`,
|
||||
method: 'DELETE',
|
||||
}),
|
||||
invalidatesTags: ['regions'],
|
||||
invalidatesTags: (result, _error, reg_coord_id) =>
|
||||
typeof result !== 'undefined' ? [{ type: 'region', id: reg_coord_id }, 'regions'] : [],
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -29,6 +29,9 @@ const speciesApi = api.injectEndpoints({
|
||||
url: `/species/${id}`,
|
||||
method: 'DELETE',
|
||||
}),
|
||||
|
||||
invalidatesTags: (result, _error, species_id) =>
|
||||
typeof result !== 'undefined' ? [{ type: 'species', id: species_id }, 'specieslist'] : [],
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -33,6 +33,8 @@ const timeboundsApi = api.injectEndpoints({
|
||||
url: `/time-bound/${id}`,
|
||||
method: 'DELETE',
|
||||
}),
|
||||
invalidatesTags: (result, _error, bid) =>
|
||||
typeof result !== 'undefined' ? [{ type: 'timebound', id: bid }, 'timebounds'] : [],
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -39,7 +39,8 @@ const timeunitsApi = api.injectEndpoints({
|
||||
url: `/time-unit/${id}`,
|
||||
method: 'DELETE',
|
||||
}),
|
||||
invalidatesTags: ['timeunits'],
|
||||
invalidatesTags: (result, _error, tu_name) =>
|
||||
typeof result !== 'undefined' ? [{ type: 'timeunit', id: tu_name }, 'timeunits'] : [],
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user