feat(json-diff): add new tool to get the diff of two given JSONs

This commit is contained in:
Carsten Götzinger 2023-04-13 15:06:46 +02:00
parent 7d7cc99866
commit 80af4a3eea
9 changed files with 559 additions and 1 deletions

View file

@ -0,0 +1,28 @@
import { test, expect } from '@playwright/test';
test.describe('Tool - Json diff', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/json-diff');
});
test('Has correct title', async ({ page }) => {
await expect(page).toHaveTitle('JSON diff - IT Tools');
});
test('Compare two identical JSONs with corresponding result message', async ({ page }) => {
const json = '{"foo":"bar","list":["item",{"key":"value"}]}';
await page.getByTestId('leftJson').fill(json);
await page.getByTestId('rightJson').fill(json);
const generatedResult = await page.getByTestId('result').innerText();
expect(generatedResult.trim()).toContain('both JSONs are identical');
});
test('Compare two different JSONs with corresponding result message', async ({ page }) => {
await page.getByTestId('leftJson').fill('{"foo":"bar","list":["item","item2",{"key":"value"}]}');
await page.getByTestId('rightJson').fill('{"foo":"bar","list":["item",{"key":"value"}]}');
await expect(page.getByTestId('result').getByRole('listitem')).toHaveCount(6);
});
});