Skip to content

Commit

Permalink
adding polling for web
Browse files Browse the repository at this point in the history
  • Loading branch information
xoscar committed Jun 17, 2024
1 parent bc7be74 commit c4de4f7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
22 changes: 12 additions & 10 deletions playwright/home.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ test.afterAll(async ({}, testInfo) => {
await tracetest?.summary();
});

test('Playwright: creates a pokemon', async ({ page }) => {
expect(await page.getByText('Pokeshop')).toBeTruthy();
// test('Playwright: creates a pokemon', async ({ page }) => {
// expect(await page.getByText('Pokeshop')).toBeTruthy();

await page.click('text=Add');
// await page.click('text=Add');

await page.getByLabel('Name').fill('Charizard');
await page.getByLabel('Type').fill('Flying');
await page
.getByLabel('Image URL')
.fill('https://upload.wikimedia.org/wikipedia/en/1/1f/Pok%C3%A9mon_Charizard_art.png');
await page.getByRole('button', { name: 'OK', exact: true }).click();
});
// await page.getByLabel('Name').fill('Charizard');
// await page.getByLabel('Type').fill('Flying');
// await page
// .getByLabel('Image URL')
// .fill('https://upload.wikimedia.org/wikipedia/en/1/1f/Pok%C3%A9mon_Charizard_art.png');
// await page.getByRole('button', { name: 'OK', exact: true }).click();
// });

test('Playwright: imports a pokemon', async ({ page }) => {
expect(await page.getByText('Pokeshop')).toBeTruthy();
Expand All @@ -74,6 +74,8 @@ test('Playwright: imports a pokemon', async ({ page }) => {
page.waitForResponse(resp => resp.url().includes('/pokemon/import') && resp.status() === 200),
page.getByRole('button', { name: 'OK', exact: true }).click(),
]);

await page.waitForTimeout(4000);
});

test('Playwright: deletes a pokemon', async ({ page }) => {
Expand Down
8 changes: 6 additions & 2 deletions web/src/hooks/usePokemonCrud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ const FEATURED_CACHE_KEY = `${CACHE_KEY}/featured`;

const usePokemonCrud = () => {
const queryClient = useQueryClient();
const allPokemon = useQuery(CACHE_KEY, PokemonGateway.getAll);
const allPokemon = useQuery(CACHE_KEY, PokemonGateway.getAll, {
refetchInterval: 500,
});

const featuredPokemon = useQuery(FEATURED_CACHE_KEY, PokemonGateway.getFeatured);
const featuredPokemon = useQuery(FEATURED_CACHE_KEY, PokemonGateway.getFeatured, {
refetchInterval: 500,
});

const createPokemon = useMutation(PokemonGateway.create, {
onSuccess: () => {
Expand Down

0 comments on commit c4de4f7

Please sign in to comment.