Skip to content

Commit aa4b9ca

Browse files
authored
feat: create preheat scope add percentage and count (#535)
1 parent b3769f3 commit aa4b9ca

File tree

13 files changed

+452
-56
lines changed

13 files changed

+452
-56
lines changed

cypress/e2e/job/preheats/create-preheat.cy.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,36 @@ describe('Create preheat', () => {
3939
cy.viewport(1440, 1080);
4040
});
4141

42+
it('can create an All Peers task with a preheat scope of 30%', () => {
43+
// By default, there is no percentage and count.
44+
cy.get('#count-or-percentage').should('not.exist');
45+
46+
// Scope select all peers.
47+
cy.get('#select-scope').click();
48+
cy.get('#all_peers').click();
49+
50+
cy.get('#all').should('have.text', `Preheat to each peer in the P2P cluster.`);
51+
52+
cy.get('#count-or-percentage').should('exist');
53+
54+
cy.get('#radio-percentage').click();
55+
56+
cy.get('#percentage').click(100, 10);
57+
58+
// Select count.
59+
cy.get('#radio-count').click();
60+
61+
cy.get('#count').click();
62+
63+
cy.get('#count').type('50');
64+
65+
// Scope select all seed peers.
66+
cy.get('#select-scope').click();
67+
cy.get('#all_seed_peers').click();
68+
69+
cy.get('#all').should('have.text', `Preheat to each seed peer in the P2P cluster.`);
70+
});
71+
4272
it('click the `CANCEL button', () => {
4373
cy.get('#cancel').click();
4474

@@ -427,6 +457,27 @@ describe('Create preheat', () => {
427457

428458
cy.get('#url').type('https://docs');
429459

460+
// Should display message Piece Length the validation error.
461+
cy.get('#select-scope').click();
462+
cy.get('#all_peers').click();
463+
464+
cy.get('#radio-count').click();
465+
466+
cy.get('#count').should('have.value', '1');
467+
468+
cy.get('#count').clear();
469+
470+
cy.get('#count').type('0');
471+
472+
// Show verification error message.
473+
cy.get('#count-helper-text').should('have.text', 'Fill in the characters, the length is 1-200.');
474+
475+
cy.get('#count').clear();
476+
477+
cy.get('#count').type('201');
478+
479+
cy.get('#count-helper-text').should('have.text', 'Fill in the characters, the length is 1-200.');
480+
430481
// Should display message Piece Length the validation error.
431482
cy.get('#pieceLength').type('0');
432483

cypress/e2e/job/preheats/preheat.cy.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ describe('Preheat', () => {
9898
cy.get('[data-testid="preheat-isloading"]').should('not.exist');
9999

100100
// Show preheat scope.
101-
cy.get('#scope').should('have.text', 'All Peers');
101+
cy.get('#scope').should('contain', 'All Peers');
102+
103+
// Show preheat scope count.
104+
cy.get('#count').should('contain', '100');
102105

103106
// Show preheat status.
104107
cy.get('#status')
@@ -208,7 +211,10 @@ describe('Preheat', () => {
208211
.and('not.exist');
209212

210213
// Show preheat scope.
211-
cy.get('#scope').should('have.text', 'All Seed Peers');
214+
cy.get('#scope').should('contain', 'All Seed Peers');
215+
216+
// Show preheat scope.
217+
cy.get('#percentage').should('contain', '100%');
212218

213219
// Show preheat piece length.
214220
cy.get('#piece-length').should('have.text', '-');

cypress/fixtures/job/preheats/failure-preheat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"application": "application-1",
1212
"concurrent_count": 50,
1313
"content_for_calculating_task_id": null,
14-
"count": null,
14+
"count": 100,
1515
"filtered_query_params": "X-Amz-Algorithm\u0026X-Amz-Credential\u0026X-Amz-Date\u0026X-Amz-Expires\u0026X-Amz-SignedHeaders\u0026X-Amz-Signature\u0026X-Amz-Security-Token\u0026X-Amz-User-Agent\u0026X-Goog-Algorithm\u0026X-Goog-Credential\u0026X-Goog-Date\u0026X-Goog-Expires\u0026X-Goog-SignedHeaders\u0026X-Goog-Signature\u0026OSSAccessKeyId\u0026Expires\u0026Signature\u0026SecurityToken\u0026AccessKeyId\u0026Signature\u0026Expires\u0026X-Obs-Date\u0026X-Obs-Security-Token\u0026q-sign-algorithm\u0026q-ak\u0026q-sign-time\u0026q-key-time\u0026q-header-list\u0026q-url-param-list\u0026q-signature\u0026x-cos-security-token\u0026ns",
1616
"headers": { "Connection": "keep-alive" },
1717
"load_to_cache": false,

cypress/fixtures/job/preheats/pending-preheat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"headers": { "Authorization": "Bearer yJhbGciOiJSUzI1NiIsImtpZCI6IjNEWT" },
1717
"load_to_cache": false,
1818
"password": "",
19-
"percentage": null,
19+
"percentage": 100,
2020
"piece_length": null,
2121
"platform": "",
2222
"scope": "all_seed_peers",

cypress/support/e2e.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@
1414
// ***********************************************************
1515

1616
// Import commands.js using ES2015 syntax:
17-
import './commands'
17+
import './commands';
1818

1919
// Alternatively you can use CommonJS syntax:
2020
// require('./commands')
21-
import '@cypress/code-coverage/support'
21+
import '@cypress/code-coverage/support';
22+
23+
Cypress.on('uncaught:exception', (err, runnable) => {
24+
// returning false here prevents Cypress from
25+
// failing the test
26+
return false;
27+
});
Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 6 additions & 0 deletions
Loading

src/components/job/preheats/new.module.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@
5959
background-color: var(--palette-background-paper) !important;
6060
}
6161

62+
.scope {
63+
width: 37rem;
64+
margin: 1rem 0;
65+
border-radius: 0.25rem !important;
66+
background-color: var(--palette-background-paper) !important;
67+
border-color: var(--palette-description-color) !important;
68+
}
69+
70+
.countSelect {
71+
width: 12rem;
72+
margin: 0.8rem 0 !important;
73+
}
74+
6275
.contentForCalculatingTaskIDIcon {
6376
width: 1.25rem;
6477
height: 1.25rem;

0 commit comments

Comments
 (0)