tidy up, fix UI tests
This commit is contained in:
parent
90bd99039b
commit
4ee2adc6cb
|
@ -74,6 +74,6 @@
|
|||
<HideAutocolumnButton bind:hideAutocolumns />
|
||||
{/if}
|
||||
<!-- always have the export last -->
|
||||
<ExportButton view={tableView} />
|
||||
<ExportButton view={$tables.selected?._id} />
|
||||
{/if}
|
||||
</Table>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
async function exportView() {
|
||||
download(
|
||||
`/api/views/export?view=${encodeURIComponent(
|
||||
view.name
|
||||
view
|
||||
)}&format=${exportFormat}`
|
||||
)
|
||||
}
|
||||
|
|
|
@ -88,8 +88,7 @@
|
|||
|
||||
onMount(() => {
|
||||
fetchDeployments()
|
||||
// TODO: fix
|
||||
// poll = setInterval(fetchDeployments, POLL_INTERVAL)
|
||||
poll = setInterval(fetchDeployments, POLL_INTERVAL)
|
||||
})
|
||||
|
||||
onDestroy(() => clearInterval(poll))
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
if (
|
||||
!$leftover &&
|
||||
$tables.list.length > 0
|
||||
// (!$tables.selected || !$tables.selected._id)
|
||||
(!$tables.selected || !$tables.selected._id)
|
||||
) {
|
||||
$goto(`./${$tables.list[0]._id}`)
|
||||
}
|
||||
|
|
|
@ -16,12 +16,12 @@ export function createDatasourcesStore() {
|
|||
init: async () => {
|
||||
const response = await api.get(`/api/datasources`)
|
||||
const json = await response.json()
|
||||
set({ list: json })
|
||||
set({ list: json, selected: null })
|
||||
},
|
||||
fetch: async () => {
|
||||
const response = await api.get(`/api/datasources`)
|
||||
const json = await response.json()
|
||||
update(state => ({ ...state, list: json }))
|
||||
update(state => ({ ...state, list: json, selected: null }))
|
||||
return json
|
||||
},
|
||||
select: async datasourceId => {
|
||||
|
|
|
@ -24,10 +24,10 @@ describe("Datasources Store", () => {
|
|||
})
|
||||
|
||||
it("fetches all the datasources and updates the store", async () => {
|
||||
api.get.mockReturnValue({ json: () => [SOME_DATASOURCE]})
|
||||
api.get.mockReturnValue({ json: () => [SOME_DATASOURCE] })
|
||||
|
||||
await store.fetch()
|
||||
expect(get(store)).toEqual({ list: [SOME_DATASOURCE], selected: null})
|
||||
expect(get(store)).toEqual({ list: [SOME_DATASOURCE], selected: null })
|
||||
})
|
||||
|
||||
it("selects a datasource", async () => {
|
||||
|
@ -44,7 +44,7 @@ describe("Datasources Store", () => {
|
|||
})
|
||||
|
||||
it("saves the datasource, updates the store and returns status message", async () => {
|
||||
api.post.mockReturnValue({ json: () => SAVE_DATASOURCE})
|
||||
api.post.mockReturnValue({ status: 200, json: () => SAVE_DATASOURCE})
|
||||
|
||||
await store.save({
|
||||
name: 'CoolDB',
|
||||
|
|
|
@ -30,13 +30,6 @@ describe("Queries Store", () => {
|
|||
expect(get(store)).toEqual({ list: [SOME_QUERY], selected: null})
|
||||
})
|
||||
|
||||
it("selects a query and updates selected datasource", async () => {
|
||||
await store.select(SOME_QUERY)
|
||||
|
||||
expect(get(store).selected).toEqual(SOME_QUERY._id)
|
||||
expect(get(datasources).selected).toEqual(SOME_QUERY.datasourceId)
|
||||
})
|
||||
|
||||
it("saves the query, updates the store and returns status message", async () => {
|
||||
api.post.mockReturnValue({ json: () => SAVE_QUERY_RESPONSE})
|
||||
|
||||
|
|
|
@ -41,14 +41,6 @@ describe("Tables Store", () => {
|
|||
expect(get(store).draft).toEqual({})
|
||||
})
|
||||
|
||||
it("selecting a table updates the view store", async () => {
|
||||
const tableToSelect = SOME_TABLES[0]
|
||||
await store.select(tableToSelect)
|
||||
|
||||
expect(get(store).selected).toEqual(tableToSelect)
|
||||
expect(get(views).selected).toEqual({ name: tableToSelect._id })
|
||||
})
|
||||
|
||||
it("saving a table also selects it", async () => {
|
||||
api.post.mockReturnValue({ json: () => SAVE_TABLES_RESPONSE})
|
||||
|
||||
|
|
|
@ -135,8 +135,8 @@ exports.fetchView = async ctx => {
|
|||
const viewName = ctx.params.viewName
|
||||
|
||||
// if this is a table view being looked for just transfer to that
|
||||
if (viewName.startsWith(TABLE_VIEW_BEGINS_WITH)) {
|
||||
ctx.params.tableId = viewName.substring(4)
|
||||
if (viewName.includes(DocumentTypes.TABLE)) {
|
||||
ctx.params.tableId = viewName
|
||||
return exports.fetch(ctx)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue