diff --git a/src/main/g8/apps/jvm/src/test/scala/apps/.gitignore b/src/main/g8/apps/jvm/src/test/scala/apps/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/main/g8/apps/jvm/src/test/scala/apps/WebappTest.scala b/src/main/g8/apps/jvm/src/test/scala/apps/WebappTest.scala deleted file mode 100644 index 04cedd33c02cc40ae335048fc14df4ffd44a3319..0000000000000000000000000000000000000000 --- a/src/main/g8/apps/jvm/src/test/scala/apps/WebappTest.scala +++ /dev/null @@ -1,79 +0,0 @@ -package apps.testUtils - -import java.net.URI -import java.net.http.HttpRequest -import scala.concurrent.duration.Duration -import scala.reflect.ClassTag -import cs214.webapp.* -import cs214.webapp.server.StateMachine - -/** Abstract test suite to help testing logic of Webapps */ -abstract class WebappTest[Event, State, View] extends munit.FunSuite: - - protected val UID0: String = "yak" - protected val UID1: String = "hut" - protected val UID2: String = "kik" - - /** Mock user IDs that can be used in tests */ - protected val USER_IDS = Seq(UID0, UID1, UID2) - - /** Your app logic */ - val sm: StateMachine[Event, State, View] - - override val munitTimeout: Duration = Duration(10, "s") - - /// Testing helpers - - extension [U](u: U) - /** Asserts that u is an instance of type V */ - inline def assertInstanceOf[V](using tag: ClassTag[V]): V = - assert(u.isInstanceOf[V], f"$u has unexpected type ${u.getClass} (expecting ${tag} instead)") - u.asInstanceOf[V] - - /** Asserts that this try is a success */ - def assertSuccess[V](ts: util.Try[V]): V = - assert(ts.isSuccess, f"Unexpected failure: $ts") - ts.get - - /** Asserts that actions contains a single action which is of type - * Action.Render. In case of success, returns this render action. - */ - def assertSingleRender[V](actions: Seq[Action[V]]): V = - assertEquals(actions.length, 1) - val r = actions.head.assertInstanceOf[Action.Render[V]] - r.st - - /** Asserts that ts is a success and contains a single action which is of type - * Action.Render. In case of success, returns this render action. - */ - def assertSingleRender[V](ts: util.Try[Seq[Action[V]]]): V = - assertSingleRender(assertSuccess(ts)) - - /** Asserts that ts is a success and contains more than one action. In case of - * success, returns these actions. - */ - def assertMultipleActions[K](ts: util.Try[Seq[Action[K]]], n: Int): Seq[Action[K]] = - val actions = assertSuccess(ts) - assertEquals(actions.length, n) - actions.map(_.asInstanceOf[Action[K]]) - - // [Any] is a trick to avoid using [?] - /** Asserts that ts is a failure and returns this failure. */ - inline def assertFailure[F <: Throwable](ts: util.Try[Seq[Action[Any]]])(using ClassTag[F]): F = - assert(ts.isFailure) - ts.failed.get.assertInstanceOf[F] - - /** Asserts that encoding then decoding t succeeds and doesn't modify t. In - * case of success, returns t. - */ - def testWire[T](w: WireFormat[T])(t: T): T = - val d = w.decode(w.encode(t)) - assert(d.isSuccess) - assertEquals(d.get, t) - t - - extension (v: View) - def testViewWire: View = testWire(sm.wire.viewFormat)(v) - - extension (e: Event) - def testEventWire: Event = testWire(sm.wire.eventFormat)(e) diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index 00d33aa5991b4b2c89b33f41873d05ba9de24d52..29d7a38233854ddc53e90c29fbc4ffdbe0cb0819 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -41,16 +41,16 @@ lazy val app = (crossProject(JVMPlatform, JSPlatform) in file("./apps")) // WEBAPP LIBRARY RESOLUTION //========= ==== == = -val webappLibRepo = "https://gitlab.epfl.ch/cs214/ul2024/webapp-lib.git#v0.1.0" +val webappLibRepo = "https://gitlab.epfl.ch/cs214/ul2024/webapp-lib.git#v0.3.0" -lazy val client: ClasspathDep[ProjectReference] = ProjectRef(uri(webappLibRepo), "client") +lazy val client: ProjectReference = ProjectRef(uri(webappLibRepo), "client") -lazy val server: ClasspathDep[ProjectReference] = ProjectRef(uri(webappLibRepo), "server") +lazy val server: ProjectReference = ProjectRef(uri(webappLibRepo), "server") //========= ==== == = lazy val appJS = app.js.dependsOn(client) -lazy val appJVM = app.jvm.dependsOn(server) +lazy val appJVM = app.jvm.dependsOn(server % "compile->compile;test->test") /// Aggregate project