Skip to content

Commit

Permalink
Fix cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
wg102 committed Nov 20, 2024
1 parent 6526d15 commit 9b23b51
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
6 changes: 3 additions & 3 deletions components/centraldashboard/cypress/e2e/landing-page.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Landing Page', () => {
});

it('should access the landing page', ()=>{
cy.get('main-page').shadow().find('blocked-user-view').should('not.be.visible');
cy.get('main-page').shadow().find('blocked-user-view').should('not.exist');
cy.get('main-page').shadow().find('landing-page').should('exist');
cy.get('main-page').shadow().find('landing-page').shadow().find('#MainCard > neon-animatable > h2').should('have.text', 'Welcome');
cy.get('main-page').shadow().find('landing-page').shadow().find('#MainCard > neon-animatable > p').find('a').should('exist').and('have.prop', 'href', 'https://zone.pages.cloud.statcan.ca/docs/en/');
Expand Down Expand Up @@ -74,7 +74,7 @@ describe('Landing Page', () => {

//assert the main page and that the default notebook shows up
cy.get('main-page').shadow().find('landing-page').should('not.be.visible');
cy.get('main-page').shadow().find('blocked-user-view').should('not.be.visible');
cy.get('main-page').shadow().find('blocked-user-view').should('not.exist');
cy.get('main-page').shadow().find('dashboard-view').should('exist');
cy.get('main-page').shadow().find('dashboard-view').shadow().find('notebook-default-card').shadow().find('paper-card#DefaultNotebookCard').should('exist');
cy.get('main-page').shadow().find('dashboard-view').shadow().find('notebook-default-card').shadow().find('paper-card#DefaultNotebookCard > .data-content > .button-div > paper-button#Details').should('exist');
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('Landing Page', () => {

cy.wait(['@mockWorkgroupRequest', '@mockDashboardLinksRequest']);

cy.get('main-page').shadow().find('blocked-user-view').should('not.be.visible');
cy.get('main-page').shadow().find('blocked-user-view').should('not.exist');
cy.get('main-page').shadow().find('landing-page').should('exist');
cy.get('main-page').shadow().find('landing-page').shadow().find('#MainCard > neon-animatable > h2').should('have.text', 'Welcome');
cy.get('main-page').shadow().find('landing-page').shadow().find('#MainCard > neon-animatable > p').should('have.text', 'You are currently logged in using [email protected], this domain is not supported. Please log out and log in using your “@statcan.gc.ca” email.');
Expand Down
19 changes: 18 additions & 1 deletion components/centraldashboard/cypress/e2e/main-page.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Main Page', () => {

it('should access the dashboard', () => {
cy.get('main-page').should('exist');
cy.get('main-page').shadow().find('blocked-user-view').should('not.be.visible');
cy.get('main-page').shadow().find('blocked-user-view').should('not.exist');
cy.get('main-page').shadow().find('dashboard-view').should('exist');
// create new notebook link
cy.get('main-page').shadow().find('dashboard-view').shadow().find('paper-card#Quick-Links').should('exist');
Expand Down Expand Up @@ -168,6 +168,23 @@ describe('Main Page', () => {
cy.get('main-page').shadow().find('a[href="https://zone.pages.cloud.statcan.ca/docs/en/"]').find('paper-item').should('have.text', 'Documentation');
});

it('should block access to user', () =>{
cy.intercept('GET', `/api/workgroup/exists`, {
"hasAuth":true,
"user":"[email protected]",
"email": "[email protected]",
"hasWorkgroup":true,
"registrationFlowAllowed":true,
"isAllowed": false
}).as('mockWorkgroupRequest');
cy.visit('/');

cy.wait('@mockWorkgroupRequest');

cy.get('main-page').should('exist');
cy.get('main-page').shadow().find('blocked-user-view').should('exist');
});

describe('Notebook Default Card', () => {
it('should have a notebook card', () => {
cy.get('main-page').should('exist');
Expand Down
3 changes: 1 addition & 2 deletions components/centraldashboard/public/components/main-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class MainPage extends mixinBehaviors([AppLocalizeBehavior], utilitiesMix
allNamespaces: {type: Boolean, value: false, readOnly: true},
notFoundInIframe: {type: Boolean, value: false, readOnly: true},
registrationFlow: {type: Boolean, value: false, readOnly: true},
isAllowed: {type: Boolean, value: false, readOnly: true},
isAllowed: {type: Boolean, value: true, readOnly: true},
workgroupStatusHasLoaded: {
type: Boolean,
value: false,
Expand Down Expand Up @@ -259,7 +259,6 @@ export class MainPage extends mixinBehaviors([AppLocalizeBehavior], utilitiesMix
*/
_onHasWorkgroupError(ev) {
this.showError('mainPage.errGeneric');
this.isAllowed = true;
return;
}

Expand Down

0 comments on commit 9b23b51

Please sign in to comment.