Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions extralit-frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
node_modules
/test-results/
/playwright-report/
/playwright/.cache/
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ describe("useDocumentViewModel", () => {

// Get the computed function that was passed to mockComputed
const computedCalls = mockComputed.mock.calls;
const hasDocumentLoadedCall = computedCalls.find(
(call) => call[0].toString().includes("document.id")
);
const hasDocumentLoadedCall = computedCalls.find((call) => call[0].toString().includes("document.id"));

expect(hasDocumentLoadedCall).toBeDefined();
const hasDocumentLoaded = hasDocumentLoadedCall[0]();
Expand All @@ -127,9 +125,7 @@ describe("useDocumentViewModel", () => {

// Get the computed function that was passed to mockComputed
const computedCalls = mockComputed.mock.calls;
const hasDocumentLoadedCall = computedCalls.find(
(call) => call[0].toString().includes("document.id")
);
const hasDocumentLoadedCall = computedCalls.find((call) => call[0].toString().includes("document.id"));

expect(hasDocumentLoadedCall).toBeDefined();
const hasDocumentLoaded = hasDocumentLoadedCall[0]();
Expand All @@ -144,7 +140,7 @@ describe("useDocumentViewModel", () => {

mockGetDocumentUseCase.createParams.mockReturnValue({
workspace_id: workspaceId,
pmid: "12345"
pmid: "12345",
});

useDocumentViewModel({ record: { metadata } });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

<div
class="settings__edition-form__group --subcategories"
v-if="question.isMultiLabelType || question.isSingleLabelType || question.isSpanType || question.isRankingType"
v-if="
question.isMultiLabelType || question.isSingleLabelType || question.isSpanType || question.isRankingType
"
>
<label :for="`options-${question.id}`" v-text="$t('question.labels')" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const useSettingsQuestionsViewModel = () => {

question.settings.options.push({
value: text.toLowerCase().replace(/\s+/g, '_'),
text: text
text
});

newLabelText.value[question.id] = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</BaseButton>
</div>
<BaseButton @click="addOption" class="secondary small dataset-config-ranking__add-button"
><svgicon name="plus" width="12" color="var(--fg-secondary)" /> {{$t("question.addLabel")}}</BaseButton
><svgicon name="plus" width="12" color="var(--fg-secondary)" /> {{ $t("question.addLabel") }}</BaseButton
>
</div>
</template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mount } from '@vue/test-utils';
import DocumentsList from './DocumentsList.vue';
import { Document } from '~/v1/domain/entities/document/Document';
import { mount } from "@vue/test-utils";
import DocumentsList from "./DocumentsList.vue";
import { Document } from "~/v1/domain/entities/document/Document";

// Mock the view model
const mockShowDocumentMetadata = jest.fn();
Expand All @@ -13,36 +13,36 @@ const mockViewModel = {
totalFiles: 0,
showMetadataModal: false,
selectedDocumentMetadata: null,
selectedDocumentName: '',
selectedDocumentName: "",
loadDocuments: jest.fn(),
openDocument: jest.fn(),
showDocumentMetadata: mockShowDocumentMetadata,
closeMetadataModal: mockCloseMetadataModal,
};

jest.mock('./useDocumentsListViewModel', () => ({
jest.mock("./useDocumentsListViewModel", () => ({
useDocumentsListViewModel: () => mockViewModel,
}));

// Mock base components
jest.mock('~/components/base/base-modal/BaseModal.vue', () => ({
name: 'BaseModal',
jest.mock("~/components/base/base-modal/BaseModal.vue", () => ({
name: "BaseModal",
template: '<div class="base-modal"><slot /></div>',
props: ['modalVisible', 'modalTitle', 'modalClass'],
props: ["modalVisible", "modalTitle", "modalClass"],
}));

jest.mock('~/components/base/base-button/BaseButton.vue', () => ({
name: 'BaseButton',
jest.mock("~/components/base/base-button/BaseButton.vue", () => ({
name: "BaseButton",
template: '<button class="base-button" @click="$emit(\'click\')"><slot /></button>',
}));

describe('DocumentsList', () => {
describe("DocumentsList", () => {
let wrapper;

const createWrapper = (props = {}) => {
return mount(DocumentsList, {
propsData: {
workspaceId: 'test-workspace',
workspaceId: "test-workspace",
...props,
},
stubs: {
Expand All @@ -67,7 +67,7 @@ describe('DocumentsList', () => {
mockViewModel.documents = [];
mockViewModel.showMetadataModal = false;
mockViewModel.selectedDocumentMetadata = null;
mockViewModel.selectedDocumentName = '';
mockViewModel.selectedDocumentName = "";
mockViewModel.groupedDocuments = [];

wrapper = createWrapper();
Expand All @@ -77,27 +77,29 @@ describe('DocumentsList', () => {
wrapper.destroy();
});

describe('metadata modal functionality', () => {
it('should show metadata button when document has metadata', async () => {
describe("metadata modal functionality", () => {
it("should show metadata button when document has metadata", async () => {
const documentWithMetadata = new Document(
'doc-1',
'http://example.com/doc.pdf',
'test.pdf',
'pmid123',
'doi123',
"doc-1",
"http://example.com/doc.pdf",
"test.pdf",
"pmid123",
"doi123",
1,
'Test Reference',
"Test Reference",
[],
{ workflow_status: 'completed', analysis_metadata: { ocr_quality: { total_chars: 1000 } } }
{ workflow_status: "completed", analysis_metadata: { ocr_quality: { total_chars: 1000 } } }
);

// Update the mock view model data instead of using setData
mockViewModel.documents = [documentWithMetadata];
mockViewModel.groupedDocuments = [{
reference: 'Test Reference',
documents: [documentWithMetadata],
metadata: documentWithMetadata.metadata
}];
mockViewModel.groupedDocuments = [
{
reference: "Test Reference",
documents: [documentWithMetadata],
metadata: documentWithMetadata.metadata,
},
];

await wrapper.vm.$nextTick();

Expand All @@ -106,33 +108,35 @@ describe('DocumentsList', () => {
expect(mockViewModel.documents[0].metadata).toBeDefined();
});

it('should open metadata modal when metadata button is clicked', async () => {
it("should open metadata modal when metadata button is clicked", async () => {
const testMetadata = {
workflow_status: 'completed',
workflow_status: "completed",
analysis_metadata: {
ocr_quality: { total_chars: 1000, ocr_quality_score: 0.95 }
}
ocr_quality: { total_chars: 1000, ocr_quality_score: 0.95 },
},
};

const documentWithMetadata = new Document(
'doc-1',
'http://example.com/doc.pdf',
'test-document.pdf',
'pmid123',
'doi123',
"doc-1",
"http://example.com/doc.pdf",
"test-document.pdf",
"pmid123",
"doi123",
1,
'Test Reference',
"Test Reference",
[],
testMetadata
);

// Update the mock view model data
mockViewModel.documents = [documentWithMetadata];
mockViewModel.groupedDocuments = [{
reference: 'Test Reference',
documents: [documentWithMetadata],
metadata: documentWithMetadata.metadata
}];
mockViewModel.groupedDocuments = [
{
reference: "Test Reference",
documents: [documentWithMetadata],
metadata: documentWithMetadata.metadata,
},
];

await wrapper.vm.$nextTick();

Expand All @@ -144,11 +148,11 @@ describe('DocumentsList', () => {
expect(mockShowDocumentMetadata).toHaveBeenCalledTimes(1);
});

it('should close metadata modal when closeMetadataModal is called', () => {
it("should close metadata modal when closeMetadataModal is called", () => {
// Set up initial modal state
mockViewModel.showMetadataModal = true;
mockViewModel.selectedDocumentMetadata = { some: 'data' };
mockViewModel.selectedDocumentName = 'test.pdf';
mockViewModel.selectedDocumentMetadata = { some: "data" };
mockViewModel.selectedDocumentName = "test.pdf";

// Call the method through the mock
mockCloseMetadataModal();
Expand All @@ -157,4 +161,4 @@ describe('DocumentsList', () => {
expect(mockCloseMetadataModal).toHaveBeenCalledTimes(1);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("useImportBatchProgressViewModel", () => {
workspace: { id: "workspace-1" },
uploadData: {
confirmedDocuments: {},
documentActions: {}
documentActions: {},
},
bibFileName: "test.bib",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<ul class="oauth__container__providers">
<li v-for="provider in providers" :key="provider.name">
<HuggingFaceButton v-if="provider.isHuggingFace" @click="authorize(provider.name)" />
<ExtralitHubButton v-else-if="provider.isExtralitHub" @click="authorize(provider.name)" />
<OAuthLoginButton v-else :provider="provider.name" @click="authorize(provider.name)" />
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<template>
<BaseButton class="button-extralit-hub" @click="$emit('click')">
<brand-icon class="brand-icon" color="white" aria-label="Extralit icon" />
{{ $t("button.extralithub-login") }}
</BaseButton>
</template>

<script>
export default {
name: "ExtralitHubButton",
};
</script>

<style lang="scss" scoped>
.button-extralit-hub {
@extend %button !optional;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: var(--color-white);
width: 100%;
min-height: $base-space * 6;
padding: calc($base-space / 2) $base-space * 4;
justify-content: center;
border: none;
transition: all 0.3s ease;

&:hover {
background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

&:active {
transform: translateY(0);
}

svg {
width: 30px;
height: auto;
margin-right: $base-space;
}
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<!-- Simplified Extralit logo -->
<rect width="32" height="32" rx="6" fill="url(#gradient)" />
<path d="M8 12h16v2H8v-2zm0 4h12v2H8v-2zm0 4h16v2H8v-2z" fill="white" opacity="0.9" />
<circle cx="22" cy="10" r="2" fill="white" opacity="0.8" />
<defs>
<linearGradient id="gradient" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color: #667eea; stop-opacity: 1" />
<stop offset="100%" style="stop-color: #764ba2; stop-opacity: 1" />
</linearGradient>
</defs>
</svg>
</template>

<script>
export default {
name: "ExtralitLogo",
};
</script>
1 change: 1 addition & 0 deletions extralit-frontend/translation/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export default {
login: "Anmelden",
signin_with_provider: "Mit {provider} anmelden",
"hf-login": "Mit Hugging Face anmelden",
"extralithub-login": "Mit Extralit Hub anmelden",
sign_in_with_username: "Mit Benutzername anmelden",
cancel: "Abbrechen",
continue: "Fortfahren",
Expand Down
1 change: 1 addition & 0 deletions extralit-frontend/translation/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export default {
login: "Sign in",
signin_with_provider: "Sign in with {provider}",
"hf-login": "Sign in with Hugging Face",
"extralithub-login": "Sign in with Extralit Hub",
sign_in_with_username: "Sign in with username",
cancel: "Cancel",
confirmCancel: "Are you sure you want to cancel? Any unsaved changes will be lost.",
Expand Down
1 change: 1 addition & 0 deletions extralit-frontend/translation/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export default {
login: "Iniciar sesión",
signin_with_provider: "Iniciar sesión con {provider}",
"hf-login": "Iniciar sesión con Hugging Face",
"extralithub-login": "Iniciar sesión con Extralit Hub",
sign_in_with_username: "Iniciar sesión con nombre de usuario",
cancel: "Cancelar",
continue: "Continuar",
Expand Down
1 change: 1 addition & 0 deletions extralit-frontend/translation/ja.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export default {
login: "サインイン",
signin_with_provider: "{provider}でサインイン",
"hf-login": "Hugging Faceでサインイン",
"extralithub-login": "Extralit Hubでサインイン",
sign_in_with_username: "ユーザー名でサインイン",
cancel: "キャンセル",
continue: "続ける",
Expand Down
Loading