Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ctot-nondef committed Feb 5, 2024
1 parent eeabc78 commit 2184cbb
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 77 deletions.
34 changes: 20 additions & 14 deletions e2e/fixtures/corpsum.fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
import { test as base } from '@playwright/test';
import { test as base } from "@playwright/test";

interface Account {
username: string;
password: string;
}

export const login = base.extend<NonNullable<unknown>, { account: Account }>({
account: [{ username: "", password: "" }, { scope: 'worker' }],
account: [{ username: "", password: "" }, { scope: "worker" }],
page: async ({ page, account }, use) => {
const { username, password } = account;
await page.goto('/en/login');
await page.getByLabel('Username').fill(username);
await page.getByLabel('Password').fill(password);
const loginPromise = page.waitForResponse('https://noskecrystal5corpsum.acdh-dev.oeaw.ac.at/run.cgi/corpora');
await page.locator('#main-content').getByRole('button', { name: 'Login' }).click();
await page.goto("/en/login");
await page.getByLabel("Username").fill(username);
await page.getByLabel("Password").fill(password);
const loginPromise = page.waitForResponse(
"https://noskecrystal5corpsum.acdh-dev.oeaw.ac.at/run.cgi/corpora",
);
await page.locator("#main-content").getByRole("button", { name: "Login" }).click();
await loginPromise;
await use(page);
},
});

export const search = login.extend<NonNullable<unknown>, { term: string }>({
term: ["", { scope: 'worker' }],
term: ["", { scope: "worker" }],
page: async ({ page, term }, use) => {
await page.getByRole('combobox').first().click();
const corpusPromise = page.waitForResponse('https://noskecrystal5corpsum.acdh-dev.oeaw.ac.at/run.cgi/corp_info?corpname=amc_4.2&subcorpora=1&format=json');
await page.getByRole('option', { name: 'amc_4.2' }).click();
await page.getByRole("combobox").first().click();
const corpusPromise = page.waitForResponse(
"https://noskecrystal5corpsum.acdh-dev.oeaw.ac.at/run.cgi/corp_info?corpname=amc_4.2&subcorpora=1&format=json",
);
await page.getByRole("option", { name: "amc_4.2" }).click();
await corpusPromise;
await page.getByPlaceholder('Your search term').fill(term)
const wordformFreqsPromise = page.waitForResponse(`https://noskecrystal5corpsum.acdh-dev.oeaw.ac.at/run.cgi/freqml?usecorp=amc_4.2&corpname=amc_4.2&default_attr=lemma&attrs=word&refs==doc.id&attr_allpos=all&viewmode=kwic&cup_hl=q&structs=s,+g&fromp=1&pagesize=20&kwicleftctx=100%23&kwicrightctx=100%23&json=%7B%22concordance_query%22:%7B%22iquery%22:%22${term}%22,%22queryselector%22:%22iqueryrow%22%7D%7D`);
await page.getByPlaceholder('Your search term').press('Enter');
await page.getByPlaceholder("Your search term").fill(term);
const wordformFreqsPromise = page.waitForResponse(
`https://noskecrystal5corpsum.acdh-dev.oeaw.ac.at/run.cgi/freqml?usecorp=amc_4.2&corpname=amc_4.2&default_attr=lemma&attrs=word&refs==doc.id&attr_allpos=all&viewmode=kwic&cup_hl=q&structs=s,+g&fromp=1&pagesize=20&kwicleftctx=100%23&kwicrightctx=100%23&json=%7B%22concordance_query%22:%7B%22iquery%22:%22${term}%22,%22queryselector%22:%22iqueryrow%22%7D%7D`,
);
await page.getByPlaceholder("Your search term").press("Enter");
await wordformFreqsPromise;
await use(page);
},
Expand Down
92 changes: 56 additions & 36 deletions e2e/pages/query.test.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,68 @@
import { expect } from '@playwright/test';
import { expect } from "@playwright/test";

import { login as test } from '../fixtures/corpsum.fixtures';
import { login as test } from "../fixtures/corpsum.fixtures";

const account = { username: process.env.TEST_USER!, password: process.env.TEST_PASSWORD! };
test.use({ account });

test.describe("Query Interface", () => {
test('should be able to display information on multiple queries', async ({ page }) => {
await page.getByRole('combobox').first().click();
const corpusPromise = page.waitForResponse('https://noskecrystal5corpsum.acdh-dev.oeaw.ac.at/run.cgi/corp_info?corpname=amc_4.2&subcorpora=1&format=json');
await page.getByRole('option', { name: 'amc_4.2' }).click();
test("should be able to display information on multiple queries", async ({ page }) => {
await page.getByRole("combobox").first().click();
const corpusPromise = page.waitForResponse(
"https://noskecrystal5corpsum.acdh-dev.oeaw.ac.at/run.cgi/corp_info?corpname=amc_4.2&subcorpora=1&format=json",
);
await page.getByRole("option", { name: "amc_4.2" }).click();
await corpusPromise;
await expect(page.locator('form')).toContainText('Number of tokens:');
await page.getByPlaceholder('Your search term').fill('haus')
await page.getByPlaceholder('Your search term').press('Enter');
await expect(page.locator('div:nth-child(1) > .v-card-title > div > .text-xl')).toBeVisible();
await expect(page.locator('div:nth-child(1) > .v-card-title > div > .text-xl')).toHaveText('haus');
await expect(page.locator('.flex > span > .v-chip__content').first()).toBeVisible()
await expect(page.locator('.flex > span > .v-chip__content').first()).toHaveText('amc_4.2');
await expect(page.locator('.flex > span > .v-chip__content').nth(1)).toBeVisible();
await expect(page.locator('.flex > span > .v-chip__content').nth(1)).toHaveText('iqueryrow');
await expect(page.locator("form")).toContainText("Number of tokens:");
await page.getByPlaceholder("Your search term").fill("haus");
await page.getByPlaceholder("Your search term").press("Enter");
await expect(page.locator("div:nth-child(1) > .v-card-title > div > .text-xl")).toBeVisible();
await expect(page.locator("div:nth-child(1) > .v-card-title > div > .text-xl")).toHaveText(
"haus",
);
await expect(page.locator(".flex > span > .v-chip__content").first()).toBeVisible();
await expect(page.locator(".flex > span > .v-chip__content").first()).toHaveText("amc_4.2");
await expect(page.locator(".flex > span > .v-chip__content").nth(1)).toBeVisible();
await expect(page.locator(".flex > span > .v-chip__content").nth(1)).toHaveText("iqueryrow");

await page.getByRole('combobox').first().click();
await page.getByRole('option', { name: 'amc_3.2' }).click();
await page.getByRole('combobox').nth(2).click();
await page.getByRole('option', { name: 'Word search' }).click();
await page.getByPlaceholder('Your search term').click();
await page.getByPlaceholder('Your search term').fill('tomate');
await page.getByPlaceholder('Your search term').press('Enter');
await expect(page.locator('div:nth-child(2) > .v-card-title > div > .text-xl')).toBeVisible();
await expect(page.locator('div:nth-child(2) > .v-card-title > div > .text-xl')).toHaveText('tomate');
await expect(page.locator('div:nth-child(2) > .v-card-text > .flex > span > .v-chip__content').first()).toBeVisible()
await expect(page.locator('div:nth-child(2) > .v-card-text > .flex > span > .v-chip__content').first()).toHaveText('amc_3.2');
await expect(page.locator('div:nth-child(2) > .v-card-text > .flex > span > .v-chip__content').nth(1)).toBeVisible();
await expect(page.locator('div:nth-child(2) > .v-card-text > .flex > span > .v-chip__content').nth(1)).toHaveText('wordrow');
await page.getByRole("combobox").first().click();
await page.getByRole("option", { name: "amc_3.2" }).click();
await page.getByRole("combobox").nth(2).click();
await page.getByRole("option", { name: "Word search" }).click();
await page.getByPlaceholder("Your search term").click();
await page.getByPlaceholder("Your search term").fill("tomate");
await page.getByPlaceholder("Your search term").press("Enter");
await expect(page.locator("div:nth-child(2) > .v-card-title > div > .text-xl")).toBeVisible();
await expect(page.locator("div:nth-child(2) > .v-card-title > div > .text-xl")).toHaveText(
"tomate",
);
await expect(
page.locator("div:nth-child(2) > .v-card-text > .flex > span > .v-chip__content").first(),
).toBeVisible();
await expect(
page.locator("div:nth-child(2) > .v-card-text > .flex > span > .v-chip__content").first(),
).toHaveText("amc_3.2");
await expect(
page.locator("div:nth-child(2) > .v-card-text > .flex > span > .v-chip__content").nth(1),
).toBeVisible();
await expect(
page.locator("div:nth-child(2) > .v-card-text > .flex > span > .v-chip__content").nth(1),
).toHaveText("wordrow");
});
test('should be able select a corpus and select the available subcorpora', async ({ page }) => {
await page.getByRole('combobox').first().click();
const corpusPromise = page.waitForResponse('https://noskecrystal5corpsum.acdh-dev.oeaw.ac.at/run.cgi/corp_info?corpname=amc_4.2&subcorpora=1&format=json');
await page.getByRole('option', { name: 'amc_4.2' }).click();
test("should be able select a corpus and select the available subcorpora", async ({ page }) => {
await page.getByRole("combobox").first().click();
const corpusPromise = page.waitForResponse(
"https://noskecrystal5corpsum.acdh-dev.oeaw.ac.at/run.cgi/corp_info?corpname=amc_4.2&subcorpora=1&format=json",
);
await page.getByRole("option", { name: "amc_4.2" }).click();
await corpusPromise;
await expect(page.locator('form')).toContainText('Number of tokens:');
await page.getByRole('combobox').nth(1).click();
await page.locator('div').filter({ hasText: /^AustriazismenSFB$/ }).first().click();
await expect(page.locator('form')).toContainText('tokens:');
await expect(page.locator("form")).toContainText("Number of tokens:");
await page.getByRole("combobox").nth(1).click();
await page
.locator("div")
.filter({ hasText: /^AustriazismenSFB$/ })
.first()
.click();
await expect(page.locator("form")).toContainText("tokens:");
});
});
22 changes: 12 additions & 10 deletions e2e/pages/results.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { expect } from '@playwright/test';
import { expect } from "@playwright/test";

import { search as test } from '../fixtures/corpsum.fixtures';
import { search as test } from "../fixtures/corpsum.fixtures";

const account = { username: process.env.TEST_USER!, password: process.env.TEST_PASSWORD! };
test.use({ account, term: 'haus' });
test.use({ account, term: "haus" });

test.describe("Search Result Display", () => {
test('should be able to display result information on selected searches', async ({page}) => {
await expect(page.locator('div:nth-child(1) > .v-card-title > div > .text-xl')).toBeVisible();
await expect(page.locator('div:nth-child(1) > .v-card-title > div > .text-xl')).toHaveText('haus');
await expect(page.locator('.flex > span > .v-chip__content').first()).toBeVisible()
await expect(page.locator('.flex > span > .v-chip__content').first()).toHaveText('amc_4.2');
await expect(page.locator('.flex > span > .v-chip__content').nth(1)).toBeVisible();
await expect(page.locator('.flex > span > .v-chip__content').nth(1)).toHaveText('iqueryrow');
test("should be able to display result information on selected searches", async ({ page }) => {
await expect(page.locator("div:nth-child(1) > .v-card-title > div > .text-xl")).toBeVisible();
await expect(page.locator("div:nth-child(1) > .v-card-title > div > .text-xl")).toHaveText(
"haus",
);
await expect(page.locator(".flex > span > .v-chip__content").first()).toBeVisible();
await expect(page.locator(".flex > span > .v-chip__content").first()).toHaveText("amc_4.2");
await expect(page.locator(".flex > span > .v-chip__content").nth(1)).toBeVisible();
await expect(page.locator(".flex > span > .v-chip__content").nth(1)).toHaveText("iqueryrow");
});
});
5 changes: 3 additions & 2 deletions src/app.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script setup lang="ts">
const auth = useAuth();
const route = useRoute()
const route = useRoute();
onMounted(async () => {
if (!auth.username && (route.path === "/en" || route.path === "/de")) return navigateTo("/en/login");
if (!auth.username && (route.path === "/en" || route.path === "/de"))
return navigateTo("/en/login");
});
</script>

Expand Down
5 changes: 3 additions & 2 deletions src/components/DataDisplay/DataDisplayKeywordInContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ async function createSubcorpus() {
title: t("createSubcorpus"),
text: `${t("createSubcorpusConfirm1")} '${subCorpusName.value}' ${t(
"createSubcorpusConfirm2",
)} ${selected.value.length || 0} ${t("createSubcorpusConfirm3")} ${selectedCorpus.value
?.name}?`,
)} ${selected.value.length || 0} ${t("createSubcorpusConfirm3")} ${
selectedCorpus.value?.name
}?`,
showDenyButton: true,
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/Search/SearchDimensions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ const { selectedSearches, possibleSearchKeys } = storeToRefs(searchSettings);
chips
:items="possibleSearchKeys"
>
<template v-slot:chip="{ props, item }">
<template #chip="{ props, item }">
<VChip v-bind="props" :text="t(item.value)"></VChip>
</template>

<template v-slot:item="{ props, item }">
<template #item="{ props, item }">
<!-- @vue-ignore i18n typing doesn't seem to work for templated strings -->
<VListItem
v-bind="props"
Expand Down
2 changes: 1 addition & 1 deletion src/components/imprint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const imprint = await useFetch(String(createImprintUrl(locale.value, redmineId))
responseType: "text",
onResponseError(error) {
throw createError({ fatal: true, statusCode: error.response.status });
}
},
});
</script>

Expand Down
15 changes: 7 additions & 8 deletions src/pages/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ definePageMeta({
title: "LoginPage.meta.title",
});
const localeRoute = useLocaleRoute()
const { locale } = useI18n()
const localeRoute = useLocaleRoute();
const { locale } = useI18n();
const auth = useAuth();
const username = ref("");
const password = ref("");
async function login() {
if (!(await auth.login(username.value, password.value)))
return alert(t('WrongCredentials'));
await navigateTo(localeRoute('/', locale.value));
if (!(await auth.login(username.value, password.value))) return alert(t("WrongCredentials"));
await navigateTo(localeRoute("/", locale.value));
}
onMounted(async () => {
if (auth.basicAuthToken) await navigateTo(localeRoute('/', locale.value));
if (auth.basicAuthToken) await navigateTo(localeRoute("/", locale.value));
});
</script>

Expand All @@ -28,9 +27,9 @@ onMounted(async () => {
<VContainer class="flex justify-center">
<div class="flex w-full flex-col sm:w-1/2">
<h1>Please Login</h1>
<VTextField v-model="username" :label="t('username')" ></VTextField>
<VTextField v-model="username" :label="t('username')"></VTextField>
<VTextField v-model="password" type="password" :label="t('password')"></VTextField>
<VBtn type="submit" block>{{t('login')}}</VBtn>
<VBtn type="submit" block>{{ t("login") }}</VBtn>
</div>
</VContainer>
</VForm>
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
/**
* @see https://github.com/microsoft/TypeScript/issues/54057
*/
"incremental": false
}
"incremental": false,
},
}

0 comments on commit 2184cbb

Please sign in to comment.