-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix Compose recommended config * add runDesktopUltronUiTest * upd docs
- Loading branch information
1 parent
4db0a4e
commit 07327cd
Showing
47 changed files
with
783 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// see https://kotlinlang.org/docs/js-project-setup.html#webpack-configuration-file | ||
// This file provides karma.config.d configuration to run tests with k/wasm | ||
|
||
const path = require("path"); | ||
|
||
config.browserConsoleLogOptions.level = "debug"; | ||
|
||
const basePath = config.basePath; | ||
const projectPath = path.resolve(basePath, "..", "..", "..", ".."); | ||
const generatedAssetsPath = path.resolve(projectPath, "build", "karma-webpack-out") | ||
|
||
const debug = message => console.log(`[karma-config] ${message}`); | ||
|
||
debug(`karma basePath: ${basePath}`); | ||
debug(`karma generatedAssetsPath: ${generatedAssetsPath}`); | ||
|
||
config.proxies["/"] = path.resolve(basePath, "kotlin"); | ||
|
||
config.files = [ | ||
{pattern: path.resolve(generatedAssetsPath, "**/*"), included: false, served: true, watched: false}, | ||
{pattern: path.resolve(basePath, "kotlin", "**/*.png"), included: false, served: true, watched: false}, | ||
{pattern: path.resolve(basePath, "kotlin", "**/*.gif"), included: false, served: true, watched: false}, | ||
{pattern: path.resolve(basePath, "kotlin", "**/*.ttf"), included: false, served: true, watched: false}, | ||
{pattern: path.resolve(basePath, "kotlin", "**/*.txt"), included: false, served: true, watched: false}, | ||
{pattern: path.resolve(basePath, "kotlin", "**/*.json"), included: false, served: true, watched: false}, | ||
{pattern: path.resolve(basePath, "kotlin", "**/*.xml"), included: false, served: true, watched: false}, | ||
].concat(config.files); | ||
|
||
function KarmaWebpackOutputFramework(config) { | ||
// This controller is instantiated and set during the preprocessor phase. | ||
const controller = config.__karmaWebpackController; | ||
|
||
// only if webpack has instantiated its controller | ||
if (!controller) { | ||
console.warn( | ||
"Webpack has not instantiated controller yet.\n" + | ||
"Check if you have enabled webpack preprocessor and framework before this framework" | ||
) | ||
return | ||
} | ||
|
||
config.files.push({ | ||
pattern: `${controller.outputPath}/**/*`, | ||
included: false, | ||
served: true, | ||
watched: false | ||
}) | ||
} | ||
|
||
const KarmaWebpackOutputPlugin = { | ||
'framework:webpack-output': ['factory', KarmaWebpackOutputFramework], | ||
}; | ||
|
||
config.plugins.push(KarmaWebpackOutputPlugin); | ||
config.frameworks.push("webpack-output"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.testTag | ||
import androidx.compose.ui.test.ExperimentalTestApi | ||
import androidx.compose.ui.test.hasTestTag | ||
import com.atiurin.ultron.core.compose.runUltronUiTest | ||
import com.atiurin.ultron.extensions.assertTextEquals | ||
import com.atiurin.ultron.extensions.click | ||
import com.atiurin.ultron.page.Page | ||
import kotlin.test.Test | ||
|
||
class IOSSampleTest { | ||
@OptIn(ExperimentalTestApi::class) | ||
@Test | ||
fun sampleTest() = runUltronUiTest { | ||
setContent { | ||
var text by remember { mutableStateOf("Hello") } | ||
|
||
Text( | ||
text = text, | ||
modifier = Modifier.testTag("text") | ||
) | ||
Button( | ||
onClick = { text = "Compose" }, | ||
modifier = Modifier.testTag("button") | ||
) { | ||
Text("Click me") | ||
} | ||
} | ||
|
||
SamplePage { | ||
someStep() | ||
} | ||
} | ||
} | ||
|
||
object SamplePage : Page<SamplePage>() { | ||
private val text = hasTestTag("text") | ||
private val button = hasTestTag("button") | ||
|
||
fun someStep(){ | ||
text.assertTextEquals("Hello") | ||
button.click() | ||
text.assertTextEquals("Compose") | ||
} | ||
} |
Oops, something went wrong.