Skip to content

Commit

Permalink
Merge branch 'master' into feat/toolbar-3000
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Sep 14, 2023
2 parents ff797d2 + 491960d commit e403885
Show file tree
Hide file tree
Showing 261 changed files with 5,904 additions and 2,271 deletions.
10 changes: 0 additions & 10 deletions .coveragerc

This file was deleted.

26 changes: 0 additions & 26 deletions .deepsource.toml

This file was deleted.

1 change: 0 additions & 1 deletion .environment

This file was deleted.

21 changes: 20 additions & 1 deletion .github/workflows/ci-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,30 @@ jobs:
id: chunk
run: echo "chunks=$(ls cypress/e2e/* | jq --slurp --raw-input -c 'split("\n")[:-1] | _nwise(3) | join("\n")' | jq --slurp -c .)" >> $GITHUB_OUTPUT

container:
name: Build and cache container image
runs-on: ubuntu-latest
timeout-minutes: 60
needs: [changes]
permissions:
contents: read
id-token: write # allow issuing OIDC tokens for this workflow run
steps:
- name: Checkout
if: needs.changes.outputs.shouldTriggerCypress == 'true'
uses: actions/checkout@v3
- name: Get Docker image cached in Depot
if: needs.changes.outputs.shouldTriggerCypress == 'true'
# Build the container image in preparation for the E2E tests
uses: ./.github/actions/build-n-cache-image
with:
actions-id-token-request-url: ${{ env.ACTIONS_ID_TOKEN_REQUEST_URL }}

cypress:
name: Cypress E2E tests (${{ strategy.job-index }})
runs-on: ubuntu-latest
timeout-minutes: 60
needs: [chunks, changes]
needs: [chunks, changes, container]
permissions:
id-token: write # allow issuing OIDC tokens for this workflow run

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/customer-data-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
images: ghcr.io/${{ steps.lowercase.outputs.repository }}/cdp

# Make the image tags used for docker cache. We use this rather than
# ${{ github.repository }} directly because the repository
# ${{ github.repository }} directly because the repository
# organization name is has upper case characters, which are not
# allowed in docker image names.
- uses: docker/metadata-action@v4
Expand Down
11 changes: 11 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ const setupMsw = () => {
// Make sure the msw worker is started
worker.start({
quiet: true,
onUnhandledRequest(request, print) {
// MSW warns on all unhandled requests, but we don't necessarily care
const pathAllowList = ['/images/']

if (pathAllowList.some((path) => request.url.pathname.startsWith(path))) {
return
}

// Otherwise, default MSW warning behavior
print.warning()
},
})
;(window as any).__mockServiceWorker = worker
;(window as any).POSTHOG_APP_CONTEXT = getStorybookAppContext()
Expand Down
1 change: 1 addition & 0 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const LOADER_SELECTORS = [
'.LemonTableLoader',
'[aria-busy="true"]',
'.SessionRecordingPlayer--buffering',
'.Lettermark--unknown',
]

const customSnapshotsDir = `${process.cwd()}/frontend/__snapshots__`
Expand Down
1 change: 0 additions & 1 deletion .test_durations

This file was deleted.

3 changes: 0 additions & 3 deletions codecov.yml

This file was deleted.

43 changes: 43 additions & 0 deletions cypress/e2e/notebooks-creation-and-deletion.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { randomString } from '../support/random'

function visitNotebooksList(): void {
cy.clickNavMenu('dashboards')
cy.location('pathname').should('include', '/dashboard')
cy.get('h1').should('contain', 'Dashboards & Notebooks')
cy.get('li').contains('Notebooks').should('exist').click()
}

function createNotebookAndFindInList(notebookTitle: string): void {
cy.get('[data-attr="new-notebook"]').click()
cy.get('.NotebookEditor').type(notebookTitle)

visitNotebooksList()
cy.get('[data-attr="notebooks-search"]').type(notebookTitle)
}

describe('Notebooks', () => {
beforeEach(() => {
visitNotebooksList()
})

it('can create and name a notebook', () => {
const notebookTitle = randomString('My new notebook')

createNotebookAndFindInList(notebookTitle)
cy.get('[data-attr="notebooks-table"] tbody tr').should('have.length', 1)
})

it('can delete a notebook', () => {
const notebookTitle = randomString('My notebook to delete')

createNotebookAndFindInList(notebookTitle)

cy.contains('[data-attr="notebooks-table"] tr', notebookTitle).within(() => {
cy.get('[aria-label="more"]').click()
})
cy.contains('.LemonButton', 'Delete').click()

// and the table updates
cy.contains('[data-attr="notebooks-table"] tr', notebookTitle).should('not.exist')
})
})
44 changes: 43 additions & 1 deletion cypress/e2e/notebooks.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,23 @@ describe('Notebooks', () => {
'loadSessionRecordingsList'
)
})

cy.fixture('api/session-recordings/recording.json').then((recording) => {
cy.intercept('GET', /api\/projects\/\d+\/session_recordings\/.*\?.*/, { body: recording }).as(
'loadSessionRecording'
)
})

cy.fixture('api/notebooks/notebooks.json').then((notebook) => {
cy.intercept('GET', /api\/projects\/\d+\/notebooks\//, { body: notebook }).as('loadNotebooksList')
})

cy.fixture('api/notebooks/notebook.json').then((notebook) => {
cy.intercept('GET', /api\/projects\/\d+\/notebooks\/.*\//, { body: notebook }).as('loadNotebook')
// this means saving doesn't work but so what?
cy.intercept('PATCH', /api\/projects\/\d+\/notebooks\/.*\//, (req, res) => {
res.reply(req.body)
}).as('patchNotebook')
})

cy.clickNavMenu('dashboards')
Expand All @@ -34,7 +41,7 @@ describe('Notebooks', () => {
})

it('Insertion suggestions can be dismissed', () => {
cy.visit(urls.notebookEdit('h11RoiwV'))
cy.visit(urls.notebook('h11RoiwV'))
cy.get('.NotebookEditor').type('{enter}')

cy.get('.NotebookRecordingTimestamp--preview').should('exist')
Expand All @@ -53,4 +60,39 @@ describe('Notebooks', () => {
cy.get('.ph-recording.NotebookNode').should('be.visible')
cy.get('.NotebookRecordingTimestamp').should('contain.text', '0:00')
})

describe('text types', () => {
beforeEach(() => {
cy.get('li').contains('Notebooks').should('exist').click()
cy.get('[data-attr="new-notebook"]').click()
// we don't actually get a new notebook because the API is mocked
// so, "exit" the timestamp block we start in
cy.get('.NotebookEditor').type('{esc}{enter}{enter}')
})

it('Can add a number list', () => {
cy.get('.NotebookEditor').type('1. the first')
cy.get('.NotebookEditor').type('{enter}')
// no need to type the number now. it should be inserted automatically
cy.get('.NotebookEditor').type('the second')
cy.get('.NotebookEditor').type('{enter}')
cy.get('ol').should('contain.text', 'the first')
cy.get('ol').should('contain.text', 'the second')
// the numbered list auto inserts the next list item
cy.get('.NotebookEditor ol li').should('have.length', 3)
})

it('Can add bold', () => {
cy.get('.NotebookEditor').type('**bold**')
cy.get('.NotebookEditor p').last().should('contain.html', '<strong>bold</strong>')
})

it('Can add bullet list', () => {
cy.get('.NotebookEditor').type('* the first{enter}the second{enter}')
cy.get('ul').should('contain.text', 'the first')
cy.get('ul').should('contain.text', 'the second')
// the list auto inserts the next list item
cy.get('.NotebookEditor ul li').should('have.length', 3)
})
})
})
3 changes: 3 additions & 0 deletions docker-compose.hobby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ services:
extends:
file: docker-compose.base.yml
service: db
# Pin to postgres 12 until we have a process for pg_upgrade to postgres 15 for exsisting installations
image: ${DOCKER_REGISTRY_PREFIX:-}postgres:12-alpine
volumes:
- postgres-data:/var/lib/postgresql/data

redis:
extends:
file: docker-compose.base.yml
Expand Down
4 changes: 2 additions & 2 deletions ee/api/test/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
from typing import Dict, Optional, cast

import pytz
from zoneinfo import ZoneInfo

from ee.api.test.fixtures.available_product_features import AVAILABLE_PRODUCT_FEATURES
from ee.models.license import License, LicenseManager
Expand Down Expand Up @@ -30,7 +30,7 @@ def setUpTestData(cls):
cls.license = super(LicenseManager, cast(LicenseManager, License.objects)).create(
key=cls.CONFIG_LICENSE_KEY,
plan=cls.CONFIG_LICENSE_PLAN,
valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7, tzinfo=pytz.UTC),
valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7, tzinfo=ZoneInfo("UTC")),
)
if hasattr(cls, "organization") and cls.organization: # type: ignore
cls.organization.available_product_features = AVAILABLE_PRODUCT_FEATURES # type: ignore
Expand Down
8 changes: 4 additions & 4 deletions ee/api/test/test_billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from uuid import uuid4

import jwt
import pytz
from zoneinfo import ZoneInfo
from dateutil.relativedelta import relativedelta
from django.utils.timezone import now
from freezegun import freeze_time
Expand Down Expand Up @@ -377,13 +377,13 @@ def test_license_is_updated_on_billing_load(self, mock_request):
self.client.get("/api/billing-v2")
self.license.refresh_from_db()

self.license.valid_until = datetime(2022, 1, 2, 0, 0, 0, tzinfo=pytz.UTC)
self.license.valid_until = datetime(2022, 1, 2, 0, 0, 0, tzinfo=ZoneInfo("UTC"))
self.license.save()
assert self.license.plan == "scale"
TEST_clear_instance_license_cache()
license = get_cached_instance_license()
assert license.plan == "scale"
assert license.valid_until == datetime(2022, 1, 2, 0, 0, 0, tzinfo=pytz.UTC)
assert license.valid_until == datetime(2022, 1, 2, 0, 0, 0, tzinfo=ZoneInfo("UTC"))

mock_request.return_value.json.return_value = {
"license": {
Expand All @@ -396,7 +396,7 @@ def test_license_is_updated_on_billing_load(self, mock_request):
license = get_cached_instance_license()
assert license.plan == "enterprise"
# Should be extended by 30 days
assert license.valid_until == datetime(2022, 1, 31, 12, 0, 0, tzinfo=pytz.UTC)
assert license.valid_until == datetime(2022, 1, 31, 12, 0, 0, tzinfo=ZoneInfo("UTC"))

@patch("ee.api.billing.requests.get")
def test_organization_available_features_updated_if_different(self, mock_request):
Expand Down
4 changes: 2 additions & 2 deletions ee/api/test/test_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from unittest.mock import Mock, patch

import pytest
import pytz
from zoneinfo import ZoneInfo
from dateutil.relativedelta import relativedelta
from django.utils import timezone
from django.utils.timezone import now
Expand All @@ -27,7 +27,7 @@ def test_can_list_and_retrieve_licenses(self):
self.assertEqual(response_data["results"][0]["key"], "12345::67890")
self.assertEqual(
response_data["results"][0]["valid_until"],
timezone.datetime(2038, 1, 19, 3, 14, 7, tzinfo=pytz.UTC).isoformat().replace("+00:00", "Z"),
timezone.datetime(2038, 1, 19, 3, 14, 7, tzinfo=ZoneInfo("UTC")).isoformat().replace("+00:00", "Z"),
)

retrieve_response = self.client.get(f"/api/license/{response_data['results'][0]['id']}")
Expand Down
20 changes: 10 additions & 10 deletions ee/clickhouse/models/test/__snapshots__/test_cohort.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
(SELECT pdi.person_id AS person_id,
countIf(timestamp > now() - INTERVAL 2 year
AND timestamp < now()
AND event = '$pageview') > 0 AS performed_event_condition_15_level_level_0_level_0_level_0_0
AND event = '$pageview') > 0 AS performed_event_condition_17_level_level_0_level_0_level_0_0
FROM events e
INNER JOIN
(SELECT distinct_id,
Expand Down Expand Up @@ -113,7 +113,7 @@
HAVING max(is_deleted) = 0
AND (((((NOT has(['something1'], replaceRegexpAll(JSONExtractRaw(argMax(person.properties, version), '$some_prop'), '^"|"$', ''))))))))) person ON person.person_id = behavior_query.person_id
WHERE 1 = 1
AND ((((performed_event_condition_15_level_level_0_level_0_level_0_0)))) ) as person
AND ((((performed_event_condition_17_level_level_0_level_0_level_0_0)))) ) as person
UNION ALL
SELECT person_id,
cohort_id,
Expand Down Expand Up @@ -148,7 +148,7 @@
(SELECT pdi.person_id AS person_id,
countIf(timestamp > now() - INTERVAL 2 year
AND timestamp < now()
AND event = '$pageview') > 0 AS performed_event_condition_17_level_level_0_level_0_level_0_0
AND event = '$pageview') > 0 AS performed_event_condition_19_level_level_0_level_0_level_0_0
FROM events e
INNER JOIN
(SELECT distinct_id,
Expand Down Expand Up @@ -178,7 +178,7 @@
HAVING max(is_deleted) = 0
AND (((((NOT has(['something1'], replaceRegexpAll(JSONExtractRaw(argMax(person.properties, version), '$some_prop'), '^"|"$', ''))))))))) person ON person.person_id = behavior_query.person_id
WHERE 1 = 1
AND ((((performed_event_condition_17_level_level_0_level_0_level_0_0)))) ) ))
AND ((((performed_event_condition_19_level_level_0_level_0_level_0_0)))) ) ))
'
---
# name: TestCohort.test_cohortpeople_with_not_in_cohort_operator_for_behavioural_cohorts
Expand All @@ -195,7 +195,7 @@
FROM
(SELECT pdi.person_id AS person_id,
minIf(timestamp, event = 'signup') >= now() - INTERVAL 15 day
AND minIf(timestamp, event = 'signup') < now() as first_time_condition_18_level_level_0_level_0_0
AND minIf(timestamp, event = 'signup') < now() as first_time_condition_20_level_level_0_level_0_0
FROM events e
INNER JOIN
(SELECT distinct_id,
Expand All @@ -208,7 +208,7 @@
AND event IN ['signup']
GROUP BY person_id) behavior_query
WHERE 1 = 1
AND (((first_time_condition_18_level_level_0_level_0_0))) ) as person
AND (((first_time_condition_20_level_level_0_level_0_0))) ) as person
UNION ALL
SELECT person_id,
cohort_id,
Expand Down Expand Up @@ -237,9 +237,9 @@
(SELECT pdi.person_id AS person_id,
countIf(timestamp > now() - INTERVAL 2 year
AND timestamp < now()
AND event = '$pageview') > 0 AS performed_event_condition_19_level_level_0_level_0_level_0_0,
AND event = '$pageview') > 0 AS performed_event_condition_21_level_level_0_level_0_level_0_0,
minIf(timestamp, event = 'signup') >= now() - INTERVAL 15 day
AND minIf(timestamp, event = 'signup') < now() as first_time_condition_19_level_level_0_level_1_level_0_level_0_level_0_0
AND minIf(timestamp, event = 'signup') < now() as first_time_condition_21_level_level_0_level_1_level_0_level_0_level_0_0
FROM events e
INNER JOIN
(SELECT distinct_id,
Expand All @@ -252,8 +252,8 @@
AND event IN ['$pageview', 'signup']
GROUP BY person_id) behavior_query
WHERE 1 = 1
AND ((((performed_event_condition_19_level_level_0_level_0_level_0_0))
AND ((((NOT first_time_condition_19_level_level_0_level_1_level_0_level_0_level_0_0)))))) ) as person
AND ((((performed_event_condition_21_level_level_0_level_0_level_0_0))
AND ((((NOT first_time_condition_21_level_level_0_level_1_level_0_level_0_level_0_0)))))) ) as person
UNION ALL
SELECT person_id,
cohort_id,
Expand Down
2 changes: 1 addition & 1 deletion ee/clickhouse/models/test/__snapshots__/test_property.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
))
',
<class 'dict'> {
'global_cohort_id_0': 47,
'global_cohort_id_0': 1,
'global_version_0': None,
},
)
Expand Down
Loading

0 comments on commit e403885

Please sign in to comment.