Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
delfrrr committed Aug 31, 2024
1 parent d678a04 commit 3619ff6
Show file tree
Hide file tree
Showing 32 changed files with 511 additions and 451 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ jobs:
-e DEKART_SNOWFLAKE_ACCOUNT_ID=${{ secrets.SNOWFLAKE_ACCOUNT_ID }} \
-e DEKART_SNOWFLAKE_USER=${{ secrets.SNOWFLAKE_USER }} \
-e DEKART_SNOWFLAKE_PASSWORD=${{ secrets.SNOWFLAKE_PASSWORD }} \
-e DEKART_DEV_CLAIMS_EMAIL=test@gmail.com \
-e DEKART_REQUIRE_AMAZON_OIDC=1 \
dekartxyz/dekart:${{ env.IMAGE_CACHE_KEY }}
- name: Upload cypress artifacts
if: failure()
Expand Down
27 changes: 14 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.PHONY: proto-build proto-docker proto docker docker-compose-up docker-compose-rm version minor patch
.PHONY: proto-clean proto-build proto-docker proto nodetest docker-compose-up down cloudsql up-and-down

# load .env
# https://lithic.tech/blog/2020-05/makefile-dot-env
ifneq (,$(wildcard ./.env))
include .env
export
# export # don't export, it will be available only in this Makefile
endif

UNAME := $(shell uname -m)
Expand Down Expand Up @@ -184,8 +184,6 @@ docker: # build docker for local use

up-and-down:
docker-compose --env-file .env --profile local up; docker-compose --env-file .env --profile local down --volumes


up:
docker-compose --env-file .env --profile local up

Expand All @@ -195,21 +193,24 @@ down:
cloudsql:
docker-compose --env-file .env --profile cloudsql up

server:
go run ./src/server/main.go

server-custom-env:
env -i PATH=${PATH} PWD=${PWD} HOME=${HOME} sh -c 'set -a; . $(DEV_CUSTOM_ENV_FILE); set +a; go run ./src/server/main.go'
define run_server
@set -a; \
. $(1); \
set +a; \
go run ./src/server/main.go
endef

server-scope-info:
DEKART_DEV_REFRESH_TOKEN=${DEV_REFRESH_TOKEN_INFO} go run ./src/server/main.go
# Pattern rule to match any target starting with ".env."
server-%:
$(call run_server,.env.$*)

server-scope-all:
DEKART_DEV_REFRESH_TOKEN=${DEV_REFRESH_TOKEN} go run ./src/server/main.go
# Rule for the default .env file
server:
$(call run_server,.env)

npm:
npm i --legacy-peer-deps

prerelease:
npm version prerelease --preid=rc
preminor:
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/athena/spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import copy from '../../fixtures/copy.json'
describe('basic query flow', () => {
it('should make simple athena query and get ready status', () => {
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()
cy.get('button:contains("Add data from...")').click()
cy.get('span:contains("SQL query")').click()
cy.get('textarea').type(copy.simple_athena_query, { force: true })
Expand All @@ -17,7 +17,7 @@ describe('basic query flow', () => {
describe('cancelling query', () => {
it('should cancels query', () => {
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()
cy.get('button:contains("Add data from...")').click()
cy.get('span:contains("SQL query")').click()
cy.get('textarea').type(copy.simple_athena_query, { force: true })
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/bq/basicFlow.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import copy from '../../fixtures/copy.json'
describe('basic query flow', () => {
it('should make simple bigquery query and get ready status', () => {
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()
cy.get('button:contains("Add data from...")').click()
cy.get('span:contains("SQL query")').click()
cy.get('textarea').type(copy.simple_sql_query, { force: true })
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/bq/cancelQuery.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import copy from '../../fixtures/copy.json'
describe('cancelling query', () => {
it('should cancels query', () => {
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()
cy.get('button:contains("Add data from...")').click()
cy.get('span:contains("SQL query")').click()
cy.get('textarea').type(copy.simple_sql_query, { force: true })
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/bq/scripts.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import copy from '../../fixtures/copy.json'
describe('support bq scripts', () => {
it('retrieve result for bigquery script', () => {
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()
cy.get('button:contains("Add data from...")').click()
cy.get('span:contains("SQL query")').click()
cy.get('textarea').type(copy.bigquery_script, { force: true })
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/bq/updateDataset.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('update dataset', () => {
it('should persist kepler config when updating dataset', () => {
// create report
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()

// first query
cy.get('button:contains("Add data from...")').click()
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/pg/cancelQuery.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import copy from '../../fixtures/copy.json'
describe('cancelling query', () => {
it('should cancels query', () => {
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()
cy.get('button:contains("Add data from...")').click()
cy.get('span:contains("SQL query")').click()
cy.get('textarea').type(copy.simple_pg_query_long, { force: true })
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/pg/happyPath.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import copy from '../../fixtures/copy.json'
describe('happy path', () => {
it('should make simple postgres query and get ready status', () => {
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()
cy.get('button:contains("Add data from...")').click()
cy.get('span:contains("SQL query")').click()
cy.get('textarea').type(copy.simple_pg_query, { force: true })
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/snowflake-s3/cancelQuery.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import copy from '../../fixtures/copy.json'
describe('cancelling query', () => {
it('should cancels query', () => {
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()
cy.get('button:contains("Add data from...")').click()
cy.get('span:contains("SQL query")').click()
cy.get('textarea').type(copy.simple_snowflake_query, { force: true })
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/snowflake-s3/emptyResult.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import copy from '../../fixtures/copy.json'
describe('empty path', () => {
it('should complete query returning empty result', () => {
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()
cy.get('button:contains("Add data from...")').click()
cy.get('span:contains("SQL query")').click()
cy.get('textarea').type('SELECT ROUND(uniform(-90::float, 90::float, random()), 6) AS lat, ROUND(uniform(-180::float, 180::float, random()), 6) AS lon FROM TABLE(GENERATOR(ROWCOUNT => 0))', { force: true })
Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/snowflake-s3/fork.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ async function getColorAtMapCenter (win) {

describe('fork', () => {
it('should have same viz style after fork', () => {
let originalColor
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()
cy.get('button:contains("Add data from...")').click()
cy.get('span:contains("SQL query")').click()
cy.get('textarea').type('select 0 as lat, 0 as lon', { force: true })
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/snowflake-s3/happyPath.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import copy from '../../fixtures/copy.json'
describe('happy path', () => {
it('should make simple snowflake query and get ready status', () => {
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()
cy.get('button:contains("Add data from...")').click()
cy.get('span:contains("SQL query")').click()
cy.get('textarea').type(copy.simple_snowflake_query, { force: true })
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/snowflake-s3/spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import copy from '../../fixtures/copy.json'
describe('basic query flow', () => {
it('should make simple snowflake query and get ready status', () => {
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()
cy.get('button:contains("Add data from...")').click()
cy.get('span:contains("SQL query")').click()
cy.get('textarea').type(copy.simple_snowflake_query, { force: true })
Expand All @@ -18,7 +18,7 @@ describe('basic query flow', () => {
describe('cancelling query', () => {
it('should cancels query', () => {
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()
cy.get('button:contains("Add data from...")').click()
cy.get('span:contains("SQL query")').click()
cy.get('textarea').type(copy.simple_snowflake_query, { force: true })
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/snowflake/happyPath.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import copy from '../../fixtures/copy.json'
describe('happy path', () => {
it('should make simple snowflake query and get ready status', () => {
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()
cy.get('textarea').type(copy.simple_snowflake_query, { force: true })
cy.get(`button:contains("${copy.execute}")`).click()
cy.get(`span:contains("${copy.ready}")`, { timeout: 20000 }).should('be.visible')
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/snowflake/runAllQueries.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import copy from '../../fixtures/copy.json'
describe('run all queries', () => {
it('should run all queries', () => {
cy.visit('/')
cy.get(`button:contains("${copy.create_report}")`).click()
cy.get('button#dekart-create-report').click()
cy.get('textarea').type('SELECT ROUND(uniform(-90::float, 90::float, random()), 6) AS lat, ROUND(uniform(-180::float, 180::float, random()), 6) AS lon FROM TABLE(GENERATOR(ROWCOUNT => 1000))', { force: true })
cy.get(`button:contains("${copy.execute}")`).click()
cy.get(`span:contains("${copy.ready}")`, { timeout: 20000 }).should('be.visible')
Expand Down
1 change: 0 additions & 1 deletion cypress/fixtures/copy.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"create_report": "Report",
"bigquery_query": "BigQuery query",
"athena_query": "Athena query",
"snowflake_query": "Snowflake query",
Expand Down
2 changes: 2 additions & 0 deletions proto/dekart.proto
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ message GetEnvResponse {
TYPE_UX_SAMPLE_QUERY_SQL = 15;
TYPE_AES_KEY = 16;
TYPE_AES_IV = 17;
TYPE_AUTH_ENABLED = 18;
TYPE_USER_DEFINED_CONNECTION = 19;
}
Type type = 1;
string value = 2;
Expand Down
25 changes: 18 additions & 7 deletions src/client/DekartMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { createReport } from './actions/report'
export default function DekartMenu () {
const env = useSelector(state => state.env)
const usage = useSelector(state => state.usage)
const userDefinedConnection = useSelector(state => state.connection.userDefined)
const dispatch = useDispatch()
const { authEnabled } = env
const ref = getUrlRef(env, usage)
Expand All @@ -18,13 +19,23 @@ export default function DekartMenu () {
<Menu.SubMenu
popupClassName={styles.subMenu} title={<MenuOutlined />} key='home' active='yes'
>
<Menu.Item key='my'>
<Link to='/'>{authEnabled ? 'My Reports' : 'Reports'}</Link>
</Menu.Item>
<Menu.Item key='shared' >
<Link to='/shared'>Shared reports</Link>
</Menu.Item>
<Menu.Item key='connections' ><Link to='/connections'>Connections</Link></Menu.Item>
{authEnabled
? (
<>
<Menu.Item key='my'>
<Link to='/'>My Reports</Link>
</Menu.Item>
<Menu.Item key='shared'>
<Link to='/shared'>Shared reports</Link>
</Menu.Item>
</>
)
: (
<Menu.Item key='reports'>
<Link to='/'>Reports</Link>
</Menu.Item>
)}
{userDefinedConnection ? (<Menu.Item key='connections'><Link to='/connections'>Connections</Link></Menu.Item>) : null}
<Menu.Divider />
<Menu.Item key='create' onClick={() => dispatch(createReport())}>New Report</Menu.Item>
</Menu.SubMenu>
Expand Down
61 changes: 30 additions & 31 deletions src/client/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,47 @@ function getSignature (email) {
function User ({ buttonDivider }) {
const token = useSelector(state => state.token)
const userStream = useSelector(state => state.user.stream)
const { authEnabled } = useSelector(state => state.env)
const dispatch = useDispatch()
if (!userStream || !token) {
if (!userStream || !authEnabled) {
return null
}
const items = [{
label: userStream && userStream.email,
disabled: true
}]
if (token) {
items.push({
label: 'Switch account',
onClick: () => {
const state = new AuthState()
state.setUiUrl(window.location.href)
state.setAction(AuthState.Action.ACTION_REQUEST_CODE)
state.setSwitchAccount(true)
dispatch(authRedirect(state))
}
})
items.push({
label: 'Sign out',
onClick: () => {
const state = new AuthState()
state.setUiUrl(window.location.href)
state.setAction(AuthState.Action.ACTION_REVOKE)
state.setAccessTokenToRevoke(token.access_token)
dispatch(authRedirect(state))
}
})
}
return (
<div className={classNames(
styles.user,
{ [styles.buttonDivider]: buttonDivider }
)}
>
<Dropdown
overlayClassName={styles.userDropdown} menu={{
items: [
{
label: userStream && userStream.email,
disabled: true
},
{
label: 'Switch account',
onClick: () => {
const state = new AuthState()
state.setUiUrl(window.location.href)
state.setAction(AuthState.Action.ACTION_REQUEST_CODE)
state.setSwitchAccount(true)
dispatch(authRedirect(state))
}
},
{
label: 'Sign out',
onClick: () => {
const state = new AuthState()
state.setUiUrl(window.location.href)
state.setAction(AuthState.Action.ACTION_REVOKE)
state.setAccessTokenToRevoke(token.access_token)
dispatch(authRedirect(state))
}
}
]
}}
><Avatar>{getSignature(userStream && userStream.email)}</Avatar>
overlayClassName={styles.userDropdown} menu={{ items }}
><Avatar>{getSignature(userStream.email)}</Avatar>
</Dropdown>

</div>
)
}
Expand Down
15 changes: 9 additions & 6 deletions src/client/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,15 @@ function filterColumns (filter) {
return filter.map(f => columns.find(c => c.dataIndex === f))
}

function getColumns (reportFilter, archived) {
function getColumns (reportFilter, archived, authEnabled) {
if (reportFilter === 'my') {
if (archived) {
return filterColumns(['archivedTitle', 'delete'])
}
return filterColumns(['icon', 'title', 'delete'])
if (authEnabled) {
return filterColumns(['icon', 'title', 'delete'])
}
return filterColumns(['title', 'delete'])
} else if (reportFilter === 'connections') {
return filterColumns(['connectionIcon', 'connectionName', 'author', 'setDefault'])
} else {
Expand All @@ -156,7 +159,7 @@ function FirstReportOnboarding () {
subTitle='Everything is ready to create you first map.'
extra={(
<>
<Button icon={<PlusOutlined />} type='primary' onClick={() => dispatch(createReport())}>Create report</Button>
<Button icon={<PlusOutlined />} id='dekart-create-report' type='primary' onClick={() => dispatch(createReport())}>Create report</Button>
</>
)}
/>
Expand Down Expand Up @@ -272,7 +275,7 @@ function ReportsHeader (
)
: null
}
<Button onClick={() => dispatch(createReport())}>New Report</Button>
<Button id='dekart-create-report' onClick={() => dispatch(createReport())}>New Report</Button>
</>
)
}
Expand All @@ -285,7 +288,7 @@ function ReportsHeader (
function Reports ({ createReportButton, reportFilter }) {
const [archived, setArchived] = useState(false)
const reportsList = useSelector(state => state.reportsList)
const { loaded: envLoaded } = useSelector(state => state.env)
const { loaded: envLoaded, authEnabled } = useSelector(state => state.env)
const connectionList = useSelector(state => state.connection.list)
const userDefinedConnection = useSelector(state => state.connection.userDefined)
const newConnectionScreen = useSelector(state => state.connection.screen)
Expand Down Expand Up @@ -328,7 +331,7 @@ function Reports ({ createReportButton, reportFilter }) {
? (
<Table
dataSource={dataSource}
columns={getColumns(reportFilter, archived)}
columns={getColumns(reportFilter, archived, authEnabled)}
showHeader={false}
rowClassName={styles.reportsRow}
pagination={false}
Expand Down
Loading

0 comments on commit 3619ff6

Please sign in to comment.