Skip to content

Commit

Permalink
Update snapshots. Fix mobile state fixtures.
Browse files Browse the repository at this point in the history
  • Loading branch information
tnajdek committed Sep 14, 2024
1 parent f3a3f66 commit 6aa9ac9
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 21 deletions.
41 changes: 22 additions & 19 deletions scripts/generate-fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { stateProcessSymbols, stateToJSON } from '../test/utils/state.js';
import secret from '../.secret.json' with { type: "json" };
import child_process from "child_process";

// this file depends on a .secret.json file in the root directory with the following structure:
// This script can be used to generate/update state fixtures used in tests.
// It starts the web library configured to use the test library and generates state
// fixtures for the URLs in the fixtures array.
// This file depends on a .secret.json file in the root directory with the following structure:
// {
// "apiKey": "",
// "userName": "",
Expand All @@ -17,6 +20,23 @@ import child_process from "child_process";
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
const NPMST_TIMEOUT = 30000;

const fixtures = [
[`${URL}groups/5119976/animals/items/X9WEHDAN/item-list`, 'desktop-test-group-item-view'],
[`${URL}testuser/items/3JCLFUG4/attachment/37V7V4NT/library`, 'desktop-test-user-attachment-view'],
[`${URL}testuser/collections/5PB9WKTC/items/MNRM7HER/collection`, 'desktop-test-user-formatting-collection'],
[`${URL}testuser/collections/WTTJ2J56/items/VR82JUX8/item-details`, 'desktop-test-user-item-view'],
[`${URL}testuser`, 'desktop-test-user-library-view'],
[`${URL}testuser/collections/CSB4KZUU/items/BLVYJQMH/note/GNVWD3U4/item-details`, 'desktop-test-user-note-view'],
[`${URL}testuser/items/KBFTPTI4/reader`, 'desktop-test-user-reader-parent-item-view'],
[`${URL}testuser/items/KBFTPTI4/attachment/N2PJUHD6/reader`, 'desktop-test-user-reader-view'],
[`${URL}testuser/search/retriever/titleCreatorYear/items/KBFTPTI4/item-list`, 'desktop-test-user-search-phrase-selected'],
[`${URL}testuser/tags/to%20read/search/pathfinding/titleCreatorYear/items/J489T6X3,3JCLFUG4/item-list`, 'desktop-test-user-search-selected'],
[`${URL}testuser/collections/CSB4KZUU/items/3JCLFUG4/attachment/37V7V4NT/item-details`, 'desktop-test-user-attachment-in-collection-view'],
[`${URL}testuser/trash`, 'desktop-test-user-trash-view'],
[`${URL}testuser/collections/CSB4KZUU/items/3JCLFUG4/item-details`, 'mobile-test-user-item-details-view'],
[`${URL}testuser/collections/WTTJ2J56/item-list`, 'mobile-test-user-item-list-view']
];

const config = JSON.stringify({
translateUrl: secret.translateServerURL,
libraries: {
Expand Down Expand Up @@ -98,28 +118,11 @@ async function checkOrStartServer() {
}
}

const fixtures = [
[`${URL}groups/5119976/animals/items/X9WEHDAN/item-list`, 'desktop-test-group-item-view'],
[`${URL}testuser/items/3JCLFUG4/attachment/37V7V4NT/library`, 'desktop-test-user-attachment-view'],
[`${URL}testuser/collections/5PB9WKTC/items/MNRM7HER/collection`, 'desktop-test-user-formatting-collection'],
[`${URL}testuser/collections/WTTJ2J56/items/VR82JUX8/item-details`, 'desktop-test-user-item-view'],
[`${URL}testuser`, 'desktop-test-user-library-view'],
[`${URL}testuser/collections/CSB4KZUU/items/BLVYJQMH/note/GNVWD3U4/item-details`, 'desktop-test-user-note-view'],
[`${URL}testuser/items/KBFTPTI4/reader`, 'desktop-test-user-reader-parent-item-view'],
[`${URL}testuser/items/KBFTPTI4/attachment/N2PJUHD6/reader`, 'desktop-test-user-reader-view'],
[`${URL}testuser/search/retriever/titleCreatorYear/items/KBFTPTI4/item-list`, 'desktop-test-user-search-phrase-selected'],
[`${URL}testuser/tags/to%20read/search/pathfinding/titleCreatorYear/items/J489T6X3,3JCLFUG4/item-list`, 'desktop-test-user-search-selected'],
[`${URL}testuser/collections/CSB4KZUU/items/3JCLFUG4/attachment/37V7V4NT/item-details`, 'desktop-test-user-attachment-in-collection-view'],
[`${URL}testuser/trash`, 'desktop-test-user-trash-view'],
[`${URL}testuser/collections/CSB4KZUU/items/3JCLFUG4/item-details`, 'mobile-test-user-item-details-view'],
[`${URL}testuser/collections/WTTJ2J56/item-list`, 'mobile-test-user-item-list-view']
];

async function makeFixture(stateURL, name) {
console.log(`Generating state fixture for "${name}"`);
const browser = await chromium.launch();
const contextConfig = name.startsWith('mobile') ?
{ viewport: { width: 375, height: 667 }, isMobile: true } :
{ viewport: { width: 820, height: 1180 }, isMobile: true, hasTouch: true } :
{ viewport: { width: 1920, height: 1080 } };
const context = await browser.newContext(contextConfig);

Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/fixtures/state/mobile-test-user-item-list-view.json

Large diffs are not rendered by default.

Binary file modified test/snapshots/desktop-items-list-macos-safari.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/snapshots/desktop-items-list-windows-chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/snapshots/mobile-item-details-ipad-pro-landscape-emulator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/snapshots/mobile-item-details-pixel-7-chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/snapshots/mobile-items-list-ipad-emulator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/snapshots/mobile-items-list-ipad-pro-landscape-emulator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/snapshots/mobile-items-list-iphone-emulator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/snapshots/mobile-items-list-pixel-7-chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6aa9ac9

Please sign in to comment.