Skip to content

Commit

Permalink
Couple more haku related ui tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SalamaGofore committed Apr 3, 2024
1 parent eb02f73 commit 42539b6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/app/components/haku-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const HakuSelector = ({haut, hakutavat}: {haut : Haku[], hakutavat: Koodi
/>
<div>
<label htmlFor="hakutapa-select">Hakutapa</label>
<select name="hakutapa-select" onChange={changeHakutapa}>
<select data-testid="haku-hakutapa-select" name="hakutapa-select" onChange={changeHakutapa}>
<option value={undefined}>Valitse...</option>
{hakutavat.map((tapa, index) => {
return <option value={index} key={tapa.koodiUri}>{tapa.nimi.fi}</option> //TODO: translate
Expand All @@ -73,7 +73,7 @@ export const HakuSelector = ({haut, hakutavat}: {haut : Haku[], hakutavat: Koodi
</div>
<div>
<label htmlFor="alkamiskausi-select">Koulutuksen alkamiskausi</label>
<select name="alkamiskausi-select" onChange={changeAlkamisKausi}>
<select data-testid="haku-kausi-select" name="alkamiskausi-select" onChange={changeAlkamisKausi}>
<option value={undefined}>Valitse...</option>
{alkamisKaudet.map((kausi, index) => {
return <option value={index} key={kausi.alkamisVuosi + kausi.alkamisKausiKoodiUri}>{kausi.alkamisVuosi} {kausi.alkamisKausiNimi}</option> //TODO: translate
Expand Down
25 changes: 23 additions & 2 deletions tests/haku.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('filters active haku', async ({ page }) => {
await expect(page.locator('tbody tr')).toContainText('Hausjärven lukio jatkuva haku');
});

test('selects passive haku', async ({ page }) => {
test('filters passive haku', async ({ page }) => {
await page.goto('http://localhost:3404');
await page.getByTestId('haku-tila-toggle').click();

Expand All @@ -23,4 +23,25 @@ test('selects passive haku', async ({ page }) => {
hakuInput.fill('Leppä');
await expect(page.locator('tbody tr')).toHaveCount(1);
await expect(page.locator('tbody tr')).toContainText('Leppävirran lukio - Jatkuva haku');
});
});

test('filters by hakutapa', async ({page}) => {
await page.goto('http://localhost:3404');
await page.getByTestId('haku-hakutapa-select').selectOption('Erillishaku');
await expect(page.locator('tbody tr')).toHaveCount(1);
await page.getByTestId('haku-hakutapa-select').selectOption('Jatkuva haku');
await expect(page.locator('tbody tr')).toHaveCount(2);
});

test('filters by start period', async ({page}) => {
await page.goto('http://localhost:3404');
await page.getByTestId('haku-kausi-select').selectOption('2024 SYKSY');
await expect(page.locator('tbody tr')).toHaveCount(1);
});

test('navigates to haku page', async ({page}) => {
await page.goto('http://localhost:3404');
await page.locator('tbody tr:last-child td:first-child a').click();
await expect(page).toHaveURL('http://localhost:3404/haku/1.2.246.562.29.00000000000000045102');
await expect(page.locator('h2')).toHaveText('Tampere University Separate Admission/ Finnish MAOL Competition Route 2024');
});

0 comments on commit 42539b6

Please sign in to comment.