-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(nextcloud): Add checks to ensure that all available props are parsed #2558
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: provokateurin <kate@provokateurin.de>
Signed-off-by: provokateurin <kate@provokateurin.de>
…rsed Signed-off-by: provokateurin <kate@provokateurin.de>
4ae9f68
to
548176b
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2558 +/- ##
==========================================
+ Coverage 28.66% 28.71% +0.04%
==========================================
Files 366 366
Lines 136296 136274 -22
==========================================
+ Hits 39076 39128 +52
+ Misses 97220 97146 -74
*This pull request uses carry forward flags. Click here to find out more. |
List<String> _getMultistatusPropNames(XmlElement root) { | ||
return root.firstElementChild!.childElements | ||
.singleWhere( | ||
(node) => | ||
node.name.local == 'propstat' && | ||
node.childElements.singleWhere((node) => node.name.local == 'status').innerText.contains('200 OK'), | ||
) | ||
.childElements | ||
.singleWhere((node) => node.name.local == 'prop') | ||
.childElements | ||
.map((el) => '{${el.name.namespaceUri}}${el.name.local}') | ||
.toList() | ||
.sorted(); | ||
} | ||
|
||
Future<void> _expectAllPropsAreParsed(NextcloudTester tester, WebDavMultistatus result, PathUri uri) async { | ||
final parsedProps = _getMultistatusPropNames(result.toXmlElement(namespaces: namespaces)); | ||
expect(parsedProps, isNotEmpty); | ||
|
||
final streamedResponse = await tester.client.webdav.httpClient.send(tester.client.webdav.propfind_Request(uri)); | ||
expect(streamedResponse.statusCode, 207); | ||
final rawResponse = await http.Response.fromStream(streamedResponse); | ||
|
||
final expectedProps = _getMultistatusPropNames(XmlDocument.parse(rawResponse.body).rootElement); | ||
expect(expectedProps, isNotEmpty); | ||
|
||
expect(parsedProps, expectedProps); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this being here.
I'd rather have it be a Matcher
from package:test_api
and have it be located inside nextcloud_test
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems like quite a lot of effort for this little thing that is only used twice, no?
final parsedProps = _getMultistatusPropNames(result.toXmlElement(namespaces: namespaces)); | ||
expect(parsedProps, isNotEmpty); | ||
|
||
final streamedResponse = await tester.client.webdav.httpClient.send(tester.client.webdav.propfind_Request(uri)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these calls need to be in the fixtures?
I'd rather have it not included.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we can exclude them
This is going to become a lot more useful when sabre-io/dav#1564 is merged and in a released Nextcloud version, as we are currently missing out on a lot of props when requesting all available props.