Skip to content

Commit

Permalink
fix: :team_id isn't the path any more
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Nov 8, 2023
1 parent f808085 commit 7d46594
Show file tree
Hide file tree
Showing 36 changed files with 121 additions and 121 deletions.
2 changes: 1 addition & 1 deletion frontend/src/exporter/Exporter.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TrendsLineInsight.args = { insight: require('../mocks/fixtures/api/projects/team

export const TrendsLineMultiInsight: Story = Template.bind({})
TrendsLineMultiInsight.args = {
insight: require('../mocks/fixtures/api/projects/:team_id/insights/trendsLineMulti.json'),
insight: require('../mocks/fixtures/api/projects/team_id/insights/trendsLineMulti.json'),
}
TrendsLineMultiInsight.parameters = {
mockDate: '2023-07-10',
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/layout/navigation-3000/Navigation.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ const meta: Meta = {
decorators: [
mswDecorator({
get: {
'/api/projects/:team_id/dashboards/': require('../../scenes/dashboard/__mocks__/dashboards.json'),
'/api/projects/:team_id/dashboards/1/': require('../../scenes/dashboard/__mocks__/dashboard1.json'),
'/api/projects/:team_id/dashboards/1/collaborators/': [],
'/api/projects/:team_id/insights/my_last_viewed/': require('../../scenes/saved-insights/__mocks__/insightsMyLastViewed.json'),
'/api/projects/:team_id/session_recordings/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/team_id/dashboards/': require('../../scenes/dashboard/__mocks__/dashboards.json'),
'/api/projects/team_id/dashboards/1/': require('../../scenes/dashboard/__mocks__/dashboard1.json'),
'/api/projects/team_id/dashboards/1/collaborators/': [],
'/api/projects/team_id/insights/my_last_viewed/': require('../../scenes/saved-insights/__mocks__/insightsMyLastViewed.json'),
'/api/projects/team_id/session_recordings/': EMPTY_PAGINATED_RESPONSE,
},
}),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const multipliedFeatureFlagsJson = {
export function Dashboards(): JSX.Element {
useStorybookMocks({
get: {
'/api/projects/:team_id/dashboards/': dashboardsJson,
'/api/projects/team_id/dashboards/': dashboardsJson,
},
})
const { showSidebar } = useActions(navigation3000Logic)
Expand All @@ -54,7 +54,7 @@ export function Dashboards(): JSX.Element {
export function FeatureFlags(): JSX.Element {
useStorybookMocks({
get: {
'/api/projects/:team_id/feature_flags/': multipliedFeatureFlagsJson,
'/api/projects/team_id/feature_flags/': multipliedFeatureFlagsJson,
},
})
const { showSidebar } = useActions(navigation3000Logic)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ function useInsightMocks(interval: string = 'day', timezone: string = 'UTC'): vo
}
useMocks({
get: {
'/api/projects/:team_id/insights/': () => {
'/api/projects/team_id/insights/': () => {
return [
200,
{
results: [insight],
},
]
},
[`/api/projects/:team_id/insights/${MOCK_INSIGHT_NUMERIC_ID}`]: () => {
[`/api/projects/team_id/insights/${MOCK_INSIGHT_NUMERIC_ID}`]: () => {
return [200, insight]
},
},
Expand All @@ -148,7 +148,7 @@ function useInsightMocks(interval: string = 'day', timezone: string = 'UTC'): vo
function useAnnotationsMocks(): void {
useMocks({
get: {
'/api/projects/:team_id/annotations/': {
'/api/projects/team_id/annotations/': {
results: [
MOCK_ANNOTATION_ORG_SCOPED,
MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const meta: Meta = {
mswDecorator({
get: {
'/api/projects/:team_id': { id: 2 },
'/api/projects/:team_id/event_definitions': {
'/api/projects/team_id/event_definitions': {
count: eventDefinitions.length,
next: null,
previous: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const meta: Meta<typeof PersonPropertySelect> = {
decorators: [
mswDecorator({
get: {
'/api/projects/:team_id/persons/properties': [
'/api/projects/team_id/persons/properties': [
{ name: 'Property A', count: 10 },
{ name: 'Property B', count: 20 },
{ name: 'Property C', count: 30 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { mockActionDefinition } from '~/test/mocks'

export const taxonomicFilterMocksDecorator = mswDecorator({
get: {
'/api/projects/:team_id/actions': { results: [mockActionDefinition] },
'/api/projects/:team_id/persons/properties': [
'/api/projects/team_id/actions': { results: [mockActionDefinition] },
'/api/projects/team_id/persons/properties': [
{ id: 1, name: 'location', count: 1 },
{ id: 2, name: 'role', count: 2 },
{ id: 3, name: 'height', count: 3 },
{ id: 4, name: '$browser', count: 4 },
],
'/api/projects/:team_id/property_definitions': [
'/api/projects/team_id/property_definitions': [
{
name: 'file_count',
count: 205,
Expand All @@ -36,7 +36,7 @@ export const taxonomicFilterMocksDecorator = mswDecorator({
count: 205,
},
],
'/api/projects/:team_id/event_definitions': [
'/api/projects/team_id/event_definitions': [
{
id: 'a',
name: 'signed up',
Expand All @@ -57,7 +57,7 @@ export const taxonomicFilterMocksDecorator = mswDecorator({
count: 103,
},
],
'/api/projects/:team_id/cohorts/': [
'/api/projects/team_id/cohorts/': [
{
id: 1,
name: 'Properties Cohort',
Expand Down
36 changes: 18 additions & 18 deletions frontend/src/mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@ export const toPaginatedResponse = (results: any[]): typeof EMPTY_PAGINATED_RESP

export const defaultMocks: Mocks = {
get: {
'/api/projects/:team_id/activity_log/important_changes/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/:team_id/actions/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/:team_id/annotations/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/:team_id/event_definitions/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/:team_id/cohorts/': toPaginatedResponse([MOCK_DEFAULT_COHORT]),
'/api/projects/:team_id/dashboards/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/team_id/activity_log/important_changes/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/team_id/actions/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/team_id/annotations/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/team_id/event_definitions/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/team_id/cohorts/': toPaginatedResponse([MOCK_DEFAULT_COHORT]),
'/api/projects/team_id/dashboards/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/@current/dashboard_templates/repository/': [],
'/api/projects/:team_id/groups/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/:team_id/groups_types/': [],
'/api/projects/:team_id/insights/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/:team_id/insights/:insight_id/sharing/': {
'/api/projects/team_id/groups/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/team_id/groups_types/': [],
'/api/projects/team_id/insights/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/team_id/insights/:insight_id/sharing/': {
enabled: false,
access_token: 'foo',
created_at: '2020-11-11T00:00:00Z',
} as SharingConfigurationType,
'/api/projects/:team_id/property_definitions/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/:team_id/feature_flags/': EMPTY_PAGINATED_RESPONSE,
'api/projects/:team_id/feature_flags/:feature_flag_id/role_access': EMPTY_PAGINATED_RESPONSE,
'/api/projects/:team_id/experiments/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/:team_id/explicit_members/': [],
'/api/projects/team_id/property_definitions/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/team_id/feature_flags/': EMPTY_PAGINATED_RESPONSE,
'api/projects/team_id/feature_flags/:feature_flag_id/role_access': EMPTY_PAGINATED_RESPONSE,
'/api/projects/team_id/experiments/': EMPTY_PAGINATED_RESPONSE,
'/api/projects/team_id/explicit_members/': [],
'/api/organizations/@current/': (): MockSignature => [
200,
{ ...MOCK_DEFAULT_ORGANIZATION, available_features: getAvailableFeatures() },
Expand All @@ -61,8 +61,8 @@ export const defaultMocks: Mocks = {
'/api/plugin_config/': toPaginatedResponse([MOCK_DEFAULT_PLUGIN_CONFIG]),
[`/api/projects/${MOCK_TEAM_ID}/plugin_configs/${MOCK_DEFAULT_PLUGIN_CONFIG.id}/`]: MOCK_DEFAULT_PLUGIN_CONFIG,
'/api/projects/@current/persons/properties/': toPaginatedResponse(MOCK_PERSON_PROPERTIES),
'/api/projects/:team_id/persons': EMPTY_PAGINATED_RESPONSE,
'/api/projects/:team_id/persons/properties/': toPaginatedResponse(MOCK_PERSON_PROPERTIES),
'/api/projects/team_id/persons': EMPTY_PAGINATED_RESPONSE,
'/api/projects/team_id/persons/properties/': toPaginatedResponse(MOCK_PERSON_PROPERTIES),
'/api/personal_api_keys/': [],
'/api/users/@me/': (): MockSignature => [
200,
Expand Down Expand Up @@ -94,7 +94,7 @@ export const defaultMocks: Mocks = {
'https://app.posthog.com/decide/': (): MockSignature => [200, 'ok'],
'/decide/': (): MockSignature => [200, 'ok'],
'https://app.posthog.com/engage/': (): MockSignature => [200, 'ok'],
'/api/projects/:team_id/insights/:insight_id/viewed/': (): MockSignature => [201, null],
'/api/projects/team_id/insights/:insight_id/viewed/': (): MockSignature => [201, null],
},
patch: {
'/api/prompts/my_prompts': (): MockSignature => [200, {}],
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/models/dashboardsModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('the dashboards model', () => {
beforeEach(async () => {
useMocks({
get: {
'/api/projects/:team_id/dashboards/': () => {
'/api/projects/team_id/dashboards/': () => {
return [
200,
{
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/models/propertyDefinitionsModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('the property definitions model', () => {
beforeEach(async () => {
useMocks({
get: {
'/api/projects/:team_id/property_definitions/': (req) => {
'/api/projects/team_id/property_definitions/': (req) => {
const propertiesToFind = (req.url.searchParams.get('properties') || '').split(',')
if (propertiesToFind[0] === 'network error') {
return
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/queries/nodes/DataNode/DataNode.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const meta: Meta<typeof Query> = {
decorators: [
mswDecorator({
get: {
'/api/projects/:team_id/events': events,
'/api/projects/:team_id/persons': persons,
'/api/projects/team_id/events': events,
'/api/projects/team_id/persons': persons,
},
}),
],
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/queries/nodes/DataTable/DataTable.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const meta: Meta<typeof Query> = {
decorators: [
mswDecorator({
get: {
'/api/projects/:team_id/events': events,
'/api/projects/:team_id/persons': persons,
'/api/projects/team_id/events': events,
'/api/projects/team_id/persons': persons,
},
}),
],
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/scenes/annotations/Annotations.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const meta: Meta = {
decorators: [
mswDecorator({
get: {
'/api/projects/:team_id/annotations/': annotations,
'/api/projects/:team_id/annotations/:annotationId/': (req) => [
'/api/projects/team_id/annotations/': annotations,
'/api/projects/team_id/annotations/:annotationId/': (req) => [
200,
annotations.results.find((r) => r.id === Number(req.params['annotationId'])),
],
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/apps/AppMetricsScene.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const meta: Meta = {
decorators: [
mswDecorator({
get: {
'/api/projects/:team_id/app_metrics/:plugin_config_id/': {
'/api/projects/team_id/app_metrics/:plugin_config_id/': {
metrics: {
dates: [
'2023-01-10',
Expand Down
16 changes: 8 additions & 8 deletions frontend/src/scenes/batch_exports/__mocks__/api-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ export const createExportServiceHandlers = (
): { exports: { [id: number]: BatchExportConfiguration }; handlers: any } => {
const handlers = {
get: {
'/api/projects/:team_id/groups_types/': [],
'/api/projects/:team_id/batch_exports/': (_req: any, res: any, ctx: any) => {
'/api/projects/team_id/groups_types/': [],
'/api/projects/team_id/batch_exports/': (_req: any, res: any, ctx: any) => {
return res(
ctx.delay(1000),
ctx.json({
results: Object.values(exports),
} as CountedPaginatedResponse<BatchExportConfiguration>)
)
},
'/api/projects/:team_id/batch_exports/:export_id': (req: any, res: any, ctx: any) => {
'/api/projects/team_id/batch_exports/:export_id': (req: any, res: any, ctx: any) => {
const id = req.params.export_id as string
return res(ctx.delay(1000), ctx.json(exports[id]))
},
'/api/projects/:team_id/batch_exports/:export_id/runs': (req: any, res: any, ctx: any) => {
'/api/projects/team_id/batch_exports/:export_id/runs': (req: any, res: any, ctx: any) => {
const id = req.params.export_id as string
return res(
ctx.delay(1000),
Expand All @@ -30,7 +30,7 @@ export const createExportServiceHandlers = (
},
},
post: {
'/api/projects/:team_id/batch_exports/': (req: any, res: any, ctx: any) => {
'/api/projects/team_id/batch_exports/': (req: any, res: any, ctx: any) => {
const body = req.body as BatchExportConfiguration
const id = (Object.keys(exports).length + 1).toString()
exports[id] = {
Expand All @@ -44,19 +44,19 @@ export const createExportServiceHandlers = (
}
return res(ctx.delay(1000), ctx.json(exports[id]))
},
'/api/projects/:team_id/batch_exports/:export_id/pause/': (req: any, res: any, ctx: any) => {
'/api/projects/team_id/batch_exports/:export_id/pause/': (req: any, res: any, ctx: any) => {
const id = req.params.export_id as string
exports[id].paused = true
return res(ctx.delay(1000), ctx.json(exports[id]))
},
'/api/projects/:team_id/batch_exports/:export_id/unpause/': (req: any, res: any, ctx: any) => {
'/api/projects/team_id/batch_exports/:export_id/unpause/': (req: any, res: any, ctx: any) => {
const id = req.params.export_id as string
exports[id].paused = false
return res(ctx.delay(1000), ctx.json(exports[id]))
},
},
delete: {
'/api/projects/:team_id/batch_exports/:export_id': (req: any, res: any, ctx: any) => {
'/api/projects/team_id/batch_exports/:export_id': (req: any, res: any, ctx: any) => {
const id = req.params.export_id as string
delete exports[id]
return res(ctx.delay(1000))
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/scenes/dashboard/Dashboards.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const meta: Meta = {
decorators: [
mswDecorator({
get: {
'/api/projects/:team_id/dashboards/': require('./__mocks__/dashboards.json'),
'/api/projects/:team_id/dashboards/1/': require('./__mocks__/dashboard1.json'),
'/api/projects/:team_id/dashboards/1/collaborators/': [],
'/api/projects/:team_id/dashboard_templates/': require('./__mocks__/dashboard_templates.json'),
'/api/projects/:team_id/dashboard_templates/json_schema/': require('./__mocks__/dashboard_template_schema.json'),
'/api/projects/:team_id/dashboards/:dash_id/sharing/': {
'/api/projects/team_id/dashboards/': require('./__mocks__/dashboards.json'),
'/api/projects/team_id/dashboards/1/': require('./__mocks__/dashboard1.json'),
'/api/projects/team_id/dashboards/1/collaborators/': [],
'/api/projects/team_id/dashboard_templates/': require('./__mocks__/dashboard_templates.json'),
'/api/projects/team_id/dashboard_templates/json_schema/': require('./__mocks__/dashboard_template_schema.json'),
'/api/projects/team_id/dashboards/:dash_id/sharing/': {
created_at: '2023-02-25T13:28:20.454940Z',
enabled: false,
access_token: 'a-secret-token',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ const meta: Meta = {
decorators: [
mswDecorator({
get: {
'/api/projects/:team_id/ingestion_warnings/': () => {
'/api/projects/team_id/ingestion_warnings/': () => {
return [200, ingestionWarningsResponse(dayjs('2023-02-15T16:00:00.000Z'))]
},
},
post: {
'/api/projects/:team_id/query/': (req) => {
'/api/projects/team_id/query/': (req) => {
if ((req.body as any).query.kind === 'DatabaseSchemaQuery') {
return [200, MOCK_DATABASE]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,19 @@ const meta: Meta = {
decorators: [
mswDecorator({
get: {
'/api/projects/:team_id/early-access-feature': {
'/api/projects/team_id/early-access-feature': {
count: 2,
results: EARLY_ACCESS_FEATURE_RESULT as any[],
next: null,
previous: null,
},
'/api/projects/:team_id/early-access-feature/not-found/': [
'/api/projects/team_id/early-access-feature/not-found/': [
404,
{
detail: 'Not found.',
},
],
'/api/projects/:team_id/early-access-feature/:flagId/':
'/api/projects/team_id/early-access-feature/:flagId/':
EARLY_ACCESS_FEATURE_RESULT[0] as EarlyAccessFeatureType,
},
}),
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/events/Events.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const meta: Meta = {
decorators: [
mswDecorator({
post: {
'/api/projects/:team_id/query': eventsQuery,
'/api/projects/team_id/query': eventsQuery,
},
}),
],
Expand Down
Loading

0 comments on commit 7d46594

Please sign in to comment.