-
Notifications
You must be signed in to change notification settings - Fork 25
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
Showing
3 changed files
with
18 additions
and
41 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
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 |
---|---|---|
|
@@ -19,49 +19,25 @@ import selectors from "../support/selectors"; | |
|
||
context("Transcript Export Tests", () => { | ||
|
||
const deleteDownloadDir = () => { | ||
try { | ||
cy.log('trying to remove downloads dir') | ||
cy.exec('rm cypress/downloads/*'); | ||
cy.log('remove downloads dir') | ||
} catch (error) { | ||
throw Error(`Failed to remove downloads with ${error}`); | ||
} finally { | ||
return null; | ||
} | ||
}; | ||
|
||
|
||
beforeEach(() => { | ||
deleteDownloadDir() | ||
|
||
Cypress.Commands.add("printLocInfo", () => { | ||
cy.wait(2000) | ||
cy.exec('ls ./').then((result) => { | ||
cy.log(result.stdout); | ||
}); | ||
cy.exec('ls ./cypress/downloads').then((result) => { | ||
cy.log(result.stdout); | ||
}); | ||
}) | ||
}) | ||
if (Utils.skillsServiceVersionLaterThan('3.1.0')) { | ||
const expectedHeaderAndFooter = 'For All Dragons enjoyment' | ||
const expectedHeaderAndFooterCommunityProtected = 'For Divine Dragon enjoyment' | ||
|
||
it('export user transcript', () => { | ||
cy.createDefaultTinyProject() | ||
const projName = 'Export1' | ||
cy.createDefaultTinyProject('proj1', projName) | ||
|
||
// visit client display | ||
cy.visitSkillsDisplay(); | ||
cy.clientDisplay().find(selectors.titleSection).contains('User Skills'); | ||
cy.clientDisplay().find(selectors.myRankButton) | ||
|
||
cy.wrapIframe().find('[data-cy="downloadTranscriptBtn"]').click() | ||
cy.printLocInfo() | ||
|
||
Cypress.Commands.add("readTranscript", () => { | ||
const pathToPdf = './cypress/downloads/Very Cool Project with id proj1 - user1 - Transcript.pdf' | ||
const pathToPdf = `./cypress/downloads/${projName} - user1 - Transcript.pdf` | ||
cy.readFile(pathToPdf, { timeout: 10000 }).then(() => { | ||
// file exists and was successfully read | ||
cy.log(`Transcript [${pathToPdf}] Found!`) | ||
|
@@ -74,7 +50,7 @@ context("Transcript Export Tests", () => { | |
cy.readTranscript().then((doc) => { | ||
expect(doc.numpages).to.equal(2) | ||
expect(clean(doc.text)).to.include('SkillTree Transcript') | ||
expect(clean(doc.text)).to.include('Very Cool Project with id proj1') | ||
expect(clean(doc.text)).to.include(projName) | ||
expect(clean(doc.text)).to.include('Level: 0 / 5 ') | ||
expect(clean(doc.text)).to.include('Points: 0 / 100 ') | ||
expect(clean(doc.text)).to.include('Skills: 0 / 2 ') | ||
|
@@ -98,7 +74,8 @@ context("Transcript Export Tests", () => { | |
res.send(conf); | ||
}); | ||
}).as('getPublicConfig'); | ||
cy.createDefaultTinyProject() | ||
const projName = 'Export2' | ||
cy.createDefaultTinyProject('proj1', projName) | ||
|
||
// visit client display | ||
cy.visitSkillsDisplay(); | ||
|
@@ -107,9 +84,8 @@ context("Transcript Export Tests", () => { | |
cy.clientDisplay().find(selectors.myRankButton) | ||
|
||
cy.wrapIframe().find('[data-cy="downloadTranscriptBtn"]').click() | ||
cy.printLocInfo() | ||
Cypress.Commands.add("readTranscript", () => { | ||
const pathToPdf = 'cypress/downloads/Very Cool Project with id proj1 - user1 - Transcript.pdf' | ||
const pathToPdf = `cypress/downloads/${projName} - user1 - Transcript.pdf` | ||
cy.readFile(pathToPdf, { timeout: 10000 }).then(() => { | ||
// file exists and was successfully read | ||
cy.log(`Transcript [${pathToPdf}] Found!`) | ||
|
@@ -122,7 +98,7 @@ context("Transcript Export Tests", () => { | |
cy.readTranscript().then((doc) => { | ||
expect(doc.numpages).to.equal(2) | ||
expect(clean(doc.text)).to.include('SkillTree Transcript') | ||
expect(clean(doc.text)).to.include('Very Cool Project with id proj1') | ||
expect(clean(doc.text)).to.include(projName) | ||
expect(clean(doc.text)).to.include('Level: 0 / 5 ') | ||
expect(clean(doc.text)).to.include('Points: 0 / 100 ') | ||
expect(clean(doc.text)).to.include('Skills: 0 / 2 ') | ||
|
@@ -146,7 +122,8 @@ context("Transcript Export Tests", () => { | |
res.send(conf); | ||
}); | ||
}).as('getPublicConfig'); | ||
cy.createDefaultTinyProject() | ||
const projName = 'Export3' | ||
cy.createDefaultTinyProject('proj1', projName) | ||
|
||
const allDragonsUser = '[email protected]' | ||
cy.fixture('vars.json').then((vars) => { | ||
|
@@ -164,7 +141,7 @@ context("Transcript Export Tests", () => { | |
}); | ||
cy.backendPost(`/admin/projects/proj1`, { | ||
projectId: 'proj1', | ||
name: `Very Cool Project with id proj1`, | ||
name: projName, | ||
enableProtectedUserCommunity: true | ||
}) | ||
|
||
|
@@ -175,9 +152,8 @@ context("Transcript Export Tests", () => { | |
cy.clientDisplay().find(selectors.myRankButton) | ||
|
||
cy.wrapIframe().find('[data-cy="downloadTranscriptBtn"]').click() | ||
cy.printLocInfo() | ||
Cypress.Commands.add("readTranscript", () => { | ||
const pathToPdf = 'cypress/downloads/Very Cool Project with id proj1 - Firstname LastName (user1) - Transcript.pdf' | ||
const pathToPdf = `cypress/downloads/${projName} - Firstname LastName (user1) - Transcript.pdf` | ||
cy.readFile(pathToPdf, { timeout: 10000 }).then(() => { | ||
// file exists and was successfully read | ||
cy.log(`Transcript [${pathToPdf}] Found!`) | ||
|
@@ -190,7 +166,7 @@ context("Transcript Export Tests", () => { | |
cy.readTranscript().then((doc) => { | ||
expect(doc.numpages).to.equal(2) | ||
expect(clean(doc.text)).to.include('SkillTree Transcript') | ||
expect(clean(doc.text)).to.include('Very Cool Project with id proj1') | ||
expect(clean(doc.text)).to.include(projName) | ||
expect(clean(doc.text)).to.include('Level: 0 / 5 ') | ||
expect(clean(doc.text)).to.include('Points: 0 / 100 ') | ||
expect(clean(doc.text)).to.include('Skills: 0 / 2 ') | ||
|
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