Skip to content

Commit 23d1cd4

Browse files
committed
Fixed Cypress Component tests after rebase #137
1 parent 8f62509 commit 23d1cd4

2 files changed

Lines changed: 23 additions & 24 deletions

File tree

cypress/tests/component/CodecheckReviewDisplay.cy.js

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ import '../../support/pkp-mock.js';
22
import CodecheckReviewDisplay from '../../../resources/js/Components/CodecheckReviewDisplay.vue';
33

44
describe('CodecheckReviewDisplay Component', () => {
5+
beforeEach(() => {
6+
let status = 'plugins.generic.codecheck.status.needsCodechecker';
7+
8+
cy.intercept('GET', '**/codecheck/status*', {
9+
statusCode: 200,
10+
body: {
11+
statusRecord: { status: status }
12+
}
13+
}).as('getStatus');
14+
});
15+
516
it('shows not opted in message when codecheckOptIn is false', () => {
617
cy.mount(CodecheckReviewDisplay, {
718
props: {
@@ -15,39 +26,28 @@ describe('CodecheckReviewDisplay Component', () => {
1526
cy.get('.codecheck-info').should('not.exist');
1627
});
1728

18-
it('shows pending status when opted in but no metadata', () => {
19-
cy.mount(CodecheckReviewDisplay, {
20-
props: {
21-
submission: {
22-
codecheckOptIn: true,
23-
codecheckMetadata: {}
24-
}
25-
}
26-
});
27-
28-
cy.get('.status-pending').should('exist');
29-
cy.contains('plugins.generic.codecheck.status.pending').should('exist');
30-
});
29+
it('shows status', () => {
30+
let status = 'plugins.generic.codecheck.status.needsCodechecker';
31+
32+
cy.intercept('GET', '**/codecheck/status*', {
33+
body: { statusRecord: { status: status } }
34+
}).as('getStatus');
3135

32-
it('shows in-progress status with partial metadata', () => {
3336
cy.mount(CodecheckReviewDisplay, {
3437
props: {
3538
submission: {
39+
id: 1,
3640
codecheckOptIn: true,
37-
codecheckMetadata: {
38-
configVersion: 'latest',
39-
manifest: [{ file: 'output.png' }],
40-
codecheckers: [{ name: 'John Doe' }]
41-
}
41+
codecheckMetadata: {}
4242
}
4343
}
4444
});
4545

46-
cy.get('.status-in-progress').should('exist');
47-
cy.contains('plugins.generic.codecheck.status.inProgress').should('exist');
46+
cy.wait('@getStatus');
47+
cy.contains(status).should('exist');
4848
});
4949

50-
it('shows complete status with full metadata', () => {
50+
it('shows complete information with full metadata', () => {
5151
cy.mount(CodecheckReviewDisplay, {
5252
props: {
5353
submission: {
@@ -67,7 +67,6 @@ describe('CodecheckReviewDisplay Component', () => {
6767
}
6868
});
6969

70-
cy.get('.status-complete').should('exist');
7170
cy.contains('CODECHECK-2024-001').should('exist');
7271
cy.contains('John Doe').should('exist');
7372
cy.contains('0000-0001-2345-6789').should('exist');

resources/js/Components/CodecheckReviewDisplay.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const dataLoaded = ref(false);
101101
102102
onMounted(async () => {
103103
try {
104-
if (!props.submission?.id) return;
104+
if (!props.submission?.id) {dataLoaded.value = true; return};
105105
106106
const submissionId = props.submission.id;
107107
const apiUrl = `${pkp.context.apiBaseUrl}codecheck/status?submissionId=${submissionId}`;

0 commit comments

Comments
 (0)