-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6634a4
commit e41c246
Showing
2 changed files
with
68 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,57 @@ | ||
import {TestHarness} from './harness'; | ||
import {ContentNode, TopologyNode} from './nodes'; | ||
|
||
it('manifest fetch on content nodes failure', () => { | ||
const projectId = 'test-proj'; | ||
const content0 = new ContentNode('content0', projectId, 'manifest-does-not-exist'); | ||
const topology0 = new TopologyNode('topology0', [content0]); | ||
describe('Manifest fetch tests', () => { | ||
it('manifest fetch on content nodes failure', () => { | ||
const projectId = 'test-proj'; | ||
const content0 = new ContentNode('content0', projectId); | ||
const topology0 = new TopologyNode('topology0', [content0]); | ||
|
||
const harness = new TestHarness(projectId, [topology0], [content0]); | ||
harness.intercept(); | ||
harness.spyOnMessages(window); | ||
const harness = new TestHarness(projectId, [topology0], [content0]); | ||
harness.intercept(); | ||
harness.spyOnMessages(window); | ||
|
||
content0.failResource('earthfast.json'); | ||
// Fail both primary and fallback manifest files | ||
content0.failResource('earthfast.json'); | ||
content0.failResource('armada.json'); | ||
|
||
cy.visit(harness.domainNode.url); | ||
cy.visit(harness.domainNode.url); | ||
|
||
cy.wrap(harness).should(harness => { | ||
// a single node failed | ||
expect(harness.messageTypes).to.include('MANIFEST_FETCH_ERROR'); | ||
cy.wrap(harness).should(harness => { | ||
// We expect two MANIFEST_FETCH_ERROR messages now, one for each file | ||
expect(harness.messageTypes.filter(type => type === 'MANIFEST_FETCH_ERROR').length) | ||
.to.equal(2); | ||
|
||
// all nodes failed | ||
expect(harness.messageTypes).to.include('MANIFEST_FETCH_FAILURE_NO_CONSENSUS'); | ||
// all nodes failed for both files | ||
expect(harness.messageTypes).to.include('MANIFEST_FETCH_FAILURE_NO_CONSENSUS'); | ||
}); | ||
}); | ||
}); | ||
|
||
it('manifest fetch fallback succeeds', () => { | ||
const projectId = 'test-proj'; | ||
const content0 = new ContentNode('content0', projectId); | ||
const topology0 = new TopologyNode('topology0', [content0]); | ||
|
||
const harness = new TestHarness(projectId, [topology0], [content0]); | ||
harness.intercept(); | ||
harness.spyOnMessages(window); | ||
|
||
// Fail the primary manifest file, but allow the fallback to succeed | ||
content0.failResource('earthfast.json'); | ||
content0.addResource('armada.json', '{"version": "1"}'); | ||
|
||
cy.visit(harness.domainNode.url); | ||
|
||
cy.wrap(harness).should(harness => { | ||
// We expect one MANIFEST_FETCH_ERROR message for the primary file | ||
expect(harness.messageTypes.filter(type => type === 'MANIFEST_FETCH_ERROR').length) | ||
.to.equal(1); | ||
|
||
// We don't expect a MANIFEST_FETCH_FAILURE_NO_CONSENSUS message | ||
expect(harness.messageTypes).not.to.include('MANIFEST_FETCH_FAILURE_NO_CONSENSUS'); | ||
|
||
// We might expect a successful initialization message, depending on your implementation | ||
expect(harness.messageTypes).to.include('INITIALIZED'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters