Skip to content

Commit

Permalink
Worked on review comments for refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
subsingh-akamai committed Sep 5, 2024
1 parent c838bae commit dbc04a5
Showing 1 changed file with 15 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ const mockLinodes = new Array(5).fill(null).map(

const mockLinodesData = makeResourcePage(mockLinodes);

const emptyLinode: Linode[] = [];

const emptyLinodeData = makeResourcePage(emptyLinode);

const sortByRegion = (a: Linode, b: Linode) => {
return a.region.localeCompare(b.region);
};
Expand Down Expand Up @@ -399,23 +395,17 @@ describe('linode landing checks', () => {

describe('linode landing checks for empty state', () => {
beforeEach(() => {
const mockAccountSettings = accountSettingsFactory.build({
managed: false,
});

cy.intercept('GET', apiMatcher('account/settings'), (req) => {
req.reply(mockAccountSettings);
}).as('getAccountSettings');
cy.intercept('GET', apiMatcher('profile')).as('getProfile');
cy.intercept('GET', apiMatcher('linode/instances/*'), (req) => {
req.reply(emptyLinodeData);
});
cy.visitWithLogin('/', { preferenceOverrides });
cy.wait('@getAccountSettings');
cy.url().should('endWith', routes.linodeLanding);
// Mock setup to display the Linode landing page in an empty state
mockGetLinodes([]).as('getLinodes');
});

it('checks empty state on linode landing page', () => {
// Login and wait for application to load
cy.visitWithLogin(routes.linodeLanding);
cy.wait('@getLinodes');
cy.url().should('endWith', routes.linodeLanding);

// Aliases created for accessing child elements during assertions
cy.get('div[data-qa-placeholder-container="resources-section"]').as(
'resourcesSection'
);
Expand Down Expand Up @@ -461,10 +451,10 @@ describe('linode landing checks for empty state', () => {
.contains('Download CSV')
.should('not.exist');
});
});

describe('linode landing checks for restricted user', () => {
beforeEach(() => {
it('checks restricted user has no access to create linode on linode landing page', () => {
// Mock setup for user profile, account user, and user grants with restricted permissions,
// simulating a default user without the ability to add Linodes.
const mockProfile = profileFactory.build({
username: randomLabel(),
restricted: true,
Expand All @@ -485,14 +475,12 @@ describe('linode landing checks for restricted user', () => {
mockGetProfile(mockProfile);
mockGetProfileGrants(mockGrants);
mockGetUser(mockUser);
cy.intercept('GET', apiMatcher('linode/instances/*'), (req) => {
req.reply(emptyLinodeData);
});
cy.visitWithLogin('/', { preferenceOverrides });

// Login and wait for application to load
cy.visitWithLogin(routes.linodeLanding);
cy.wait('@getLinodes');
cy.url().should('endWith', routes.linodeLanding);
});

it('checks restricted user has no access to create linode on linode landing page', () => {
// Assert that Create Linode button is visible and disabled
ui.button
.findByTitle('Create Linode')
Expand Down

0 comments on commit dbc04a5

Please sign in to comment.