Skip to content

Commit

Permalink
chore(deps): Upgrade to Django 5 (#23626)
Browse files Browse the repository at this point in the history
  • Loading branch information
webjunkie authored Aug 29, 2024
1 parent 5f5ef51 commit 9418235
Show file tree
Hide file tree
Showing 60 changed files with 375 additions and 667 deletions.
6 changes: 3 additions & 3 deletions cypress/e2e/auth-password-reset.cy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { auth } from '../support'

const VALID_PASSWORD = 'hedgE-hog-123%'

describe('Password Reset', () => {
beforeEach(() => {
cy.get('[data-attr=menu-item-me]').click()
cy.get('[data-attr=top-menu-item-logout]').click()
cy.location('pathname').should('eq', '/login')
auth.logout()
})

it('Can request password reset', () => {
Expand Down
32 changes: 8 additions & 24 deletions cypress/e2e/auth.cy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
describe('Auth', () => {
beforeEach(() => {
cy.get('[data-attr=menu-item-me]').click()
})
import { auth } from '../support'

describe('Auth', () => {
it('Logout', () => {
cy.get('[data-attr=top-menu-item-logout]').click()
cy.location('pathname').should('eq', '/login')
auth.logout()
})

it('Logout and login', () => {
cy.get('[data-attr=top-menu-item-logout]').click()
auth.logout()

cy.get('[data-attr=login-email]').type('[email protected]').should('have.value', '[email protected]').blur()
cy.get('[data-attr=password]', { timeout: 5000 }).should('be.visible') // Wait for login precheck (note blur above)
Expand All @@ -22,7 +19,7 @@ describe('Auth', () => {
})

it('Logout and verify that Google login button has correct link', () => {
cy.get('[data-attr=top-menu-item-logout]').click()
auth.logout()

cy.window().then((win) => {
win.POSTHOG_APP_CONTEXT.preflight.available_social_auth_providers = {
Expand All @@ -34,7 +31,7 @@ describe('Auth', () => {
})

it('Try logging in improperly and then properly', () => {
cy.get('[data-attr=top-menu-item-logout]').click()
auth.logout()

cy.get('[data-attr=login-email]').type('[email protected]').should('have.value', '[email protected]').blur()
cy.get('[data-attr=password]', { timeout: 5000 }).should('be.visible') // Wait for login precheck (note blur above)
Expand All @@ -50,8 +47,7 @@ describe('Auth', () => {
})

it('Redirect to appropriate place after login', () => {
cy.visit('/logout')
cy.location('pathname').should('include', '/login')
auth.logout()

cy.visit('/activity/explore')
cy.location('pathname').should('include', '/login') // Should be redirected to login because we're now logged out
Expand All @@ -65,8 +61,7 @@ describe('Auth', () => {
})

it('Redirect to appropriate place after login with complex URL', () => {
cy.visit('/logout')
cy.location('pathname').should('include', '/login')
auth.logout()

cy.visit('/insights?search=testString')
cy.location('pathname').should('include', '/login') // Should be redirected to login because we're now logged out
Expand All @@ -84,15 +79,4 @@ describe('Auth', () => {
cy.visit('/signup')
cy.location('pathname').should('eq', '/project/1')
})

it('Logout in another tab results in logout in the current tab too', () => {
cy.window().then(async (win) => {
// Hit /logout *in the background* by using fetch()
await win.fetch('/logout')
})

cy.clickNavMenu('dashboards') // This should cause logout bacause of new data fetching being initiated

cy.location('pathname').should('eq', '/login') // We should be quickly redirected to the login page
})
})
9 changes: 4 additions & 5 deletions cypress/e2e/auto-redirect.cy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { auth } from '../support'

describe('Redirect to other subdomain if logged in', () => {
beforeEach(() => {
cy.clearAllCookies()
})
it('Redirects to the EU instance', () => {
cy.visit('/logout')
auth.logout()

const redirect_path = '/test'

Expand All @@ -23,7 +22,7 @@ describe('Redirect to other subdomain if logged in', () => {
})

it('Redirects to the US instance', () => {
cy.visit('/logout')
auth.logout()

const redirect_path = '/test'

Expand Down
10 changes: 5 additions & 5 deletions cypress/e2e/invites.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { auth } from '../support'
import { randomString } from '../support/random'

const VALID_PASSWORD = 'hedgE-hog-123%'
Expand Down Expand Up @@ -47,8 +48,7 @@ describe('Invite Signup', () => {
headers: { Authorization: 'Bearer e2e_demo_api_key' },
}).then((response) => {
expect(response.status).to.eq(201)
cy.get('[data-attr=menu-item-me]').click()
cy.get('[data-attr=top-menu-item-logout]').click()
auth.logout()
cy.visit('/signup/' + response.body.id)
})
cy.get('.error-view-container').should('not.exist')
Expand Down Expand Up @@ -81,8 +81,7 @@ describe('Invite Signup', () => {
cy.get('[data-attr=invite-link]')
.last()
.then((element) => {
cy.get('[data-attr=menu-item-me]').click()
cy.get('[data-attr=top-menu-item-logout]').click()
auth.logout()
cy.visit(element.text())
})
cy.get('[data-attr="password"]').type(VALID_PASSWORD)
Expand All @@ -94,7 +93,8 @@ describe('Invite Signup', () => {
cy.location('pathname').should('include', 'verify_email')

// Log out, log in as main
cy.visit('/logout')
cy.clearAllCookies()
cy.visit('/login')
cy.login()

// Go to organization settings
Expand Down
8 changes: 5 additions & 3 deletions cypress/e2e/preflight.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { auth } from '../support'

const preflightSuccessResponse = {
django: true,
redis: true,
Expand All @@ -22,7 +24,7 @@ describe('Preflight', () => {
it('Preflight experimentation', () => {
cy.intercept('GET', '/_preflight', preflightSuccessResponse)

cy.visit('/logout')
auth.logout()
cy.visit('/preflight')

cy.get('[data-attr=preflight-experimentation]').click()
Expand All @@ -37,7 +39,7 @@ describe('Preflight', () => {
it('Preflight live mode', () => {
cy.intercept('GET', '/_preflight', preflightSuccessResponse)

cy.visit('/logout')
auth.logout()
cy.visit('/preflight')

cy.get('[data-attr=preflight-live]').click()
Expand All @@ -53,7 +55,7 @@ describe('Preflight', () => {
it('Preflight can have errors too', () => {
cy.intercept('GET', '/_preflight', { ...preflightSuccessResponse, celery: false })

cy.visit('/logout')
auth.logout()
cy.visit('/preflight')

cy.get('[data-attr=preflight-live]').click()
Expand Down
11 changes: 4 additions & 7 deletions cypress/e2e/signup.cy.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { decideResponse } from '../fixtures/api/decide'
import { auth } from '../support'

const VALID_PASSWORD = 'hedgE-hog-123%'

describe('Signup', () => {
beforeEach(() => {
cy.get('[data-attr=menu-item-me]').click()
cy.get('[data-attr=top-menu-item-logout]').click()
cy.location('pathname').should('include', '/login')
auth.logout()
cy.visit('/signup')
})

Expand Down Expand Up @@ -146,8 +145,7 @@ describe('Signup', () => {
// We can't actually test the social login feature.
// But, we can make sure the form exists as it should, and that upon submit
// we get the expected error that no social session exists.
cy.visit('/logout')
cy.location('pathname').should('include', '/login')
cy.clearAllCookies()
cy.visit('/organization/confirm-creation?organization_name=&first_name=Test&email=test%40posthog.com')

cy.get('[name=email]').should('have.value', '[email protected]')
Expand All @@ -170,8 +168,7 @@ describe('Signup', () => {
)
)

cy.visit('/logout')
cy.location('pathname').should('include', '/login')
cy.clearAllCookies()

cy.visit('/signup?maintenanceRedirect=true', {
onLoad(win: Cypress.AUTWindow) {
Expand Down
8 changes: 8 additions & 0 deletions cypress/productAnalytics/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { urls } from 'scenes/urls'

export const auth = {
logout: (): void => {
cy.get('[data-attr=menu-item-me]').click()
cy.get('[data-attr=top-menu-item-logout]').click()
cy.location('pathname').should('include', '/login')
},
}

export const savedInsights = {
checkInsightIsInListView: (insightName: string): void => {
cy.visit(urls.savedInsights())
Expand Down
8 changes: 7 additions & 1 deletion cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@ declare global {
}
}

export {}
export const auth = {
logout: (): void => {
cy.get('[data-attr=menu-item-me]').click()
cy.get('[data-attr=top-menu-item-logout]').click()
cy.location('pathname').should('include', '/login')
},
}
10 changes: 5 additions & 5 deletions ee/api/test/test_action.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
from typing import cast

import pytest
from django.utils import timezone
from rest_framework import status

from posthog.cloud_utils import is_cloud
Expand All @@ -19,7 +19,7 @@ def test_create_action_update_delete_tags(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
key="key_123",
plan="enterprise",
valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7),
valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7),
)

response = self.client.post(f"/api/projects/{self.team.id}/actions/", data={"name": "user signed up"})
Expand Down Expand Up @@ -47,7 +47,7 @@ def test_create_action_with_tags(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
key="key_123",
plan="enterprise",
valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7),
valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7),
)

response = self.client.post(
Expand All @@ -66,7 +66,7 @@ def test_actions_does_not_nplus1(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
key="key_123",
plan="enterprise",
valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7),
valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7),
)

# Ensure the cloud check is cached to not affect the number of queries
Expand All @@ -91,7 +91,7 @@ def test_actions_no_duplicate_tags(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
key="key_123",
plan="enterprise",
valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7),
valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7),
)
response = self.client.post(
f"/api/projects/{self.team.id}/actions/",
Expand Down
4 changes: 2 additions & 2 deletions ee/api/test/test_dashboard.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime
from typing import cast

from django.utils import timezone
from rest_framework import status

from ee.api.test.base import APILicensedTest
Expand Down Expand Up @@ -232,7 +232,7 @@ def test_dashboard_no_duplicate_tags(self):
super(LicenseManager, cast(LicenseManager, License.objects)).create(
key="key_123",
plan="enterprise",
valid_until=timezone.datetime(2038, 1, 19, 3, 14, 7),
valid_until=datetime.datetime(2038, 1, 19, 3, 14, 7),
)
dashboard = Dashboard.objects.create(team=self.team, name="Edit-restricted dashboard", created_by=self.user)

Expand Down
Loading

0 comments on commit 9418235

Please sign in to comment.