Skip to content

Commit 27ffba8

Browse files
author
Yehudit Kerido
committed
feat(ws): Notebooks 2.0 // Frontend // Fetch workspaces
Signed-off-by: Yehudit Kerido <yehudit.kerido@nokia.com>
1 parent b523448 commit 27ffba8

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

workspaces/frontend/src/__tests__/cypress/cypress/support/commands/axe.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@ declare global {
55
namespace Cypress {
66
interface Chainable {
77
testA11y: (context?: Parameters<cy['checkA11y']>[0]) => void;
8-
getDataTest(dataTestSelector: string): Chainable<JQuery<HTMLElement>>;
98
}
109
}
1110
}
1211

13-
Cypress.Commands.add('getDataTest', (dataTestSelector) => {
14-
return cy.get(`[data-test="${dataTestSelector}"]`);
15-
});
16-
1712
Cypress.Commands.add('testA11y', { prevSubject: 'optional' }, (subject, context) => {
1813
const test = (c: Parameters<typeof cy.checkA11y>[0]) => {
1914
cy.window({ log: false }).then((win) => {

workspaces/frontend/src/__tests__/cypress/cypress/tests/e2e/Workspaces.cy.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ import { mockBFFResponse } from '~/__mocks__/utils';
1010
// Helper function to validate the content of a single workspace row in the table
1111
const validateWorkspaceRow = (workspace: any, index: number) => {
1212
// Validate the workspace name
13-
cy.getDataTest(`workspace-row-${index}`)
14-
.find('[data-test="workspace-name"]')
13+
cy.findByTestId(`workspace-row-${index}`)
14+
.find('[data-testid="workspace-name"]')
1515
.should('have.text', workspace.name);
1616

1717
// Map workspace state to the expected label
1818
const expectedLabel = WorkspaceState[workspace.status.state];
1919

2020
// Validate the state label and pod configuration
21-
cy.getDataTest(`workspace-row-${index}`)
22-
.find('[data-test="state-label"]')
21+
cy.findByTestId(`workspace-row-${index}`)
22+
.find('[data-testid="state-label"]')
2323
.should('have.text', expectedLabel);
2424

25-
cy.getDataTest(`workspace-row-${index}`)
26-
.find('[data-test="pod-config"]')
25+
cy.findByTestId(`workspace-row-${index}`)
26+
.find('[data-testid="pod-config"]')
2727
.should('have.text', workspace.options.podConfig);
2828
};
2929

@@ -38,7 +38,7 @@ describe('Workspaces tests', () => {
3838
});
3939

4040
it('should display the correct number of workspaces', () => {
41-
cy.getDataTest('workspaces-table')
41+
cy.findByTestId('workspaces-table')
4242
.find('tbody tr')
4343
.should('have.length', mockWorkspaces.length);
4444
});
@@ -54,7 +54,7 @@ describe('Workspaces tests', () => {
5454
cy.intercept('GET', '/api/v1/workspaces', { statusCode: 200, body: { data: [] } });
5555
cy.visit('/');
5656

57-
cy.getDataTest('workspaces-table').find('tbody tr').should('not.exist');
57+
cy.findByTestId('workspaces-table').find('tbody tr').should('not.exist');
5858
});
5959
});
6060

@@ -81,7 +81,7 @@ describe('Workspace by namespace functionality', () => {
8181
it('should update workspaces when namespace changes', () => {
8282
// Verify initial state (default namespace)
8383
cy.wait('@getWorkspaces');
84-
cy.getDataTest('workspaces-table')
84+
cy.findByTestId('workspaces-table')
8585
.find('tbody tr')
8686
.should('have.length', mockWorkspaces.length);
8787

@@ -95,7 +95,7 @@ describe('Workspace by namespace functionality', () => {
9595
.should('include', '/api/v1/workspaces/kubeflow');
9696

9797
// Verify the length of workspaces list is updated
98-
cy.getDataTest('workspaces-table')
98+
cy.findByTestId('workspaces-table')
9999
.find('tbody tr')
100100
.should('have.length', mockWorkspacesByNS.length);
101101
});

workspaces/frontend/src/app/pages/Workspaces/Workspaces.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ export const Workspaces: React.FunctionComponent = () => {
357357
<Title headingLevel="h1">Kubeflow Workspaces</Title>
358358
<p>View your existing workspaces or create new workspaces.</p>
359359
{toolbar}
360-
<Table data-test="workspaces-table" aria-label="Sortable table" ouiaId="SortableTable">
360+
<Table data-testid="workspaces-table" aria-label="Sortable table" ouiaId="SortableTable">
361361
<Thead>
362362
<Tr>
363363
<Th sort={getSortParams(0)}>{columnNames.name}</Th>
@@ -379,17 +379,17 @@ export const Workspaces: React.FunctionComponent = () => {
379379
</Thead>
380380
<Tbody>
381381
{sortedWorkspaces.map((workspace, rowIndex) => (
382-
<Tr key={rowIndex} data-test={`workspace-row-${rowIndex}`}>
383-
<Td dataLabel={columnNames.name} data-test="workspace-name">
382+
<Tr key={rowIndex} data-testid={`workspace-row-${rowIndex}`}>
383+
<Td dataLabel={columnNames.name} data-testid="workspace-name">
384384
{workspace.name}
385385
</Td>
386386
<Td dataLabel={columnNames.kind}>{workspace.kind}</Td>
387387
<Td dataLabel={columnNames.image}>{workspace.options.imageConfig}</Td>
388-
<Td dataLabel={columnNames.podConfig} data-test="pod-config">
388+
<Td dataLabel={columnNames.podConfig} data-testid="pod-config">
389389
{workspace.options.podConfig}
390390
</Td>
391391
<Td dataLabel={columnNames.state}>
392-
<Label color={stateColors[workspace.status.state]} data-test="state-label">
392+
<Label color={stateColors[workspace.status.state]} data-testid="state-label">
393393
{WorkspaceState[workspace.status.state]}
394394
</Label>
395395
</Td>

0 commit comments

Comments
 (0)