Home / File/ view-transitions.test.js — astro Source File

view-transitions.test.js — astro Source File

Architecture documentation for view-transitions.test.js, a javascript file in the astro codebase. 4 imports, 0 dependents.

File javascript E2ETesting TestFixtures 4 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  b4c19437_37d7_2f07_374e_31b46d21464b["view-transitions.test.js"]
  2ca394f6_a63d_3921_1f12_c5a979ea0039["test-utils.js"]
  b4c19437_37d7_2f07_374e_31b46d21464b --> 2ca394f6_a63d_3921_1f12_c5a979ea0039
  e27f6887_ea47_dd44_7933_5faa0f6bcf4d["testFactory"]
  b4c19437_37d7_2f07_374e_31b46d21464b --> e27f6887_ea47_dd44_7933_5faa0f6bcf4d
  c373140e_7fdf_7fff_8884_991b85bc22b5["waitForHydrate"]
  b4c19437_37d7_2f07_374e_31b46d21464b --> c373140e_7fdf_7fff_8884_991b85bc22b5
  f8fbe851_c5d6_c4ee_c044_67a751668c18["test"]
  b4c19437_37d7_2f07_374e_31b46d21464b --> f8fbe851_c5d6_c4ee_c044_67a751668c18
  style b4c19437_37d7_2f07_374e_31b46d21464b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { expect } from '@playwright/test';
import { testFactory, waitForHydrate } from './test-utils.js';

const test = testFactory(import.meta.url, { root: './fixtures/view-transitions/' });

let devServer;

test.beforeAll(async ({ astro }) => {
	devServer = await astro.startDevServer();
});

test.afterAll(async () => {
	await devServer.stop();
});

function collectLoads(page) {
	const loads = [];
	page.on('load', async () => {
		const url = page.url();
		if (url !== 'about:blank') loads.push(await page.title());
	});
	return loads;
}
function scrollToBottom(page) {
	return page.evaluate(() => {
		window.scrollY = document.documentElement.scrollHeight;
		window.dispatchEvent(new Event('scroll'));
	});
}

function collectPreloads(page) {
	return page.evaluate(() => {
		window.preloads = [];
		const observer = new MutationObserver((mutations) => {
			mutations.forEach((mutation) =>
				mutation.addedNodes.forEach((node) => {
					if (node.nodeName === 'LINK' && node.rel === 'preload') preloads.push(node.href);
				}),
			);
		});
		observer.observe(document.head, { childList: true });
	});
}

async function nativeViewTransition(page) {
	return page.evaluate(() => document.startViewTransition !== undefined);
}

test.describe('View Transitions', () => {
	test('Moving from page 1 to page 2', async ({ page, astro }) => {
		const loads = collectLoads(page);

		// Go to page 1
		await page.goto(astro.resolveUrl('/one'));
		let p = page.locator('#one');
		await expect(p, 'should have content').toHaveText('Page 1');

		// go to page 2
		await page.click('#click-two');
		p = page.locator('#two');
// ... (1703 more lines)

Domain

Subdomains

Frequently Asked Questions

What does view-transitions.test.js do?
view-transitions.test.js is a source file in the astro codebase, written in javascript. It belongs to the E2ETesting domain, TestFixtures subdomain.
What functions are defined in view-transitions.test.js?
view-transitions.test.js defines 4 function(s): collectLoads, collectPreloads, nativeViewTransition, scrollToBottom.
What does view-transitions.test.js depend on?
view-transitions.test.js imports 4 module(s): test, test-utils.js, testFactory, waitForHydrate.
Where is view-transitions.test.js in the architecture?
view-transitions.test.js is located at packages/astro/e2e/view-transitions.test.js (domain: E2ETesting, subdomain: TestFixtures, directory: packages/astro/e2e).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free