Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions writeopia_ui/config/ktlint/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,10 @@
<error line="148" column="1" source="standard:indent" />
</file>
<file name="src/commonTest/kotlin/io/writeopia/ui/utils/MapStoryData.kt">
<error line="189" column="1" source="standard:max-line-length" />
<error line="288" column="1" source="standard:max-line-length" />
<error line="303" column="1" source="standard:max-line-length" />
<error line="372" column="1" source="standard:max-line-length" />
<error line="197" column="1" source="standard:max-line-length" />
<error line="296" column="1" source="standard:max-line-length" />
<error line="311" column="1" source="standard:max-line-length" />
<error line="380" column="1" source="standard:max-line-length" />
</file>
<file name="src/jsMain/kotlin/io/writeopia/ui/draganddrop/target/DragCardTarget.js.kt">
<error line="76" column="13" source="standard:chain-wrapping" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ import io.writeopia.sdk.repository.StoriesRepository
import io.writeopia.sdk.repository.UserRepository
import io.writeopia.ui.model.TextInput
import io.writeopia.ui.utils.MapStoryData
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runTest
import kotlinx.datetime.Clock
import kotlin.test.*
import kotlin.test.Ignore
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNull
import kotlin.test.assertTrue
import kotlin.test.fail

@OptIn(ExperimentalCoroutinesApi::class)
class WriteopiaStateManagerTest {
Expand All @@ -37,6 +44,10 @@ class WriteopiaStateManagerTest {
override suspend fun history(): Map<Int, StoryStep> = MapStoryData.singleMessage()
}

private val singleMessageRepoLineBreak: StoriesRepository = object : StoriesRepository {
override suspend fun history(): Map<Int, StoryStep> = MapStoryData.singleMessageLineBreak()
}

private val complexMessagesRepository: StoriesRepository = object : StoriesRepository {
override suspend fun history(): Map<Int, StoryStep> = MapStoryData.syncHistory()
}
Expand Down Expand Up @@ -115,8 +126,6 @@ class WriteopiaStateManagerTest {
}

@Test
// Todo: Come back to this test later
@Ignore
fun whenNewTitleChangesItShouldChangeTheDocumentTitleChangesToo() = runTest {
val input = MapStoryData.singleCheckItem()

Expand All @@ -125,7 +134,7 @@ class WriteopiaStateManagerTest {
val storyManager =
WriteopiaStateManager.create(
writeopiaManager = WriteopiaManager(),
dispatcher = UnconfinedTestDispatcher(),
dispatcher = Dispatchers.Main,
userRepository = userRepository,
).apply {
loadDocument(
Expand Down Expand Up @@ -539,7 +548,6 @@ class WriteopiaStateManagerTest {
}

@Test
@Ignore // This should be fixed later
fun itShouldBePossibleToRevertMove() = runTest {
val now = Clock.System.now()

Expand Down Expand Up @@ -676,19 +684,18 @@ class WriteopiaStateManagerTest {
}

@Test
@Ignore
fun whenALineBreakHappensANewStoryUnitWithTheSameTypeShouldBeCreated_SimpleTest() =
runTest {
val now = Clock.System.now()

val storyManager = WriteopiaStateManager.create(
writeopiaManager = WriteopiaManager(),
dispatcher = UnconfinedTestDispatcher(testScheduler),
dispatcher = Dispatchers.Unconfined,
userRepository = userRepository,
)
storyManager.loadDocument(
Document(
content = singleMessageRepo.history(),
content = singleMessageRepoLineBreak.history(),
userId = "",
createdAt = now,
lastUpdatedAt = now,
Expand All @@ -711,7 +718,6 @@ class WriteopiaStateManagerTest {
}

@Test
@Ignore
fun whenALineBreakHappensANewStoryUnitWithTheSameTypeShouldBeCreated_ComplexTest() =
runTest {
val now = Clock.System.now()
Expand All @@ -723,7 +729,7 @@ class WriteopiaStateManagerTest {
)
storyManager.loadDocument(
Document(
content = messagesRepo.history(),
content = singleMessageRepoLineBreak.history(),
userId = "",
createdAt = now,
lastUpdatedAt = now,
Expand Down Expand Up @@ -840,7 +846,6 @@ class WriteopiaStateManagerTest {
}

@Test
@Ignore
fun itShouldBePossibleToAddContentAndUndoIt_OneUnit() {
val now = Clock.System.now()

Expand Down Expand Up @@ -872,7 +877,6 @@ class WriteopiaStateManagerTest {
}

@Test
@Ignore
fun itShouldBePossibleToAddContentAndUndoIt_ManyUnits() = runTest {
val now = Clock.System.now()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ object MapStoryData {
)
)

fun singleMessageLineBreak(): Map<Int, StoryStep> = mapOf(
0 to StoryStep(
localId = "0",
type = StoryTypes.TEXT.type,
text = "hi!\n",
)
)

fun messagesInLine(): Map<Int, StoryStep> = mapOf(
0 to StoryStep(
localId = "0",
Expand Down