Skip to content

Commit

Permalink
Update hakukohde list to have organisaationimi
Browse files Browse the repository at this point in the history
  • Loading branch information
SalamaGofore committed Apr 2, 2024
1 parent ba05816 commit eb02f73
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
9 changes: 6 additions & 3 deletions src/app/haku/[oid]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ export default async function HakuPage({
<div>
<h1>Valintojen Toteuttaminen</h1>
<h2>{getTranslation(hakuNimi)}</h2>
<ul>
<div>
{hakukohteet.map((hk: Hakukohde) =>
<li key={hk.oid}>{getTranslation(hk.nimi)}</li>)}
</ul>
<div key={hk.oid}>
<p title={hk.organisaatioOid}>{getTranslation(hk.organisaatioNimi)}</p>
<p title={hk.oid}>{getTranslation(hk.nimi)}</p>
</div>)}
</div>
</div>
</main>
);
Expand Down
11 changes: 7 additions & 4 deletions src/app/lib/kouta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ export type Haku = {

export type Hakukohde = {
oid: string,
nimi: TranslatedName
}
nimi: TranslatedName,
organisaatioOid: string,
organisaatioNimi: TranslatedName
};

export enum Tila {
JULKAISTU, ARKISTOITU
Expand Down Expand Up @@ -83,8 +85,9 @@ export async function getHaku(oid: string): Promise<TranslatedName> {

export async function getHakukohteet(hakuOid: string): Promise<Hakukohde[]> {
const response = await axios.get(`${configuration.hakukohteetUrl}?haku=${hakuOid}`);
const hakukohteet: Hakukohde[] = response.data.map((h: { oid: string; nimi: TranslatedName}) => {
return {oid: h.oid, nimi: h.nimi};
const hakukohteet: Hakukohde[] = response.data.map((h: { oid: string; nimi: TranslatedName, organisaatioOid: string,
organisaatioNimi: TranslatedName}) => {
return {oid: h.oid, nimi: h.nimi, organisaatioNimi: h.organisaatioNimi, organisaatioOid: h.organisaatioOid};
});
return hakukohteet;
}
18 changes: 10 additions & 8 deletions tests/haku.spec.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import { test, expect } from '@playwright/test';

test('selects haku', async ({ page }) => {
test('filters active haku', async ({ page }) => {
await page.goto('http://localhost:3404');

await expect(page.locator('tbody tr')).toHaveCount(3);

const hakuInput = await page.locator('input[type=text]');
hakuInput.fill('Luk');
await expect(page.getByTestId('haku-results').locator('.cursor-pointer')).toHaveCount(1);
await page.getByTestId('haku-results').locator('.cursor-pointer').first().click();
await expect(page.locator('input[type=text]')).toHaveValue('Hausjärven lukio jatkuva haku');
await expect(page.locator('tbody tr')).toHaveCount(1);
await expect(page.locator('tbody tr')).toContainText('Hausjärven lukio jatkuva haku');
});

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

await expect(page.locator('tbody tr')).toHaveCount(3);

const hakuInput = await page.locator('input[type=text]');
hakuInput.fill('hak');
await expect(page.getByTestId('haku-results').locator('.cursor-pointer')).toHaveCount(3);
await expect(page.locator('tbody tr')).toHaveCount(3);
hakuInput.fill('Leppä');
await expect(page.getByTestId('haku-results').locator('.cursor-pointer')).toHaveCount(1);
await page.getByTestId('haku-results').locator('.cursor-pointer').first().click();
await expect(page.locator('input[type=text]')).toHaveValue('Leppävirran lukio - Jatkuva haku');
await expect(page.locator('tbody tr')).toHaveCount(1);
await expect(page.locator('tbody tr')).toContainText('Leppävirran lukio - Jatkuva haku');
});

0 comments on commit eb02f73

Please sign in to comment.