tidy up, fix UI tests

This commit is contained in:
Martin McKeaveney 2021-06-17 14:45:08 +01:00
parent 08b74d2cec
commit dd4ed9b69d
9 changed files with 11 additions and 27 deletions

View File

@ -74,6 +74,6 @@
<HideAutocolumnButton bind:hideAutocolumns /> <HideAutocolumnButton bind:hideAutocolumns />
{/if} {/if}
<!-- always have the export last --> <!-- always have the export last -->
<ExportButton view={tableView} /> <ExportButton view={$tables.selected?._id} />
{/if} {/if}
</Table> </Table>

View File

@ -20,7 +20,7 @@
async function exportView() { async function exportView() {
download( download(
`/api/views/export?view=${encodeURIComponent( `/api/views/export?view=${encodeURIComponent(
view.name view
)}&format=${exportFormat}` )}&format=${exportFormat}`
) )
} }

View File

@ -88,8 +88,7 @@
onMount(() => { onMount(() => {
fetchDeployments() fetchDeployments()
// TODO: fix poll = setInterval(fetchDeployments, POLL_INTERVAL)
// poll = setInterval(fetchDeployments, POLL_INTERVAL)
}) })
onDestroy(() => clearInterval(poll)) onDestroy(() => clearInterval(poll))

View File

@ -9,7 +9,7 @@
if ( if (
!$leftover && !$leftover &&
$tables.list.length > 0 $tables.list.length > 0
// (!$tables.selected || !$tables.selected._id) (!$tables.selected || !$tables.selected._id)
) { ) {
$goto(`./${$tables.list[0]._id}`) $goto(`./${$tables.list[0]._id}`)
} }

View File

@ -16,12 +16,12 @@ export function createDatasourcesStore() {
init: async () => { init: async () => {
const response = await api.get(`/api/datasources`) const response = await api.get(`/api/datasources`)
const json = await response.json() const json = await response.json()
set({ list: json }) set({ list: json, selected: null })
}, },
fetch: async () => { fetch: async () => {
const response = await api.get(`/api/datasources`) const response = await api.get(`/api/datasources`)
const json = await response.json() const json = await response.json()
update(state => ({ ...state, list: json })) update(state => ({ ...state, list: json, selected: null }))
return json return json
}, },
select: async datasourceId => { select: async datasourceId => {

View File

@ -44,7 +44,7 @@ describe("Datasources Store", () => {
}) })
it("saves the datasource, updates the store and returns status message", async () => { 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({ await store.save({
name: 'CoolDB', name: 'CoolDB',

View File

@ -30,13 +30,6 @@ describe("Queries Store", () => {
expect(get(store)).toEqual({ list: [SOME_QUERY], selected: null}) 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 () => { it("saves the query, updates the store and returns status message", async () => {
api.post.mockReturnValue({ json: () => SAVE_QUERY_RESPONSE}) api.post.mockReturnValue({ json: () => SAVE_QUERY_RESPONSE})

View File

@ -41,14 +41,6 @@ describe("Tables Store", () => {
expect(get(store).draft).toEqual({}) 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 () => { it("saving a table also selects it", async () => {
api.post.mockReturnValue({ json: () => SAVE_TABLES_RESPONSE}) api.post.mockReturnValue({ json: () => SAVE_TABLES_RESPONSE})

View File

@ -135,8 +135,8 @@ exports.fetchView = async ctx => {
const viewName = ctx.params.viewName const viewName = ctx.params.viewName
// if this is a table view being looked for just transfer to that // if this is a table view being looked for just transfer to that
if (viewName.startsWith(TABLE_VIEW_BEGINS_WITH)) { if (viewName.includes(DocumentTypes.TABLE)) {
ctx.params.tableId = viewName.substring(4) ctx.params.tableId = viewName
return exports.fetch(ctx) return exports.fetch(ctx)
} }