Skip to content

feat: add title field and metadata handling for ZIM file creation #855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 22, 2025
Merged
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 Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pytest-cov = "*"
supervisor = "~=4.2"
yoyo-migrations = "==7.3.2"
pysocks = "*"
regex = "==2024.11.6"

# Versions required for dependabot
sqlparse = "~=0.5.0"
Expand Down
131 changes: 116 additions & 15 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 33 additions & 10 deletions wp1-frontend/cypress/e2e/zimFile.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,29 @@ describe('the zim file creation page', () => {
cy.get('#longdesc').should('be.visible');
});

it('validates the title input on losing focus', () => {
cy.get('#zimtitle').click();
cy.get('#zimtitle').clear();
cy.get('#longdesc').click();
cy.get('#zimtitle-group > .invalid-feedback').should('be.visible');
});

it('validates the title input to have max 30 graphemes', () => {
const longTitle = 'A'.repeat(31);
cy.get('#zimtitle').click();
cy.get('#zimtitle').clear();
cy.get('#zimtitle').type(longTitle);
cy.get('#zimtitle').should('have.value', longTitle.substring(0, 30));
});

it('handles graphems correctly', () => {
const longTitle = "में".repeat(30);
cy.get('#zimtitle').click();
cy.get('#zimtitle').clear();
cy.get('#zimtitle').type(longTitle);
cy.get('#zimtitle').should('have.value', "में".repeat(30));
});

it('validates the description input on losing focus', () => {
cy.get('#desc').click();
cy.get('#longdesc').click();
Expand All @@ -39,10 +62,10 @@ describe('the zim file creation page', () => {

it('displays the Request ZIM file button', () => {
cy.get('#request').should('be.visible');
cy.get('#request').should('not.have.attr', 'disabled');
cy.get('#request').should('have.attr', 'disabled');
});

describe('when the description is missing and the submit button is clicked', () => {
describe('when the description is missing', () => {
beforeEach(() => {
cy.intercept('POST', 'v1/builders/1/zim', () => {
throw new Error(
Expand All @@ -51,14 +74,14 @@ describe('the zim file creation page', () => {
}).as('request');
});

it('does not submit the form', () => {
cy.get('#request').click();
});
it('disables the submit button', () => {
cy.get('#request').should('have.attr', 'disabled');
});

it('shows the error message', () => {
cy.get('#request').click();
it('shows the error message', () => {
cy.get('#request').click({ force: true });
cy.get('#desc-group > .invalid-feedback').should('be.visible');
});
});
});

describe('when the Request ZIM file button is clicked', () => {
Expand Down Expand Up @@ -152,7 +175,7 @@ describe('the zim file creation page', () => {

it('displays the Request ZIM file button', () => {
cy.get('#request').should('be.visible');
cy.get('#request').should('not.have.attr', 'disabled');
cy.get('#request').should('have.attr', 'disabled');
});

describe('when the Request ZIM file button is clicked', () => {
Expand Down Expand Up @@ -194,7 +217,7 @@ describe('the zim file creation page', () => {

it('displays the Request ZIM file button', () => {
cy.get('#request').should('be.visible');
cy.get('#request').should('not.have.attr', 'disabled');
cy.get('#request').should('have.attr', 'disabled');
});
});
});
Expand Down
1 change: 1 addition & 0 deletions wp1-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"popper.js": "^1.16.0",
"postcss": "^8.4.31",
"serialize-javascript": "^3.1.0",
"split-by-grapheme": "^1.0.1",
"vite": "^3.2.11",
"vue": "^2.7.14",
"vue-router": "^3.1.6",
Expand Down
Loading