Add widget catalog and restore canvas preview tools
This commit is contained in:
1 parent
12a8c24441
commit
beeca041ef
13 files changed
+489
-35
No files matched your search
@@ -34,6 +34,43 @@ class LayoutApiTest {
|
||||
|
||||
@TempDir Path dir;
|
||||
|
||||
@Test
|
||||
void widgetCatalogRequiresAdminAndPersistsUniqueComponents() throws Exception {
|
||||
String path = "/api/admin/widget-providers";
|
||||
Path database = dir.resolve("widgets.sqlite");
|
||||
try (var connection = DriverManager.getConnection("jdbc:sqlite:" + database);
|
||||
var statement = connection.createStatement()) {
|
||||
statement.execute("CREATE TABLE widget_providers (component TEXT PRIMARY KEY) STRICT");
|
||||
}
|
||||
MockMvc mvc = mvc(database);
|
||||
mvc.perform(get(path).header("Authorization", DEVICE)).andExpect(status().isUnauthorized());
|
||||
mvc.perform(put(path)).andExpect(status().isUnauthorized());
|
||||
mvc.perform(put(path).header("Authorization", ADMIN).contentType(MediaType.APPLICATION_JSON)
|
||||
.content("""
|
||||
{"providers":["com.example/.Widget","invalid"]}
|
||||
"""))
|
||||
.andExpect(status().isBadRequest());
|
||||
mvc.perform(get(path).header("Authorization", ADMIN)).andExpect(content().json("""
|
||||
{"providers":[]}
|
||||
"""));
|
||||
mvc.perform(put(path).header("Authorization", ADMIN).contentType(MediaType.APPLICATION_JSON)
|
||||
.content("""
|
||||
{"providers":[{"component":"com.example/.Widget","label":"快捷搜索","appLabel":"示例应用"},
|
||||
"com.example/com.example.Widget",
|
||||
{"component":"com.android.deskclock/.Clock","label":"时钟","category":"system"},
|
||||
"com.android.deskclock/com.android.deskclock.Clock"]}
|
||||
"""))
|
||||
.andExpect(status().isOk());
|
||||
mvc(database).perform(get(path).header("Authorization", ADMIN))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().json("""
|
||||
{"providers":[{"component":"com.example/com.example.Widget","label":"快捷搜索","appLabel":"示例应用",
|
||||
"category":"third-party"},
|
||||
{"component":"com.android.deskclock/com.android.deskclock.Clock","label":"时钟",
|
||||
"category":"system"}]}
|
||||
"""));
|
||||
}
|
||||
|
||||
@Test
|
||||
void migratedDatabaseRetainsLayoutsAndSupportsPublishRollbackAndRestart() throws Exception {
|
||||
Path database = dir.resolve("layouts.sqlite");
|
||||
|
||||
Reference in new issue
Block a user