Files
react-native-devtools-frontend/test/e2e/issues/twa-issues_test.ts
T
Jack Franklin e839c0cf22 Enable long import wrapping for JS imports
DISABLE_THIRD_PARTY_CHECK=big clang format run against all files in
front_end and test/

Bug: 1319340
Change-Id: I1fff63cb07544ccd0e3059fc901f9a48ff4af13b
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3598879
Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Wolfgang Beyer <wolfi@chromium.org>
2022-05-03 10:22:12 +00:00

107 lines
3.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {assertNotNullOrUndefined, getBrowserAndPages, goToResource} from '../../shared/helper.js';
import {describe, it} from '../../shared/mocha-extensions.js';
import {
expandIssue,
getIssueByTitle,
getResourcesElement,
navigateToIssuesTab,
waitForTableFromResourceSectionContents,
} from '../helpers/issues-helpers.js';
describe('Trusted Web Activity issue', async () => {
beforeEach(async () => {
await goToResource('empty.html');
});
it('should display correct information for type kHttpError', async () => {
await navigateToIssuesTab();
const {frontend} = getBrowserAndPages();
frontend.evaluate(() => {
const issue = {
'code': 'TrustedWebActivityIssue',
'details': {
'twaQualityEnforcementDetails': {
'url': 'test1.example.com',
'violationType': 'kHttpError',
'httpStatusCode': 404,
},
},
};
// @ts-ignore
window.addIssueForTest(issue);
});
await expandIssue();
const issueElement = await getIssueByTitle(
'Trusted Web Activity navigations must succeed or be handled by the ServiceWorker. Your app may crash in the future.');
assertNotNullOrUndefined(issueElement);
const section = await getResourcesElement('1 resource', issueElement);
const expectedTableRows = [
['Status code', 'Url'],
['404', 'test1.example.com'],
];
await waitForTableFromResourceSectionContents(section.content, expectedTableRows);
});
it('should display correct information for type kUnavailableOffline', async () => {
await navigateToIssuesTab();
const {frontend} = getBrowserAndPages();
frontend.evaluate(() => {
const issue = {
'code': 'TrustedWebActivityIssue',
'details': {
'twaQualityEnforcementDetails': {
'url': 'test2.example.com',
'violationType': 'kUnavailableOffline',
},
},
};
// @ts-ignore
window.addIssueForTest(issue);
});
await expandIssue();
const issueElement = await getIssueByTitle(
'Trusted Web Activity does not work offline. In the future, your app may crash if the user’s device goes offline.');
assertNotNullOrUndefined(issueElement);
const section = await getResourcesElement('1 resource', issueElement);
const expectedTableRows = [
['Url'],
['test2.example.com'],
];
await waitForTableFromResourceSectionContents(section.content, expectedTableRows);
});
it('should display correct information for type kDigitalAssetLinks', async () => {
await navigateToIssuesTab();
const {frontend} = getBrowserAndPages();
frontend.evaluate(() => {
const issue = {
'code': 'TrustedWebActivityIssue',
'details': {
'twaQualityEnforcementDetails': {
'url': 'test3.example.com',
'violationType': 'kDigitalAssetLinks',
'packageName': 'test.package',
'signature': '1A:2B:3C',
},
},
};
// @ts-ignore
window.addIssueForTest(issue);
});
await expandIssue();
const issueElement = await getIssueByTitle(
'Digital asset links of the Trusted Web Activity failed verification. Your app may crash in the future.');
assertNotNullOrUndefined(issueElement);
const section = await getResourcesElement('1 resource', issueElement);
const expectedTableRows = [
['Package name', 'Url', 'Package signature'],
['test.package', 'test3.example.com', '1A:2B:3C'],
];
await waitForTableFromResourceSectionContents(section.content, expectedTableRows);
});
});