[CLD-7567] Deprecate Self Serve: Second Pass (#26853)

* Deprecate Self Serve: First Pass

* Fix ci

* Fix more ci

* Remmove outdated server tests

* Fix a missed spot opening purchase modal in Self Hosted

* Fix i18n

* Clean up some more server code, fix webapp test

* Fix alignment of button

* Fix linter

* Fix i18n server side

* Deprecate in product true up

* Add back translation

* Remove client functions

* Put back client functions

* webapp deprecation

* Deprecate Self Serve: Second Pass

* Fix various pipeline issues

* Fix linter

* Fix pipelines

* Fix handlers_test.go

* Fix console.error around hostedCustomer in reducer

* PICKY LINTER PLEASE

* Fix webapp tests, various other fixes for the CI pipelines

* Fix i18n

* Updates to accomadate enterprise code removal

* Fix mocks

* More removal

* Fix

* Adjustments from PR

* Fixes for QA Feedback

* Update

* Add migrations to remove true up review history

* Fix migrations check

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: maria.nunez <maria.nunez@mattermost.com>
Этот коммит содержится в:
Nick Misasi
2024-05-02 09:15:15 -04:00
коммит произвёл GitHub
родитель 6028cbe4e2
Коммит f1019d076e
127 изменённых файлов: 169 добавлений и 8222 удалений

Просмотреть файл

@@ -1,82 +0,0 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package utils
import (
"time"
)
const trueUpReviewDueDay = 15
const day = time.Hour * 24
type DueDateWindow struct {
Start time.Time
End time.Time
}
func GetNextTrueUpReviewDueDate(now time.Time) time.Time {
nowYear := now.Year()
nowMonth := now.Month()
nowDay := now.Day()
finalQuarterYear := nowYear
if nowMonth >= time.October && nowMonth <= time.December {
finalQuarterYear = nowYear + 1
}
trueUpSubmissionWindows := []DueDateWindow{
{
Start: time.Date(now.Year(), time.January, 16, 0, 0, 0, 0, now.Location()),
End: time.Date(now.Year(), time.April, 15, 0, 0, 0, 0, now.Location()),
},
{
Start: time.Date(now.Year(), time.April, 16, 0, 0, 0, 0, now.Location()),
End: time.Date(now.Year(), time.July, 15, 0, 0, 0, 0, now.Location()),
},
{
Start: time.Date(now.Year(), time.July, 16, 0, 0, 0, 0, now.Location()),
End: time.Date(now.Year(), time.October, 15, 0, 0, 0, 0, now.Location()),
},
{
Start: time.Date(now.Year(), time.October, 16, 0, 0, 0, 0, now.Location()),
End: time.Date(finalQuarterYear, time.January, 15, 0, 0, 0, 0, now.Location()),
},
}
for _, window := range trueUpSubmissionWindows {
withinWindow := false
// Our due dates "wrap" around (i.e. can go into the next year), so we'll need to check the months different. Since January = 1 and December = 12, the checks
// for the current month being greater or equal to the start month and less than or equal to the end month will not work.
if window.End.Month() == time.January {
withinWindow = (nowMonth != time.January && nowMonth >= window.Start.Month()) || nowMonth == window.End.Month()
} else {
withinWindow = nowMonth >= window.Start.Month() && nowMonth <= window.End.Month()
}
// Only check the days if the current month is equal to the start or end months.
// The dates of the middle month(s) don't matter so much.
isFirstMonth := nowMonth == window.Start.Month()
if isFirstMonth {
withinWindow = withinWindow && nowDay >= window.Start.Day()
}
isFinalMonth := nowMonth == window.End.Month()
if isFinalMonth {
withinWindow = withinWindow && nowDay <= window.End.Day()
}
if withinWindow {
return window.End
}
}
return trueUpSubmissionWindows[0].End
}
func IsTrueUpReviewDueDateWithinTheNext30Days(now time.Time, dueDate time.Time) bool {
dueDateWindow := dueDate.Add(-day * 30)
if now.Before(dueDateWindow) || now.After(dueDate) {
return false
}
return true
}

Просмотреть файл

@@ -1,125 +0,0 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package utils
import (
"fmt"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestGetNextTrueUpReviewDueDate(t *testing.T) {
t.Run("Due date always falls on the 15th", func(t *testing.T) {
// Before the 15th
now := time.Date(2022, time.March, 14, 0, 0, 0, 0, time.Local)
due := GetNextTrueUpReviewDueDate(now)
assert.Equal(t, trueUpReviewDueDay, due.Day())
// On the 15th
now = time.Date(2022, time.December, 15, 0, 0, 0, 0, time.Local)
due = GetNextTrueUpReviewDueDate(now)
assert.Equal(t, trueUpReviewDueDay, due.Day())
// After the 15th
now = time.Date(2022, time.September, 16, 0, 0, 0, 0, time.Local)
due = GetNextTrueUpReviewDueDate(now)
assert.Equal(t, trueUpReviewDueDay, due.Day())
})
t.Run("Due date will always be in next quarter if the current date is past the 15th", func(t *testing.T) {
now := time.Date(2022, time.March, 16, 0, 0, 0, 0, time.Local)
due := GetNextTrueUpReviewDueDate(now)
assert.Equal(t, time.April, due.Month())
now = time.Date(2022, time.June, 16, 0, 0, 0, 0, time.Local)
due = GetNextTrueUpReviewDueDate(now)
assert.Equal(t, time.July, due.Month())
now = time.Date(2022, time.September, 16, 0, 0, 0, 0, time.Local)
due = GetNextTrueUpReviewDueDate(now)
assert.Equal(t, time.October, due.Month())
now = time.Date(2022, time.December, 16, 0, 0, 0, 0, time.Local)
due = GetNextTrueUpReviewDueDate(now)
assert.Equal(t, time.January, due.Month())
})
t.Run("Due date will always be in the current quarter if the current date is before or on the 15th", func(t *testing.T) {
now := time.Date(2022, time.April, 15, 0, 0, 0, 0, time.Local)
due := GetNextTrueUpReviewDueDate(now)
assert.Equal(t, time.April, due.Month())
now = time.Date(2022, time.July, 15, 0, 0, 0, 0, time.Local)
due = GetNextTrueUpReviewDueDate(now)
assert.Equal(t, time.July, due.Month())
now = time.Date(2022, time.October, 14, 0, 0, 0, 0, time.Local)
due = GetNextTrueUpReviewDueDate(now)
assert.Equal(t, time.October, due.Month())
now = time.Date(2022, time.January, 14, 0, 0, 0, 0, time.Local)
due = GetNextTrueUpReviewDueDate(now)
assert.Equal(t, time.January, due.Month())
})
t.Run("Due date will be in the next year if the next quarter is not within the current year", func(t *testing.T) {
now := time.Date(2022, time.October, 21, 0, 0, 0, 0, time.Local)
due := GetNextTrueUpReviewDueDate(now)
assert.Equal(t, time.January, due.Month())
assert.Equal(t, 2023, due.Year())
})
}
func TestIsTrueUpReviewDueDateWithinTheNext15Days(t *testing.T) {
t.Run("Ensure a date within 30 days before the due date returns true", func(t *testing.T) {
// 1 Day before the due date
now := time.Date(2022, time.March, 16, 0, 0, 0, 0, time.Local)
// Due date is December 15th, 2022
due := GetNextTrueUpReviewDueDate(now)
res := IsTrueUpReviewDueDateWithinTheNext30Days(now, due)
assert.True(t, res)
})
t.Run("Ensure a date that is more than two weeks before the due date returns false", func(t *testing.T) {
// 15 Days before the due date
now := time.Date(2022, time.October, 16, 0, 0, 0, 0, time.Local)
// Due date is December 15th, 2022
due := GetNextTrueUpReviewDueDate(now)
res := IsTrueUpReviewDueDateWithinTheNext30Days(now, due)
assert.False(t, res)
})
t.Run("Ensure a date that is past the due date returns false", func(t *testing.T) {
now := time.Date(2022, time.April, 15, 0, 0, 0, 0, time.Local)
// Due date is April 16th, 2022
dueNow := time.Date(2022, time.April, 16, 0, 0, 0, 0, time.Local)
due := GetNextTrueUpReviewDueDate(dueNow)
res := IsTrueUpReviewDueDateWithinTheNext30Days(now, due)
assert.False(t, res)
})
t.Run("Ensure a date that is on the due date returns true", func(t *testing.T) {
now := time.Date(2022, time.January, 15, 0, 0, 0, 0, time.Local)
due := GetNextTrueUpReviewDueDate(now)
fmt.Printf("\n\ndue date: %s\n\n", due.Format("2006-Jan-02"))
fmt.Printf("\n\nnow: %s\n\n", now.Format("2006-Jan-02"))
res := IsTrueUpReviewDueDateWithinTheNext30Days(now, due)
assert.True(t, res)
})
t.Run("Ensure a date that is on the first day of the due date window returns true", func(t *testing.T) {
now := time.Date(2022, time.December, 16, 0, 0, 0, 0, time.Local)
due := GetNextTrueUpReviewDueDate(now)
res := IsTrueUpReviewDueDateWithinTheNext30Days(now, due)
assert.True(t, res)
})
}