Files
react-native-devtools-frontend/test/e2e/application/storage_test.ts
T
Jack Franklin 3b3a782f3a Enable interaction tests
This CL introduces the infrastructure and first test for what we're calling
"Interaction tests". These are tests that can be used to test component
behaviour that cannot be tested via Karma unit tests but don't require an e2e
test either.

The best example here is complex user interactions: clicking and dragging a
mouse, or doing multiple tabs to navigate through the UI.

Note that the one interaction test added here for theme_colors isn't the best
example of a complex test, but it's a test that's good enough for now whilst we
get everything set up on infrastructure and make sure it runs without flaking.

Bug: 1153281
Change-Id: Ifb37639a557c459974f703b8954ae68a93d5d368
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2566808
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
2020-12-03 10:44:22 +00:00

114 lines
3.6 KiB
TypeScript

// Copyright 2020 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 {assert} from 'chai';
import {describe, it} from 'mocha';
import {click, getBrowserAndPages, getTestServerPort, waitForFunction} from '../../shared/helper.js';
import {doubleClickSourceTreeItem, getStorageItemsData, navigateToApplicationTab} from '../helpers/application-helpers.js';
const COOKIES_SELECTOR = '[aria-label="Cookies"]';
const STORAGE_SELECTOR = '[aria-label="Storage"]';
const CLEAR_SITE_DATA_BUTTON_SELECTOR = '#storage-view-clear-button';
const INCLUDE_3RD_PARTY_COOKIES_SELECTOR = '[aria-label="including third-party cookies"]';
let DOMAIN_SELECTOR: string;
describe('The Application Tab', async () => {
before(async () => {
DOMAIN_SELECTOR = `${COOKIES_SELECTOR} + ol > [aria-label="https://localhost:${getTestServerPort()}"]`;
});
afterEach(async () => {
const {target} = getBrowserAndPages();
const cookies = await target.cookies();
await target.deleteCookie(...cookies);
});
it('deletes only first party cookies when clearing site data', async () => {
const {target} = getBrowserAndPages();
await navigateToApplicationTab(target, 'cross-origin-cookies');
await doubleClickSourceTreeItem(COOKIES_SELECTOR);
await doubleClickSourceTreeItem(DOMAIN_SELECTOR);
const dataGridRowValuesBefore = await waitForFunction(async () => {
const data = await getStorageItemsData(['name', 'value']);
return data.length ? data : undefined;
});
assert.sameDeepMembers(dataGridRowValuesBefore, [
{
name: 'third_party',
value: 'test',
},
{
name: 'foo2',
value: 'bar',
},
{
name: 'foo',
value: 'bar',
},
]);
await doubleClickSourceTreeItem(STORAGE_SELECTOR);
await click(CLEAR_SITE_DATA_BUTTON_SELECTOR);
await doubleClickSourceTreeItem(COOKIES_SELECTOR);
await doubleClickSourceTreeItem(DOMAIN_SELECTOR);
const dataGridRowValuesAfter = await waitForFunction(async () => {
const data = await getStorageItemsData(['name', 'value']);
return data.length ? data : undefined;
});
assert.sameDeepMembers(dataGridRowValuesAfter, [{
name: 'third_party',
value: 'test',
}]);
});
it('deletes first and third party cookies when clearing site data with the flag enabled', async () => {
const {target} = getBrowserAndPages();
// This sets a new cookie foo=bar
await navigateToApplicationTab(target, 'cross-origin-cookies');
await doubleClickSourceTreeItem(COOKIES_SELECTOR);
await doubleClickSourceTreeItem(DOMAIN_SELECTOR);
const dataGridRowValuesBefore = await waitForFunction(async () => {
const data = await getStorageItemsData(['name', 'value']);
return data.length ? data : undefined;
});
assert.sameDeepMembers(dataGridRowValuesBefore, [
{
name: 'third_party',
value: 'test',
},
{
name: 'foo2',
value: 'bar',
},
{
name: 'foo',
value: 'bar',
},
]);
await doubleClickSourceTreeItem(STORAGE_SELECTOR);
await click(INCLUDE_3RD_PARTY_COOKIES_SELECTOR);
await click(CLEAR_SITE_DATA_BUTTON_SELECTOR);
await doubleClickSourceTreeItem(COOKIES_SELECTOR);
await doubleClickSourceTreeItem(DOMAIN_SELECTOR);
await waitForFunction(async () => {
const data = await getStorageItemsData(['name', 'value']);
return data.length === 0;
});
});
});