Не подтверждена Коммит c0d3bc48 создал по автору Simon Binder's avatar Simon Binder
Просмотр файлов

Make web integration tests functional

владелец 9b45662e
...@@ -281,7 +281,9 @@ final class DatabaseClient implements WebSqlite { ...@@ -281,7 +281,9 @@ final class DatabaseClient implements WebSqlite {
if (result.canUseOpfs) { if (result.canUseOpfs) {
available.add((StorageMode.opfs, AccessMode.throughSharedWorker)); available.add((StorageMode.opfs, AccessMode.throughSharedWorker));
} else { } else if (result.sharedCanSpawnDedicated) {
// Only report OPFS as unavailable if we can spawn dedicated workers.
// If we can't, it's known that we can't use OPFS.
_missingFeatures.add(MissingBrowserFeature.fileSystemAccess); _missingFeatures.add(MissingBrowserFeature.fileSystemAccess);
} }
......
...@@ -72,7 +72,7 @@ void main() { ...@@ -72,7 +72,7 @@ void main() {
for (final browser in Browser.values) { for (final browser in Browser.values) {
group(browser.name, () { group(browser.name, () {
late Process driverProcess; late Process driverProcess;
late DriftWebDriver driver; late TestWebDriver driver;
setUpAll(() async => driverProcess = await browser.spawnDriver()); setUpAll(() async => driverProcess = await browser.spawnDriver());
tearDownAll(() => driverProcess.kill()); tearDownAll(() => driverProcess.kill());
...@@ -83,8 +83,19 @@ void main() { ...@@ -83,8 +83,19 @@ void main() {
uri: browser.driverUri, uri: browser.driverUri,
); );
driver = DriftWebDriver(server, rawDriver); driver = TestWebDriver(server, rawDriver);
await driver.driver.get('http://localhost:8080/'); await driver.driver.get('http://localhost:8080/');
while (true) {
try {
// This element is created after main() has completed, make sure
// all the callbacks have been installed.
await driver.driver.findElement(By.id('ready'));
break;
} on NoSuchElementException {
continue;
}
}
}); });
tearDown(() => driver.driver.quit()); tearDown(() => driver.driver.quit());
...@@ -95,6 +106,16 @@ void main() { ...@@ -95,6 +106,16 @@ void main() {
expect(result.missingFeatures, browser.missingFeatures); expect(result.missingFeatures, browser.missingFeatures);
expect(result.impls, browser.availableImplementations); expect(result.impls, browser.availableImplementations);
}); });
for (final (storage, access) in browser.availableImplementations) {
test('$storage through $access', () async {
await driver.openDatabase((storage, access));
await driver.execute('CREATE TABLE foo (bar TEXT);');
final event = driver.waitForUpdate();
await driver.execute("INSERT INTO foo (bar) VALUES ('hello');");
await event;
});
}
}); });
} }
} }
...@@ -98,11 +98,11 @@ class TestAssetServer { ...@@ -98,11 +98,11 @@ class TestAssetServer {
} }
} }
class DriftWebDriver { class TestWebDriver {
final TestAssetServer server; final TestAssetServer server;
final WebDriver driver; final WebDriver driver;
DriftWebDriver(this.server, this.driver); TestWebDriver(this.server, this.driver);
Future< Future<
({ ({
......
...@@ -33,6 +33,8 @@ void main() { ...@@ -33,6 +33,8 @@ void main() {
print('selected storage: ${database.storage} through ${database.access}'); print('selected storage: ${database.storage} through ${database.access}');
print('missing features: ${database.features.missingFeatures}'); print('missing features: ${database.features.missingFeatures}');
}); });
document.body!.children.add(DivElement()..id = 'ready');
} }
void _addCallbackForWebDriver( void _addCallbackForWebDriver(
...@@ -105,6 +107,6 @@ Future<JSAny?> _open(String? implementationName) async { ...@@ -105,6 +107,6 @@ Future<JSAny?> _open(String? implementationName) async {
} }
Future<JSAny?> _exec(String? sql) async { Future<JSAny?> _exec(String? sql) async {
database!.execute(sql!); await database!.execute(sql!);
return null; return null;
} }
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать