Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
publish_test: complete TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
molon committed Jun 3, 2024
1 parent 0468290 commit 7d03ee2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func flowDuplicate(t *testing.T, f *FlowDuplicate) {
require.NoError(t, f.db.Where("id = ? AND version = ?", nid, nver).First(&m).Error)

// for compare, change from to as expected
// TODO: maybe need handle multiple pkey ?
from.Model = gorm.Model{}
from.Status = publish.Status{Status: publish.StatusDraft}
from.Schedule = publish.Schedule{}
Expand Down
30 changes: 10 additions & 20 deletions docsrc/examples/examples_admin/publish_test/flow_publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"net/http"
"net/http/httptest"
"testing"
"time"

"github.com/qor5/admin/v3/utils/testflow"
"github.com/qor5/docs/v3/docsrc/examples/examples_admin"
Expand Down Expand Up @@ -72,45 +71,36 @@ func flowPublish(t *testing.T, f *FlowPublish) {
flowPublish_Step00_Event_presets_DetailingDrawer(t, f).ThenValidate(ensureVersionBarDisplay(true, false, true))

// Execute publish and ensure data is modified, internally ensures Reload
previous := time.Now()
flowPublish_Step01_Event_publish_EventPublish(t, f)
{
previous := f.db.NowFunc()
assertAfterPublish := func() {
var m examples_admin.WithPublishProduct
require.NoError(t, db.First(&m).Error)
assert.True(t, m.ActualStartAt.After(previous))
assert.True(t, m.ActualEndAt == nil)
// TODO: What about changes to the schedule data?

assert.True(t, m.ScheduledStartAt == nil)
prev = m
}
flowPublish_Step01_Event_publish_EventPublish(t, f)
assertAfterPublish()

// Open the drawer and confirm the display of online status
flowPublish_Step02_Event_presets_DetailingDrawer(t, f).ThenValidate(ensureVersionBarDisplay(false, true, true))

previous = time.Now()
previous = f.db.NowFunc()
flowPublish_Step03_Event_publish_EventRepublish(t, f)
{
// TODO: The logic here can be reused to some extent from the previous step
var m examples_admin.WithPublishProduct
require.NoError(t, db.First(&m).Error)
assert.True(t, m.ActualStartAt.After(previous))
assert.True(t, m.ActualEndAt == nil)
// TODO: What about changes to the schedule data?

prev = m
}
assertAfterPublish()

// Open the drawer and confirm the display after republishing
flowPublish_Step04_Event_presets_DetailingDrawer(t, f).ThenValidate(ensureVersionBarDisplay(false, true, true))

previous = time.Now()
previous = f.db.NowFunc()
flowPublish_Step05_Event_publish_EventUnpublish(t, f)
{
var m examples_admin.WithPublishProduct
require.NoError(t, db.First(&m).Error)
assert.True(t, m.ActualEndAt.After(previous))
// TODO: What about changes to the schedule data?

assert.True(t, m.ScheduledStartAt == nil)
assert.True(t, m.ScheduledEndAt == nil)
prev = m
}

Expand Down

0 comments on commit 7d03ee2

Please sign in to comment.