Home / File/ actions-react-19.test.js — astro Source File

actions-react-19.test.js — astro Source File

Architecture documentation for actions-react-19.test.js, a javascript file in the astro codebase. 4 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  3507241b_b7f9_3c03_54c1_613a90b1cf41["actions-react-19.test.js"]
  2ca394f6_a63d_3921_1f12_c5a979ea0039["test-utils.js"]
  3507241b_b7f9_3c03_54c1_613a90b1cf41 --> 2ca394f6_a63d_3921_1f12_c5a979ea0039
  e27f6887_ea47_dd44_7933_5faa0f6bcf4d["testFactory"]
  3507241b_b7f9_3c03_54c1_613a90b1cf41 --> e27f6887_ea47_dd44_7933_5faa0f6bcf4d
  c373140e_7fdf_7fff_8884_991b85bc22b5["waitForHydrate"]
  3507241b_b7f9_3c03_54c1_613a90b1cf41 --> c373140e_7fdf_7fff_8884_991b85bc22b5
  f8fbe851_c5d6_c4ee_c044_67a751668c18["test"]
  3507241b_b7f9_3c03_54c1_613a90b1cf41 --> f8fbe851_c5d6_c4ee_c044_67a751668c18
  style 3507241b_b7f9_3c03_54c1_613a90b1cf41 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/actions-react-19/' });

let devServer;

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

test.afterEach(async ({ astro }) => {
	// Force database reset between tests
	await astro.editFile('./db/seed.ts', (original) => original, false);
});

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

test.describe('Astro Actions - React 19', () => {
	test('Like action - client pending state', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/blog/first-post/'));
		const likeButton = page.getByLabel('likes-client');
		await waitForHydrate(page, likeButton);
		await new Promise((resolve) => setTimeout(resolve, 500));

		await expect(likeButton).toBeVisible();
		await likeButton.click();
		await expect(likeButton, 'like button should be disabled when pending').toBeDisabled();
		await expect(likeButton).not.toBeDisabled();
	});

	test('Like action - server progressive enhancement', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/blog/first-post/'));

		const likeButton = page.getByLabel('likes-server');
		await expect(likeButton, 'like button starts with 10 likes').toContainText('10');
		await likeButton.click();

		await expect(likeButton, 'like button increments').toContainText('11');
	});

	test('Like action - client useActionState', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/blog/first-post/'));

		const likeButton = page.getByLabel('likes-action-client');
		await waitForHydrate(page, likeButton);

		await expect(likeButton).toBeVisible();
		await likeButton.click();

		await expect(likeButton, 'like button increments').toContainText('11');
	});

	test('Like action - server useActionState progressive enhancement', async ({ page, astro }) => {
		await page.goto(astro.resolveUrl('/blog/first-post/'));

		const likeButton = page.getByLabel('likes-action-server');
		await expect(likeButton, 'like button starts with 10 likes').toContainText('10');
		await likeButton.click();

		await expect(likeButton, 'like button increments').toContainText('11');
	});
});

Domain

Frequently Asked Questions

What does actions-react-19.test.js do?
actions-react-19.test.js is a source file in the astro codebase, written in javascript. It belongs to the E2ETesting domain.
What does actions-react-19.test.js depend on?
actions-react-19.test.js imports 4 module(s): test, test-utils.js, testFactory, waitForHydrate.
Where is actions-react-19.test.js in the architecture?
actions-react-19.test.js is located at packages/astro/e2e/actions-react-19.test.js (domain: E2ETesting, directory: packages/astro/e2e).

Analyze Your Own Codebase

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

Try Supermodel Free